71 _pdfClone(0), _acceptRejectFunc(0), _generator(0),
72 _maxVar(0), _uniIter(0), _updateFMaxPerEvent(0)
75 <<
" for generation of observable(s) " << vars ;
78 if (forceDirect && forceDirect->
getSize()>0)
ccxcoutI(
Generation) <<
" with internal generation forced for observables " << *forceDirect ;
86 coutE(
Generation) <<
"RooGenContext::RooGenContext(" <<
GetName() <<
") Couldn't deep-clone PDF, abort," << endl ;
97 fullNormSet.
add(*prototype->
get()) ;
110 coutE(
Generation) <<
"RooGenContext::ctor(): cannot generate values for derived \"" << tmp->
GetName() <<
"\"" << endl;
118 <<
"\" which will have uniform distribution" << endl;
126 if (forceDirect==0 || !forceDirect->
find(
direct->GetName())) {
128 cxcoutD(
Generation) <<
"RooGenContext::ctor() observable " << arg->
GetName() <<
" has been determined to be unsafe for internal generation" << endl;
145 coutE(
Generation) <<
"RooGenContext::ctor() constructor failed with errors" << endl;
152 cxcoutD(
Generation) <<
"RooGenContext::ctor() observables " <<
_directVars <<
" are safe for internal generator (if supported by p.d.f)" << endl ;
155 cxcoutD(
Generation) <<
"RooGenContext::ctor() observables " <<
_otherVars <<
" are NOT safe for internal generator (if supported by p.d.f)" << endl ;
162 cxcoutD(
Generation) <<
"RooGenContext::ctor() Model depends on supplied protodata observables, static initialization of internal generator will not be allowed" << endl ;
170 cxcoutD(
Generation) <<
"RooGenContext::ctor() Model indicates that it can internally generate observables "
171 << generatedVars <<
" with configuration identifier " <<
_code << endl ;
199 ntitle.
Append(
" (Accept/Reject)") ;
210 if(depList.
empty()) {
215 if (maxFindCode != 0) {
216 coutI(
Generation) <<
"RooGenContext::ctor() no prototype data provided, all observables are generated with numerically and "
217 <<
"model supports analytical maximum findin:, can provide analytical pdf maximum to numeric generator" << endl ;
220 cxcoutD(
Generation) <<
"RooGenContext::ctor() maximum value returned by RooAbsPdf::maxVal() is " << maxVal << endl ;
243 if (maxFindCode != 0) {
245 coutI(
Generation) <<
"RooGenContext::ctor() prototype data provided, and "
246 <<
"model supports analytical maximum finding in the full phase space: "
247 <<
"can provide analytical pdf maximum to numeric generator" << endl ;
251 if (maxFindCode != 0) {
253 coutI(
Generation) <<
"RooGenContext::ctor() prototype data provided, and "
254 <<
"model supports analytical maximum finding in the variables which are not"
255 <<
" internally generated. Can provide analytical pdf maximum to numeric "
256 <<
"generator" << endl;
257 cxcoutD(
Generation) <<
"RooGenContext::ctor() maximum value must be reevaluated for each "
258 <<
"event with configuration code " << maxFindCode << endl ;
268 otherAndProto.
add(protoDeps) ;
272 cxcoutD(
Generation) <<
"RooGenContext::ctor() prototype data provided, observables are generated numericaly no "
273 <<
"analytical estimate of maximum function value provided by model, must determine maximum value through initial sampling space "
274 <<
"of accept/reject observables plus prototype observables: " << otherAndProto << endl ;
285 <<
") ERROR: generating conditional p.d.f. which requires prior knowledge of function maximum, "
286 <<
"but chosen numeric generator (" << maxFinder->
IsA()->
GetName() <<
") does not support maximum finding" << endl ;
288 throw string(
"RooGenContext::ctor()") ;
292 cxcoutD(
Generation) <<
"RooGenContext::ctor() maximum function value found through initial sampling is " << max << endl ;
350 while((arg=iter.
next())) {
361 cxcoutD(
Generation) <<
"RooGenContext::initGenerator() initializing internal generator of model with code " <<
_code << endl ;
384 cxcoutD(
Generation) <<
"RooGenContext::initGenerator() reevaluation of maximum function value is required for each event, new value is " << max << endl ;
391 if (resampleRatio<1) {
392 coutI(
Generation) <<
"RooGenContext::generateEvent INFO: accept/reject generator requests resampling of previously produced events by factor "
393 << resampleRatio <<
" due to increased maximum weight" << endl ;
397 coutE(
Generation) <<
"RooGenContext::generateEvent ERROR accept/reject generator failed" << endl ;
419 coutE(
Generation) <<
"RooGenContext::generateEvent(" <<
GetName() <<
") ERROR: uniform variable " << uniVar->
GetName() <<
" is not an lvalue" << endl ;
436 os <<
indent <<
" --- RooGenContext --- " << endl ;
437 os <<
indent <<
"Using PDF ";
static void indent(ostringstream &buf, int indent_level)
RooAbsArg is the common abstract base class for objects that represent a value and a "shape" in RooFi...
RooArgSet * getObservables(const RooArgSet &set, Bool_t valueOnly=kTRUE) const
Given a set of possible observables, return the observables that this PDF depends on.
Bool_t dependsOn(const RooAbsCollection &serverList, const RooAbsArg *ignoreArg=0, Bool_t valueOnly=kFALSE) const
Test whether we depend on (ie, are served by) any object in the specified collection.
virtual Bool_t isFundamental() const
Is this object a fundamental type that can be added to a dataset? Fundamental-type subclasses overrid...
void setOperMode(OperMode mode, Bool_t recurseADirty=kTRUE)
Set the operation mode of this node.
TIterator * serverIterator() const
Bool_t recursiveRedirectServers(const RooAbsCollection &newServerList, Bool_t mustReplaceAll=kFALSE, Bool_t nameChange=kFALSE, Bool_t recurseInNewSet=kTRUE)
Recursively replace all servers with the new servers in newSet.
virtual void removeAll()
Remove all arguments from our set, deleting them if we own them.
RooAbsCollection & assignValueOnly(const RooAbsCollection &other, bool forceIfSizeOne=false)
Sets the value of any argument in our set that also appears in the other set.
virtual Bool_t add(const RooAbsArg &var, Bool_t silent=kFALSE)
Add the specified argument to list.
Int_t getSize() const
Return the number of elements in the collection.
RooFIter fwdIterator() const
One-time forward iterator.
void assign(const RooAbsCollection &other) const
Sets the value, cache and constant attribute of any argument in our set that also appears in the othe...
virtual Bool_t remove(const RooAbsArg &var, Bool_t silent=kFALSE, Bool_t matchByNameOnly=kFALSE)
Remove the specified argument from our list.
TIterator * createIterator(Bool_t dir=kIterForward) const
TIterator-style iteration over contained elements.
RooAbsArg * find(const char *name) const
Find object with given name in list.
RooAbsGenContext is the abstract base class for generator contexts of RooAbsPdf objects.
void printMultiline(std::ostream &os, Int_t contents, Bool_t verbose=kFALSE, TString indent="") const override
Interface for multi-line printing.
RooArgSet _theEvent
Pointer to observable event being generated.
Bool_t _isValid
Is context in valid state?
void resampleData(Double_t &ratio)
Rescale existing output buffer with given ratio.
RooArgSet _protoVars
Prototype observables.
Bool_t _verbose
Verbose messaging?
Abstract base class for objects that are lvalues, i.e.
virtual void randomize(const char *rangeName=0)=0
Class RooAbsNumGenerator is the abstract base class for MC event generator implementations like RooAc...
TClass * IsA() const override
virtual Double_t getFuncMax()
void attachParameters(const RooArgSet &vars)
Reattach original parameters to function clone.
virtual const RooArgSet * generateEvent(UInt_t remaining, Double_t &resampleRatio)=0
Double_t getNorm(const RooArgSet &nset) const
Get normalisation term needed to normalise the raw values returned by getVal().
virtual void generateEvent(Int_t code)
Interface for generation of an event using the algorithm corresponding to the specified code.
virtual void resetErrorCounters(Int_t resetValue=10)
Reset error counter to given value, limiting the number of future error messages for this pdf to 'res...
virtual Int_t getGenerator(const RooArgSet &directVars, RooArgSet &generateVars, Bool_t staticInitOK=kTRUE) const
Load generatedVars with the subset of directVars that we can generate events for, and return a code t...
virtual Bool_t isDirectGenSafe(const RooAbsArg &arg) const
Check if given observable can be safely generated using the pdfs internal generator mechanism (if tha...
const RooNumGenConfig * getGeneratorConfig() const
Return the numeric MC generator configuration used for this object.
virtual void initGenerator(Int_t code)
Interface for one-time initialization to setup the generator for the specified code.
RooAbsReal * createIntegral(const RooArgSet &iset, const RooCmdArg &arg1, const RooCmdArg &arg2=RooCmdArg::none(), const RooCmdArg &arg3=RooCmdArg::none(), const RooCmdArg &arg4=RooCmdArg::none(), const RooCmdArg &arg5=RooCmdArg::none(), const RooCmdArg &arg6=RooCmdArg::none(), const RooCmdArg &arg7=RooCmdArg::none(), const RooCmdArg &arg8=RooCmdArg::none()) const
Create an object that represents the integral of the function over one or more observables listed in ...
Double_t getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
virtual Double_t maxVal(Int_t code) const
Return maximum value for set of observables identified by code assigned in getMaxVal.
virtual void fixAddCoefNormalization(const RooArgSet &addNormSet=RooArgSet(), Bool_t force=kTRUE)
Fix the interpretation of the coefficient of any RooAddPdf component in the expression tree headed by...
virtual Int_t getMaxVal(const RooArgSet &vars) const
Advertise capability to determine maximum value of function for given set of observables.
RooArgSet is a container object that can hold multiple RooAbsArg objects.
RooArgSet * snapshot(bool deepCopy=true) const
Use RooAbsCollection::snapshot(), but return as RooArgSet.
RooDataSet is a container class to hold unbinned data.
const RooArgSet * get(Int_t index) const override
Return RooArgSet with coordinates of event 'index'.
static void softAbort()
Soft abort function that interrupts macro execution but doesn't kill ROOT.
A one-time forward iterator working on RooLinkedList or RooAbsCollection.
RooAbsArg * next()
Return next element or nullptr if at end.
Class RooGenContext implement a universal generator context for all RooAbsPdf classes that do not hav...
void generateEvent(RooArgSet &theEvent, Int_t remaining) override
Generate one event.
RooArgSet _otherVars
List of observables generated internally, randomly, and by accept/reject sampling.
void printMultiline(std::ostream &os, Int_t content, Bool_t verbose=kFALSE, TString indent="") const override
Printing interface.
Int_t _code
Internal generation code.
void initGenerator(const RooArgSet &theEvent) override
Perform one-time initialization of the generator context.
~RooGenContext() override
Destructor.
TIterator * _uniIter
Iterator over uniform observables.
RooAbsPdf * _pdfClone
Clone of input p.d.f.
RooArgSet _cloneSet
Clone of all nodes of input p.d.f.
RooGenContext(const RooAbsPdf &model, const RooArgSet &vars, const RooDataSet *prototype=0, const RooArgSet *auxProto=0, Bool_t verbose=kFALSE, const RooArgSet *forceDirect=0)
Initialize a new context for generating events with the specified variables, using the specified PDF ...
Int_t _updateFMaxPerEvent
If true, maximum p.d.f value needs to be recalculated for each event.
RooRealIntegral * _acceptRejectFunc
Projection function to be passed to accept/reject sampler.
void attach(const RooArgSet ¶ms) override
Attach the cloned model to the event buffer we will be filling.
RooAbsNumGenerator * _generator
MC sampling generation engine.
RooRealVar * _maxVar
Variable holding maximum value of p.d.f.
static RooNumGenFactory & instance()
Static method returning reference to singleton instance of factory.
RooAbsNumGenerator * createSampler(RooAbsReal &func, const RooArgSet &genVars, const RooArgSet &condVars, const RooNumGenConfig &config, Bool_t verbose=kFALSE, RooAbsReal *maxFuncVal=0)
Construct a numeric integrator instance that operates on function 'func' and is configured with 'conf...
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,...
RooRealIntegral performs hybrid numerical/analytical integrals of RooAbsReal objects.
RooRealVar represents a variable that can be changed from the outside.
void setVal(Double_t value) override
Set value of variable to 'value'.
Iterator abstract base class.
virtual TObject * Next()=0
const char * GetName() const override
Returns name of object.
const char * GetTitle() const override
Returns title of object.
TString & Append(const char *cs)