ToyMCSampler is an implementation of the TestStatSampler interface.
It generates Toy Monte Carlo for a given parameter point and evaluates a TestStatistic.
Definition at line 66 of file ToyMCSampler.h.
Public Member Functions | |
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 | 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) |
![]() | |
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 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 | |
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 | ( | TestStatistic & | ts, |
Int_t | ntoys ) |
Definition at line 142 of file ToyMCSampler.cxx.
|
override |
Definition at line 158 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 91 of file ToyMCSampler.h.
|
virtual |
Extended interface to append to sampling distribution more samples.
Definition at line 550 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 168 of file ToyMCSampler.cxx.
Definition at line 287 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 573 of file ToyMCSampler.cxx.
|
inlineoverridevirtual |
Get the Confidence level for the test.
Implements RooStats::TestStatSampler.
Definition at line 131 of file ToyMCSampler.h.
Definition at line 287 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 184 of file ToyMCSampler.cxx.
|
protected |
Definition at line 194 of file ToyMCSampler.cxx.
|
inlineoverridevirtual |
Main interface to evaluate the test statistic on a dataset.
Implements RooStats::TestStatSampler.
Definition at line 121 of file ToyMCSampler.h.
|
inlinevirtual |
Main interface to evaluate the test statistic on a dataset.
Definition at line 118 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 479 of file ToyMCSampler.cxx.
|
virtual |
generate global observables
Definition at line 347 of file ToyMCSampler.cxx.
|
inlinevirtual |
Reimplemented in RooStats::ToyMCImportanceSampler.
Definition at line 107 of file ToyMCSampler.h.
|
inlinevirtual |
Reimplemented in RooStats::ToyMCImportanceSampler, and RooStats::ToyMCImportanceSampler.
Definition at line 111 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 413 of file ToyMCSampler.cxx.
|
inlinevirtual |
generates toy data without weight
Reimplemented in RooStats::ToyMCImportanceSampler.
Definition at line 102 of file ToyMCSampler.h.
Definition at line 138 of file ToyMCSampler.h.
|
inline |
Definition at line 206 of file ToyMCSampler.h.
|
overridevirtual |
main interface
Implements RooStats::TestStatSampler.
Definition at line 226 of file ToyMCSampler.cxx.
|
virtual |
Use for serial and parallel runs.
Definition at line 246 of file ToyMCSampler.cxx.
|
virtual |
This is the main function for serial runs.
Reimplemented in RooStats::ToyMCImportanceSampler.
Definition at line 255 of file ToyMCSampler.cxx.
|
inlinevirtual |
Definition at line 125 of file ToyMCSampler.h.
|
inlineoverridevirtual |
Get the TestStatistic.
Implements RooStats::TestStatSampler.
Definition at line 129 of file ToyMCSampler.h.
|
inlineoverridevirtual |
Common Initialization.
Implements RooStats::TestStatSampler.
Definition at line 132 of file ToyMCSampler.h.
|
inlineoverridevirtual |
Reimplemented from RooStats::TestStatSampler.
Definition at line 287 of file ToyMCSampler.h.
|
static |
Definition at line 138 of file ToyMCSampler.cxx.
Definition at line 192 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 175 of file ToyMCSampler.h.
Definition at line 191 of file ToyMCSampler.h.
set auto binned generation (=> see RooFit::AutoBinned() option)
Definition at line 202 of file ToyMCSampler.h.
control to use bin data generation (=> see RooFit::AllBinned() option)
Definition at line 198 of file ToyMCSampler.h.
|
inline |
name of the tag for individual components to be generated binned (=> see RooFit::GenBinned() option)
Definition at line 200 of file ToyMCSampler.h.
specify the conditional observables
Implements RooStats::TestStatSampler.
Definition at line 169 of file ToyMCSampler.h.
|
inline |
This option forces a maximum number of total toys.
Definition at line 209 of file ToyMCSampler.h.
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 142 of file ToyMCSampler.h.
Definition at line 139 of file ToyMCSampler.h.
specify the nuisance parameters (eg. the rest of the parameters)
Implements RooStats::TestStatSampler.
Definition at line 165 of file ToyMCSampler.h.
specify the observables in the dataset (needed to evaluate the test statistic)
Implements RooStats::TestStatSampler.
Definition at line 167 of file ToyMCSampler.h.
|
inlineoverridevirtual |
Set the Pdf, add to the workspace if not already there.
Implements RooStats::TestStatSampler.
Definition at line 148 of file ToyMCSampler.h.
|
inlineoverridevirtual |
Set the Pdf, add to the workspace if not already there.
Implements RooStats::TestStatSampler.
Definition at line 154 of file ToyMCSampler.h.
|
inlineoverridevirtual |
How to randomize the prior. Set to nullptr to deactivate randomization.
Implements RooStats::TestStatSampler.
Definition at line 157 of file ToyMCSampler.h.
|
inline |
Definition at line 227 of file ToyMCSampler.h.
|
inlineoverridevirtual |
Set the name of the sampling distribution used for plotting.
Implements RooStats::TestStatSampler.
Definition at line 205 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 173 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 189 of file ToyMCSampler.h.
|
inlinevirtual |
Set the TestStatistic (want the argument to be a function of the data & parameter points.
Definition at line 178 of file ToyMCSampler.h.
|
inline |
Definition at line 221 of file ToyMCSampler.h.
Definition at line 211 of file ToyMCSampler.h.
Definition at line 216 of file ToyMCSampler.h.
|
inline |
Definition at line 75 of file ToyMCSampler.h.
|
overridevirtual |
Reimplemented from RooStats::TestStatSampler.
|
inline |
Definition at line 287 of file ToyMCSampler.h.
|
mutableprotected |
!
Definition at line 275 of file ToyMCSampler.h.
|
mutableprotected |
! GenSpec #1
Definition at line 279 of file ToyMCSampler.h.
|
mutableprotected |
! GenSpec #2
Definition at line 280 of file ToyMCSampler.h.
|
mutableprotected |
! GenSpec #3
Definition at line 281 of file ToyMCSampler.h.
|
mutableprotected |
! GenSpec #4
Definition at line 282 of file ToyMCSampler.h.
|
mutableprotected |
!
Definition at line 278 of file ToyMCSampler.h.
|
mutableprotected |
!
Definition at line 277 of file ToyMCSampler.h.
|
mutableprotected |
! We don't own those objects
Definition at line 276 of file ToyMCSampler.h.
|
protected |
Definition at line 268 of file ToyMCSampler.h.
|
protected |
tails
Definition at line 267 of file ToyMCSampler.h.
|
protected |
whether to use expectation values for nuisance parameters (ie Asimov data set)
Definition at line 253 of file ToyMCSampler.h.
Use PrepareMultiGen always.
Definition at line 284 of file ToyMCSampler.h.
Definition at line 257 of file ToyMCSampler.h.
Definition at line 255 of file ToyMCSampler.h.
|
protected |
Definition at line 256 of file ToyMCSampler.h.
Definition at line 249 of file ToyMCSampler.h.
|
protected |
maximum no of toys (taking weights into account, therefore double)
Definition at line 265 of file ToyMCSampler.h.
|
protected |
number of events per toy (may be ignored depending on settings)
Definition at line 251 of file ToyMCSampler.h.
|
protected |
number of toys to generate
Definition at line 250 of file ToyMCSampler.h.
|
mutableprotected |
!
Definition at line 272 of file ToyMCSampler.h.
Definition at line 247 of file ToyMCSampler.h.
Definition at line 248 of file ToyMCSampler.h.
Definition at line 242 of file ToyMCSampler.h.
|
protected |
densities, snapshots, and test statistics to reweight to
model (can be alt or null)
Definition at line 241 of file ToyMCSampler.h.
|
protected |
prior pdf for nuisance parameters
Definition at line 246 of file ToyMCSampler.h.
|
protected |
in dev
Definition at line 270 of file ToyMCSampler.h.
|
protected |
name of the model
Definition at line 245 of file ToyMCSampler.h.
|
protected |
Definition at line 252 of file ToyMCSampler.h.
|
protected |
Definition at line 243 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 262 of file ToyMCSampler.h.
Use PrepareMultiGen?
Definition at line 285 of file ToyMCSampler.h.