ToyMCImportanceSampler is an extension of the ToyMCSampler for Importance Sampling.
Implementation based on a work by Cranmer, Kreiss, Read (in Preparation)
Definition at line 22 of file ToyMCImportanceSampler.h.
Public Member Functions | |
ToyMCImportanceSampler ()=default | |
Proof constructor. Do not use. | |
ToyMCImportanceSampler (TestStatistic &ts, Int_t ntoys) | |
~ToyMCImportanceSampler () override | |
void | AddImportanceDensity (RooAbsPdf *p, const RooArgSet *s) |
For importance sampling with multiple densities/snapshots: This is used to check the current Likelihood against Likelihoods from other importance densities apart from the one given as importance snapshot. | |
void | AddNullDensity (RooAbsPdf *p, const RooArgSet *s=nullptr) |
The pdf can be nullptr in which case the density from SetPdf() is used. | |
int | CreateImpDensitiesForOnePOIAdaptively (RooAbsPdf &pdf, const RooArgSet &allPOI, RooRealVar &poi, double nStdDevOverlap=0.5, double poiValueForBackground=0.0) |
poi has to be fitted beforehand. This function expects this to be the muhat value. | |
int | CreateNImpDensitiesForOnePOI (RooAbsPdf &pdf, const RooArgSet &allPOI, RooRealVar &poi, int n, double poiValueForBackground=0.0) |
n is the number of importance densities | |
virtual RooAbsData * | GenerateToyData (RooArgSet ¶mPoint) const |
virtual RooAbsData * | GenerateToyData (RooArgSet ¶mPoint, double &weight) const |
RooAbsData * | GenerateToyData (RooArgSet ¶mPoint, double &weight) const override |
virtual RooAbsData * | GenerateToyData (RooArgSet ¶mPoint, double &weight, RooAbsPdf &pdf) const |
generates toy data with weight | |
virtual RooAbsData * | GenerateToyData (RooArgSet ¶mPoint, double &weight, std::vector< double > &impNLLs, double &nullNLL) const |
virtual RooAbsData * | GenerateToyData (RooArgSet ¶mPoint, RooAbsPdf &pdf) const |
generates toy data without weight | |
virtual RooAbsData * | GenerateToyData (std::vector< double > &weights) const |
virtual RooAbsData * | GenerateToyData (std::vector< double > &weights, std::vector< double > &nullNLLs, std::vector< double > &impNLLs) const |
This method generates a toy data set for importance sampling for the given parameter point taking global observables into account. | |
RooDataSet * | GetSamplingDistributionsSingleWorker (RooArgSet ¶mPoint) override |
overwrite GetSamplingDistributionsSingleWorker(paramPoint) with a version that loops over nulls and importance densities, but calls the parent ToyMCSampler::GetSamplingDistributionsSingleWorker(paramPoint). | |
TClass * | IsA () const override |
void | SetApplyVeto (bool b=true) |
When set to true, this sets the weight of all toys to zero that do not have the largest likelihood under the density it was generated compared to the other densities. | |
virtual void | SetConditionalObservables (const RooArgSet &set) |
set the conditional observables which will be used when creating the NLL so the pdf's will not be normalized on the conditional observables when computing the NLL Since the class use a NLL we need to set the conditional observables if they exist in the model | |
void | SetDensityToGenerateFromByIndex (unsigned int i, bool fromNull=false) |
specifies the pdf to sample from | |
void | SetEqualNumToysPerDensity (void) |
void | SetExpIncreasingNumToysPerDensity (void) |
void | SetParametersForTestStat (const RooArgSet &nullpoi) override |
overwrite from ToyMCSampler | |
void | SetPdf (RooAbsPdf &pdf) override |
overwrite from ToyMCSampler | |
void | SetReuseNLL (bool r=true) |
void | Streamer (TBuffer &) override |
void | StreamerNVirtual (TBuffer &ClassDef_StreamerNVirtual_b) |
Public Member Functions inherited from RooStats::ToyMCSampler | |
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 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 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) |
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 Public Member Functions inherited from RooStats::ToyMCSampler | |
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 | |
void | ClearCache () override |
helper method for clearing the cache | |
Protected Member Functions inherited from RooStats::ToyMCSampler | |
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 | |
bool | fApplyVeto = true |
RooArgSet | fConditionalObs |
set of conditional observables | |
bool | fGenerateFromNull = true |
std::vector< std::unique_ptr< RooAbsReal > > | fImpNLLs |
! | |
std::vector< RooAbsPdf * > | fImportanceDensities |
std::vector< const RooArgSet * > | fImportanceSnapshots |
unsigned int | fIndexGenDensity = 0 |
std::vector< RooAbsPdf * > | fNullDensities |
support multiple null densities | |
std::vector< std::unique_ptr< RooAbsReal > > | fNullNLLs |
! | |
std::vector< const RooArgSet * > | fNullSnapshots |
bool | fReuseNLL = true |
toysStrategies | fToysStrategy = EQUALTOYSPERDENSITY |
Protected Attributes inherited from RooStats::ToyMCSampler | |
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? | |
Additional Inherited Members | |
Static Protected Attributes inherited from RooStats::ToyMCSampler | |
static bool | fgAlwaysUseMultiGen = false |
Use PrepareMultiGen always. | |
#include <RooStats/ToyMCImportanceSampler.h>
|
default |
Proof constructor. Do not use.
|
inline |
Definition at line 28 of file ToyMCImportanceSampler.h.
|
override |
Definition at line 37 of file ToyMCImportanceSampler.cxx.
|
inline |
For importance sampling with multiple densities/snapshots: This is used to check the current Likelihood against Likelihoods from other importance densities apart from the one given as importance snapshot.
The pdf can be nullptr in which case the density from SetImportanceDensity() is used. The snapshot is also optional.
Definition at line 65 of file ToyMCImportanceSampler.h.
|
inline |
The pdf can be nullptr in which case the density from SetPdf() is used.
The snapshot and TestStatistic is also optional.
Definition at line 86 of file ToyMCImportanceSampler.h.
|
static |
|
static |
|
inlinestaticconstexpr |
Definition at line 181 of file ToyMCImportanceSampler.h.
|
overrideprotectedvirtual |
helper method for clearing the cache
Reimplemented from RooStats::ToyMCSampler.
Definition at line 44 of file ToyMCImportanceSampler.cxx.
int RooStats::ToyMCImportanceSampler::CreateImpDensitiesForOnePOIAdaptively | ( | RooAbsPdf & | pdf, |
const RooArgSet & | allPOI, | ||
RooRealVar & | poi, | ||
double | nStdDevOverlap = 0.5 , |
||
double | poiValueForBackground = 0.0 |
||
) |
poi has to be fitted beforehand. This function expects this to be the muhat value.
Definition at line 428 of file ToyMCImportanceSampler.cxx.
int RooStats::ToyMCImportanceSampler::CreateNImpDensitiesForOnePOI | ( | RooAbsPdf & | pdf, |
const RooArgSet & | allPOI, | ||
RooRealVar & | poi, | ||
int | n, | ||
double | poiValueForBackground = 0.0 |
||
) |
n is the number of importance densities
Definition at line 451 of file ToyMCImportanceSampler.cxx.
|
inlinestatic |
Definition at line 181 of file ToyMCImportanceSampler.h.
|
inlinevirtual |
Reimplemented from RooStats::ToyMCSampler.
Definition at line 108 of file ToyMCSampler.h.
|
inlinevirtual |
Reimplemented from RooStats::ToyMCSampler.
Definition at line 112 of file ToyMCSampler.h.
|
overridevirtual |
Reimplemented from RooStats::ToyMCSampler.
Definition at line 129 of file ToyMCImportanceSampler.cxx.
|
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 from RooStats::ToyMCSampler.
Definition at line 111 of file ToyMCSampler.cxx.
|
virtual |
Definition at line 171 of file ToyMCImportanceSampler.cxx.
|
inlinevirtual |
generates toy data without weight
Reimplemented from RooStats::ToyMCSampler.
Definition at line 103 of file ToyMCSampler.h.
|
virtual |
Definition at line 210 of file ToyMCImportanceSampler.cxx.
|
virtual |
This method generates a toy data set for importance sampling 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.
Definition at line 234 of file ToyMCImportanceSampler.cxx.
|
overridevirtual |
overwrite GetSamplingDistributionsSingleWorker(paramPoint) with a version that loops over nulls and importance densities, but calls the parent ToyMCSampler::GetSamplingDistributionsSingleWorker(paramPoint).
Reimplemented from RooStats::ToyMCSampler.
Definition at line 53 of file ToyMCImportanceSampler.cxx.
|
inlineoverridevirtual |
Reimplemented from RooStats::TestStatSampler.
Definition at line 181 of file ToyMCImportanceSampler.h.
|
inline |
When set to true, this sets the weight of all toys to zero that do not have the largest likelihood under the density it was generated compared to the other densities.
Definition at line 127 of file ToyMCImportanceSampler.h.
|
inlinevirtual |
set the conditional observables which will be used when creating the NLL so the pdf's will not be normalized on the conditional observables when computing the NLL Since the class use a NLL we need to set the conditional observables if they exist in the model
Definition at line 134 of file ToyMCImportanceSampler.h.
|
inline |
specifies the pdf to sample from
Definition at line 45 of file ToyMCImportanceSampler.h.
|
inline |
Definition at line 151 of file ToyMCImportanceSampler.h.
|
inline |
Definition at line 152 of file ToyMCImportanceSampler.h.
|
inlineoverridevirtual |
overwrite from ToyMCSampler
Implements RooStats::TestStatSampler.
Definition at line 112 of file ToyMCImportanceSampler.h.
|
inlineoverridevirtual |
overwrite from ToyMCSampler
Implements RooStats::TestStatSampler.
Definition at line 102 of file ToyMCImportanceSampler.h.
|
inline |
Definition at line 129 of file ToyMCImportanceSampler.h.
|
overridevirtual |
Reimplemented from RooStats::TestStatSampler.
|
inline |
Definition at line 181 of file ToyMCImportanceSampler.h.
|
protected |
Definition at line 161 of file ToyMCImportanceSampler.h.
|
protected |
set of conditional observables
Definition at line 163 of file ToyMCImportanceSampler.h.
|
protected |
Definition at line 160 of file ToyMCImportanceSampler.h.
|
mutableprotected |
!
Definition at line 178 of file ToyMCImportanceSampler.h.
|
protected |
Definition at line 170 of file ToyMCImportanceSampler.h.
|
protected |
Definition at line 171 of file ToyMCImportanceSampler.h.
|
protected |
Definition at line 159 of file ToyMCImportanceSampler.h.
|
protected |
support multiple null densities
Definition at line 166 of file ToyMCImportanceSampler.h.
|
mutableprotected |
!
Definition at line 177 of file ToyMCImportanceSampler.h.
|
mutableprotected |
Definition at line 167 of file ToyMCImportanceSampler.h.
|
protected |
Definition at line 173 of file ToyMCImportanceSampler.h.
|
protected |
Definition at line 175 of file ToyMCImportanceSampler.h.