80 std::map<std::string, RooAbsPdf *>
pdfMap;
82 for (
unsigned int i = 0; i <
inPdfList.size(); ++i) {
138 <<
" ERROR: Number PDF list entries must match number of index category states, no PDFs added";
139 coutE(InputArguments) <<
errMsg.str() << std::endl;
140 throw std::invalid_argument(
errMsg.str());
163 _plotCoefNormSet(
"!plotCoefNormSet",
"plotCoefNormSet",
this,
false,
false),
164 _partIntMgr(
this, 10),
165 _indexCat(
"indexCat",
"Index category",
this, *
initInfo.indexCat)
167 for (std::size_t i = 0; i <
initInfo.finalPdfs.size(); ++i) {
192std::unique_ptr<RooSimultaneous::InitializationOutput>
194 std::map<std::string, RooAbsPdf *>
const&
pdfMap)
197 auto out = std::make_unique<RooSimultaneous::InitializationOutput>();
202 for (
auto const& item :
pdfMap) {
211 for (
auto const& item :
pdfMap) {
212 out->addPdf(*item.second,item.first);
217 std::string
msgPrefix =
"RooSimultaneous::initialize(" +
name +
") ";
220 oocoutI(
nullptr, InputArguments) <<
msgPrefix <<
"INFO: one or more input component of simultaneous p.d.f.s are"
221 <<
" simultaneous p.d.f.s themselves, rewriting composite expressions as one-level simultaneous p.d.f. in terms of"
222 <<
" final constituents and extended index category" << std::endl;
226 std::map<string,RooSimultaneousAux::CompInfo>
compMap ;
227 for (
auto const& item :
pdfMap) {
228 RooSimultaneousAux::CompInfo
ci ;
229 ci.pdf = item.second ;
234 ci.subIndexComps =
simComp->indexCat().isFundamental()
235 ? std::make_unique<RooArgSet>(
simComp->indexCat())
236 : std::unique_ptr<RooArgSet>(
simComp->indexCat().getVariables());
240 ci.subIndex =
nullptr;
249 out->superIndex = std::make_unique<RooSuperCategory>(
siname.c_str(),
siname.c_str(),allCats) ;
250 auto *superIndex = out->superIndex.get();
251 out->indexCat = superIndex;
257 if (
citem.second.subIndexComps) {
262 if (!
citem.second.simPdf) {
272 string superLabel = superIndex->getCurrentLabel() ;
275 <<
"assigning pdf " <<
citem.second.pdf->GetName() <<
" to super label " <<
superLabel << std::endl ;
285 for (
const auto&
type : *
citem.second.subIndex) {
287 string superLabel = superIndex->getCurrentLabel() ;
292 <<
"assigning pdf " <<
compPdf->GetName() <<
"(member of " <<
citem.second.pdf->GetName()
293 <<
") to super label " <<
superLabel << std::endl ;
295 oocoutW(
nullptr, InputArguments) <<
msgPrefix <<
"WARNING: No p.d.f. associated with label "
296 <<
type.second <<
" for component RooSimultaneous p.d.f " <<
citem.second.pdf->GetName()
297 <<
"which is associated with master index label " <<
citem.first << std::endl ;
308 for (
const auto& stype : *
citem.second.subIndex) {
313 const string superLabel = superIndex->getCurrentLabel() ;
318 <<
"assigning pdf " <<
compPdf->GetName() <<
"(member of " <<
citem.second.pdf->GetName()
319 <<
") to super label " <<
superLabel << std::endl ;
321 oocoutW(
nullptr, InputArguments) <<
msgPrefix <<
"WARNING: No p.d.f. associated with label "
322 << stype.second <<
" for component RooSimultaneous p.d.f " <<
citem.second.pdf->GetName()
323 <<
"which is associated with master index label " <<
citem.first << std::endl ;
340 _plotCoefNormSet(
"!plotCoefNormSet",
this,
other._plotCoefNormSet),
341 _plotCoefNormRange(
other._plotCoefNormRange),
343 _indexCat(
"indexCat",
this,
other._indexCat),
344 _numPdf(
other._numPdf)
393 coutE(InputArguments) <<
"RooSimultaneous::addPdf(" <<
GetName() <<
"): PDF '" << pdf.
GetName()
394 <<
"' overlaps with index category '" <<
_indexCat.
arg().GetName() <<
"'."<< std::endl ;
400 coutE(InputArguments) <<
"RooSimultaneous::addPdf(" <<
GetName() <<
"): index state '"
401 <<
catLabel <<
"' has already an associated PDF." << std::endl ;
408 coutE(InputArguments) <<
"RooSimultaneous::addPdf(" <<
GetName()
409 <<
") ERROR: you cannot add a RooSimultaneous component to a RooSimultaneous using addPdf()."
410 <<
" Use the constructor with RooArgList if input p.d.f.s or the map<string,RooAbsPdf&> instead." << std::endl ;
435 if (pdf.mustBeExtended())
462 if(!pdf2.canBeExtended()) {
509 if (
proxy==
nullptr)
return 0 ;
512 return (
static_cast<RooAbsPdf*
>(
proxy->absArg()))->expectedEvents(nset);
592 pc.
defineObject(
"sliceCatList",
"SliceCat",0,
nullptr,
true) ;
599 pc.
defineSet(
"projDataSet",
"ProjData",0) ;
615 double scaleFactor = pc.
getDouble(
"scaleFactor") ;
626 sliceSet = std::make_unique<RooArgSet>();
648 coutE(InputArguments) <<
"RooSimultaneous::plotOn(" <<
GetName() <<
") ERROR: must have a projection dataset for index category" << std::endl ;
663 coutI(Plotting) <<
"RooAbsReal::plotOn(" <<
GetName() <<
") slice variable "
664 <<
sliceArg->GetName() <<
" was not projected anyway" << std::endl ;
667 }
else if (projSet) {
681 coutE(Plotting) <<
"RooSimultaneous::plotOn(" <<
GetName() <<
") ERROR: Projection over index category "
682 <<
"requested, but projection data set doesn't contain index category" << std::endl ;
710 if (!projData->
get()->find(
server->GetName())) {
717 coutE(Plotting) <<
"RooSimultaneous::plotOn(" <<
GetName()
718 <<
") ERROR: Projection dataset doesn't contain complete set of index categories to do projection."
719 <<
"\n\tcategory " <<
missing <<
" is missing." << std::endl ;
745 <<
" represents a slice in the index category (" <<
_indexCat.
arg().GetName() <<
")" << std::endl ;
764 std::unique_ptr<RooAbsData>
773 if (!
cmdList.find(
"Asymmetry")) {
853 <<
" represents a slice in index category components " << *
idxCompSliceSet << std::endl ;
860 <<
" averages with data index category components " <<
idxCompProjSet << std::endl ;
864 <<
" averages with data index category (" <<
_indexCat.
arg().GetName() <<
")" << std::endl ;
874 if (!
cmdList.find(
"Asymmetry")) {
960 coutE(InputArguments) <<
"RooSimultaneous::generateSimGlobal(" <<
GetName()
961 <<
") asking to generate without the index category!\n"
962 <<
"It's not clear what to do. you probably want to either:\n"
964 <<
" 1. Generate according to the currently-selected pdf.\n"
965 <<
" Please do this explicitly with:\n"
966 <<
" simpdf->getPdf(simpdf->indexCat().getCurrentLabel())->generate(vars, ...)\n"
968 <<
" 1. Generate global observable values according to the union of all component pdfs.\n"
969 <<
" For this, please use simpdf->generateSimGlobal(vars, ...)\n"
980 coutE(Plotting) <<
"RooSimultaneous::genContext: ERROR: prototype must include either all "
981 <<
" components of the RooSimultaneous index category or none " << std::endl;
1035 coutE(InputArguments) <<
"RooSimultaneous::generateSimGlobal(" <<
GetName()
1036 <<
") asking to generate global obserables at the same time as the index category!\n"
1037 <<
"This doesn't make any sense: global observables are generally not related to a specific channel.\n"
1046 auto data = std::make_unique<RooDataSet>(
"gensimglobal",
"gensimglobal",
whatVars);
1048 for (
Int_t i=0 ; i<nEvents ; i++) {
1076 if (precision < 0.)
return;
1080 for (
auto const &item : this->
indexCat()) {
1082 auto const &
catName = item.first;
1090 (std::string(
"ORIGNAME:") + pdf.GetName()).c_str());
1113 std::map<std::string, double>
const&
precisions,
1120 for (
auto const &item : this->
indexCat()) {
1122 auto const &
catName = item.first;
1124 std::string
pdfName = pdf.GetName();
1127 const double precision =
1137 (std::string(
"ORIGNAME:") + pdf.GetName()).c_str());
1172 server->setAttribute(
"__obs__");
1173 }
else if (!
server->isFundamental()) {
1188 }
else if (!
server->isFundamental()) {
1196std::unique_ptr<RooAbsArg>
1210 const std::string prefix =
"_" +
catName +
"_";
1219 std::unique_ptr<RooArgSet>(
pdfClone->getVariables())->selectByAttrib(
"__obs__",
true)};
1259 for (std::size_t i = 0; i <
newPdfs.size(); ++i) {
1260 const char *label =
catNames[i].c_str();
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
RooTemplateProxy< RooAbsReal > RooRealProxy
Compatibility typedef replacing the old RooRealProxy class.
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
const_iterator begin() const
const_iterator end() const
Common abstract base class for objects that represent a value and a "shape" in RooFit.
bool dependsOn(const RooAbsCollection &serverList, const RooAbsArg *ignoreArg=nullptr, bool valueOnly=false) const
Test whether we depend on (ie, are served by) any object in the specified collection.
void setStringAttribute(const Text_t *key, const Text_t *value)
Associate string 'value' to this object under key 'key'.
void SetName(const char *name) override
Set the name of the TNamed.
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'.
bool redirectServers(const RooAbsCollection &newServerList, bool mustReplaceAll=false, bool nameChange=false, bool isRecursionStep=false)
Replace all direct servers of this object with the new servers in newServerList.
bool getAttribute(const Text_t *name) const
Check if a named attribute is set. By default, all attributes are unset.
TObject * Clone(const char *newname=nullptr) const override
Make a clone of an object using the Streamer facility.
Abstract base class for objects that represent a discrete value that can be set from the outside,...
A space to attach TBranches.
bool contains(const RooAbsArg &var) const
Check if collection contains an argument with the same name as var.
virtual bool add(const RooAbsArg &var, bool silent=false)
Add the specified argument to list.
virtual bool addOwned(RooAbsArg &var, bool silent=false)
Add an argument and transfer the ownership to the collection.
RooAbsArg * find(const char *name) const
Find object with given name in list.
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.
RooFit::OwningPtr< RooAbsData > reduce(const RooCmdArg &arg1, const RooCmdArg &arg2={}, const RooCmdArg &arg3={}, const RooCmdArg &arg4={}, const RooCmdArg &arg5={}, const RooCmdArg &arg6={}, const RooCmdArg &arg7={}, const RooCmdArg &arg8={}) const
Create a reduced copy of this dataset.
virtual Int_t numEntries() const
Return number of entries in dataset, i.e., count unweighted entries.
Abstract base class for generator contexts of RooAbsPdf objects.
Abstract interface for all probability density functions.
RooArgSet const * _normSet
Normalization integral (owned by _normMgr)
RooPlot * plotOn(RooPlot *frame, const RooCmdArg &arg1={}, const RooCmdArg &arg2={}, const RooCmdArg &arg3={}, const RooCmdArg &arg4={}, const RooCmdArg &arg5={}, const RooCmdArg &arg6={}, const RooCmdArg &arg7={}, const RooCmdArg &arg8={}, const RooCmdArg &arg9={}, const RooCmdArg &arg10={}) const override
Helper calling plotOn(RooPlot*, RooLinkedList&) const.
bool canBeExtended() const
If true, PDF can provide extended likelihood term.
Abstract base class for objects that represent a real value and implements functionality common to al...
RooDataHist * fillDataHist(RooDataHist *hist, const RooArgSet *nset, double scaleFactor, bool correctForBinVolume=false, bool showProgress=false) const
Fill a RooDataHist with values sampled from this function at the bin centers.
double getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
bool plotSanityChecks(RooPlot *frame) const
Utility function for plotOn(), perform general sanity check on frame to ensure safe plotting operatio...
void makeProjectionSet(const RooAbsArg *plotVar, const RooArgSet *allVars, RooArgSet &projectedVars, bool silent) const
Utility function for plotOn() that constructs the set of observables to project when plotting ourselv...
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.
RooArgSet is a container object that can hold multiple RooAbsArg objects.
RooArgSet * snapshot(bool deepCopy=true) const
Use RooAbsCollection::snapshot(), but return as RooArgSet.
RooArgSet * selectCommon(const RooAbsCollection &refColl) const
Use RooAbsCollection::selecCommon(), but return as RooArgSet.
static std::unique_ptr< RooAbsPdf > create(RooAbsPdf &pdf, RooAbsData const &data, double precision)
Creates a wrapping RooBinSamplingPdf if appropriate.
Int_t setObj(const RooArgSet *nset, T *obj, const TNamed *isetRangeName=nullptr)
Setter function without integration set.
T * getObjByIndex(Int_t index) const
Retrieve payload object by slot index.
Int_t lastIndex() const
Return index of slot used in last get or set operation.
T * getObj(const RooArgSet *nset, Int_t *sterileIndex=nullptr, const TNamed *isetRangeName=nullptr)
Getter function without integration set.
Named container for two doubles, two integers two object points and three string pointers that can be...
Configurable parser for RooCmdArg named arguments.
void defineMutex(const char *head, Args_t &&... tail)
Define arguments where any pair is mutually exclusive.
bool process(const RooCmdArg &arg)
Process given RooCmdArg.
double getDouble(const char *name, double defaultValue=0.0) const
Return double property registered with name 'name'.
bool defineDouble(const char *name, const char *argName, int doubleNum, double defValue=0.0)
Define double property name 'name' mapped to double in slot 'doubleNum' in RooCmdArg with name argNam...
RooArgSet * getSet(const char *name, RooArgSet *set=nullptr) const
Return RooArgSet property registered with name 'name'.
bool defineSet(const char *name, const char *argName, int setNum, const RooArgSet *set=nullptr)
Define TObject property name 'name' mapped to object in slot 'setNum' in RooCmdArg with name argName ...
bool ok(bool verbose) const
Return true of parsing was successful.
bool defineObject(const char *name, const char *argName, int setNum, const TObject *obj=nullptr, bool isArray=false)
Define TObject property name 'name' mapped to object in slot 'setNum' in RooCmdArg with name argName ...
const char * getString(const char *name, const char *defaultValue="", bool convEmptyToNull=false) const
Return string property registered with name 'name'.
bool defineString(const char *name, const char *argName, int stringNum, const char *defValue="", bool appendMode=false)
Define double property name 'name' mapped to double in slot 'stringNum' in RooCmdArg with name argNam...
const RooLinkedList & getObjectList(const char *name) const
Return list of objects registered with name 'name'.
bool defineInt(const char *name, const char *argName, int intNum, int defValue=0)
Define integer property name 'name' mapped to integer in slot 'intNum' in RooCmdArg with name argName...
void allowUndefined(bool flag=true)
If flag is true the processing of unrecognized RooCmdArgs is not considered an error.
int getInt(const char *name, int defaultValue=0) const
Return integer property registered with name 'name'.
TObject * getObject(const char *name, TObject *obj=nullptr) const
Return TObject property registered with name 'name'.
void removeAll() override
Remove all argument inset using remove(const RooAbsArg&).
bool add(const RooAbsArg &var, bool valueServer, bool shapeServer, bool silent)
Overloaded RooCollection_t::add() method insert object into set and registers object as server to own...
Container class to hold N-dimensional binned data.
double weight(std::size_t i) const
Return weight of i-th bin.
void set(std::size_t binNumber, double weight, double wgtErr)
Set bin content of bin that was last loaded with get(std::size_t).
double sumEntries() const override
Sum the weights of all bins.
Container class to hold unbinned data.
void compileServers(RooAbsArg &arg, RooArgSet const &normSet)
bool likelihoodMode() const
Collection class for internal use, storing a collection of RooAbsArg pointers in a doubly linked list...
static const TNamed * ptr(const char *stringPtr)
Return a unique TNamed pointer for given C++ string.
Plot frame and a container for graphics objects within that frame.
const RooArgSet * getNormVars() const
RooAbsRealLValue * getPlotVar() const
Facilitates simultaneous fitting of multiple PDFs to subsets of a given dataset.
void selectNormalization(const RooArgSet *depSet=nullptr, bool force=false) override
Interface function used by test statistics to freeze choice of observables for interpretation of frac...
double evaluate() const override
Return the current value: the value of the PDF associated with the current index category state.
Int_t _numPdf
Number of registered PDFs.
void selectNormalizationRange(const char *rangeName=nullptr, bool force=false) override
Interface function used by test statistics to freeze choice of range for interpretation of fraction c...
TList _pdfProxyList
List of PDF proxies (named after applicable category state)
RooObjCacheManager _partIntMgr
! Component normalization manager
~RooSimultaneous() override
Destructor.
RooFit::OwningPtr< RooDataSet > generateSimGlobal(const RooArgSet &whatVars, Int_t nEvents) override
Special generator interface for generation of 'global observables' – for RooStats tools.
RooArgSet const & flattenedCatList() const
Internal utility function to get a list of all category components for this RooSimultaneous.
RooPlot * plotOn(RooPlot *frame, const RooCmdArg &arg1, const RooCmdArg &arg2={}, const RooCmdArg &arg3={}, const RooCmdArg &arg4={}, const RooCmdArg &arg5={}, const RooCmdArg &arg6={}, const RooCmdArg &arg7={}, const RooCmdArg &arg8={}, const RooCmdArg &arg9={}, const RooCmdArg &arg10={}) const override
ExtendMode extendMode() const override
Examine the pdf components and check if one of them can be extended or must be extended.
RooCategoryProxy _indexCat
Index category.
double analyticalIntegralWN(Int_t code, const RooArgSet *normSet, const char *rangeName=nullptr) const override
Return analytical integration defined by given code.
Int_t getAnalyticalIntegralWN(RooArgSet &allVars, RooArgSet &numVars, const RooArgSet *normSet, const char *rangeName=nullptr) const override
Forward determination of analytical integration capabilities to component p.d.f.s A unique code is as...
double expectedEvents(const RooArgSet *nset) const override
Return the number of expected events: If the index is in nset, then return the sum of the expected ev...
friend class RooSimGenContext
RooAbsGenContext * autoGenContext(const RooArgSet &vars, const RooDataSet *prototype=nullptr, const RooArgSet *auxProto=nullptr, bool verbose=false, bool autoBinned=true, const char *binnedTag="") const override
RooAbsPdf * getPdf(RooStringView catName) const
Return the p.d.f associated with the given index category name.
std::unique_ptr< RooAbsArg > compileForNormSet(RooArgSet const &normSet, RooFit::Detail::CompileContext &ctx) const override
static std::unique_ptr< RooSimultaneous::InitializationOutput > initialize(std::string const &name, RooAbsCategoryLValue &inIndexCat, std::map< std::string, RooAbsPdf * > const &pdfMap)
void wrapPdfsInBinSamplingPdfs(RooAbsData const &data, double precision)
Wraps the components of this RooSimultaneous in RooBinSamplingPdfs.
const TNamed * _plotCoefNormRange
RooAbsGenContext * genContext(const RooArgSet &vars, const RooDataSet *prototype=nullptr, const RooArgSet *auxProto=nullptr, bool verbose=false) const override
Return specialized generator context for simultaneous p.d.f.s.
std::unique_ptr< RooArgSet > _indexCatSet
! Index category wrapped in a RooArgSet if needed internally
bool addPdf(const RooAbsPdf &pdf, const char *catLabel)
Associate given PDF with index category state label 'catLabel'.
RooSetProxy _plotCoefNormSet
const RooAbsCategoryLValue & indexCat() const
friend class RooSimSplitGenContext
virtual RooDataHist * fillDataHist(RooDataHist *hist, const RooArgSet *nset, double scaleFactor, bool correctForBinVolume=false, bool showProgress=false) const
The RooStringView is a wrapper around a C-style string that can also be constructed from a std::strin...
Joins several RooAbsCategoryLValue objects into a single category.
const char * label() const
Get the label of the current category state. This function only makes sense for category proxies.
const T & arg() const
Return reference to object held in proxy.
TObject * FindObject(const char *name) const override
Find an object in this list using its name.
void Add(TObject *obj) override
void Delete(Option_t *option="") override
Remove all objects from the list AND delete all heap based objects.
const char * GetName() const override
Returns name of object.
Mother of all ROOT objects.
virtual Int_t IndexOf(const TObject *obj) const
Return index of object in collection.
RooCmdArg SelectVars(const RooArgSet &vars)
RooCmdArg ProjWData(const RooAbsData &projData, bool binData=false)
RooCmdArg Project(const RooArgSet &projSet)
RooCmdArg Normalization(double scaleFactor)
RooCmdArg Cut(const char *cutSpec)
std::vector< std::string > Split(std::string_view str, std::string_view delims, bool skipEmpty=false)
Splits a string at each character in delims.
std::string makeSliceCutString(RooArgSet const &sliceDataSet)
The namespace RooFit contains mostly switches that change the behaviour of functions of PDFs (or othe...
T * OwningPtr
An alias for raw pointers for indicating that the return type of a RooFit function is an owning point...
OwningPtr< T > makeOwningPtr(std::unique_ptr< T > &&ptr)
Internal helper to turn a std::unique_ptr<T> into an OwningPtr.
std::unique_ptr< T > cloneTreeWithSameParameters(T const &arg, RooArgSet const *observables=nullptr)
Clone RooAbsArg object and reattach to original parameters.
std::string getRangeNameForSimComponent(std::string const &rangeName, bool splitRange, std::string const &catName)
Internal struct used for initialization.
std::vector< RooAbsPdf const * > finalPdfs
std::vector< std::string > finalCatLabels
void addPdf(const RooAbsPdf &pdf, std::string const &catLabel)
static uint64_t sum(uint64_t i)