Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RooAcceptReject Class Reference

Generic Monte Carlo toy generator implement the accept/reject sampling technique on any positively valued function.

The RooAcceptReject generator is used by the various generator context classes to take care of generation of observables for which p.d.fs do not define internal methods

Definition at line 29 of file RooAcceptReject.h.

Public Member Functions

 RooAcceptReject ()
 
 RooAcceptReject (const RooAbsReal &func, const RooArgSet &genVars, const RooNumGenConfig &config, bool verbose=false, const RooAbsReal *maxFuncVal=nullptr)
 Initialize an accept-reject generator for the specified distribution function, which must be non-negative but does not need to be normalized over the variables to be generated, genVars.
 
bool canSampleCategories () const override
 
bool canSampleConditional () const override
 
RooAbsNumGeneratorclone (const RooAbsReal &func, const RooArgSet &genVars, const RooArgSet &, const RooNumGenConfig &config, bool verbose=false, const RooAbsReal *maxFuncVal=nullptr) const override
 
const RooArgSetgenerateEvent (UInt_t remaining, double &resampleRatio) override
 Return a pointer to a generated event.
 
std::string const & generatorName () const override
 Return unique name of generator implementation.
 
double getFuncMax () override
 
- Public Member Functions inherited from RooAbsNumGenerator
 RooAbsNumGenerator ()
 
 RooAbsNumGenerator (const RooAbsReal &func, const RooArgSet &genVars, bool verbose=false, const RooAbsReal *maxFuncVal=nullptr)
 Initialize an accept-reject generator for the specified distribution function, which must be non-negative but does not need to be normalized over the variables to be generated, genVars.
 
virtual ~RooAbsNumGenerator ()
 
void attachParameters (const RooArgSet &vars)
 Reattach original parameters to function clone.
 
bool isValid () const
 
bool isVerbose () const
 
void setVerbose (bool verbose=true)
 

Protected Member Functions

void addEventToCache ()
 Add a trial event to our cache and update our estimates of the function maximum value and integral.
 
const RooArgSetnextAcceptedEvent ()
 Scan through events in the cache which have not been used yet, looking for the first accepted one which is added to the specified container.
 

Static Protected Member Functions

static void registerSampler (RooNumGenFactory &fact)
 Register RooIntegrator1D, is parameters and capabilities with RooNumIntFactory.
 

Protected Attributes

UInt_t _catSampleMult
 Number of discrete dimensions to be sampled.
 
UInt_t _eventsUsed
 Accepted number of function samples.
 
double _funcSum
 Maximum function value found, and sum of all samples made.
 
double _maxFuncVal
 
UInt_t _minTrials
 Minimum number of max.finding trials, total number of samples.
 
UInt_t _minTrialsArray [4]
 Minimum number of trials samples for 1,2,3 dimensional problems.
 
UInt_t _realSampleDim
 Number of real dimensions to be sampled.
 
UInt_t _totalEvents
 Total number of function samples.
 
- Protected Attributes inherited from RooAbsNumGenerator
std::unique_ptr< RooDataSet_cache
 Dataset holding generared values of observables.
 
RooArgSet _catVars
 Set of discrete observabeles.
 
RooArgSet _cloneSet
 Set owning clone of input function.
 
RooAbsReal_funcClone = nullptr
 Pointer to top level node of cloned function.
 
const RooAbsReal_funcMaxVal = nullptr
 Container for maximum function value.
 
RooRealVar_funcValPtr = nullptr
 RRV storing function value in output dataset.
 
std::unique_ptr< RooAbsArg_funcValStore
 RRV storing function value in context.
 
bool _isValid = false
 Valid flag.
 
RooArgSet _realVars
 Set of real valued observabeles.
 
bool _verbose = false
 Verbose flag.
 

Friends

class RooNumGenFactory
 

#include </home/sftnight/build/workspace/root-makedoc-v632/rootspi/rdoc/src/v6-32-00-patches/roofit/roofitcore/src/RooAcceptReject.h>

Inheritance diagram for RooAcceptReject:
[legend]

Constructor & Destructor Documentation

◆ RooAcceptReject() [1/2]

RooAcceptReject::RooAcceptReject ( )
inline

Definition at line 31 of file RooAcceptReject.h.

◆ RooAcceptReject() [2/2]

RooAcceptReject::RooAcceptReject ( const RooAbsReal func,
const RooArgSet genVars,
const RooNumGenConfig config,
bool  verbose = false,
const RooAbsReal maxFuncVal = nullptr 
)

Initialize an accept-reject generator for the specified distribution function, which must be non-negative but does not need to be normalized over the variables to be generated, genVars.

The function and its dependents are cloned and so will not be disturbed during the generation process.

Definition at line 74 of file RooAcceptReject.cxx.

Member Function Documentation

◆ addEventToCache()

void RooAcceptReject::addEventToCache ( )
protected

Add a trial event to our cache and update our estimates of the function maximum value and integral.

Definition at line 271 of file RooAcceptReject.cxx.

◆ canSampleCategories()

bool RooAcceptReject::canSampleCategories ( ) const
inlineoverridevirtual

Reimplemented from RooAbsNumGenerator.

Definition at line 46 of file RooAcceptReject.h.

◆ canSampleConditional()

bool RooAcceptReject::canSampleConditional ( ) const
inlineoverridevirtual

Reimplemented from RooAbsNumGenerator.

Definition at line 45 of file RooAcceptReject.h.

◆ clone()

RooAbsNumGenerator * RooAcceptReject::clone ( const RooAbsReal func,
const RooArgSet genVars,
const RooArgSet ,
const RooNumGenConfig config,
bool  verbose = false,
const RooAbsReal maxFuncVal = nullptr 
) const
inlineoverridevirtual

Implements RooAbsNumGenerator.

Definition at line 35 of file RooAcceptReject.h.

◆ generateEvent()

const RooArgSet * RooAcceptReject::generateEvent ( UInt_t  remaining,
double resampleRatio 
)
overridevirtual

Return a pointer to a generated event.

The caller does not own the event and it will be overwritten by a subsequent call. The input parameter 'remaining' should contain your best guess at the total number of subsequent events you will request.

Implements RooAbsNumGenerator.

Definition at line 152 of file RooAcceptReject.cxx.

◆ generatorName()

std::string const & RooAcceptReject::generatorName ( ) const
overridevirtual

Return unique name of generator implementation.

Implements RooAbsNumGenerator.

Definition at line 320 of file RooAcceptReject.cxx.

◆ getFuncMax()

double RooAcceptReject::getFuncMax ( )
overridevirtual

Reimplemented from RooAbsNumGenerator.

Definition at line 299 of file RooAcceptReject.cxx.

◆ nextAcceptedEvent()

const RooArgSet * RooAcceptReject::nextAcceptedEvent ( )
protected

Scan through events in the cache which have not been used yet, looking for the first accepted one which is added to the specified container.

Return a pointer to the accepted event, or else zero if we use up the cache before we accept an event. The caller does not own the event and it will be overwritten by a subsequent call.

Definition at line 242 of file RooAcceptReject.cxx.

◆ registerSampler()

void RooAcceptReject::registerSampler ( RooNumGenFactory fact)
staticprotected

Register RooIntegrator1D, is parameters and capabilities with RooNumIntFactory.

Definition at line 55 of file RooAcceptReject.cxx.

Friends And Related Symbol Documentation

◆ RooNumGenFactory

friend class RooNumGenFactory
friend

Definition at line 52 of file RooAcceptReject.h.

Member Data Documentation

◆ _catSampleMult

UInt_t RooAcceptReject::_catSampleMult
protected

Number of discrete dimensions to be sampled.

Definition at line 60 of file RooAcceptReject.h.

◆ _eventsUsed

UInt_t RooAcceptReject::_eventsUsed
protected

Accepted number of function samples.

Definition at line 63 of file RooAcceptReject.h.

◆ _funcSum

double RooAcceptReject::_funcSum
protected

Maximum function value found, and sum of all samples made.

Definition at line 58 of file RooAcceptReject.h.

◆ _maxFuncVal

double RooAcceptReject::_maxFuncVal
protected

Definition at line 58 of file RooAcceptReject.h.

◆ _minTrials

UInt_t RooAcceptReject::_minTrials
protected

Minimum number of max.finding trials, total number of samples.

Definition at line 61 of file RooAcceptReject.h.

◆ _minTrialsArray

UInt_t RooAcceptReject::_minTrialsArray[4]
protected

Minimum number of trials samples for 1,2,3 dimensional problems.

Definition at line 65 of file RooAcceptReject.h.

◆ _realSampleDim

UInt_t RooAcceptReject::_realSampleDim
protected

Number of real dimensions to be sampled.

Definition at line 59 of file RooAcceptReject.h.

◆ _totalEvents

UInt_t RooAcceptReject::_totalEvents
protected

Total number of function samples.

Definition at line 62 of file RooAcceptReject.h.

  • roofit/roofitcore/src/RooAcceptReject.h
  • roofit/roofitcore/src/RooAcceptReject.cxx