RooCustomizer is a factory class to produce clones of a prototype composite PDF object with the same structure but different leaf servers (parameters or dependents).
RooCustomizer supports two kinds of modifications:
Splitting is particularly useful when building simultaneous fits to subsets of the data sample with different background properties. In such a case, the user builds a single prototype PDF representing the structure of the signal and background and splits the dataset into categories with different background properties. Using RooCustomizer a PDF for each subfit can be constructed from the prototype that has same structure and signal parameters, but different instances of the background parameters: e.g.
If the master category state is a super category, leaves may be split by any subset of that master category. E.g. if the master category is 'A x B', leaves may be split by A, B or AxB.
In addition to replacing leaf nodes, RooCustomizer clones all branch nodes that depend directly or indirectly on modified leaf nodes, so that the input pdf is untouched by each build operation.
The customizer owns all the branch nodes including the returned top level node, so the customizer should live as longs as the cloned composites are needed.
Any leaf nodes that are created by the customizer will be put into the leaf list that is passed into the customizers constructor (splitLeaves in the above example. The list owner is responsible for deleting these leaf nodes after the customizer is deleted.
By default, the customizer clones the prototype leaf node when splitting a leaf, but the user can feed pre-defined split leaves in leaf list. These leaves must have the name <split_leaf>_<splitcat_label>
to be picked up. The list of pre-supplied leaves may be partial, any missing split leaves will be auto generated.
Another common construction is to have two prototype PDFs, each to be customized by a separate customizer instance, that share parameters. To ensure that the customized clones also share their respective split leaves, i.e.
feed the same split leaf list into both customizers. In that case, the second customizer will pick up the split leaves instantiated by the first customizer and the link between the two PDFs is retained.
If leaf nodes are provided in the sets, the customiser will use them. This is a complete example that customises the yield
parameter, and splits (automatically clones) the mean of the Gaussian. This is a short version of the tutorial rf514_RooCustomizer.C.
Definition at line 36 of file RooCustomizer.h.
Public Member Functions | |
RooCustomizer (const RooAbsArg &pdf, const char *name) | |
Sterile Constructor. | |
RooCustomizer (const RooAbsArg &pdf, const RooAbsCategoryLValue &masterCat, RooArgSet &splitLeafListOwned, RooArgSet *splitLeafListAll=nullptr) | |
Constructor with a prototype and masterCat index category. | |
RooCustomizer (const RooCustomizer &)=delete | |
RooCustomizer (RooCustomizer &&)=delete | |
RooAbsArg * | build (bool verbose=false) |
Build a clone of the prototype executing all registered 'replace' rules. | |
RooAbsArg * | build (const char *masterCatState, bool verbose=false) |
Build a clone of the prototype executing all registered 'replace' rules and 'split' rules for the masterCat state named 'masterCatState'. | |
const RooArgSet & | cloneBranchList () const |
Return list of cloned branch nodes. | |
const RooArgSet & | cloneLeafList () const |
Return list of cloned leaf nodes. | |
RooCustomizer & | operator= (const RooCustomizer &)=delete |
RooCustomizer & | operator= (RooCustomizer &&)=delete |
RooAbsPdf const & | pdf () const |
void | printArgs (std::ostream &os) const |
Print arguments of customizer, i.e. input p.d.f and input master category (if any) | |
void | printMultiline (std::ostream &os, Int_t content, bool verbose=false, TString indent="") const |
Print customizer configuration details. | |
void | replaceArg (const RooAbsArg &orig, const RooAbsArg &subst) |
Replace any occurrence of arg 'orig' with arg 'subst'. | |
void | setCloneBranchSet (RooArgSet &cloneBranchSet) |
Releases ownership of list of cloned branch nodes. | |
void | setOwning (bool flag) |
If flag is true, make customizer own all created components. | |
void | splitArg (const RooAbsArg &arg, const RooAbsCategory &splitCat) |
Split all argument 'arg' into individualized clones for each defined state of 'splitCat'. | |
void | splitArgs (const RooArgSet &argSet, const RooAbsCategory &splitCat) |
Split all arguments in 'set' into individualized clones for each defined state of 'splitCat'. | |
Protected Member Functions | |
RooAbsArg * | doBuild (const char *masterCatState, bool verbose) |
Back-end implementation of the p.d.f building functionality. | |
void | initialize () |
Initialize the customizer. | |
Protected Attributes | |
RooArgSet * | _cloneBranchList = nullptr |
Pointer to list of cloned branches used. | |
RooArgSet * | _cloneNodeListAll = nullptr |
List of all cloned nodes. | |
RooArgSet * | _cloneNodeListOwned = nullptr |
List of owned cloned nodes. | |
RooArgSet | _internalCloneBranchList |
List of branches of internal clone. | |
RooArgSet | _masterBranchList |
List of branch nodes. | |
RooAbsCategoryLValue * | _masterCat = nullptr |
Pointer to input master category. | |
RooArgSet | _masterLeafList |
List of leaf nodes. | |
RooAbsArg * | _masterPdf |
Pointer to input p.d.f. | |
TString | _name |
Name of this object. | |
bool | _owning |
If true we own all created components. | |
RooArgList | _replaceArgList |
List of RooAbsArgs to be replaced. | |
RooArgList | _replaceSubList |
List of replacement RooAbsArgs. | |
RooArgList | _splitArgList |
List of RooAbsArgs to be split. | |
RooArgList | _splitCatList |
List of categories to be used for above splits. | |
bool | _sterile |
If true we do not have as associated master category. | |
#include <RooCustomizer.h>
RooCustomizer::RooCustomizer | ( | const RooAbsArg & | pdf, |
const RooAbsCategoryLValue & | masterCat, | ||
RooArgSet & | splitLeaves, | ||
RooArgSet * | splitLeavesAll = nullptr |
||
) |
Constructor with a prototype and masterCat index category.
Customizers created by this constructor offer both the replaceArg() and splitArg() functionality.
[in] | Proto PDF to be customised. | |
[in] | masterCat | Category to be used for splitting. |
[in,out] | splitLeaves | All nodes created in the customisation process are added to this set. The user can provide nodes that are taken from the set if they have a name that matches <parameterNameToBeReplaced>_<category> . |
[in,out] | splitLeavesAll | All leaves that are used when customising are collected here. If this set already contains leaves, they will be used for customising if the names match as above. |
Definition at line 223 of file RooCustomizer.cxx.
RooCustomizer::RooCustomizer | ( | const RooAbsArg & | pdf, |
const char * | name | ||
) |
Sterile Constructor.
Customizers created by this constructor offer only the replace() method. The supplied 'name' is used as suffix for any cloned branch nodes
Definition at line 247 of file RooCustomizer.cxx.
|
delete |
|
delete |
Build a clone of the prototype executing all registered 'replace' rules.
If verbose is set, a message is printed for each leaf or branch node modification. The returned head node owns all cloned branch nodes that were created in the cloning process.
Definition at line 347 of file RooCustomizer.cxx.
Build a clone of the prototype executing all registered 'replace' rules and 'split' rules for the masterCat state named 'masterCatState'.
If verbose is set a message is printed for each leaf or branch node modification. The returned composite arg is owned by the customizer. This function cannot be called on customizer build with the sterile constructor.
Definition at line 383 of file RooCustomizer.cxx.
|
inline |
Return list of cloned branch nodes.
Definition at line 56 of file RooCustomizer.h.
|
inline |
Return list of cloned leaf nodes.
Definition at line 60 of file RooCustomizer.h.
Back-end implementation of the p.d.f building functionality.
Definition at line 406 of file RooCustomizer.cxx.
|
protected |
Initialize the customizer.
Definition at line 267 of file RooCustomizer.cxx.
|
delete |
|
delete |
RooAbsPdf const & RooCustomizer::pdf | ( | ) | const |
Definition at line 647 of file RooCustomizer.cxx.
void RooCustomizer::printArgs | ( | std::ostream & | os | ) | const |
Print arguments of customizer, i.e. input p.d.f and input master category (if any)
Definition at line 596 of file RooCustomizer.cxx.
void RooCustomizer::printMultiline | ( | std::ostream & | os, |
Int_t | content, | ||
bool | verbose = false , |
||
TString | indent = "" |
||
) | const |
Print customizer configuration details.
Definition at line 610 of file RooCustomizer.cxx.
Replace any occurrence of arg 'orig' with arg 'subst'.
Definition at line 327 of file RooCustomizer.cxx.
void RooCustomizer::setCloneBranchSet | ( | RooArgSet & | cloneBranchSet | ) |
Releases ownership of list of cloned branch nodes.
Install the input RooArgSet as container in which all cloned branches will be stored.
Definition at line 640 of file RooCustomizer.cxx.
|
inline |
If flag is true, make customizer own all created components.
Definition at line 45 of file RooCustomizer.h.
void RooCustomizer::splitArg | ( | const RooAbsArg & | arg, |
const RooAbsCategory & | splitCat | ||
) |
Split all argument 'arg' into individualized clones for each defined state of 'splitCat'.
The 'splitCats' category must be subset of or equal to the master category supplied in the customizer constructor.
Splitting is only available on customizers created with a master index category
Definition at line 304 of file RooCustomizer.cxx.
void RooCustomizer::splitArgs | ( | const RooArgSet & | set, |
const RooAbsCategory & | splitCat | ||
) |
Split all arguments in 'set' into individualized clones for each defined state of 'splitCat'.
The 'splitCats' category must be subset of or equal to the master category supplied in the customizer constructor.
Splitting is only available on customizers created with a master index category
Definition at line 281 of file RooCustomizer.cxx.
|
protected |
Pointer to list of cloned branches used.
Definition at line 102 of file RooCustomizer.h.
|
protected |
List of all cloned nodes.
Definition at line 105 of file RooCustomizer.h.
|
protected |
List of owned cloned nodes.
Definition at line 106 of file RooCustomizer.h.
|
protected |
List of branches of internal clone.
Definition at line 101 of file RooCustomizer.h.
|
protected |
List of branch nodes.
Definition at line 98 of file RooCustomizer.h.
|
protected |
Pointer to input master category.
Definition at line 96 of file RooCustomizer.h.
|
protected |
List of leaf nodes.
Definition at line 99 of file RooCustomizer.h.
|
protected |
Pointer to input p.d.f.
Definition at line 95 of file RooCustomizer.h.
|
protected |
Name of this object.
Definition at line 86 of file RooCustomizer.h.
|
protected |
If true we own all created components.
Definition at line 85 of file RooCustomizer.h.
|
protected |
List of RooAbsArgs to be replaced.
Definition at line 91 of file RooCustomizer.h.
|
protected |
List of replacement RooAbsArgs.
Definition at line 92 of file RooCustomizer.h.
|
protected |
List of RooAbsArgs to be split.
Definition at line 88 of file RooCustomizer.h.
|
protected |
List of categories to be used for above splits.
Definition at line 89 of file RooCustomizer.h.
|
protected |
If true we do not have as associated master category.
Definition at line 84 of file RooCustomizer.h.