72 bool generateBinned =
false;
78void workspaceName =
"combined",
89 bool generateBinned =
optHT.generateBinned;
122 SimpleLikelihoodRatioTestStat::SetAlwaysReuseNLL(
true);
123 ProfileLikelihoodTestStat::SetAlwaysReuseNLL(
true);
124 RatioOfProfiledLikelihoodsTestStat::SetAlwaysReuseNLL(
true);
140 filename =
"results/example_combined_GaussExample_model.root";
145 cout <<
"will run standard hist2workspace example" << endl;
146 gROOT->ProcessLine(
".! prepareHistFactory .");
147 gROOT->ProcessLine(
".! hist2workspace config/example.xml");
148 cout <<
"\n\n---------------------" << endl;
149 cout <<
"Done creating example input" << endl;
150 cout <<
"---------------------\n\n" << endl;
161 cout <<
"StandardRooStatsDemoMacro: Input file " <<
filename <<
" is not found" << endl;
172 cout <<
"workspace not found" << endl;
186 cout <<
"data or ModelConfig was not found" << endl;
197 std::cout <<
"StandardHypoTestInvDemo"
198 <<
" - Switch off all systematics by setting them constant to their initial values" << std::endl;
209 Info(
"StandardHypoTestInvDemo",
"The background model %s does not exist",
modelBName);
210 Info(
"StandardHypoTestInvDemo",
"Copy it from ModelConfig %s and set POI to zero",
modelSBName);
224 Info(
"StandardHypoTestDemo",
"Model %s has no snapshot - make one using model poi",
modelSBName);
242 if (
bModel->GetNuisanceParameters())
247 if (
sbModel->GetNuisanceParameters())
255 ropl->SetSubtractMLE(
false);
258 profll->SetOneSidedDiscovery(1);
262 slrts->EnableDetailedOutput();
263 profll->EnableDetailedOutput();
264 ropl->EnableDetailedOutput();
271 AsymptoticCalculator::SetPrintLevel(
printLevel);
295 Warning(
"StandardHypoTestDemo",
296 "Only the PL test statistic can be used with AsymptoticCalculator - use by default a two-sided PL");
306 Info(
"StandardHypoTestDemo",
307 "No nuisance pdf given for the HybridCalculator - try to deduce pdf from the model");
314 if (
bModel->GetPriorPdf()) {
316 Info(
"StandardHypoTestDemo",
317 "No nuisance pdf given - try to use %s that is defined as a prior pdf in the B model",
320 Error(
"StandardHypoTestDemo",
"Cannot run Hybrid calculator because no prior on the nuisance parameter is "
321 "specified or can be derived");
326 Info(
"StandardHypoTestDemo",
"Using as nuisance Pdf ... ");
330 (
bModel->GetNuisanceParameters()) ?
bModel->GetNuisanceParameters() :
sbModel->GetNuisanceParameters();
332 if (
np->getSize() == 0) {
333 Warning(
"StandardHypoTestDemo",
334 "Prior nuisance does not depend on nuisance parameters. They will be smeared in their full range");
349 if (
sbModel->GetPdf()->canBeExtended()) {
351 Warning(
"StandardHypoTestDemo",
"Pdf is extended: but number counting flag is set: ignore it ");
355 int nEvents =
data->numEntries();
356 Info(
"StandardHypoTestDemo",
357 "Pdf is not extended: number of events to generate taken from observed data set is %d", nEvents);
358 sampler->SetNEventsPerToy(nEvents);
360 Info(
"StandardHypoTestDemo",
"using a number counting pdf");
365 if (
data->isWeighted() && !generateBinned) {
366 Info(
"StandardHypoTestDemo",
"Data set is weighted, nentries = %d and sum of weights = %8.1f but toy "
367 "generation is unbinned - it would be faster to set generateBinned to true\n",
368 data->numEntries(),
data->sumEntries());
371 sampler->SetGenerateBinned(generateBinned);
383 htr->SetPValueIsRightTail(
true);
384 htr->SetBackgroundAsAlt(
false);
394 plot->SetLogYaxis(
true);
397 std::cout <<
"Asymptotic results " << std::endl;
410 for (
int i = 0; i < 5; ++i) {
414 std::vector<double> values =
altDist->GetSamplingDistribution();
417 for (
int i = 0; i < 5; ++i) {
418 htExp.SetTestStatisticData(
q[i]);
420 std::cout <<
" Expected p -value and significance at " << sig <<
" sigma = " <<
htExp.NullPValue()
421 <<
" significance " <<
htExp.Significance() <<
" sigma " << std::endl;
425 for (
int i = 0; i < 5; ++i) {
428 double pval = AsymptoticCalculator::GetExpectedPValues(
htr->NullPValue(),
htr->AlternatePValue(), -sig,
false);
429 std::cout <<
" Expected p -value and significance at " << sig <<
" sigma = " <<
pval <<
" significance "
439 Info(
"StandardHypoTestDemo",
"Detailed output will be written in output result file");
450 name.Replace(0,
name.Last(
'/') + 1,
"");
453 resultFileName,
"RECREATE");
455 Info(
"StandardHypoTestDemo",
"HypoTestResult has been written in the file %s",
resultFileName.Data());
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
void Error(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
void Warning(const char *location, const char *msgfmt,...)
Use this function in warning situations.
winID h TVirtualViewer3D TVirtualGLPainter p
winID h TVirtualViewer3D TVirtualGLPainter char TVirtualGLPainter plot
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char filename
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t np
R__EXTERN TSystem * gSystem
Abstract base class for binned and unbinned datasets.
Abstract interface for all probability density functions.
double getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Variable that can be changed from the outside.
void setVal(double value) override
Set value of variable to 'value'.
Hypothesis Test Calculator based on the asymptotic formulae for the profile likelihood ratio.
Does a frequentist hypothesis test.
Same purpose as HybridCalculatorOriginal, but different implementation.
Common base class for the Hypothesis Test Calculators.
This class provides the plots for the result of a study performed with any of the HypoTestCalculatorG...
HypoTestResult is a base class for results from hypothesis tests.
ModelConfig is a simple class that holds configuration information specifying how a model should be u...
ProfileLikelihoodTestStat is an implementation of the TestStatistic interface that calculates the pro...
TestStatistic that returns the ratio of profiled likelihoods.
This class simply holds a sampling distribution of some test statistic.
TestStatistic class that returns -log(L[null] / L[alt]) where L is the likelihood.
ToyMCSampler is an implementation of the TestStatSampler interface.
Persistable container for RooFit projects.
TObject * Get(const char *namecycle) override
Return pointer to object identified by namecycle.
A ROOT file is an on-disk file, usually with extension .root, that stores objects in a file-system-li...
static TFile * Open(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=ROOT::RCompressionSetting::EDefaults::kUseCompiledDefault, Int_t netopt=0)
Create / open a file.
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
virtual Bool_t AccessPathName(const char *path, EAccessMode mode=kFileExists)
Returns FALSE if one can access a file using the specified access mode.
double normal_cdf(double x, double sigma=1, double x0=0)
Cumulative distribution function of the normal (Gaussian) distribution (lower tail).
double normal_quantile_c(double z, double sigma)
Inverse ( ) of the cumulative distribution function of the upper tail of the normal (Gaussian) distri...
The namespace RooFit contains mostly switches that change the behaviour of functions of PDFs (or othe...
Namespace for the RooStats classes.
bool SetAllConstant(const RooAbsCollection &coll, bool constant=true)
utility function to set all variable constant in a collection (from G.
RooAbsPdf * MakeNuisancePdf(RooAbsPdf &pdf, const RooArgSet &observables, const char *name)
extract constraint terms from pdf
void Quantiles(Int_t n, Int_t nprob, Double_t *x, Double_t *quantiles, Double_t *prob, Bool_t isSorted=kTRUE, Int_t *index=nullptr, Int_t type=7)
Computes sample quantiles, corresponding to the given probabilities.