221 TNamed(pdf.GetName(),pdf.GetTitle()),
226 _masterBranchList(
"masterBranchList"),
227 _masterLeafList(
"masterLeafList"),
228 _internalCloneBranchList(
"cloneBranchList"),
229 _cloneNodeListAll(splitLeafsAll),
230 _cloneNodeListOwned(&splitLeafs)
245 TNamed(pdf.GetName(),pdf.GetTitle()),
251 _masterBranchList(
"masterBranchList"),
252 _masterLeafList(
"masterLeafList"),
253 _internalCloneBranchList(
"cloneBranchList"),
254 _cloneNodeListAll(0),
255 _cloneNodeListOwned(0)
298 coutE(InputArguments) <<
"RooCustomizer::splitArgs(" <<
_name
299 <<
") ERROR cannot set spitting rules on this sterile customizer" << endl ;
303 for (
auto arg : set) {
321 coutE(InputArguments) <<
"RooCustomizer(" <<
GetName() <<
") ERROR: multiple splitting rules defined for "
322 << arg.
GetName() <<
" only using first rule" << endl ;
327 coutE(InputArguments) <<
"RooCustomizer::splitArg(" <<
_name
328 <<
") ERROR cannot set spitting rules on this sterile customizer" << endl ;
344 coutE(InputArguments) <<
"RooCustomizer(" <<
GetName() <<
") ERROR: multiple replacement rules defined for "
345 << orig.
GetName() <<
" only using first rule" << endl ;
376 allOwned.remove(*ret) ;
380 if (allOwned.getSize()>0) {
400 coutE(InputArguments) <<
"RooCustomizer::build(" <<
_name
401 <<
") ERROR cannot use leaf spitting build() on this sterile customizer" << endl ;
407 coutE(InputArguments) <<
"RooCustomizer::build(" <<
_masterPdf->
GetName() <<
"): ERROR label '" << masterCatState
408 <<
"' not defined for master splitting category " <<
_masterCat->
GetName() << endl ;
412 return doBuild(masterCatState,verbose) ;
423 RooArgSet masterNodesToBeSplit(
"masterNodesToBeSplit") ;
424 RooArgSet masterNodesToBeReplaced(
"masterNodesToBeReplaced") ;
425 RooArgSet masterReplacementNodes(
"masterReplacementNodes") ;
426 RooArgSet clonedMasterNodes(
"clonedMasterNodes") ;
433 for (
auto node : nodeList) {
439 <<
"): tree node " << node->GetName() <<
" is split by category " << splitCat->
GetName() << endl ;
442 TString newName(node->GetName()) ;
443 if (masterCatState) {
453 clonedMasterNodes.
add(*specNode) ;
456 <<
") Adding existing node specialization " << newName <<
" to clonedMasterNodes" << endl ;
460 TString nameAttrib(
"ORIGNAME:") ;
461 nameAttrib.
Append(node->GetName()) ;
472 if (node->isDerived()) {
474 <<
"): WARNING: branch node " << node->GetName() <<
" is split but has no pre-defined specializations" << endl ;
477 TString newTitle(node->GetTitle()) ;
488 TString nameAttrib(
"ORIGNAME:") ;
489 nameAttrib.
Append(node->GetName()) ;
497 clonedMasterNodes.
add(*clone) ;
507 masterNodesToBeSplit.
add(*node) ;
515 <<
"): tree node " << node->GetName() <<
" will be replaced by " << substArg->
GetName() << endl ;
519 TString nameAttrib(
"ORIGNAME:") ;
520 nameAttrib.
Append(node->GetName()) ;
524 masterNodesToBeReplaced.
add(*node) ;
525 masterReplacementNodes.
add(*substArg) ;
530 RooArgSet masterBranchesToBeCloned(
"masterBranchesToBeCloned") ;
534 if (masterNodesToBeSplit.
find(branch->GetName())) {
536 coutI(ObjectHandling) <<
"RooCustomizer::build(" <<
_masterPdf->
GetName() <<
") Branch node " << branch->GetName() <<
" is already split" << endl ;
540 if (masterNodesToBeReplaced.
find(branch->GetName())) {
542 coutI(ObjectHandling) <<
"RooCustomizer::build(" <<
_masterPdf->
GetName() <<
") Branch node " << branch->GetName() <<
" is already replaced" << endl ;
547 if (branch->dependsOn(masterNodesToBeSplit)) {
550 << branch->IsA()->GetName() <<
"::" << branch->GetName() <<
" cloned: depends on a split parameter" << endl ;
552 masterBranchesToBeCloned.
add(*branch) ;
553 }
else if (branch->dependsOn(masterNodesToBeReplaced)) {
556 << branch->IsA()->GetName() <<
"::" << branch->GetName() <<
" cloned: depends on a replaced parameter" << endl ;
558 masterBranchesToBeCloned.
add(*branch) ;
564 RooArgSet clonedMasterBranches(
"clonedMasterBranches") ;
566 for (
auto branch : masterBranchesToBeCloned) {
567 TString newName(branch->GetName()) ;
568 if (masterCatState) {
570 newName.
Append(masterCatState) ;
576 TString nameAttrib(
"ORIGNAME:") ;
577 nameAttrib.
Append(branch->GetName()) ;
584 clonedMasterBranches.
add(*clone) ;
597 for (
auto branch : clonedMasterBranches) {
598 branch->redirectServers(clonedMasterBranches,
kFALSE,
kTRUE) ;
599 branch->redirectServers(clonedMasterNodes,
kFALSE,
kTRUE) ;
600 branch->redirectServers(masterReplacementNodes,
kFALSE,
kTRUE) ;
603 return cloneTopPdf ? cloneTopPdf :
_masterPdf ;
630 os << IsA()->GetName() ;
657 os <<
indent <<
" Splitting rules:" << endl ;
658 for (i=0 ; i<nsplit ; i++) {
665 os <<
indent <<
" Replacement rules:" << endl ;
666 for (i=0 ; i<nrepl ; i++) {
695 throw string(
Form(
"RooCustomizer::CustIFace::create() ERROR: expect at least 2 arguments for EDIT: the input object and at least one $Replace() rule")) ;
698 if (
string(typeName)!=
"EDIT") {
699 throw string(
Form(
"RooCustomizer::CustIFace::create() ERROR: unknown type requested: %s",typeName)) ;
705 throw string(
Form(
"RooCustomizer::CustIFace::create() ERROR: input RooAbsArg %s does not exist",args[0].c_str())) ;
709 if (args[0]==instanceName) {
716 for (
unsigned int i=1 ; i<args.size() ; i++) {
718 strlcpy(buf,args[i].c_str(),1024) ;
719 char* sep = strchr(buf,
'=') ;
721 throw string(
Form(
"RooCustomizer::CustIFace::create() ERROR: unknown argument: %s, expect form orig=subst",args[i].c_str())) ;
726 if (
string(sep+1).find(
"$REMOVE")==0) {
732 char* sep2 = strchr(sep+1,
'(') ;
735 strlcpy(buf2,sep2+1,1024) ;
737 char* tok = R__STRTOK_R(buf2,
",)",&saveptr) ;
741 tok = R__STRTOK_R(0,
",)",&saveptr) ;
749 subst = ft.
ws().
arg(sep+1) ;
760 oocoutW((
TObject*)0,ObjectHandling) <<
"RooCustomizer::CustIFace::create() WARNING: input or replacement of a replacement operation not found, operation ignored"<< endl ;
767 throw string(
Form(
"RooCustomizer::CustIFace::create() ERROR in customizer build, object %snot created",instanceName)) ;
780 return string(instanceName?instanceName:targ->
GetName()) ;
typedef void(GLAPIENTRYP _GLUfuncptr)(void)
static void indent(ostringstream &buf, int indent_level)
char * Form(const char *fmt,...)
RooAbsArg is the common abstract base class for objects that represent a value and a "shape" in RooFi...
void setStringAttribute(const Text_t *key, const Text_t *value)
Associate string 'value' to this object under key 'key'.
void leafNodeServerList(RooAbsCollection *list, const RooAbsArg *arg=0, Bool_t recurseNonDerived=kFALSE) const
Fill supplied list with all leaf nodes of the arg tree, starting with ourself as top node.
virtual TObject * Clone(const char *newname=0) const
Make a clone of an object using the Streamer facility.
bool addOwnedComponents(const RooAbsCollection &comps)
Take ownership of the contents of 'comps'.
const Text_t * getStringAttribute(const Text_t *key) const
Get string attribute mapped under key 'key'.
void setAttribute(const Text_t *name, Bool_t value=kTRUE)
Set (default) or clear a named boolean attribute of this object.
void branchNodeServerList(RooAbsCollection *list, const RooAbsArg *arg=0, Bool_t recurseNonDerived=kFALSE) const
Fill supplied list with all branch nodes of the arg tree starting with ourself as top node.
void SetName(const char *name)
Set the name of the TNamed.
RooAbsCategoryLValue is the common abstract base class for objects that represent a discrete value th...
virtual bool setLabel(const char *label, Bool_t printError=kTRUE)=0
Change category state by specifying a state name.
RooAbsCategory is the base class for objects that represent a discrete value with a finite number of ...
virtual const char * getCurrentLabel() const
Return label string of current state.
virtual Bool_t add(const RooAbsArg &var, Bool_t silent=kFALSE)
Add the specified argument to list.
virtual Bool_t addOwned(RooAbsArg &var, Bool_t silent=kFALSE)
Add an argument and transfer the ownership to the collection.
void useHashMapForFind(bool flag) const
RooAbsArg * find(const char *name) const
Find object with given name in list.
RooArgSet is a container object that can hold multiple RooAbsArg objects.
std::string create(RooFactoryWSTool &ft, const char *typeName, const char *instanceName, std::vector< std::string > args)
RooCustomizer is a factory class to produce clones of a prototype composite PDF object with the same ...
void splitArg(const RooAbsArg &arg, const RooAbsCategory &splitCat)
Split all argument 'arg' into individualized clones for each defined state of 'splitCat'.
void setCloneBranchSet(RooArgSet &cloneBranchSet)
Install the input RooArgSet as container in which all cloned branches will be stored.
RooArgSet * _cloneNodeListAll
void replaceArg(const RooAbsArg &orig, const RooAbsArg &subst)
Replace any occurence of arg 'orig' with arg 'subst'.
const RooArgSet & cloneBranchList() const
RooArgSet * _cloneBranchList
virtual void printName(std::ostream &os) const
Print name of customizer.
virtual void printTitle(std::ostream &os) const
Print title of customizer.
RooCustomizer(const RooAbsArg &pdf, const RooAbsCategoryLValue &masterCat, RooArgSet &splitLeafListOwned, RooArgSet *splitLeafListAll=0)
Constructor with a prototype and masterCat index category.
virtual void printMultiline(std::ostream &os, Int_t content, Bool_t verbose=kFALSE, TString indent="") const
Print customizer configuration details.
RooArgSet _masterBranchList
RooAbsArg * doBuild(const char *masterCatState, Bool_t verbose)
Back-end implementation of the p.d.f building functionality.
RooArgSet _masterLeafList
virtual void printClassName(std::ostream &os) const
Print class name of customizer.
virtual ~RooCustomizer()
Destructor.
RooArgSet _internalCloneBranchList
void initialize()
Initialize the customizer.
RooAbsCategoryLValue * _masterCat
void splitArgs(const RooArgSet &argSet, const RooAbsCategory &splitCat)
Split all arguments in 'set' into individualized clones for each defined state of 'splitCat'.
RooAbsArg * build(const char *masterCatState, Bool_t verbose=kFALSE)
Build a clone of the prototype executing all registered 'replace' rules and 'split' rules for the mas...
RooArgSet * _cloneNodeListOwned
virtual void printArgs(std::ostream &os) const
Print arguments of customizer, i.e. input p.d.f and input master category (if any)
static RooConstVar & removalDummy()
Create a dummy node used in node-removal operations.
Bool_t import(const RooAbsArg &arg, const RooCmdArg &arg1=RooCmdArg(), const RooCmdArg &arg2=RooCmdArg(), const RooCmdArg &arg3=RooCmdArg(), const RooCmdArg &arg4=RooCmdArg(), const RooCmdArg &arg5=RooCmdArg(), const RooCmdArg &arg6=RooCmdArg(), const RooCmdArg &arg7=RooCmdArg(), const RooCmdArg &arg8=RooCmdArg(), const RooCmdArg &arg9=RooCmdArg())
Import a RooAbsArg object, e.g.
RooAbsArg * arg(const char *name) const
Return RooAbsArg with given name. A null pointer is returned if none is found.
virtual Int_t GetSize() const
Return the capacity of the collection, i.e.
virtual void Add(TObject *obj)
virtual TObject * FindObject(const char *name) const
Find an object in this list using its name.
virtual TObject * At(Int_t idx) const
Returns the object at position idx. Returns 0 if idx is out of range.
The TNamed class is the base class for all named ROOT classes.
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
virtual const char * GetTitle() const
Returns title of object.
virtual const char * GetName() const
Returns name of object.
Mother of all ROOT objects.
virtual const char * GetName() const
Returns name of object.
virtual Int_t IndexOf(const TObject *obj) const
Return index of object in collection.
const char * Data() const
TString & Append(const char *cs)
RooCmdArg NoRecursion(Bool_t flag=kTRUE)
RooCmdArg RecycleConflictNodes(Bool_t flag=kTRUE)
RooCmdArg RenameConflictNodes(const char *suffix, Bool_t renameOrigNodes=kFALSE)
RooCmdArg Silence(Bool_t flag=kTRUE)
void init()
Inspect hardware capabilities, and load the optimal library for RooFit computations.