This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
root:custompdfsandworkspace [2012/01/28 15:52] – created decianm | root:custompdfsandworkspace [2012/04/25 20:07] (current) – decianm | ||
---|---|---|---|
Line 2: | Line 2: | ||
===== Idea ===== | ===== Idea ===== | ||
In RooFit you can define a custom PDF shape in a C++ class. This is a good idea if the model is widely used and speed is an issue. A popular example is the class " | In RooFit you can define a custom PDF shape in a C++ class. This is a good idea if the model is widely used and speed is an issue. A popular example is the class " | ||
- | ==== Problem & Solution ==== | + | ===== Problem & Solution |
You need to define a standard constructor in your Pdf-class, so it can be stored in (and retrieved from) a RooWorkspace. However, this standard constructor must initialize all the necessary variables, otherwise you will not be able to retrieve the pdf back from a RooWorkspace (it will end in an ugly segfault). For example for RooExpAndGauss: | You need to define a standard constructor in your Pdf-class, so it can be stored in (and retrieved from) a RooWorkspace. However, this standard constructor must initialize all the necessary variables, otherwise you will not be able to retrieve the pdf back from a RooWorkspace (it will end in an ugly segfault). For example for RooExpAndGauss: | ||
<code C> | <code C> | ||
Line 52: | Line 52: | ||
| | ||
</ | </ | ||
+ | you need to define something like: | ||
+ | <code C> | ||
+ | | ||
+ | { | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | } | ||
+ | </ | ||
+ | to initialize the member variables (which are use in the evaluate-method). | ||
+ | You then can compile the class as all other private classes and add the library to you rootlogon to have it at hand. | ||
+ | **Note:** Make sure you have set the number in " | ||
- | + | **Note:** Don't even think of using the constructor " | |
- | you need to define something like: | + | |
- | <code C> | + | |
- | + | ||
- | + | ||