428 static char *strtok_r(
char *s1,
const char *s2,
char **lasts)
434 while(*s1 && strchr(s2, *s1))
439 while(*s1 && !strchr(s2, *s1))
478 using namespace std ;
488 _protoPdfSet(protoPdfSet)
504 buildConfig->
addOwned(*
new RooStringVar(
"physModels",
"List and mapping of physics models to include in build",
"",4096)) ;
505 buildConfig->
addOwned(*
new RooStringVar(
"splitCats",
"List of categories used for splitting",
"",1024)) ;
534 const char* spaceChars =
" \t" ;
538 char *buf =
new char[buflen] ;
540 strlcpy(buf,((
RooStringVar*)buildConfig.
find(
"physModels"))->getVal(),buflen) ;
542 if (strstr(buf,
" : ")) {
543 const char* physCatName = strtok(buf,spaceChars) ;
546 coutE(
InputArguments) <<
"RooSimPdfBuilder::buildPdf: ERROR physics index category " << physCatName
547 <<
" not found in dataset variables" << endl ;
551 coutI(
ObjectHandling) <<
"RooSimPdfBuilder::buildPdf: category indexing physics model: " << physCatName << endl ;
559 strtok(0,spaceChars) ;
560 physName = strtok(0,spaceChars) ;
562 physName = strtok(buf,spaceChars) ;
566 coutE(
InputArguments) <<
"RooSimPdfBuilder::buildPdf: ERROR: No models specified, nothing to do!" << endl ;
578 if (strchr(physName,
'=')) {
581 coutW(
ObjectHandling) <<
"RooSimPdfBuilder::buildPdf: WARNING: without physCat specification " 582 <<
"<physCatState>=<pdfProtoName> association is meaningless" << endl ;
584 stateName = physName ;
585 physName = strchr(stateName,
'=') ;
590 stateName = physName ;
596 << (physName?physName:
"(null)") <<
" is not defined" << endl ;
602 if (stateMap.
find(stateName)) {
603 coutW(
InputArguments) <<
"RooSimPdfBuilder::buildPdf: WARNING: multiple PDFs specified for state " 604 << stateName <<
", only first will be used" << endl ;
609 physModelSet.
add(*physModel,
kTRUE) ;
615 physName = strtok(0,spaceChars) ;
618 }
else if (physCat==0) {
619 coutW(
InputArguments) <<
"RooSimPdfBuilder::buildPdf: WARNING: without physCat specification, only the first model will be used" << endl ;
623 coutI(
ObjectHandling) <<
"RooSimPdfBuilder::buildPdf: list of physics models " << physModelSet << endl ;
628 TList splitStateList ;
632 buflen = strlen(((
RooStringVar*)buildConfig.
find(
"splitCats"))->getVal())+1 ;
633 buf =
new char[buflen] ;
634 strlcpy(buf,((
RooStringVar*)buildConfig.
find(
"splitCats"))->getVal(),buflen) ;
636 char *catName = strtok(buf,spaceChars) ;
642 if (strchr(catName,
'(')) {
644 catName = strtok_r(catName,
"(",&tokenPtr) ;
645 stateList = strtok_r(0,
")",&tokenPtr) ;
653 coutE(
InputArguments) <<
"RooSimPdfBuilder::buildPdf: ERROR requested split category " << (catName?catName:
"(null)")
654 <<
" is not a RooCategory in the dataset" << endl ;
658 splitCatSet.
add(*splitCat) ;
663 <<
" restricted to states (" << stateList <<
")" << endl ;
668 splitStateList.
Add(slist) ;
670 char* stateLabel = strtok_r(stateList,
",",&tokenPtr) ;
677 <<
" doesn't have a state named " << stateLabel << endl ;
684 stateLabel = strtok_r(0,
",",&tokenPtr) ;
688 catName = strtok(0,spaceChars) ;
690 if (physCat) splitCatSet.
add(*physCat) ;
691 RooSuperCategory masterSplitCat(
"masterSplitCat",
"Master splitting category",splitCatSet) ;
693 coutI(
ObjectHandling) <<
"RooSimPdfBuilder::buildPdf: list of splitting categories " << splitCatSet << endl ;
701 if (!auxSplitCloneSet) {
702 coutE(
InputArguments) <<
"RooSimPdfBuilder::buildPdf(" <<
GetName() <<
") Couldn't deep-clone set auxiliary splitcats, abort." << endl ;
715 coutW(
InputArguments) <<
"RooSimPdfBuilder::buildPdf: WARNING: dataset contains a fundamental splitting category " << endl
716 <<
" with the same name as an auxiliary split function (" << aux->
GetName() <<
"). " << endl
717 <<
" Auxiliary split function will be ignored" << endl ;
725 <<
" because it has servers that are not listed in splitCatSet: " << *parSet << endl ;
734 auxSplitSet.
add(*aux) ;
738 coutI(
ObjectHandling) <<
"RooSimPdfBuilder::buildPdf: list of auxiliary splitting categories " << auxSplitSet << endl ;
751 customizerList->
Add(physCustomizer) ;
758 buflen = strlen(ruleStr->
getVal())+1 ;
759 buf =
new char[buflen] ;
761 strlcpy(buf,ruleStr->
getVal(),buflen) ;
764 char* token = strtok_r(buf,spaceChars,&tokenPtr) ;
766 enum Mode { SplitCat, Colon, ParamList } ;
767 Mode mode(SplitCat) ;
777 splitCatName = token ;
779 if (strchr(splitCatName,
',')) {
784 TString origCompCatName(splitCatName) ;
789 char *catName2 = strtok_r(token,
",",&tokptr) ;
802 <<
" not found in the primary or auxilary splitcat list" << endl ;
803 customizerList->
Delete() ;
804 delete customizerList ;
810 compCatSet.
add(*cat) ;
812 catName2 = strtok_r(0,
",",&tokptr) ;
824 coutE(
InputArguments) <<
"RooSimPdfBuilder::buildPDF: ERROR: Ill defined split: auxiliary splitting category " << arg->
GetName()
825 <<
" used in composite split " << compCatSet <<
" depends on one or more of the other splitting categories in the composite split" << endl ;
828 customizerList->
Delete() ;
829 delete customizerList ;
837 splitCat =
new RooMultiCategory(origCompCatName,origCompCatName,compCatSet) ;
854 << splitCatName <<
" not found in the primary or auxiliary splitcat list" << endl ;
855 customizerList->
Delete() ;
856 delete customizerList ;
868 if (strcmp(token,
":")) {
869 coutE(
InputArguments) <<
"RooSimPdfBuilder::buildPdf: ERROR in parsing, expected ':' after " 870 << splitCat <<
", found " << token << endl ;
871 customizerList->
Delete() ;
872 delete customizerList ;
888 paramList->
add(*compList) ;
891 Bool_t lastCharIsComma = (token[strlen(token)-1]==
',') ;
894 char *paramName = strtok_r(token,
",",&tokptr) ;
897 char *remainderState = 0 ;
899 if (paramName && strtok_r(paramName,
"[",&tokptr2)) {
900 remainderState = strtok_r(0,
"]",&tokptr2) ;
906 if (remainderState) {
909 << paramName <<
" has invalid remainder state name: " << remainderState << endl ;
911 customizerList->
Delete() ;
912 delete customizerList ;
922 <<
" is not a parameter of physics model " << physModel->
GetName() << endl ;
924 customizerList->
Delete() ;
925 delete customizerList ;
930 splitParamList.
add(*param) ;
933 if (remainderState) {
936 if (!dynamic_cast<RooAbsReal*>(param)) {
937 coutE(
InputArguments) <<
"RooSimPdfBuilder::buildPdf: ERROR fraction split requested of non-real valued parameter " 940 customizerList->
Delete() ;
941 delete customizerList ;
951 if (remStateSplitList && !remStateSplitList->
FindObject(remainderState)) {
953 <<
" remainder state " << remainderState <<
" in parameter split " 954 << param->
GetName() <<
" is not actually being built" << endl ;
956 customizerList->
Delete() ;
957 delete customizerList ;
966 TString formExpr(
"1") ;
972 if (!TString(type->
GetName()).CompareTo(remainderState))
continue ;
980 TString splitLeafName(param->
GetName()) ;
981 splitLeafName.Append(
"_") ;
982 splitLeafName.Append(type->
GetName()) ;
992 fracLeafList.
add(*splitLeaf) ;
993 formExpr.Append(
Form(
"-@%d",i++)) ;
998 TString remLeafName(param->
GetName()) ;
999 remLeafName.Append(
"_") ;
1000 remLeafName.Append(remainderState) ;
1007 coutI(
ObjectHandling) <<
"RooSimPdfBuilder::buildPdf: creating remainder fraction formula for " << remainderState
1008 <<
" specialization of split parameter " << param->
GetName() <<
" " << formExpr << endl ;
1013 paramName = strtok_r(0,
",",&tokptr) ;
1014 if (paramName && strtok_r(paramName,
"[",&tokptr2)) {
1015 remainderState = strtok_r(0,
"]",&tokptr2) ;
1020 physCustomizer->
splitArgs(splitParamList,*splitCat) ;
1024 if (!lastCharIsComma) mode = SplitCat ;
1029 token = strtok_r(0,spaceChars,&tokenPtr) ;
1032 if (mode!=SplitCat) {
1034 << (mode==Colon?
":":
"parameter list") <<
" after " << (token?token:
"(null)") << endl ;
1043 coutI(
ObjectHandling) <<
"RooSimPdfBuilder::buildPdf: configured customizers for all physics models" << endl ;
1045 customizerList->
Print() ;
1050 if (physCat) fitCatList.
add(*physCat) ;
1051 fitCatList.
add(splitCatSet) ;
1093 <<
" for mode " << fcState->
GetName() << endl ;
1103 delete customizerList ;
1106 splitStateList.
Delete() ;
1108 if (auxSplitCloneSet)
delete auxSplitCloneSet ;
1127 std::list<RooSimultaneous*>::iterator iter =
_simPdfList.begin() ;
1133 std::list<RooSuperCategory*>::iterator iter2 =
_fitCatList.begin() ;
virtual TObject * clone(const char *newname=0) const =0
virtual const char * GetName() const
Returns name of object.
TIterator * createIterator(Bool_t dir=kIterForward) const
virtual Bool_t add(const RooAbsArg &var, Bool_t silent=kFALSE)
Add the specified argument to list.
virtual const char * getVal() const
Return value of object. Calculated if dirty, otherwise cached value is returned.
virtual void Delete(Option_t *option="")
Remove all objects from the list AND delete all heap based objects.
virtual Bool_t add(const RooAbsCollection &col, Bool_t silent=kFALSE)
Add a collection of arguments to this collection by calling add() for each element in the source coll...
std::list< RooSimultaneous * > _simPdfList
virtual void AddAll(const TCollection *col)
Add all objects from collection col to this collection.
Iterator abstract base class.
virtual TObject * FindObject(const char *name) const
Find an object in this list using its name.
Bool_t addPdf(const RooAbsPdf &pdf, const char *catLabel)
Associate given PDF with index category state label 'catLabel'.
if on multiple lines(like in C++). **The " * configuration fragment. * * The "import myobject continue
Parses the configuration file.
RooCatType is an auxilary class for RooAbsCategory and defines a a single category state...
TList _retiredCustomizerList
RooAbsCategoryLValue is the common abstract base class for objects that represent a discrete value th...
RooArgSet _splitNodeListOwned
RooAbsCollection * snapshot(Bool_t deepCopy=kTRUE) const
Take a snap shot of current collection contents: An owning collection is returned containing clones o...
virtual TObject * First() const
Return the first object in the list. Returns 0 when list is empty.
RooSimultaneous * buildPdf(const RooArgSet &buildConfig, const RooArgSet &dependents, const RooArgSet *auxSplitCats=0, Bool_t verbose=kFALSE)
Initialize needed components.
TIterator * typeIterator() const
Return iterator over all defined states.
virtual const Text_t * GetName() const
Returns name of object.
RooArgSet * getComponents() const
const RooCatType * lookupType(Int_t index, Bool_t printError=kFALSE) const
Find our type corresponding to the specified index, or return 0 for no match.
char * Form(const char *fmt,...)
virtual Bool_t addOwned(const RooAbsCollection &col, Bool_t silent=kFALSE)
Add a collection of arguments to this collection by calling addOwned() for each element in the source...
virtual const char * getLabel() const
Return label string of current state.
void SetName(const char *name)
RooCategory represents a fundamental (non-derived) discrete value object.
std::list< RooSuperCategory * > _fitCatList
RooMultiCategory consolidates several RooAbsCategory objects into a single category.
RooAbsArg * find(const char *name) const
Find object with given name in list.
RooArgSet _compSplitCatSet
RooArgSet * getParameters(const RooAbsData *data, Bool_t stripDisconnected=kTRUE) const
Create a list of leaf nodes in the arg tree starting with ourself as top node that don't match any of...
void addSpecializations(const RooArgSet &specSet)
Bool_t dependsOnValue(const RooAbsCollection &serverList, const RooAbsArg *ignoreArg=0) const
Mother of all ROOT objects.
void splitArgs(const RooArgSet &argSet, const RooAbsCategory &splitCat)
Split all arguments in 'set' into individualized clones for each defined state of 'splitCat'...
virtual Bool_t remove(const RooAbsArg &var, Bool_t silent=kFALSE, Bool_t matchByNameOnly=kFALSE)
Remove the specified argument from our list.
RooAbsPdf is the abstract interface for all probability density functions The class provides hybrid a...
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...
virtual void Add(TObject *obj)
virtual TObject * Next()=0
RooAbsCategory is the common abstract base class for objects that represent a discrete value with a f...
RooSimPdfBuilder(const RooArgSet &pdfProtoList)
RooSuperCategory consolidates several RooAbsCategoryLValue objects into a single category.
RooAbsArg is the common abstract base class for objects that represent a value (of arbitrary type) an...
void setHashTableSize(Int_t i)
virtual void Print(Option_t *option="") const
Default print for collections, calls Print(option, 1).
virtual const char * GetName() const
Returns name of object.
Bool_t recursiveRedirectServers(const RooAbsCollection &newServerList, Bool_t mustReplaceAll=kFALSE, Bool_t nameChange=kFALSE, Bool_t recurseInNewSet=kTRUE)
RooStringVar implements a string values RooAbsArg.
virtual Bool_t setLabel(const char *label, Bool_t printError=kTRUE)
Set the value of the super category by specifying the state name by setting the state names of the co...
RooSimultaneous facilitates simultaneous fitting of multiple PDFs to subsets of a given dataset...
RooArgSet * createProtoBuildConfig()
Make RooArgSet of configuration objects.