61 if (prototype) allPdfVars.
add(*prototype->
get(),
true) ;
64 allPdfVars.
selectCommon(model.flattenedCatList(), catsAmongAllVars);
66 if(catsAmongAllVars.
size() != model.flattenedCatList().size()) {
67 oocoutE(
_pdf,Generation) <<
"RooSimGenContext::ctor(" <<
GetName() <<
") ERROR: This context must"
68 <<
" generate all components of the index category" << std::endl ;
80 oocoutE(
_pdf,Generation) <<
"RooSimGenContext::ctor(" <<
GetName() <<
") ERROR: Need either extended mode"
81 <<
" or prototype data to calculate number of events per category" << std::endl ;
88 _numPdf = model._pdfProxyList.GetSize() ;
96 auto* pdf =
static_cast<RooAbsPdf*
>(proxy->absArg());
99 _gcList.emplace_back(pdf->genContext(pdfVars,prototype,auxProto,verbose)) ;
102 _gcList.back()->SetName(proxy->name()) ;
122 oocoutE(
_pdf,Generation) <<
"RooSimGenContext::RooSimGenContext(" <<
GetName() <<
") Couldn't deep-clone index category, abort," << std::endl ;
123 throw std::string(
"RooSimGenContext::RooSimGenContext() Couldn't deep-clone index category, abort") ;
137 _idxCat->recursiveRedirectServers(args) ;
155 _idxCat->recursiveRedirectServers(theEvent) ;
165 item->initGenerator(theEvent) ;
183 std::map<std::string,RooAbsData*> dmap ;
184 for (
const auto& nameIdx : *
_idxCat) {
186 std::unique_ptr<RooArgSet> sliceObs{slicePdf->
getObservables(obs)};
187 std::string sliceName =
name + (
"_slice_" + nameIdx.first);
188 std::string sliceTitle = title + (
" (index slice " + nameIdx.first +
")");
189 dmap[nameIdx.first] =
new RooDataSet(sliceName,sliceTitle,*sliceObs);
221 oocoutW(
_pdf,
Generation) <<
"RooSimGenContext::generateEvent: WARNING, no PDF to generate event of type " << cidx << std::endl ;
255 auto* pdf =
static_cast<RooAbsPdf*
>(proxy->absArg());
282 item->setProtoDataOrder(lut) ;
293 os <<
indent <<
"--- RooSimGenContext ---" << std::endl ;
294 os <<
indent <<
"Using PDF ";
296 os <<
indent <<
"List of component generators" << std::endl ;
302 item->printMultiline(os,content,verbose,indent2);
ROOT::RRangeCast< T, false, Range_t > static_range_cast(Range_t &&coll)
int Int_t
Signed integer 4 bytes (int).
static void indent(ostringstream &buf, int indent_level)
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.
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.
bool contains(const char *name) const
Check if collection contains an argument with a specific 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.
RooAbsGenContext(const RooAbsPdf &model, const RooArgSet &vars, const RooDataSet *prototype=nullptr, const RooArgSet *auxProto=nullptr, bool _verbose=false)
Constructor.
void printMultiline(std::ostream &os, Int_t contents, bool verbose=false, TString indent="") const override
Interface for multi-line printing.
virtual void generateEvent(RooArgSet &theEvent, Int_t remaining)=0
bool _isValid
Is context in valid state?
virtual void setProtoDataOrder(Int_t *lut)
Set the traversal order of prototype data to that in the lookup tables passed as argument.
Abstract interface for all probability density functions.
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.
Object to represent discrete states.
Container class to hold unbinned data.
const RooArgSet * get(Int_t index) const override
Return RooArgSet with coordinates of event 'index'.
static double uniform(TRandom *generator=randomGenerator())
Return a number uniformly distributed from (0,1).
RooAbsCategoryLValue * _idxCat
Clone of index category.
void initGenerator(const RooArgSet &theEvent) override
Perform one-time initialization of generator context.
std::unique_ptr< RooDataSet > _protoData
! Prototype dataset
void printMultiline(std::ostream &os, Int_t content, bool verbose=false, TString indent="") const override
Detailed printing interface.
std::unique_ptr< RooArgSet > _idxCatSet
Owner of index category components.
RooArgSet _allVarsPdf
All pdf variables.
void setProtoDataOrder(Int_t *lut) override
Set the traversal order of the prototype data to that in the given lookup table.
void updateFractions()
No action needed if we have a proto index.
std::vector< std::unique_ptr< RooAbsGenContext > > _gcList
List of component generator contexts.
const RooSimultaneous * _pdf
Original PDF.
RooSimGenContext(const RooSimultaneous &model, const RooArgSet &vars, const RooDataSet *prototype=nullptr, const RooArgSet *auxProto=nullptr, bool _verbose=false)
Constructor of specialized generator context for RooSimultaneous p.d.f.s.
RooDataSet * createDataSet(const char *name, const char *title, const RooArgSet &obs) override
Create an empty dataset to hold the events that will be generated.
TString _idxCatName
Name of index category.
void generateEvent(RooArgSet &theEvent, Int_t remaining) override
Generate event appropriate for current index state.
Int_t _numPdf
Number of generated PDFs.
std::vector< double > _fracThresh
[_numPdf] Fraction threshold array
std::vector< int > _gcIndex
Index value corresponding to component.
void attach(const RooArgSet ¶ms) override
Attach the index category clone to the given event buffer.
~RooSimGenContext() override
bool _haveIdxProto
Flag set if generation of index is requested.
Facilitates simultaneous fitting of multiple PDFs to subsets of a given dataset.
const char * GetName() const override
Returns name of object.
TString & Append(const char *cs)
RooCmdArg Link(const char *state, RooAbsData &data)
The namespace RooFit contains mostly switches that change the behaviour of functions of PDFs (or othe...