36using std::endl, std::vector, std::ostream;
47 cxcoutI(Generation) <<
"RooBinnedGenContext::ctor() setting up event special generator context for sum p.d.f. " << model.GetName()
48 <<
" for generation of observable(s) " << vars ;
49 if (prototype)
ccxcoutI(Generation) <<
" with prototype data for " << *prototype->
get() ;
50 if (auxProto && !auxProto->empty())
ccxcoutI(Generation) <<
" with auxiliary prototypes " << *auxProto ;
62 coefNSet.add(*prototype->get(),
true) ;
70 _hist = std::make_unique<RooDataHist>(
"genData",
"genData",*
_vars);
116 double nEvents = nEvt ;
120 coutE(InputArguments) <<
"RooAbsPdf::generateBinned(" <<
GetName()
121 <<
") ERROR: No event count provided and p.d.f does not provide expected number of events" << std::endl ;
139 vector<int> histOut(
_hist->numEntries()) ;
141 Int_t histOutSum(0) ;
142 for (
int i=0 ; i<
_hist->numEntries() ; i++) {
144 const double wi =
_hist->weight(i) ;
148 double w=wi*nEvents ;
149 wudata->add(*coords,
w) ;
151 }
else if (extended) {
155 wudata->add(*coords,
w) ;
165 histOutSum += histOut[i] ;
175 Int_t nEvtExtra = std::abs(
Int_t(nEvents)-histOutSum) ;
176 Int_t wgt = (histOutSum>nEvents) ? -1 : 1 ;
182 _hist->get(ibinRand) ;
185 if (ranY<_hist->weight(ibinRand)) {
187 histOut[ibinRand]++ ;
190 if (histOut[ibinRand]>0) {
191 histOut[ibinRand]-- ;
201 for (
int i=0 ; i<
_hist->numEntries() ; i++) {
203 wudata->add(*
_hist->get(),histOut[i]) ;
230 os <<
indent <<
"--- RooBinnedGenContext ---" << std::endl ;
231 os <<
indent <<
"Using PDF ";
int Int_t
Signed integer 4 bytes (int)
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.
void setOperMode(OperMode mode, bool recurseADirty=true)
Set the operation mode of this node.
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.
Storage_t const & get() const
Const access to the underlying stl container.
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.
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.
bool canBeExtended() const
If true, PDF can provide extended likelihood term.
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.
virtual void fixAddCoefNormalization(const RooArgSet &addNormSet=RooArgSet(), bool force=true)
Fix the interpretation of the coefficient of any RooAddPdf component in the expression tree headed by...
RooArgSet is a container object that can hold multiple RooAbsArg objects.
RooArgSet * snapshot(bool deepCopy=true) const
Use RooAbsCollection::snapshot(), but return as RooArgSet.
RooAbsPdf * _pdf
Pointer to cloned p.d.f.
~RooBinnedGenContext() override
bool _expectedData
Asimov?
void generateEvent(RooArgSet &theEvent, Int_t remaining) override
this method is not implemented for this context
std::unique_ptr< RooDataHist > _hist
Histogram.
void printMultiline(std::ostream &os, Int_t content, bool verbose=false, TString indent="") const override
Print the details of the context.
RooArgSet _pdfSet
Set owned all nodes of internal clone of p.d.f.
RooBinnedGenContext(const RooAbsPdf &model, const RooArgSet &vars, const RooDataSet *prototype=nullptr, const RooArgSet *auxProto=nullptr, bool _verbose=false)
Constructor.
void setExpectedData(bool) override
std::unique_ptr< RooArgSet > _vars
void initGenerator(const RooArgSet &theEvent) override
One-time initialization of generator context.
RooDataSet * generate(double nEvents=0.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...
void attach(const RooArgSet ¶ms) override
Attach given set of variables to internal p.d.f. clone.
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 TRandom * randomGenerator()
Return a pointer to a singleton random-number generator implementation.
const char * GetName() const override
Returns name of object.
RooCmdArg WeightVar(const char *name="weight", bool reinterpretAsWeight=false)