57 allPdfVars.
selectCommon(model.flattenedCatList(), catsAmongAllVars);
59 if(catsAmongAllVars.
size() != model.flattenedCatList().size()) {
60 oocoutE(
_pdf,Generation) <<
"RooSimSplitGenContext::ctor(" <<
GetName() <<
") ERROR: This context must"
61 <<
" generate all components of the index category" << std::endl ;
70 if (!model.canBeExtended()) {
71 oocoutE(
_pdf,Generation) <<
"RooSimSplitGenContext::RooSimSplitGenContext(" <<
GetName() <<
"): All components of the simultaneous PDF "
72 <<
"must be extended PDFs. Otherwise, it is impossible to calculate the number of events to be generated per component." << std::endl ;
80 _numPdf = model._pdfProxyList.GetSize() ;
84 for(
auto * proxy : static_range_cast<RooRealProxy*>(model._pdfProxyList)) {
85 auto pdf =
static_cast<RooAbsPdf*
>(proxy->absArg());
89 RooAbsGenContext* cx = pdf->autoGenContext(*compVars,
nullptr,
nullptr,verbose,autoBinned,binnedTag) ;
91 const auto state = idxCat.
lookupIndex(proxy->name());
100 oocoutE(
_pdf,Generation) <<
"RooSimSplitGenContext::RooSimSplitGenContext(" <<
GetName() <<
") Couldn't deep-clone index category, abort," << std::endl ;
101 throw std::string(
"RooSimSplitGenContext::RooSimSplitGenContext() Couldn't deep-clone index category, abort") ;
151 item->initGenerator(theEvent) ;
173 << nEvents <<
" events" << std::endl;
184 std::vector<double> nGen(
_numPdf);
185 std::vector<double> nExpected;
187 double nExpectedTotal = 0.;
191 nExpectedTotal += nExpected.back();
202 double nGenSoFar(0) ;
203 while (nGenSoFar<nEvents) {
206 for (
int i=0 ; i<
_numPdf ; i++) {
207 if (rand >= cumsum && rand < cumsum + nExpected[i]) {
212 cumsum += nExpected[i];
220 std::map<std::string,RooAbsData*> dataMap ;
226 dataMap[proxy->GetName()] =
_gcList[icomp]->generate(nGen[icomp],skipInit,extendedMode) ;
246 elem->setExpectedData(flag) ;
288 os <<
indent <<
"--- RooSimSplitGenContext ---" << std::endl ;
289 os <<
indent <<
"Using PDF ";
static void indent(ostringstream &buf, int indent_level)
bool recursiveRedirectServers(const RooAbsCollection &newSet, bool mustReplaceAll=false, bool nameChange=false, bool recurseInNewSet=true)
Recursively replace all servers with the new servers in newSet.
RooFit::OwningPtr< RooArgSet > getObservables(const RooArgSet &set, bool valueOnly=true) const
Given a set of possible observables, return the observables that this PDF depends on.
virtual bool isDerived() const
Does value or shape of this arg depend on any other arg?
Abstract base class for objects that represent a discrete value that can be set from the outside,...
value_type lookupIndex(const std::string &stateName) const
Find the index number corresponding to the state name.
virtual bool add(const RooAbsArg &var, bool silent=false)
Add the specified argument to list.
Storage_t::size_type size() const
RooAbsArg * find(const char *name) const
Find object with given name in list.
Abstract base class for generator contexts of RooAbsPdf objects.
RooArgSet _theEvent
Pointer to observable event being generated.
void printMultiline(std::ostream &os, Int_t contents, bool verbose=false, TString indent="") const override
Interface for multi-line printing.
void Print(Option_t *options=nullptr) const override
This method must be overridden when a class wants to print itself.
UInt_t _expectedEvents
Number of expected events from extended p.d.f.
bool _verbose
Verbose messaging?
bool _isValid
Is context in valid state?
Abstract interface for all probability density functions.
virtual double expectedEvents(const RooArgSet *nset) const
Return expected number of events to be used in calculation of extended likelihood.
RooArgSet is a container object that can hold multiple RooAbsArg objects.
RooArgSet * selectCommon(const RooAbsCollection &refColl) const
Use RooAbsCollection::selecCommon(), but return as RooArgSet.
Object to represent discrete states.
Container class to hold unbinned data.
virtual void printStream(std::ostream &os, Int_t contents, StyleOption style, TString indent="") const
Print description of object on ostream, printing contents set by contents integer,...
static double uniform(TRandom *generator=randomGenerator())
Return a number uniformly distributed from (0,1)
void setExpectedData(bool) override
Forward to components.
void generateEvent(RooArgSet &theEvent, Int_t remaining) override
this method is empty because it is not used in this type of context
std::vector< RooAbsGenContext * > _gcList
List of component generator contexts.
RooArgSet _allVarsPdf
All pdf variables.
void attach(const RooArgSet ¶ms) override
Attach the index category clone to the given event buffer.
RooSimSplitGenContext(const RooSimultaneous &model, const RooArgSet &vars, bool _verbose=false, bool autoBinned=true, const char *binnedTag="")
Constructor of specialized generator context for RooSimultaneous p.d.f.s.
void initGenerator(const RooArgSet &theEvent) override
Perform one-time initialization of generator context.
RooDataSet * createDataSet(const char *name, const char *title, const RooArgSet &obs) override
this method is empty because it is not used by this context
Int_t _numPdf
Number of generated PDFs.
void printMultiline(std::ostream &os, Int_t content, bool verbose=false, TString indent="") const override
Detailed printing interface.
RooArgSet _idxCatSet
Owner of index category components.
const RooSimultaneous * _pdf
Original PDF.
RooDataSet * generate(double nEvents=0, bool skipInit=false, bool extendedMode=false) override
Generate the specified number of events with nEvents>0 and and return a dataset containing the genera...
std::vector< int > _gcIndex
Index value corresponding to component.
void setProtoDataOrder(Int_t *lut) override
this method is empty because proto datasets are not supported by this context
~RooSimSplitGenContext() override
Destructor. Delete all owned subgenerator contexts.
RooAbsCategoryLValue * _idxCat
Clone of index category.
TString _idxCatName
Name of index category.
bool _expectedData
Asimov?
Facilitates simultaneous fitting of multiple PDFs to subsets of a given dataset.
TList _pdfProxyList
List of PDF proxies (named after applicable category state)
const char * GetName() const override
Returns name of object.
virtual void SetName(const char *name)
Set the name of the TNamed.
virtual const char * ClassName() const
Returns name of class to which the object belongs.
RooCmdArg Index(RooCategory &icat)
RooCmdArg Link(const char *state, RooAbsData &data)