62 if (prototype) allPdfVars.
add(*prototype->
get(),
true) ;
68 oocoutE(
_pdf,Generation) <<
"RooSimGenContext::ctor(" <<
GetName() <<
") ERROR: This context must"
69 <<
" generate all components of the index category" << std::endl ;
81 oocoutE(
_pdf,Generation) <<
"RooSimGenContext::ctor(" <<
GetName() <<
") ERROR: Need either extended mode"
82 <<
" or prototype data to calculate number of events per category" << std::endl ;
96 for(
auto * proxy : static_range_cast<RooRealProxy*>(model.
_pdfProxyList)) {
97 auto* pdf =
static_cast<RooAbsPdf*
>(proxy->absArg());
100 _gcList.emplace_back(pdf->genContext(pdfVars,prototype,auxProto,verbose)) ;
123 oocoutE(
_pdf,Generation) <<
"RooSimGenContext::RooSimGenContext(" <<
GetName() <<
") Couldn't deep-clone index category, abort," << std::endl ;
124 throw std::string(
"RooSimGenContext::RooSimGenContext() Couldn't deep-clone index category, abort") ;
166 item->initGenerator(theEvent) ;
184 std::map<std::string,RooAbsData*> dmap ;
185 for (
const auto& nameIdx : *
_idxCat) {
187 std::unique_ptr<RooArgSet> sliceObs{slicePdf->
getObservables(obs)};
188 std::string sliceName =
name + (
"_slice_" + nameIdx.first);
189 std::string sliceTitle = title + (
" (index slice " + nameIdx.first +
")");
190 dmap[nameIdx.first] =
new RooDataSet(sliceName,sliceTitle,*sliceObs);
216 if (
_gcIndex[i]==cidx) { gidx = i ; break ; }
222 oocoutW(
_pdf,Generation) <<
"RooSimGenContext::generateEvent: WARNING, no PDF to generate event of type " << cidx << std::endl ;
256 auto* pdf =
static_cast<RooAbsPdf*
>(proxy->absArg());
283 item->setProtoDataOrder(lut) ;
294 os <<
indent <<
"--- RooSimGenContext ---" << std::endl ;
295 os <<
indent <<
"Using PDF ";
297 os <<
indent <<
"List of component generators" << std::endl ;
303 item->printMultiline(os,content,verbose,indent2);
static void indent(ostringstream &buf, int indent_level)
bool recursiveRedirectServers(const RooAbsCollection &newServerList, 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.
void SetName(const char *name) override
Set the name of the TNamed.
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,...
virtual bool setIndex(value_type index, bool printError=true)=0
Change category state by specifying the index code of the desired state.
virtual value_type getCurrentIndex() const
Return index number of current state.
value_type lookupIndex(const std::string &stateName) const
Find the index number corresponding to the state name.
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.
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.
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.
bool canBeExtended() const
If true, PDF can provide extended likelihood term.
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'.
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)
Efficient implementation of the generator context specific for RooSimultaneous PDFs when generating m...
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.
TList _pdfProxyList
List of PDF proxies (named after applicable category state)
RooArgSet const & flattenedCatList() const
Internal utility function to get a list of all category components for this RooSimultaneous.
RooAbsPdf * getPdf(RooStringView catName) const
Return the p.d.f associated with the given index category name.
const RooAbsCategoryLValue & indexCat() const
virtual Int_t GetSize() const
Return the capacity of the collection, i.e.
const char * GetName() const override
Returns name of object.
TString & Append(const char *cs)
The namespace RooFit contains mostly switches that change the behaviour of functions of PDFs (or othe...