55 using namespace RooFit;
56 using namespace RooStats;
66 const char* workspaceName =
"combined",
67 const char* modelSBName =
"ModelConfig",
68 const char* modelBName =
"",
69 const char* dataName =
"obsData",
74 const char * nuisPriorName = 0)
111 SimpleLikelihoodRatioTestStat::SetAlwaysReuseNLL(
true);
112 ProfileLikelihoodTestStat::SetAlwaysReuseNLL(
true);
113 RatioOfProfiledLikelihoodsTestStat::SetAlwaysReuseNLL(
true);
128 filename =
"results/example_combined_GaussExample_model.root";
133 cout <<
"HistFactory file cannot be generated on Windows - exit" << endl;
137 cout <<
"will run standard hist2workspace example"<<endl;
138 gROOT->ProcessLine(
".! prepareHistFactory .");
139 gROOT->ProcessLine(
".! hist2workspace config/example.xml");
140 cout <<
"\n\n---------------------"<<endl;
141 cout <<
"Done creating example input"<<endl;
142 cout <<
"---------------------\n\n"<<endl;
154 cout <<
"StandardRooStatsDemoMacro: Input file " << filename <<
" is not found" << endl;
166 cout <<
"workspace not found" << endl;
179 if(!data || !sbModel){
181 cout <<
"data or ModelConfig was not found" <<endl;
192 if (nuisPar && nuisPar->
getSize() > 0) {
193 std::cout <<
"StandardHypoTestInvDemo" <<
" - Switch off all systematics by setting them constant to their initial values" << std::endl;
205 Info(
"StandardHypoTestInvDemo",
"The background model %s does not exist",modelBName);
206 Info(
"StandardHypoTestInvDemo",
"Copy it from ModelConfig %s and set POI to zero",modelSBName);
211 double oldval = var->
getVal();
219 Info(
"StandardHypoTestDemo",
"Model %s has no snapshot - make one using model poi",modelSBName);
222 double oldval = var->
getVal();
260 AsymptoticCalculator::SetPrintLevel(
printLevel);
265 else if (calcType == 1) hypoCalc=
new HybridCalculator(*data, *sbModel, *bModel);
272 if (calcType == 2 ) {
274 if (testStatType != 2 && testStatType != 3)
275 Warning(
"StandardHypoTestDemo",
"Only the PL test statistic can be used with AsymptoticCalculator - use by default a two-sided PL");
284 if (nuisPriorName) nuisPdf = w->
pdf(nuisPriorName);
287 Info(
"StandardHypoTestDemo",
"No nuisance pdf given for the HybridCalculator - try to deduce pdf from the model");
296 Info(
"StandardHypoTestDemo",
"No nuisance pdf given - try to use %s that is defined as a prior pdf in the B model",nuisPdf->
GetName());
299 Error(
"StandardHypoTestDemo",
"Cannnot run Hybrid calculator because no prior on the nuisance parameter is specified or can be derived");
304 Info(
"StandardHypoTestDemo",
"Using as nuisance Pdf ... " );
310 Warning(
"StandardHypoTestDemo",
"Prior nuisance does not depend on nuisance parameters. They will be smeared in their full range");
323 if (sampler && (calcType == 0 || calcType == 1) ) {
327 if (useNC)
Warning(
"StandardHypoTestDemo",
"Pdf is extended: but number counting flag is set: ignore it ");
333 Info(
"StandardHypoTestDemo",
"Pdf is not extended: number of events to generate taken from observed data set is %d",nEvents);
337 Info(
"StandardHypoTestDemo",
"using a number counting pdf");
343 Info(
"StandardHypoTestDemo",
"Data set is weighted, nentries = %d and sum of weights = %8.1f but toy generation is unbinned - it would be faster to set generateBinned to true\n",data->
numEntries(), data->
sumEntries());
351 if (testStatType == 2 || testStatType == 3) sampler->
SetTestStatistic(profll);
371 std::cout <<
"Asymptotic results " << std::endl;
385 for (
int i = 0; i < 5; ++i) {
392 for (
int i = 0; i < 5; ++i) {
395 std::cout <<
" Expected p -value and significance at " << sig <<
" sigma = "
402 for (
int i = 0; i < 5; ++i) {
406 std::cout <<
" Expected p -value and significance at " << sig <<
" sigma = "
virtual Double_t sumEntries() const =0
virtual Bool_t AccessPathName(const char *path, EAccessMode mode=kFileExists)
Returns FALSE if one can access a file using the specified access mode.
void SetBackgroundAsAlt(Bool_t l=kTRUE)
void SetPrintLevel(Int_t printlevel)
ModelConfig is a simple class that holds configuration information specifying how a model should be u...
RooAbsPdf * GetPdf() const
get model PDF (return NULL if pdf has not been specified or does not exist)
RooAbsPdf * MakeNuisancePdf(RooAbsPdf &pdf, const RooArgSet &observables, const char *name)
RooAbsData * data(const char *name) const
Retrieve dataset (binned or unbinned) with given name. A null pointer is returned if not found...
double normal_quantile_c(double z, double sigma)
Inverse ( ) of the cumulative distribution function of the upper tail of the normal (Gaussian) distri...
virtual void SetName(const char *name)
Change (i.e.
RooArgSet * getObservables(const RooArgSet &set, Bool_t valueOnly=kTRUE) const
std::vector< double > values
HypoTestResult is a base class for results from hypothesis tests.
static const char * filename()
virtual void SetNEventsPerToy(const Int_t nevents)
This class provides the plots for the result of a study performed with any of the HypoTestCalculatorG...
SamplingDistribution * GetAltDistribution(void) const
void SetLogYaxis(Bool_t ly)
changes plot to log scale on y axis
void SetAltParameters(const RooArgSet &altParameters)
const std::vector< Double_t > & GetSamplingDistribution() const
Get test statistics values.
const RooArgSet * GetNuisanceParameters() const
get RooArgSet containing the nuisance parameters (return NULL if not existing)
static TFile * Open(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=1, Int_t netopt=0)
Create / open a file.
virtual void SetTestStatistic(TestStatistic *testStatistic, unsigned int i)
RooAbsArg * first() const
void plot(TString fname="data.root", TString var0="var0", TString var1="var1")
virtual ModelConfig * Clone(const char *name="") const
clone
Common base class for the Hypothesis Test Calculators.
virtual void Print(Option_t *options=0) const
Print TNamed name and title.
virtual HypoTestResult * GetHypoTest() const
inherited methods from HypoTestCalculator interface
TestStatSampler * GetTestStatSampler(void) const
void SetNullParameters(const RooArgSet &nullParameters)
void Quantiles(Int_t n, Int_t nprob, Double_t *x, Double_t *quantiles, Double_t *prob, Bool_t isSorted=kTRUE, Int_t *index=0, Int_t type=7)
Computes sample quantiles, corresponding to the given probabilities Parameters: x -the data sample n ...
double normal_cdf(double x, double sigma=1, double x0=0)
Cumulative distribution function of the normal (Gaussian) distribution (lower tail).
void Print(const Option_t *="") const
RooAbsPdf * pdf(const char *name) const
Retrieve p.d.f (RooAbsPdf) with given name. A null pointer is returned if not found.
void Draw(Option_t *options=0)
Draw this plot and all of the elements it contains.
void Info(const char *location, const char *msgfmt,...)
virtual Bool_t isWeighted() const
Double_t getVal(const RooArgSet *set=0) const
virtual Double_t NullPValue() const
Return p-value for null hypothesis.
void Error(const char *location, const char *msgfmt,...)
RooRealVar represents a fundamental (non-derived) real valued object.
virtual void setVal(Double_t value)
Set value of variable to 'value'.
R__EXTERN TSystem * gSystem
virtual Int_t numEntries() const
virtual const char * GetName() const
Returns name of object.
void SetSubtractMLE(bool subtract)
RooAbsData is the common abstract base class for binned and unbinned datasets.
void SetOneSidedDiscovery(Bool_t flag=true)
ProfileLikelihoodTestStat is an implementation of the TestStatistic interface that calculates the pro...
ToyMCSampler is an implementation of the TestStatSampler interface.
virtual Double_t Significance() const
familiar name for the Null p-value in terms of 1-sided Gaussian significance
void Warning(const char *location, const char *msgfmt,...)
void SetTestStatisticData(const Double_t tsd)
This class simply holds a sampling distribution of some test statistic.
TestStatistic that returns the ratio of profiled likelihoods.
virtual void Append(const HypoTestResult *other)
add values from another HypoTestResult
This class implements the Hypothesis test calculation using an hybrid (frequentist/bayesian) procedur...
const RooArgSet * GetObservables() const
get RooArgSet for observables (return NULL if not existing)
void SetPValueIsRightTail(Bool_t pr)
void StandardHypoTestDemo(const char *infile="", const char *workspaceName="combined", const char *modelSBName="ModelConfig", const char *modelBName="", const char *dataName="obsData", int calcType=0, int testStatType=3, int ntoys=5000, bool useNC=false, const char *nuisPriorName=0)
Bool_t canBeExtended() const
bool SetAllConstant(const RooAbsCollection &coll, bool constant=true)
const RooArgSet * GetSnapshot() const
get RooArgSet for parameters for a particular hypothesis (return NULL if not existing) ...
TestStatistic class that returns -log(L[null] / L[alt]) where L is the likelihood.
TObject * obj(const char *name) const
Return any type of object (RooAbsArg, RooAbsData or generic object) with given name) ...
virtual Double_t AlternatePValue() const
Return p-value for alternate hypothesis.
RooAbsPdf is the abstract interface for all probability density functions The class provides hybrid a...
void Print(Option_t *opts=0) const
Print contents of the workspace.
Hypothesis Test Calculator using a full frequentist procedure for sampling the test statistic distrib...
const RooArgSet * GetParametersOfInterest() const
get RooArgSet containing the parameter of interest (return NULL if not existing)
void SetGenerateBinned(bool binned=true)
RooAbsPdf * GetPriorPdf() const
get parameters prior pdf (return NULL if not existing)
virtual void SetSnapshot(const RooArgSet &set)
set parameter values for a particular hypothesis if using a common PDF by saving a snapshot in the wo...
Hypothesis Test Calculator based on the asymptotic formulae for the profile likelihood ratio...
virtual Bool_t add(const RooAbsArg &var, Bool_t silent=kFALSE)
Add element to non-owning set.
The RooWorkspace is a persistable container for RooFit projects.