175using std::endl, std::ostream, std::string;
189Int_t dummy = init() ;
229 _masterBranchList(
"masterBranchList"),
230 _masterLeafList(
"masterLeafList"),
231 _internalCloneBranchList(
"cloneBranchList"),
232 _cloneBranchList(&_internalCloneBranchList),
252 _masterBranchList(
"masterBranchList"),
253 _masterLeafList(
"masterLeafList"),
254 _internalCloneBranchList(
"cloneBranchList"),
255 _cloneBranchList(&_internalCloneBranchList)
284 oocoutE(
nullptr, InputArguments) <<
"RooCustomizer::splitArgs(" <<
_name
285 <<
") ERROR cannot set spitting rules on this sterile customizer" << endl ;
289 for (
auto arg : set) {
307 oocoutE(
nullptr, InputArguments) <<
"RooCustomizer(" <<
_masterPdf->
GetName() <<
") ERROR: multiple splitting rules defined for "
308 << arg.
GetName() <<
" only using first rule" << endl ;
313 oocoutE(
nullptr, InputArguments) <<
"RooCustomizer::splitArg(" <<
_name
314 <<
") ERROR cannot set spitting rules on this sterile customizer" << endl ;
330 oocoutE(
nullptr, InputArguments) <<
"RooCustomizer(" <<
_masterPdf->
GetName() <<
") ERROR: multiple replacement rules defined for "
331 <<
orig.GetName() <<
" only using first rule" << endl ;
386 oocoutE(
nullptr, InputArguments) <<
"RooCustomizer::build(" <<
_name
387 <<
") ERROR cannot use leaf spitting build() on this sterile customizer" << endl ;
394 <<
"' not defined for master splitting category " <<
_masterCat->
GetName() << endl ;
425 <<
"): tree node " << node->GetName() <<
" is split by category " <<
splitCat->GetName() << endl ;
442 <<
") Adding existing node specialization " <<
newName <<
" to clonedMasterNodes" << endl ;
450 if (!
specNode->getStringAttribute(
"origName")) {
451 specNode->setStringAttribute(
"origName",node->GetName()) ;
458 if (node->isDerived()) {
460 <<
"): WARNING: branch node " << node->GetName() <<
" is split but has no pre-defined specializations" << endl ;
470 clone->removeStringAttribute(
"factory_tag") ;
478 if (!
clone->getStringAttribute(
"origName")) {
479 clone->setStringAttribute(
"origName",node->GetName()) ;
501 <<
"): tree node " << node->GetName() <<
" will be replaced by " <<
substArg->GetName() << endl ;
522 oocoutI(
nullptr, ObjectHandling) <<
"RooCustomizer::build(" <<
_masterPdf->
GetName() <<
") Branch node " <<
branch->GetName() <<
" is already split" << endl ;
528 oocoutI(
nullptr, ObjectHandling) <<
"RooCustomizer::build(" <<
_masterPdf->
GetName() <<
") Branch node " <<
branch->GetName() <<
" is already replaced" << endl ;
536 <<
branch->ClassName() <<
"::" <<
branch->GetName() <<
" cloned: depends on a split parameter" << endl ;
542 <<
branch->ClassName() <<
"::" <<
branch->GetName() <<
" cloned: depends on a replaced parameter" << endl ;
561 clone->removeStringAttribute(
"factory_tag") ;
566 if (!
clone->getStringAttribute(
"origName")) {
567 clone->setStringAttribute(
"origName",
branch->GetName()) ;
617 os <<
indent <<
" Splitting rules:" << endl ;
618 for (i=0 ; i<
nsplit ; i++) {
625 os <<
indent <<
" Replacement rules:" << endl ;
626 for (i=0 ; i<
nrepl ; i++) {
648 return static_cast<RooAbsPdf&
>(*_masterPdf);
660 throw string(
Form(
"RooCustomizer::CustIFace::create() ERROR: expect at least 2 arguments for EDIT: the input object and at least one $Replace() rule")) ;
663 if (
string(typeName)!=
"EDIT") {
664 throw string(
Form(
"RooCustomizer::CustIFace::create() ERROR: unknown type requested: %s",typeName)) ;
670 throw string(
Form(
"RooCustomizer::CustIFace::create() ERROR: input RooAbsArg %s does not exist",args[0].c_str())) ;
681 for (
unsigned int i=1 ; i<args.size() ; i++) {
683 strlcpy(buf,args[i].c_str(),1024) ;
686 throw string(
Form(
"RooCustomizer::CustIFace::create() ERROR: unknown argument: %s, expect form orig=subst",args[i].c_str())) ;
691 if (
string(sep+1).find(
"$REMOVE")==0) {
710 subst->setAttribute(
"REMOVE_ALL") ;
725 oocoutW(
nullptr,ObjectHandling) <<
"RooCustomizer::CustIFace::create() WARNING: input or replacement of a replacement operation not found, operation ignored"<< endl ;
732 throw string(
Form(
"RooCustomizer::CustIFace::create() ERROR in customizer build, object %snot created",
instanceName)) ;
virtual RooAbsTestStatistic * create(const char *name, const char *title, RooAbsReal &real, RooAbsData &data, const RooArgSet &projDeps, Configuration const &cfg)=0
TObject * clone(const char *newname) const override
static void indent(ostringstream &buf, int indent_level)
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
Common abstract base class for objects that represent a value and a "shape" in RooFit.
void branchNodeServerList(RooAbsCollection *list, const RooAbsArg *arg=nullptr, bool recurseNonDerived=false) const
Fill supplied list with all branch nodes of the arg tree starting with ourself as top node.
void leafNodeServerList(RooAbsCollection *list, const RooAbsArg *arg=nullptr, bool recurseNonDerived=false) const
Fill supplied list with all leaf nodes of the arg tree, starting with ourself as top node.
Abstract base class for objects that represent a discrete value that can be set from the outside,...
virtual bool setLabel(const char *label, bool printError=true)=0
Change category state by specifying a state name.
A space to attach TBranches.
virtual bool add(const RooAbsArg &var, bool silent=false)
Add the specified argument to list.
Int_t index(const RooAbsArg *arg) const
Returns index of given arg, or -1 if arg is not in the collection.
Storage_t::size_type size() const
virtual bool addOwned(RooAbsArg &var, bool silent=false)
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.
Abstract interface for all probability density functions.
RooAbsArg * at(Int_t idx) const
Return object at given index, or nullptr if index is out of range.
RooArgSet is a container object that can hold multiple RooAbsArg objects.
RooCustomizer is a factory class to produce clones of a prototype composite PDF object with the same ...
TString _name
Name of this object.
RooArgList _replaceSubList
List of replacement RooAbsArgs.
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)
Releases ownership of list of cloned branch nodes.
RooArgSet * _cloneNodeListAll
List of all cloned nodes.
void replaceArg(const RooAbsArg &orig, const RooAbsArg &subst)
Replace any occurrence of arg 'orig' with arg 'subst'.
RooAbsArg * _masterPdf
Pointer to input p.d.f.
bool _owning
If true we own all created components.
RooAbsArg * build(const char *masterCatState, bool verbose=false)
Build a clone of the prototype executing all registered 'replace' rules and 'split' rules for the mas...
RooArgList _splitArgList
List of RooAbsArgs to be split.
RooArgList _splitCatList
List of categories to be used for above splits.
RooArgSet * _cloneBranchList
Pointer to list of cloned branches used.
RooCustomizer(const RooAbsArg &pdf, const RooAbsCategoryLValue &masterCat, RooArgSet &splitLeafListOwned, RooArgSet *splitLeafListAll=nullptr)
Constructor with a prototype and masterCat index category.
RooArgSet _masterBranchList
List of branch nodes.
RooArgSet _masterLeafList
List of leaf nodes.
void initialize()
Initialize the customizer.
RooAbsCategoryLValue * _masterCat
Pointer to input master category.
RooArgList _replaceArgList
List of RooAbsArgs to be replaced.
void splitArgs(const RooArgSet &argSet, const RooAbsCategory &splitCat)
Split all arguments in 'set' into individualized clones for each defined state of 'splitCat'.
void printMultiline(std::ostream &os, Int_t content, bool verbose=false, TString indent="") const
Print customizer configuration details.
RooAbsArg * doBuild(const char *masterCatState, bool verbose)
Back-end implementation of the p.d.f building functionality.
bool _sterile
If true we do not have as associated master category.
RooAbsPdf const & pdf() const
RooArgSet * _cloneNodeListOwned
List of owned cloned nodes.
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.
const char * GetName() const override
Returns name of object.
const char * Data() const
RooCmdArg RecycleConflictNodes(bool flag=true)
RooCmdArg Silence(bool flag=true)
RooCmdArg NoRecursion(bool flag=true)
RooCmdArg RenameConflictNodes(const char *suffix, bool renameOrigNodes=false)