61 RooAbsGenContext(model,vars,prototype,auxProto,verbose), _pdf(&model), _protoData(nullptr)
68 if (prototype) allPdfVars.
add(*prototype->
get(),
true) ;
75 <<
" generate all components of the index category" << endl ;
88 <<
" or prototype data to calculate number of events per category" << endl ;
102 for(
auto * proxy : static_range_cast<RooRealProxy*>(model.
_pdfProxyList)) {
103 auto* pdf =
static_cast<RooAbsPdf*
>(proxy->absArg());
106 RooAbsGenContext* cx = pdf->genContext(pdfVars,prototype,auxProto,verbose) ;
129 oocoutE(
_pdf,
Generation) <<
"RooSimGenContext::RooSimGenContext(" <<
GetName() <<
") Couldn't deep-clone index category, abort," << endl ;
130 throw std::string(
"RooSimGenContext::RooSimGenContext() Couldn't deep-clone index category, abort") ;
145 for (vector<RooAbsGenContext*>::iterator iter =
_gcList.begin() ; iter!=
_gcList.end() ; ++iter) {
163 for (vector<RooAbsGenContext*>::iterator iter =
_gcList.begin() ; iter!=
_gcList.end() ; ++iter) {
164 (*iter)->attach(args) ;
186 for (vector<RooAbsGenContext*>::iterator iter =
_gcList.begin() ; iter!=
_gcList.end() ; ++iter) {
187 (*iter)->initGenerator(theEvent) ;
205 map<string,RooAbsData*> dmap ;
206 for (
const auto& nameIdx : *
_idxCat) {
208 std::unique_ptr<RooArgSet> sliceObs{slicePdf->
getObservables(obs)};
209 std::string sliceName =
Form(
"%s_slice_%s",
name, nameIdx.first.c_str());
210 std::string sliceTitle =
Form(
"%s (index slice %s)", title, nameIdx.first.c_str());
211 dmap[nameIdx.first] =
new RooDataSet(sliceName,sliceTitle,*sliceObs);
237 if (
_gcIndex[i]==cidx) { gidx = i ; break ; }
243 oocoutW(
_pdf,
Generation) <<
"RooSimGenContext::generateEvent: WARNING, no PDF to generate event of type " << cidx << endl ;
277 auto* pdf =
static_cast<RooAbsPdf*
>(proxy->absArg());
303 for (vector<RooAbsGenContext*>::iterator iter =
_gcList.begin() ; iter!=
_gcList.end() ; ++iter) {
304 (*iter)->setProtoDataOrder(lut) ;
315 os <<
indent <<
"--- RooSimGenContext ---" << endl ;
316 os <<
indent <<
"Using PDF ";
318 os <<
indent <<
"List of component generators" << endl ;
323 for (vector<RooAbsGenContext*>::const_iterator iter =
_gcList.begin() ; iter!=
_gcList.end() ; ++iter) {
324 (*iter)->printMultiline(os,content,verbose,indent2);
static void indent(ostringstream &buf, int indent_level)
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
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.
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
bool selectCommon(const RooAbsCollection &refColl, RooAbsCollection &outColl) const
Create a subset of the current collection, consisting only of those elements that are contained as we...
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.
Object to represent discrete states.
RooDataSet is a 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)
RooSimGenContext is an efficient implementation of the generator context specific for RooSimultaneous...
RooAbsCategoryLValue * _idxCat
Clone of index category.
void initGenerator(const RooArgSet &theEvent) override
Perform one-time initialization of generator context.
void printMultiline(std::ostream &os, Int_t content, bool verbose=false, TString indent="") const override
Detailed printing interface.
RooArgSet _allVarsPdf
All pdf variables.
double * _fracThresh
[_numPdf] Fraction threshold array
RooArgSet * _idxCatSet
Owner of index category components.
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.
RooDataSet * _protoData
! Prototype dataset
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.
std::vector< RooAbsGenContext * > _gcList
List of component generator contexts.
void generateEvent(RooArgSet &theEvent, Int_t remaining) override
Generate event appropriate for current index state.
Int_t _numPdf
Number of generated PDFs.
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
Destructor. Delete all owned subgenerator contexts.
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.
virtual void SetName(const char *name)
Set the name of the TNamed.
TString & Append(const char *cs)
RooCmdArg Index(RooCategory &icat)
RooCmdArg Link(const char *state, RooAbsData &data)
The namespace RooFit contains mostly switches that change the behaviour of functions of PDFs (or othe...