466 _protoPdfSet(protoPdfSet)
482 buildConfig->
addOwned(*
new RooStringVar(
"physModels",
"List and mapping of physics models to include in build",
"",4096)) ;
483 buildConfig->
addOwned(*
new RooStringVar(
"splitCats",
"List of categories used for splitting",
"",1024)) ;
512 const char* spaceChars =
" \t" ;
516 char *buf =
new char[buflen] ;
518 strlcpy(buf,((
RooStringVar*)buildConfig.
find(
"physModels"))->getVal(),buflen) ;
520 if (strstr(buf,
" : ")) {
521 const char* physCatName = strtok(buf,spaceChars) ;
524 coutE(InputArguments) <<
"RooSimPdfBuilder::buildPdf: ERROR physics index category " << physCatName
525 <<
" not found in dataset variables" << endl ;
529 coutI(ObjectHandling) <<
"RooSimPdfBuilder::buildPdf: category indexing physics model: " << physCatName << endl ;
537 strtok(0,spaceChars) ;
538 physName = strtok(0,spaceChars) ;
540 physName = strtok(buf,spaceChars) ;
544 coutE(InputArguments) <<
"RooSimPdfBuilder::buildPdf: ERROR: No models specified, nothing to do!" << endl ;
556 if (strchr(physName,
'=')) {
559 coutW(ObjectHandling) <<
"RooSimPdfBuilder::buildPdf: WARNING: without physCat specification "
560 <<
"<physCatState>=<pdfProtoName> association is meaningless" << endl ;
562 stateName = physName ;
563 physName = strchr(stateName,
'=') ;
568 stateName = physName ;
573 coutE(InputArguments) <<
"RooSimPdfBuilder::buildPdf: ERROR requested physics model "
574 << (physName?physName:
"(null)") <<
" is not defined" << endl ;
580 if (stateMap.
find(stateName)) {
581 coutW(InputArguments) <<
"RooSimPdfBuilder::buildPdf: WARNING: multiple PDFs specified for state "
582 << stateName <<
", only first will be used" << endl ;
587 physModelSet.
add(*physModel,
kTRUE) ;
593 physName = strtok(0,spaceChars) ;
596 }
else if (physCat==0) {
597 coutW(InputArguments) <<
"RooSimPdfBuilder::buildPdf: WARNING: without physCat specification, only the first model will be used" << endl ;
601 coutI(ObjectHandling) <<
"RooSimPdfBuilder::buildPdf: list of physics models " << physModelSet << endl ;
606 TList splitStateList ;
610 buflen = strlen(((
RooStringVar*)buildConfig.
find(
"splitCats"))->getVal())+1 ;
611 buf =
new char[buflen] ;
612 strlcpy(buf,((
RooStringVar*)buildConfig.
find(
"splitCats"))->getVal(),buflen) ;
614 char *catName = strtok(buf,spaceChars) ;
620 if (strchr(catName,
'(')) {
622 catName = R__STRTOK_R(catName,
"(",&tokenPtr) ;
623 stateList = R__STRTOK_R(0,
")",&tokenPtr) ;
631 coutE(InputArguments) <<
"RooSimPdfBuilder::buildPdf: ERROR requested split category " << (catName?catName:
"(null)")
632 <<
" is not a RooCategory in the dataset" << endl ;
636 splitCatSet.
add(*splitCat) ;
640 coutI(ObjectHandling) <<
"RooSimPdfBuilder::buildPdf: splitting of category " << catName
641 <<
" restricted to states (" << stateList <<
")" << endl ;
646 splitStateList.
Add(slist) ;
648 char* stateLabel = R__STRTOK_R(stateList,
",",&tokenPtr) ;
654 coutE(InputArguments) <<
"RooSimPdfBuilder::buildPdf: ERROR splitCat " << splitCat->
GetName()
655 <<
" doesn't have a state named " << stateLabel << endl ;
662 stateLabel = R__STRTOK_R(0,
",",&tokenPtr) ;
666 catName = strtok(0,spaceChars) ;
668 if (physCat) splitCatSet.
add(*physCat) ;
669 RooSuperCategory masterSplitCat(
"masterSplitCat",
"Master splitting category",splitCatSet) ;
671 coutI(ObjectHandling) <<
"RooSimPdfBuilder::buildPdf: list of splitting categories " << splitCatSet << endl ;
679 if (!auxSplitCloneSet) {
680 coutE(InputArguments) <<
"RooSimPdfBuilder::buildPdf(" <<
GetName() <<
") Couldn't deep-clone set auxiliary splitcats, abort." << endl ;
685 for (
const auto arg : *auxSplitCats) {
691 coutW(InputArguments) <<
"RooSimPdfBuilder::buildPdf: WARNING: dataset contains a fundamental splitting category " << endl
692 <<
" with the same name as an auxiliary split function (" << aux->
GetName() <<
"). " << endl
693 <<
" Auxiliary split function will be ignored" << endl ;
700 coutW(InputArguments) <<
"RooSimPdfBuilder::buildPdf: WARNING: ignoring auxiliary category " << aux->
GetName()
701 <<
" because it has servers that are not listed in splitCatSet: " << *parSet << endl ;
710 auxSplitSet.
add(*aux) ;
713 coutI(ObjectHandling) <<
"RooSimPdfBuilder::buildPdf: list of auxiliary splitting categories " << auxSplitSet << endl ;
721 for (
const auto arg : physModelSet) {
722 auto physModel =
static_cast<const RooAbsPdf*
>(arg);
724 coutI(ObjectHandling) <<
"RooSimPdfBuilder::buildPdf: processing physics model " << physModel->
GetName() << endl ;
727 customizerList->
Add(physCustomizer) ;
733 enum Mode { SplitCat, Colon, ParamList } ;
734 Mode mode(SplitCat) ;
736 const char* splitCatName ;
744 splitCatName = token.data();
746 if (token.find(
',') != std::string::npos) {
751 TString origCompCatName(splitCatName) ;
765 coutE(InputArguments) <<
"RooSimPdfBuilder::buildPdf: ERROR " << catName2
766 <<
" not found in the primary or auxilary splitcat list" << endl ;
767 customizerList->
Delete() ;
768 delete customizerList ;
773 compCatSet.
add(*cat) ;
779 for (
const auto theArg : compCatSet) {
782 if (theArg->dependsOnValue(tmp)) {
783 coutE(InputArguments) <<
"RooSimPdfBuilder::buildPDF: ERROR: Ill defined split: auxiliary splitting category " << theArg->GetName()
784 <<
" used in composite split " << compCatSet <<
" depends on one or more of the other splitting categories in the composite split" << endl ;
787 customizerList->
Delete() ;
788 delete customizerList ;
794 splitCat =
new RooMultiCategory(origCompCatName,origCompCatName,compCatSet) ;
810 coutE(InputArguments) <<
"RooSimPdfBuilder::buildPdf: ERROR splitting category "
811 << splitCatName <<
" not found in the primary or auxiliary splitcat list" << endl ;
812 customizerList->
Delete() ;
813 delete customizerList ;
825 coutE(InputArguments) <<
"RooSimPdfBuilder::buildPdf: ERROR in parsing, expected ':' after "
826 << splitCat <<
", found " << token << endl ;
827 customizerList->
Delete() ;
828 delete customizerList ;
839 RooArgSet* paramList = physModel->getParameters(dependents) ;
842 RooArgSet* compList = physModel->getComponents() ;
843 paramList->
add(*compList) ;
846 const bool lastCharIsComma = (token[token.size()-1]==
',') ;
850 std::string remainderState;
851 if (
const auto pos = paramName.find(
'[') != std::string::npos) {
852 const auto posEnd = paramName.
find(
']');
853 remainderState = paramName.substr(pos+1, posEnd - pos - 1);
858 if (!remainderState.empty()) {
859 if (!splitCat->
hasLabel(remainderState)) {
860 coutE(InputArguments) <<
"RooSimPdfBuilder::buildPdf: ERROR fraction split of parameter "
861 << paramName <<
" has invalid remainder state name: " << remainderState << endl ;
863 customizerList->
Delete() ;
864 delete customizerList ;
872 coutE(InputArguments) <<
"RooSimPdfBuilder::buildPdf: ERROR " << paramName
873 <<
" is not a parameter of physics model " << physModel->
GetName() << endl ;
875 customizerList->
Delete() ;
876 delete customizerList ;
880 splitParamList.
add(*param) ;
883 if (!remainderState.empty()) {
887 coutE(InputArguments) <<
"RooSimPdfBuilder::buildPdf: ERROR fraction split requested of non-real valued parameter "
890 customizerList->
Delete() ;
891 delete customizerList ;
900 if (remStateSplitList && !remStateSplitList->
FindObject(remainderState.data())) {
901 coutE(InputArguments) <<
"RooSimPdfBuilder::buildPdf: ERROR " << paramName
902 <<
" remainder state " << remainderState <<
" in parameter split "
903 << param->
GetName() <<
" is not actually being built" << endl ;
905 customizerList->
Delete() ;
906 delete customizerList ;
923 if (remStateSplitList && !remStateSplitList->
FindObject(
type->GetName())) {
929 splitLeafName.
Append(
"_") ;
940 fracLeafList.
add(*splitLeaf) ;
948 remLeafName.
Append(remainderState) ;
955 coutI(ObjectHandling) <<
"RooSimPdfBuilder::buildPdf: creating remainder fraction formula for " << remainderState
956 <<
" specialization of split parameter " << param->
GetName() <<
" " << formExpr << endl ;
962 physCustomizer->
splitArgs(splitParamList,*splitCat) ;
966 if (!lastCharIsComma) mode = SplitCat ;
971 if (mode!=SplitCat) {
972 coutE(InputArguments) <<
"RooSimPdfBuilder::buildPdf: ERROR in parsing, expected "
973 << (mode==Colon?
":":
"parameter list") <<
" in " << ruleStr->
getVal() << endl ;
978 coutI(ObjectHandling) <<
"RooSimPdfBuilder::buildPdf: no splitting rules for " << physModel->GetName() << endl ;
982 coutI(ObjectHandling) <<
"RooSimPdfBuilder::buildPdf: configured customizers for all physics models" << endl ;
984 customizerList->
Print() ;
989 if (physCat) fitCatList.
add(*physCat) ;
990 fitCatList.
add(splitCatSet) ;
1006 for (
const auto arg : fitCatList) {
1011 if (!slist) continue ;
1017 if (!select) continue ;
1024 if (!physNameVar) continue ;
1030 coutI(ObjectHandling) <<
"RooSimPdfBuilder::buildPdf: Customizing physics model " << physCustomizer->
GetName()
1031 <<
" for mode " << fcState->
GetName() << endl ;
1041 delete customizerList ;
1043 splitStateList.
Delete() ;
1045 if (auxSplitCloneSet)
delete auxSplitCloneSet ;
1062 std::list<RooSimultaneous*>::iterator iter =
_simPdfList.begin() ;
1068 std::list<RooSuperCategory*>::iterator iter2 =
_fitCatList.begin() ;
char * Form(const char *fmt,...)
RooAbsArg is the common abstract base class for objects that represent a value and a "shape" in RooFi...
RooArgSet * getParameters(const RooAbsData *data, bool stripDisconnected=true) const
Create a list of leaf nodes in the arg tree starting with ourself as top node that don't match any of...
Bool_t recursiveRedirectServers(const RooAbsCollection &newServerList, Bool_t mustReplaceAll=kFALSE, Bool_t nameChange=kFALSE, Bool_t recurseInNewSet=kTRUE)
Recursively replace all servers with the new servers in newSet.
virtual TObject * clone(const char *newname=0) const =0
RooAbsCategoryLValue is the common abstract base class for objects that represent a discrete value th...
RooAbsCategory is the base class for objects that represent a discrete value with a finite number of ...
bool hasLabel(const std::string &label) const
Check if a state with name label exists.
virtual const char * getCurrentLabel() const
Return label string of current state.
TIterator * typeIterator() const
const RooCatType * lookupType(value_type index, Bool_t printError=kFALSE) const
Find our type corresponding to the specified index, or return nullptr for no match.
virtual Bool_t add(const RooAbsArg &var, Bool_t silent=kFALSE)
Add the specified argument to list.
void useHashMapForFind(bool flag) const
Install an internal hash map for fast finding of elements by name.
virtual Bool_t remove(const RooAbsArg &var, Bool_t silent=kFALSE, Bool_t matchByNameOnly=kFALSE)
Remove the specified argument from our list.
TIterator * createIterator(Bool_t dir=kIterForward) const
TIterator-style iteration over contained elements.
RooAbsArg * find(const char *name) const
Find object with given name in list.
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
RooArgList is a container object that can hold multiple RooAbsArg objects.
RooArgSet is a container object that can hold multiple RooAbsArg objects.
RooArgSet * snapshot(bool deepCopy=true) const
Use RooAbsCollection::snapshot(), but return as RooArgSet.
Bool_t add(const RooAbsArg &var, Bool_t silent=kFALSE) override
Add element to non-owning set.
Bool_t addOwned(RooAbsArg &var, Bool_t silent=kFALSE) override
Add element to an owning set.
RooCatType is an auxilary class for RooAbsCategory and defines a a single category state.
virtual const Text_t * GetName() const
Returns name of object.
RooCategory is an object to represent discrete states.
RooCustomizer is a factory class to produce clones of a prototype composite PDF object with the same ...
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...
RooMultiCategory connects several RooAbsCategory objects into a single category.
This tool has now been superseded by RooSimWSTool
RooArgSet _compSplitCatSet
std::list< RooSuperCategory * > _fitCatList
std::list< RooSimultaneous * > _simPdfList
RooSimultaneous * buildPdf(const RooArgSet &buildConfig, const RooArgSet &dependents, const RooArgSet *auxSplitCats=0, Bool_t verbose=kFALSE)
Initialize needed components.
RooArgSet * createProtoBuildConfig()
Make RooArgSet of configuration objects.
void addSpecializations(const RooArgSet &specSet)
RooArgSet _splitNodeListOwned
TList _retiredCustomizerList
RooSimPdfBuilder(const RooArgSet &pdfProtoList)
RooSimultaneous facilitates simultaneous fitting of multiple PDFs to subsets of a given dataset.
Bool_t addPdf(const RooAbsPdf &pdf, const char *catLabel)
Associate given PDF with index category state label 'catLabel'.
RooStringVar is a RooAbsArg implementing string values.
const char * getVal() const
The RooSuperCategory can join several RooAbsCategoryLValue objects into a single category.
virtual Bool_t setLabel(const char *label, Bool_t printError=kTRUE) override
Set the value of the super category by specifying the state name.
virtual void Print(Option_t *option="") const
Default print for collections, calls Print(option, 1).
void SetName(const char *name)
virtual void AddAll(const TCollection *col)
Add all objects from collection col to this collection.
Iterator abstract base class.
virtual TObject * Next()=0
virtual void Add(TObject *obj)
virtual TObject * FindObject(const char *name) const
Find an object in this list using its name.
virtual void Delete(Option_t *option="")
Remove all objects from the list AND delete all heap based objects.
virtual TObject * First() const
Return the first object in the list. Returns 0 when list is empty.
virtual const char * GetName() const
Returns name of object.
Mother of all ROOT objects.
virtual const char * GetName() const
Returns name of object.
int CompareTo(const char *cs, ECaseCompare cmp=kExact) const
Compare a string to char *cs2.
TString & Append(const char *cs)
std::vector< std::string > tokenise(const std::string &str, const std::string &delims, bool returnEmptyToken=true)
Tokenise the string by splitting at the characters in delims.