57 RooRealVar nTrial0D(
"nTrial0D",
"Number of trial samples for cat-only generation",100,0,1e9) ;
58 RooRealVar nTrial1D(
"nTrial1D",
"Number of trial samples for 1-dim generation",1000,0,1e9) ;
59 RooRealVar nTrial2D(
"nTrial2D",
"Number of trial samples for 2-dim generation",100000,0,1e9) ;
60 RooRealVar nTrial3D(
"nTrial3D",
"Number of trial samples for N-dim generation",10000000,0,1e9) ;
84 for (
auto * cat : static_range_cast<RooAbsCategory*>(
_catVars)) {
95 <<
" variables with accept-reject may not be accurate" << endl;
102 <<
") WARNING: performing accept/reject sampling on a p.d.f in "
103 <<
_realSampleDim <<
" dimensions without prior knowledge on maximum value "
104 <<
"of p.d.f. Determining maximum value by taking " <<
_minTrials
105 <<
" trial samples. If p.d.f contains sharp peaks smaller than average "
106 <<
"distance between trial sampling points these may be missed and p.d.f. "
107 <<
"may be sampled incorrectly." << endl ;
116 oocoutW(
nullptr, Generation) <<
"RooAcceptReject::ctor(" << func.
GetName() <<
"): WARNING: " <<
_minTrials <<
" trial samples requested by p.d.f for "
117 <<
_realSampleDim <<
"-dimensional accept/reject sampling, this may take some time" << endl ;
122 oocoutI(
nullptr, Generation) << func.
GetName() <<
"::RooAcceptReject" <<
":" << endl
123 <<
" Initializing accept-reject generator for" << endl <<
" ";
126 ooccoutI(
nullptr, Generation) <<
" Function maximum provided, no trial sampling performed" << endl ;
133 ooccoutI(
nullptr, Generation) <<
" Will generate category vars "<<
_catVars << endl ;
136 ooccoutI(
nullptr, Generation) <<
" Will generate real vars " <<
_realVars << endl ;
169 if (
_cache->numEntries()>1000000) {
170 oocoutI(
nullptr, Generation) <<
"RooAcceptReject::generateEvent: resetting event cache" << std::endl;
178 while(
nullptr ==
event) {
181 oocxcoutD(
nullptr, Generation) <<
"RooAcceptReject::generateEvent maxFuncVal has changed, need to resample already accepted events by factor"
194 oocoutE(
nullptr, Generation) <<
"RooAcceptReject::generateEvent: cannot estimate efficiency...giving up" << endl;
200 oocxcoutD(
nullptr, Generation) <<
"RooAcceptReject::generateEvent: adding " << extra <<
" events to the cache, eff = " << eff << endl;
205 oocxcoutD(
nullptr, Generation) <<
"RooAcceptReject::generateEvent: estimated function maximum increased from "
225 while(
nullptr==
event) {
257 cerr <<
"RooAcceptReject: accepted event (used " <<
_eventsUsed <<
" of "
258 <<
_cache->numEntries() <<
" so far)" << endl;
275 for(
auto * cat : static_range_cast<RooCategory*>(
_catVars)) cat->randomize();
278 for(
auto * real : static_range_cast<RooRealVar*>(
_realVars)) real->randomize();
295 cerr <<
"RooAcceptReject: generated " <<
_totalEvents <<
" events so far." << endl ;
311 if (
_cache->numEntries()>1000000) {
312 oocoutI(
nullptr, Generation) <<
"RooAcceptReject::getFuncMax: resetting event cache" << endl ;
322 static const std::string
name =
"RooAcceptReject";
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t r
double getRealValue(const char *name, double defVal=0.0, bool verbose=false) const
Get value of a RooAbsReal stored in set with given name.
Storage_t const & get() const
Const access to the underlying stl container.
Int_t getSize() const
Return the number of elements in the collection.
Class RooAbsNumGenerator is the abstract base class for MC event generator implementations like RooAc...
RooArgSet _catVars
Set of discrete observabeles.
RooArgSet _realVars
Set of real valued observabeles.
const RooAbsReal * _funcMaxVal
Container for maximum function value.
RooAbsReal * _funcClone
Pointer to top level node of cloned function.
bool _verbose
Verbose flag.
RooRealVar * _funcValPtr
RRV storing function value in output dataset.
std::unique_ptr< RooDataSet > _cache
Dataset holding generared values of observables.
Abstract base class for objects that represent a real value and implements functionality common to al...
double getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
Class RooAcceptReject is a generic toy monte carlo generator implement the accept/reject sampling tec...
UInt_t _minTrialsArray[4]
Minimum number of trials samples for 1,2,3 dimensional problems.
UInt_t _minTrials
Minimum number of max.finding trials, total number of samples.
static void registerSampler(RooNumGenFactory &fact)
Register RooIntegrator1D, is parameters and capabilities with RooNumIntFactory.
double getFuncMax() override
const RooArgSet * nextAcceptedEvent()
Scan through events in the cache which have not been used yet, looking for the first accepted one whi...
void addEventToCache()
Add a trial event to our cache and update our estimates of the function maximum value and integral.
double _funcSum
Maximum function value found, and sum of all samples made.
std::string const & generatorName() const override
Return unique name of generator implementation.
UInt_t _totalEvents
Total number of function samples.
UInt_t _catSampleMult
Number of real and discrete dimensions to be sampled.
const RooArgSet * generateEvent(UInt_t remaining, double &resampleRatio) override
Return a pointer to a generated event.
UInt_t _eventsUsed
Accepted number of function samples.
RooArgSet is a container object that can hold multiple RooAbsArg objects.
RooNumGenConfig holds the configuration parameters of the various numeric integrators used by RooReal...
const RooArgSet & getConfigSection(const char *name) const
Retrieve configuration information specific to integrator with given name.
RooNumGenFactory is a factory to instantiate numeric integrators from a given function binding and a ...
bool storeProtoSampler(RooAbsNumGenerator *proto, const RooArgSet &defConfig)
Method accepting registration of a prototype numeric integrator along with a RooArgSet of its default...
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)
RooRealVar represents a variable that can be changed from the outside.
void setVal(double value) override
Set value of variable to 'value'.
const char * GetName() const override
Returns name of object.