ToyMCSampler is an implementation of the TestStatSampler interface.
It generates Toy Monte Carlo for a given parameter point and evaluates a TestStatistic.
For parallel runs, ToyMCSampler can be given an instance of ProofConfig and then run in parallel using proof or proof-lite. Internally, it uses ToyMCStudy with the RooStudyManager.
Definition at line 67 of file ToyMCSampler.h.
Public Member Functions | |
ToyMCSampler () | |
Proof constructor. Do not use. | |
ToyMCSampler (TestStatistic &ts, Int_t ntoys) | |
~ToyMCSampler () override | |
virtual void | AddTestStatistic (TestStatistic *t=nullptr) |
The pdf can be nullptr in which case the density from SetPdf() is used. | |
virtual SamplingDistribution * | AppendSamplingDistribution (RooArgSet &allParameters, SamplingDistribution *last, Int_t additionalMC) |
Extended interface to append to sampling distribution more samples. | |
bool | CheckConfig (void) |
Checks for sufficient information to do a GetSamplingDistribution(...). | |
double | ConfidenceLevel () const override |
Get the Confidence level for the test. | |
virtual RooArgList * | EvaluateAllTestStatistics (RooAbsData &data, const RooArgSet &poi) |
Evaluate all test statistics, returning result and any detailed output. | |
double | EvaluateTestStatistic (RooAbsData &data, RooArgSet &nullPOI) override |
Main interface to evaluate the test statistic on a dataset. | |
virtual double | EvaluateTestStatistic (RooAbsData &data, RooArgSet &nullPOI, int i) |
Main interface to evaluate the test statistic on a dataset. | |
virtual void | GenerateGlobalObservables (RooAbsPdf &pdf) const |
generate global observables | |
virtual RooAbsData * | GenerateToyData (RooArgSet ¶mPoint) const |
virtual RooAbsData * | GenerateToyData (RooArgSet ¶mPoint, double &weight) const |
virtual RooAbsData * | GenerateToyData (RooArgSet ¶mPoint, double &weight, RooAbsPdf &pdf) const |
generates toy data with weight | |
virtual RooAbsData * | GenerateToyData (RooArgSet ¶mPoint, RooAbsPdf &pdf) const |
generates toy data without weight | |
virtual Int_t | GetNToys (void) |
std::string | GetSamplingDistName (void) |
SamplingDistribution * | GetSamplingDistribution (RooArgSet ¶mPoint) override |
main interface | |
virtual RooDataSet * | GetSamplingDistributions (RooArgSet ¶mPoint) |
Use for serial and parallel runs. | |
virtual RooDataSet * | GetSamplingDistributionsSingleWorker (RooArgSet ¶mPoint) |
This is the main function for serial runs. | |
virtual TestStatistic * | GetTestStatistic (unsigned int i) const |
TestStatistic * | GetTestStatistic (void) const override |
Get the TestStatistic. | |
void | Initialize (RooAbsArg &, RooArgSet &, RooArgSet &) override |
Common Initialization. | |
TClass * | IsA () const override |
virtual void | SetAsimovNuisancePar (bool i=true) |
void | SetConfidenceLevel (double cl) override |
set the confidence level for the interval (eg. 0.95 for a 95% Confidence Interval) | |
virtual void | SetExpectedNuisancePar (bool i=true) |
void | SetGenerateAutoBinned (bool autoBinned=true) |
set auto binned generation (=> see RooFit::AutoBinned() option) | |
void | SetGenerateBinned (bool binned=true) |
control to use bin data generation (=> see RooFit::AllBinned() option) | |
void | SetGenerateBinnedTag (const char *binnedTag="") |
name of the tag for individual components to be generated binned (=> see RooFit::GenBinned() option) | |
void | SetGlobalObservables (const RooArgSet &o) override |
specify the conditional observables | |
void | SetMaxToys (double t) |
This option forces a maximum number of total toys. | |
virtual void | SetNEventsPerToy (const Int_t nevents) |
Forces the generation of exactly n events even for extended PDFs. | |
virtual void | SetNToys (const Int_t ntoy) |
void | SetNuisanceParameters (const RooArgSet &np) override |
specify the nuisance parameters (eg. the rest of the parameters) | |
void | SetObservables (const RooArgSet &o) override |
specify the observables in the dataset (needed to evaluate the test statistic) | |
void | SetParametersForTestStat (const RooArgSet &nullpoi) override |
Set the Pdf, add to the workspace if not already there. | |
void | SetPdf (RooAbsPdf &pdf) override |
Set the Pdf, add to the workspace if not already there. | |
void | SetPriorNuisance (RooAbsPdf *pdf) override |
How to randomize the prior. Set to nullptr to deactivate randomization. | |
void | SetProofConfig (ProofConfig *pc=nullptr) |
calling with argument or nullptr deactivates proof | |
void | SetProtoData (const RooDataSet *d) |
void | SetSamplingDistName (const char *name) override |
Set the name of the sampling distribution used for plotting. | |
void | SetTestSize (double size) override |
set the size of the test (rate of Type I error) ( Eg. 0.05 for a 95% Confidence Interval) | |
void | SetTestStatistic (TestStatistic *t) override |
Set the TestStatistic (want the argument to be a function of the data & parameter points. | |
virtual void | SetTestStatistic (TestStatistic *testStatistic, unsigned int i) |
Set the TestStatistic (want the argument to be a function of the data & parameter points. | |
void | SetToysBothTails (double toys, double low_threshold, double high_threshold) |
void | SetToysLeftTail (double toys, double threshold) |
void | SetToysRightTail (double toys, double threshold) |
void | SetUseMultiGen (bool flag) |
void | Streamer (TBuffer &) override |
void | StreamerNVirtual (TBuffer &ClassDef_StreamerNVirtual_b) |
Public Member Functions inherited from RooStats::TestStatSampler | |
virtual | ~TestStatSampler () |
void | StreamerNVirtual (TBuffer &ClassDef_StreamerNVirtual_b) |
Static Public Member Functions | |
static TClass * | Class () |
static const char * | Class_Name () |
static constexpr Version_t | Class_Version () |
static const char * | DeclFileName () |
static void | SetAlwaysUseMultiGen (bool flag) |
Static Public Member Functions inherited from RooStats::TestStatSampler | |
static TClass * | Class () |
static const char * | Class_Name () |
static constexpr Version_t | Class_Version () |
static const char * | DeclFileName () |
Protected Member Functions | |
virtual void | ClearCache () |
helper method for clearing the cache | |
const RooArgList * | EvaluateAllTestStatistics (RooAbsData &data, const RooArgSet &poi, DetailedOutputAggregator &detOutAgg) |
std::unique_ptr< RooAbsData > | Generate (RooAbsPdf &pdf, RooArgSet &observables, const RooDataSet *protoData=nullptr, int forceEvents=0) const |
helper for GenerateToyData | |
Protected Attributes | |
std::unique_ptr< RooArgSet > | _allVars |
! | |
std::unique_ptr< RooAbsPdf::GenSpec > | _gs1 |
! GenSpec #1 | |
std::unique_ptr< RooAbsPdf::GenSpec > | _gs2 |
! GenSpec #2 | |
std::unique_ptr< RooAbsPdf::GenSpec > | _gs3 |
! GenSpec #3 | |
std::unique_ptr< RooAbsPdf::GenSpec > | _gs4 |
! GenSpec #4 | |
std::vector< std::unique_ptr< RooAbsPdf::GenSpec > > | _gsList |
! | |
std::vector< std::unique_ptr< RooArgSet > > | _obsList |
! | |
std::vector< RooAbsPdf * > | _pdfList |
! We don't own those objects | |
double | fAdaptiveHighLimit |
double | fAdaptiveLowLimit |
tails | |
bool | fExpectedNuisancePar |
whether to use expectation values for nuisance parameters (ie Asimov data set) | |
bool | fGenerateAutoBinned = true |
bool | fGenerateBinned = false |
TString | fGenerateBinnedTag = "" |
const RooArgSet * | fGlobalObservables = nullptr |
double | fMaxToys |
maximum no of toys (taking weights into account, therefore double) | |
Int_t | fNEvents = 0 |
number of events per toy (may be ignored depending on settings) | |
Int_t | fNToys |
number of toys to generate | |
NuisanceParametersSampler * | fNuisanceParametersSampler = nullptr |
! | |
const RooArgSet * | fNuisancePars = nullptr |
const RooArgSet * | fObservables = nullptr |
std::unique_ptr< const RooArgSet > | fParametersForTestStat |
RooAbsPdf * | fPdf = nullptr |
densities, snapshots, and test statistics to reweight to | |
RooAbsPdf * | fPriorNuisance = nullptr |
prior pdf for nuisance parameters | |
ProofConfig * | fProofConfig = nullptr |
! | |
const RooDataSet * | fProtoData = nullptr |
in dev | |
std::string | fSamplingDistName |
name of the model | |
double | fSize = 0.05 |
std::vector< TestStatistic * > | fTestStatistics |
double | fToysInTails = 0.0 |
minimum no of toys in tails for adaptive sampling (taking weights into account, therefore double) Default: 0.0 which means no adaptive sampling | |
bool | fUseMultiGen = false |
Use PrepareMultiGen? | |
Static Protected Attributes | |
static bool | fgAlwaysUseMultiGen = false |
Use PrepareMultiGen always. | |
#include <RooStats/ToyMCSampler.h>
RooStats::ToyMCSampler::ToyMCSampler | ( | ) |
Proof constructor. Do not use.
Definition at line 149 of file ToyMCSampler.cxx.
RooStats::ToyMCSampler::ToyMCSampler | ( | TestStatistic & | ts, |
Int_t | ntoys | ||
) |
Definition at line 162 of file ToyMCSampler.cxx.
|
override |
Definition at line 178 of file ToyMCSampler.cxx.
|
inlinevirtual |
The pdf can be nullptr in which case the density from SetPdf() is used.
The snapshot and TestStatistic is also optional.
Definition at line 93 of file ToyMCSampler.h.
|
virtual |
Extended interface to append to sampling distribution more samples.
Definition at line 615 of file ToyMCSampler.cxx.
bool RooStats::ToyMCSampler::CheckConfig | ( | void | ) |
Checks for sufficient information to do a GetSamplingDistribution(...).
only checks, no guessing/determination (do this in calculators, e.g.
using ModelConfig::GuessObsAndNuisance(...))
Definition at line 188 of file ToyMCSampler.cxx.
|
static |
|
inlinestaticconstexpr |
Definition at line 295 of file ToyMCSampler.h.
|
protectedvirtual |
helper method for clearing the cache
clear the cache obtained from the pdf used for speeding the toy and global observables generation needs to be called every time the model pdf (fPdf) changes
Reimplemented in RooStats::ToyMCImportanceSampler.
Definition at line 638 of file ToyMCSampler.cxx.
|
inlineoverridevirtual |
Get the Confidence level for the test.
Implements RooStats::TestStatSampler.
Definition at line 133 of file ToyMCSampler.h.
|
inlinestatic |
Definition at line 295 of file ToyMCSampler.h.
|
virtual |
Evaluate all test statistics, returning result and any detailed output.
PDF parameter values are saved in case they are modified by TestStatistic::Evaluate (eg. SimpleLikelihoodRatioTestStat).
Definition at line 204 of file ToyMCSampler.cxx.
|
protected |
Definition at line 214 of file ToyMCSampler.cxx.
|
inlineoverridevirtual |
Main interface to evaluate the test statistic on a dataset.
Implements RooStats::TestStatSampler.
Definition at line 123 of file ToyMCSampler.h.
|
inlinevirtual |
Main interface to evaluate the test statistic on a dataset.
Definition at line 120 of file ToyMCSampler.h.
|
protected |
helper for GenerateToyData
This is the generate function to use in the context of the ToyMCSampler instead of the standard RooAbsPdf::generate(...).
It takes into account whether the number of events is given explicitly or whether it should use the expected number of events. It also takes into account the option to generate a binned data set (i.e. RooDataHist).
Definition at line 544 of file ToyMCSampler.cxx.
|
virtual |
generate global observables
Definition at line 412 of file ToyMCSampler.cxx.
|
inlinevirtual |
Reimplemented in RooStats::ToyMCImportanceSampler.
Definition at line 109 of file ToyMCSampler.h.
|
inlinevirtual |
Reimplemented in RooStats::ToyMCImportanceSampler, and RooStats::ToyMCImportanceSampler.
Definition at line 113 of file ToyMCSampler.h.
|
virtual |
generates toy data with weight
This method generates a toy data set for the given parameter point taking global observables into account.
The values of the generated global observables remain in the pdf's variables. They have to have those values for the subsequent evaluation of the test statistics.
Reimplemented in RooStats::ToyMCImportanceSampler.
Definition at line 478 of file ToyMCSampler.cxx.
|
inlinevirtual |
generates toy data without weight
Reimplemented in RooStats::ToyMCImportanceSampler.
Definition at line 104 of file ToyMCSampler.h.
|
inlinevirtual |
Definition at line 140 of file ToyMCSampler.h.
|
inline |
Definition at line 208 of file ToyMCSampler.h.
|
overridevirtual |
main interface
Implements RooStats::TestStatSampler.
Definition at line 246 of file ToyMCSampler.cxx.
|
virtual |
Use for serial and parallel runs.
Definition at line 266 of file ToyMCSampler.cxx.
|
virtual |
This is the main function for serial runs.
It is called automatically from inside GetSamplingDistribution when no ProofConfig is given. You should not call this function yourself. This function should be used by ToyMCStudy on the workers (ie. when you explicitly want a serial run although ProofConfig is present).
Reimplemented in RooStats::ToyMCImportanceSampler.
Definition at line 320 of file ToyMCSampler.cxx.
|
inlinevirtual |
Definition at line 127 of file ToyMCSampler.h.
|
inlineoverridevirtual |
Get the TestStatistic.
Implements RooStats::TestStatSampler.
Definition at line 131 of file ToyMCSampler.h.
|
inlineoverridevirtual |
Common Initialization.
Implements RooStats::TestStatSampler.
Definition at line 134 of file ToyMCSampler.h.
|
inlineoverridevirtual |
Reimplemented from RooStats::TestStatSampler.
Definition at line 295 of file ToyMCSampler.h.
|
static |
Definition at line 144 of file ToyMCSampler.cxx.
|
inlinevirtual |
Definition at line 194 of file ToyMCSampler.h.
|
inlineoverridevirtual |
set the confidence level for the interval (eg. 0.95 for a 95% Confidence Interval)
Implements RooStats::TestStatSampler.
Definition at line 177 of file ToyMCSampler.h.
|
inlinevirtual |
Definition at line 193 of file ToyMCSampler.h.
|
inline |
set auto binned generation (=> see RooFit::AutoBinned() option)
Definition at line 204 of file ToyMCSampler.h.
|
inline |
control to use bin data generation (=> see RooFit::AllBinned() option)
Definition at line 200 of file ToyMCSampler.h.
|
inline |
name of the tag for individual components to be generated binned (=> see RooFit::GenBinned() option)
Definition at line 202 of file ToyMCSampler.h.
|
inlineoverridevirtual |
specify the conditional observables
Implements RooStats::TestStatSampler.
Definition at line 171 of file ToyMCSampler.h.
|
inline |
This option forces a maximum number of total toys.
Definition at line 211 of file ToyMCSampler.h.
|
inlinevirtual |
Forces the generation of exactly n
events even for extended PDFs.
Set to 0 to use the Poisson-distributed events from the extended PDF.
Definition at line 144 of file ToyMCSampler.h.
|
inlinevirtual |
Definition at line 141 of file ToyMCSampler.h.
|
inlineoverridevirtual |
specify the nuisance parameters (eg. the rest of the parameters)
Implements RooStats::TestStatSampler.
Definition at line 167 of file ToyMCSampler.h.
|
inlineoverridevirtual |
specify the observables in the dataset (needed to evaluate the test statistic)
Implements RooStats::TestStatSampler.
Definition at line 169 of file ToyMCSampler.h.
|
inlineoverridevirtual |
Set the Pdf, add to the workspace if not already there.
Implements RooStats::TestStatSampler.
Definition at line 150 of file ToyMCSampler.h.
|
inlineoverridevirtual |
Set the Pdf, add to the workspace if not already there.
Implements RooStats::TestStatSampler.
Definition at line 156 of file ToyMCSampler.h.
|
inlineoverridevirtual |
How to randomize the prior. Set to nullptr to deactivate randomization.
Implements RooStats::TestStatSampler.
Definition at line 159 of file ToyMCSampler.h.
|
inline |
calling with argument or nullptr deactivates proof
Definition at line 230 of file ToyMCSampler.h.
|
inline |
Definition at line 232 of file ToyMCSampler.h.
|
inlineoverridevirtual |
Set the name of the sampling distribution used for plotting.
Implements RooStats::TestStatSampler.
Definition at line 207 of file ToyMCSampler.h.
|
inlineoverridevirtual |
set the size of the test (rate of Type I error) ( Eg. 0.05 for a 95% Confidence Interval)
Implements RooStats::TestStatSampler.
Definition at line 175 of file ToyMCSampler.h.
|
inlineoverridevirtual |
Set the TestStatistic (want the argument to be a function of the data & parameter points.
Implements RooStats::TestStatSampler.
Definition at line 191 of file ToyMCSampler.h.
|
inlinevirtual |
Set the TestStatistic (want the argument to be a function of the data & parameter points.
Definition at line 180 of file ToyMCSampler.h.
|
inline |
Definition at line 223 of file ToyMCSampler.h.
Definition at line 213 of file ToyMCSampler.h.
Definition at line 218 of file ToyMCSampler.h.
|
inline |
Definition at line 77 of file ToyMCSampler.h.
|
overridevirtual |
Reimplemented from RooStats::TestStatSampler.
|
inline |
Definition at line 295 of file ToyMCSampler.h.
|
mutableprotected |
!
Definition at line 282 of file ToyMCSampler.h.
|
mutableprotected |
! GenSpec #1
Definition at line 286 of file ToyMCSampler.h.
|
mutableprotected |
! GenSpec #2
Definition at line 287 of file ToyMCSampler.h.
|
mutableprotected |
! GenSpec #3
Definition at line 288 of file ToyMCSampler.h.
|
mutableprotected |
! GenSpec #4
Definition at line 289 of file ToyMCSampler.h.
|
mutableprotected |
!
Definition at line 285 of file ToyMCSampler.h.
|
mutableprotected |
!
Definition at line 284 of file ToyMCSampler.h.
|
mutableprotected |
! We don't own those objects
Definition at line 283 of file ToyMCSampler.h.
|
protected |
Definition at line 273 of file ToyMCSampler.h.
|
protected |
tails
Definition at line 272 of file ToyMCSampler.h.
|
protected |
whether to use expectation values for nuisance parameters (ie Asimov data set)
Definition at line 258 of file ToyMCSampler.h.
|
staticprotected |
Use PrepareMultiGen always.
Definition at line 291 of file ToyMCSampler.h.
|
protected |
Definition at line 262 of file ToyMCSampler.h.
|
protected |
Definition at line 260 of file ToyMCSampler.h.
|
protected |
Definition at line 261 of file ToyMCSampler.h.
|
protected |
Definition at line 254 of file ToyMCSampler.h.
|
protected |
maximum no of toys (taking weights into account, therefore double)
Definition at line 270 of file ToyMCSampler.h.
|
protected |
number of events per toy (may be ignored depending on settings)
Definition at line 256 of file ToyMCSampler.h.
|
protected |
number of toys to generate
Definition at line 255 of file ToyMCSampler.h.
|
mutableprotected |
!
Definition at line 279 of file ToyMCSampler.h.
|
protected |
Definition at line 252 of file ToyMCSampler.h.
|
protected |
Definition at line 253 of file ToyMCSampler.h.
|
protected |
Definition at line 247 of file ToyMCSampler.h.
|
protected |
densities, snapshots, and test statistics to reweight to
model (can be alt or null)
Definition at line 246 of file ToyMCSampler.h.
|
protected |
prior pdf for nuisance parameters
Definition at line 251 of file ToyMCSampler.h.
|
protected |
!
Definition at line 277 of file ToyMCSampler.h.
|
protected |
in dev
Definition at line 275 of file ToyMCSampler.h.
|
protected |
name of the model
Definition at line 250 of file ToyMCSampler.h.
|
protected |
Definition at line 257 of file ToyMCSampler.h.
|
protected |
Definition at line 248 of file ToyMCSampler.h.
|
protected |
minimum no of toys in tails for adaptive sampling (taking weights into account, therefore double) Default: 0.0 which means no adaptive sampling
Definition at line 267 of file ToyMCSampler.h.
|
protected |
Use PrepareMultiGen?
Definition at line 292 of file ToyMCSampler.h.