95 _plotCoefNormSet(
"!plotCoefNormSet",
"plotCoefNormSet",this,
kFALSE,
kFALSE),
96 _plotCoefNormRange(0),
98 _indexCat(
"indexCat",
"Index category",this,inIndexCat),
116 _plotCoefNormSet(
"!plotCoefNormSet",
"plotCoefNormSet",this,
kFALSE,
kFALSE),
117 _plotCoefNormRange(0),
118 _partIntMgr(this,10),
119 _indexCat(
"indexCat",
"Index category",this,inIndexCat),
124 <<
" ERROR: Number PDF list entries must match number of index category states, no PDFs added" << endl ;
128 map<string,RooAbsPdf*> pdfMap ;
131 TIterator* cIter = inIndexCat.typeIterator() ;
136 pdfMap[string(
type->GetName())] = pdf ;
150 _plotCoefNormSet(
"!plotCoefNormSet",
"plotCoefNormSet",this,
kFALSE,
kFALSE),
151 _plotCoefNormRange(0),
152 _partIntMgr(this,10),
153 _indexCat(
"indexCat",
"Index category",this,inIndexCat),
177 for (map<string,RooAbsPdf*>::iterator iter=pdfMap.begin() ; iter!=pdfMap.end() ; ++iter) {
186 bool failure =
false;
187 for (map<string,RooAbsPdf*>::iterator iter=pdfMap.begin() ; iter!=pdfMap.end() ; ++iter) {
188 failure |=
addPdf(*iter->second,iter->first.c_str()) ;
192 throw std::invalid_argument(std::string(
"At least one of the PDFs of the RooSimultaneous ")
199 coutI(
InputArguments) <<
"RooSimultaneous::initialize(" <<
GetName() <<
") INFO: one or more input component of simultaneous p.d.f.s are"
200 <<
" simultaneous p.d.f.s themselves, rewriting composite expressions as one-level simultaneous p.d.f. in terms of"
201 <<
" final constituents and extended index category" << endl ;
205 map<string,RooSimultaneousAux::CompInfo> compMap ;
206 for (map<string,RooAbsPdf*>::iterator iter=pdfMap.begin() ; iter!=pdfMap.end() ; ++iter) {
207 RooSimultaneousAux::CompInfo ci ;
208 ci.pdf = iter->second ;
211 ci.simPdf = simComp ;
212 ci.subIndex = &simComp->
indexCat() ;
214 allAuxCats.
add(*(ci.subIndexComps),
kTRUE) ;
218 ci.subIndexComps = 0 ;
220 compMap[iter->first] = ci ;
225 allCats.
add(allAuxCats) ;
228 bool failure =
false;
231 for (map<string,RooSimultaneousAux::CompInfo>::iterator citer = compMap.begin() ; citer != compMap.end() ; ++citer) {
234 if (citer->second.subIndexComps) {
235 repliCats.
remove(*citer->second.subIndexComps) ;
236 delete citer->second.subIndexComps ;
238 inIndexCat.
setLabel(citer->first.c_str()) ;
240 if (!citer->second.simPdf) {
246 for (
const auto type : repliSuperCat) {
250 string superLabel = superIndex->
getLabel() ;
251 failure |=
addPdf(*citer->second.pdf,superLabel.c_str()) ;
253 <<
") assigning pdf " << citer->second.pdf->GetName() <<
" to super label " << superLabel << endl ;
265 string superLabel = superIndex->
getLabel() ;
266 RooAbsPdf* compPdf = citer->second.simPdf->getPdf(
type->GetName()) ;
268 failure |=
addPdf(*compPdf,superLabel.c_str()) ;
270 <<
") assigning pdf " << compPdf->
GetName() <<
"(member of " << citer->second.pdf->GetName()
271 <<
") to super label " << superLabel << endl ;
274 <<
type->GetName() <<
" for component RooSimultaneous p.d.f " << citer->second.pdf->GetName()
275 <<
"which is associated with master index label " << citer->first << endl ;
286 for (
const RooCatType* stype : *citer->second.subIndex) {
289 for (
const RooCatType* rtype : repliSuperCat) {
290 repliSuperCat.
setLabel(rtype->GetName()) ;
291 string superLabel = superIndex->
getLabel() ;
294 failure |=
addPdf(*compPdf,superLabel.c_str()) ;
296 <<
") assigning pdf " << compPdf->
GetName() <<
"(member of " << citer->second.pdf->GetName()
297 <<
") to super label " << superLabel << endl ;
300 << stype->
GetName() <<
" for component RooSimultaneous p.d.f " << citer->second.pdf->GetName()
301 <<
"which is associated with master index label " << citer->first << endl ;
310 throw std::invalid_argument(std::string(
"Failed to initialise RooSimultaneous ") +
GetName());
326 _plotCoefNormSet(
"!plotCoefNormSet",this,other._plotCoefNormSet),
327 _plotCoefNormRange(other._plotCoefNormRange),
328 _partIntMgr(other._partIntMgr,this),
329 _indexCat(
"indexCat",this,other._indexCat),
330 _numPdf(other._numPdf)
390 << catLabel <<
"' has already an associated PDF." << endl ;
398 <<
") ERROR: you cannot add a RooSimultaneous component to a RooSimultaneous using addPdf()."
399 <<
" Use the constructor with RooArgList if input p.d.f.s or the map<string,RooAbsPdf&> instead." << endl ;
464 if (proxy==0)
return 0 ;
478 catFrac=nEvtCat/nEvtTot ;
514 if (proxy==0)
return 0 ;
529 const RooArgSet* normSet,
const char* rangeName)
const
532 analVars.
add(allVars) ;
598 pc.defineString(
"sliceCatState",
"SliceCat",0,
"",
kTRUE) ;
599 pc.defineDouble(
"scaleFactor",
"Normalization",0,1.0) ;
601 pc.defineObject(
"sliceCatList",
"SliceCat",0,0,
kTRUE) ;
602 pc.defineObject(
"projSet",
"Project",0) ;
603 pc.defineObject(
"sliceSet",
"SliceVars",0) ;
604 pc.defineObject(
"projDataSet",
"ProjData",0) ;
605 pc.defineObject(
"projData",
"ProjData",1) ;
606 pc.defineMutex(
"Project",
"SliceVars") ;
607 pc.allowUndefined() ;
610 pc.process(cmdList) ;
620 Double_t scaleFactor =
pc.getDouble(
"scaleFactor") ;
625 const char* sliceCatState =
pc.getString(
"sliceCatState",0,
kTRUE) ;
636 strlcpy(buf,sliceCatState,1024) ;
637 const char* slabel = strtok(buf,
",") ;
649 slabel = strtok(0,
",") ;
656 coutE(
InputArguments) <<
"RooSimultaneous::plotOn(" <<
GetName() <<
") ERROR: must have a projection dataset for index category" << endl ;
673 projectedVars.
remove(*arg) ;
676 << sliceArg->
GetName() <<
" was not projected anyway" << endl ;
680 }
else if (projSet) {
694 coutE(
Plotting) <<
"RooSimultaneous::plotOn(" <<
GetName() <<
") ERROR: Projection over index category "
695 <<
"requested, but projection data set doesn't contain index category" << endl ;
714 projIdxServers.
add(*server) ;
734 <<
") ERROR: Projection dataset doesn't contain complete set of index category dependents" << endl ;
750 <<
" represents a slice in the index category (" <<
_indexCat.
arg().
GetName() <<
")" << endl ;
767 if (sliceSet && (slicedComponent = sliceSet->
find(*idxComp)) !=
nullptr) {
768 auto theCat =
static_cast<const RooAbsCategory*
>(slicedComponent);
771 idxCompLV->
setIndex(theCat->getIndex(),
false);
788 delete indexCatComps ;
802 if (!cmdList.
find(
"Asymmetry")) {
803 cmdList2.
Add(&tmp1) ;
805 cmdList2.
Add(&tmp2) ;
843 idxCompSliceIter->
Reset() ;
860 pdfCompList.
add(proxy->
arg()) ;
864 RooAddPdf *plotVar =
new RooAddPdf(plotVarName,
"weighted sum of RS components",pdfCompList,wgtCompList) ;
877 if (idxCompSliceSet->
getSize()>0) {
878 idxCompSliceIter->
Reset() ;
897 if (idxCompSliceSet->
getSize()>0) {
906 projSetTmp.
add(*projSet) ;
911 delete idxCatServers ;
917 <<
" represents a slice in index category components " << *idxCompSliceSet << endl ;
921 if (idxCompProjSet->
getSize()>0) {
923 <<
" averages with data index category components " << *idxCompProjSet << endl ;
925 delete idxCompProjSet ;
938 if (!cmdList.
find(
"Asymmetry")) {
939 cmdList2.
Add(&tmp1) ;
941 cmdList2.
Add(&tmp2) ;
947 cmdList2.
Add(&tmp3) ;
948 frame2 = plotVar->
plotOn(frame,cmdList2) ;
951 frame2 = plotVar->
plotOn(frame,cmdList2) ;
959 delete idxCompSliceIter ;
960 delete idxCompSliceSet ;
963 if (projDataTmp)
delete projDataTmp ;
1027 if (vars.
find(idxCatName) && prototype==0
1028 && (auxProto==0 || auxProto->
getSize()==0)
1029 && (autoBinned || (binnedTag && strlen(binnedTag)))) {
1050 const RooArgSet* protoVars = prototype ? prototype->
get() : 0 ;
1052 if (vars.
find(idxCatName) || (protoVars && protoVars->
find(idxCatName))) {
1081 }
else if (!allServers && anyServer) {
1083 coutE(
Plotting) <<
"RooSimultaneous::genContext: ERROR: prototype must include either all "
1084 <<
" components of the RooSimultaneous index category or none " << endl ;
1094 <<
") ERROR: no PDF associated with current state ("
1109 Bool_t correctForBinVolume,
1110 Bool_t showProgress)
const
1113 correctForBinVolume, showProgress) == 0)
1147 for (
Int_t i=0 ; i<nEvents ; i++) {
1160 *globClone = *tmp->
get(0) ;
1166 data->
add(*globClone) ;
RooTemplateProxy< RooAbsReal > RooRealProxy
Compatibility typedef for old uses of this proxy.
char * Form(const char *fmt,...)
Roo1DTable implements a one-dimensional table.
Double_t getFrac(const char *label, Bool_t silent=kFALSE) const
Return the fraction of entries in the table contained in the slot named 'label'.
RooAbsArg is the common abstract base class for objects that represent a value (of arbitrary type) an...
RooArgSet * getObservables(const RooArgSet &set, Bool_t valueOnly=kTRUE) const
Return the observables of this pdf given a set of observables.
Bool_t dependsOn(const RooAbsCollection &serverList, const RooAbsArg *ignoreArg=0, Bool_t valueOnly=kFALSE) const
Test whether we depend on (ie, are served by) any object in the specified collection.
virtual Bool_t isFundamental() const
Is this object a fundamental type that can be added to a dataset? Fundamental-type subclasses overrid...
RooArgSet * getVariables(Bool_t stripDisconnected=kTRUE) const
Return RooArgSet with all variables (tree leaf nodes of expresssion tree)
virtual Bool_t isDerived() const
Does value or shape of this arg depend on any other arg?
Bool_t addOwnedComponents(const RooArgSet &comps)
Take ownership of the contents of 'comps'.
TIterator * serverIterator() const R__SUGGEST_ALTERNATIVE("Use servers() and begin()
RooAbsCategoryLValue is the common abstract base class for objects that represent a discrete value th...
virtual Bool_t setLabel(const char *label, Bool_t printError=kTRUE)=0
virtual Bool_t setIndex(Int_t index, Bool_t printError=kTRUE)=0
RooAbsCategory is the common abstract base class for objects that represent a discrete value with a f...
virtual Int_t getIndex() const
Return index number of current state.
virtual const char * getLabel() const
Return label string of current state.
Int_t numTypes(const char *=0) const
Return number of types defined (in range named rangeName if rangeName!=0)
Bool_t contains(const RooAbsArg &var) const
virtual Bool_t addOwned(RooAbsArg &var, Bool_t silent=kFALSE)
Add the specified argument to list.
virtual TObject * Clone(const char *newname=0) const
Make a clone of an object using the Streamer facility.
virtual Bool_t add(const RooAbsArg &var, Bool_t silent=kFALSE)
Add the specified argument to list.
TIterator * createIterator(Bool_t dir=kIterForward) const R__SUGGEST_ALTERNATIVE("begin()
TIterator-style iteration over contained elements.
virtual Bool_t remove(const RooAbsArg &var, Bool_t silent=kFALSE, Bool_t matchByNameOnly=kFALSE)
Remove the specified argument from our list.
RooAbsArg * find(const char *name) const
Find object with given name in list.
RooAbsData is the common abstract base class for binned and unbinned datasets.
virtual const RooArgSet * get() const
virtual Roo1DTable * table(const RooArgSet &catSet, const char *cuts="", const char *opts="") const
Construct table for product of categories in catSet.
RooAbsData * reduce(const RooCmdArg &arg1, 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())
Create a reduced copy of this dataset.
RooAbsGenContext is the abstract base class for generator contexts of RooAbsPdf objects.
Bool_t canBeExtended() const
RooDataSet * generate(const RooArgSet &whatVars, Int_t nEvents, const RooCmdArg &arg1, const RooCmdArg &arg2=RooCmdArg::none(), const RooCmdArg &arg3=RooCmdArg::none(), const RooCmdArg &arg4=RooCmdArg::none(), const RooCmdArg &arg5=RooCmdArg::none())
See RooAbsPdf::generate(const RooArgSet&,const RooCmdArg&,const RooCmdArg&,const RooCmdArg&,...
Bool_t mustBeExtended() const
RooArgSet * _normSet
Normalization integral (owned by _normMgr)
virtual RooPlot * plotOn(RooPlot *frame, const RooCmdArg &arg1=RooCmdArg::none(), const RooCmdArg &arg2=RooCmdArg::none(), const RooCmdArg &arg3=RooCmdArg::none(), const RooCmdArg &arg4=RooCmdArg::none(), const RooCmdArg &arg5=RooCmdArg::none(), const RooCmdArg &arg6=RooCmdArg::none(), const RooCmdArg &arg7=RooCmdArg::none(), const RooCmdArg &arg8=RooCmdArg::none(), const RooCmdArg &arg9=RooCmdArg::none(), const RooCmdArg &arg10=RooCmdArg::none()) const
Helper calling plotOn(RooPlot*, RooLinkedList&) const.
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
Double_t getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
RooAbsReal * createIntegral(const RooArgSet &iset, const RooCmdArg &arg1, const RooCmdArg &arg2=RooCmdArg::none(), const RooCmdArg &arg3=RooCmdArg::none(), const RooCmdArg &arg4=RooCmdArg::none(), const RooCmdArg &arg5=RooCmdArg::none(), const RooCmdArg &arg6=RooCmdArg::none(), const RooCmdArg &arg7=RooCmdArg::none(), const RooCmdArg &arg8=RooCmdArg::none()) const
Create an object that represents the integral of the function over one or more observables listed in ...
Bool_t plotSanityChecks(RooPlot *frame) const
Utility function for plotOn(), perform general sanity check on frame to ensure safe plotting operatio...
virtual void fixAddCoefNormalization(const RooArgSet &addNormSet=RooArgSet(), Bool_t force=kTRUE)
Fix the interpretation of the coefficient of any RooAddPdf component in the expression tree headed by...
void makeProjectionSet(const RooAbsArg *plotVar, const RooArgSet *allVars, RooArgSet &projectedVars, Bool_t silent) const
Utility function for plotOn() that constructs the set of observables to project when plotting ourselv...
RooDataHist * fillDataHist(RooDataHist *hist, const RooArgSet *nset, Double_t scaleFactor, Bool_t correctForBinVolume=kFALSE, Bool_t showProgress=kFALSE) const
Fill a RooDataHist with values sampled from this function at the bin centers.
RooAddPdf is an efficient implementation of a sum of PDFs of the form.
RooArgList is a container object that can hold multiple RooAbsArg objects.
RooAbsArg * at(Int_t idx) const
Return object at given index, or nullptr if index is out of range.
virtual const char * name() const
RooAbsArg * absArg() const
RooArgSet is a container object that can hold multiple RooAbsArg objects.
RooArgSet * snapshot(bool deepCopy=true) const
Use RooAbsCollection::snapshot(), but return as RooArgSet.
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...
T * getObj(const RooArgSet *nset, Int_t *sterileIndex=0, const TNamed *isetRangeName=0)
T * getObjByIndex(Int_t index) const
Retrieve payload object by slot index.
Int_t setObj(const RooArgSet *nset, T *obj, const TNamed *isetRangeName=0)
RooCatType is an auxilary class for RooAbsCategory and defines a a single category state.
virtual const Text_t * GetName() const
Returns name of object.
virtual Bool_t setArg(RooAbsCategory &newRef)
Change object held in proxy into newRef.
const RooAbsCategory & arg() const
const char * label() const
RooCategory represents a fundamental (non-derived) discrete value object.
virtual Bool_t setLabel(const char *label, Bool_t printError=kTRUE)
Set value by specifying the name of the desired state If printError is set, a message will be printed...
RooCmdArg is a named container for two doubles, two integers two object points and three string point...
Class RooCmdConfig is a configurable parser for RooCmdArg named arguments.
The RooDataHist is a container class to hold N-dimensional binned data.
virtual Double_t weight() const
void set(Double_t weight, Double_t wgtErr=-1)
Set the weight and weight error of the bin enclosing the current (i.e.
virtual Int_t numEntries() const
Return the number of bins.
virtual const RooArgSet * get() const
RooDataSet is a container class to hold unbinned data.
virtual const RooArgSet * get(Int_t index) const override
Return RooArgSet with coordinates of event 'index'.
virtual void add(const RooArgSet &row, Double_t weight=1.0, Double_t weightError=0) override
Add a data point, with its coordinates specified in the 'data' argset, to the data set.
RooLinkedList is an collection class for internal use, storing a collection of RooAbsArg pointers in ...
TIterator * MakeIterator(Bool_t forward=kTRUE) const
Create a TIterator for this list.
void Delete(Option_t *o=0)
Remove all elements in collection and delete all elements NB: Collection does not own elements,...
TObject * find(const char *name) const
Return pointer to object with given name in collection.
virtual void Add(TObject *arg)
static const TNamed * ptr(const char *stringPtr)
Return a unique TNamed pointer for given C++ string.
A RooPlot is a plot frame and a container for graphics objects within that frame.
const RooArgSet * getNormVars() const
RooAbsRealLValue * getPlotVar() const
RooRealVar represents a variable that can be changed from the outside.
virtual Bool_t add(const RooAbsArg &var, Bool_t silent=kFALSE)
Overloaded RooArgSet::add() method inserts 'var' into set and registers 'var' as server to owner with...
virtual void removeAll()
Remove all argument inset using remove(const RooAbsArg&).
RooSimultaneous facilitates simultaneous fitting of multiple PDFs to subsets of a given dataset.
virtual RooAbsGenContext * genContext(const RooArgSet &vars, const RooDataSet *prototype=0, const RooArgSet *auxProto=0, Bool_t verbose=kFALSE) const
Return specialized generator context for simultaneous p.d.f.s.
virtual Double_t evaluate() const
Return the current value: the value of the PDF associated with the current index category state.
virtual Double_t expectedEvents(const RooArgSet *nset) const
Return the number of expected events: If the index is in nset, then return the sum of the expected ev...
virtual ~RooSimultaneous()
Destructor.
RooObjCacheManager _partIntMgr
virtual RooDataSet * generateSimGlobal(const RooArgSet &whatVars, Int_t nEvents)
Special generator interface for generation of 'global observables' – for RooStats tools.
Double_t analyticalIntegralWN(Int_t code, const RooArgSet *normSet, const char *rangeName=0) const
Return analytical integration defined by given code.
virtual RooDataHist * fillDataHist(RooDataHist *hist, const RooArgSet *nset, Double_t scaleFactor, Bool_t correctForBinVolume=kFALSE, Bool_t showProgress=kFALSE) const
RooCategoryProxy _indexCat
virtual ExtendMode extendMode() const
WVE NEEDS FIX.
virtual void selectNormalization(const RooArgSet *depSet=0, Bool_t force=kFALSE)
Interface function used by test statistics to freeze choice of observables for interpretation of frac...
Bool_t addPdf(const RooAbsPdf &pdf, const char *catLabel)
Associate given PDF with index category state label 'catLabel'.
friend class RooSimGenContext
void initialize(RooAbsCategoryLValue &inIndexCat, std::map< std::string, RooAbsPdf * > pdfMap)
virtual RooAbsGenContext * autoGenContext(const RooArgSet &vars, const RooDataSet *prototype=0, const RooArgSet *auxProto=0, Bool_t verbose=kFALSE, Bool_t autoBinned=kTRUE, const char *binnedTag="") const
virtual RooPlot * plotOn(RooPlot *frame, const RooCmdArg &arg1, 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(), const RooCmdArg &arg10=RooCmdArg()) const
Helper calling plotOn(RooPlot*, RooLinkedList&) const.
const TNamed * _plotCoefNormRange
Int_t getAnalyticalIntegralWN(RooArgSet &allVars, RooArgSet &numVars, const RooArgSet *normSet, const char *rangeName=0) const
Forward determination of analytical integration capabilities to component p.d.f.s A unique code is as...
RooSetProxy _plotCoefNormSet
const RooAbsCategoryLValue & indexCat() const
virtual void selectNormalizationRange(const char *rangeName=0, Bool_t force=kFALSE)
Interface function used by test statistics to freeze choice of range for interpretation of fraction c...
friend class RooSimSplitGenContext
RooAbsPdf * getPdf(const char *catName) const
Return the p.d.f associated with the given index category name.
RooSuperCategory can join several RooAbsCategoryLValue objects into a single category.
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...
const T & arg() const
Return reference to object held in proxy.
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 TIterator * MakeIterator(Bool_t dir=kIterForward) const
Return a list iterator.
virtual void Delete(Option_t *option="")
Remove all objects from the list AND delete all heap based objects.
virtual const char * GetName() const
Returns name of object.
Mother of all ROOT objects.
virtual Int_t IndexOf(const TObject *obj) const
Return index of object in collection.
TString & Append(const char *cs)
RooCmdArg ProjWData(const RooAbsData &projData, Bool_t binData=kFALSE)
RooCmdArg DrawOption(const char *opt)
RooCmdArg Project(const RooArgSet &projSet)
RooCmdArg Normalization(Double_t scaleFactor)
static constexpr double pc
static long int sum(long int i)