47struct BayesianNumericalOptions {
49 double confLevel = 0.95;
57 bool plotPosterior =
false;
62 double nSigmaNuisance = -1;
66BayesianNumericalOptions optBayes;
68void StandardBayesianNumericalDemo(
const char *infile =
"",
const char *workspaceName =
"combined",
69 const char *modelConfigName =
"ModelConfig",
const char *dataName =
"obsData")
73 double confLevel = optBayes.confLevel;
74 TString integrationType = optBayes.integrationType;
75 int nToys = optBayes.nToys;
76 bool scanPosterior = optBayes.scanPosterior;
77 bool plotPosterior = optBayes.plotPosterior;
78 int nScanPoints = optBayes.nScanPoints;
79 int intervalType = optBayes.intervalType;
80 int maxPOI = optBayes.maxPOI;
81 double nSigmaNuisance = optBayes.nSigmaNuisance;
88 if (!strcmp(infile,
"")) {
89 filename =
"results/example_combined_GaussExample_model.root";
94 cout <<
"will run standard hist2workspace example" << endl;
95 gROOT->ProcessLine(
".! prepareHistFactory .");
96 gROOT->ProcessLine(
".! hist2workspace config/example.xml");
97 cout <<
"\n\n---------------------" << endl;
98 cout <<
"Done creating example input" << endl;
99 cout <<
"---------------------\n\n" << endl;
110 cout <<
"StandardRooStatsDemoMacro: Input file " <<
filename <<
" is not found" << endl;
121 cout <<
"workspace not found" << endl;
134 cout <<
"data or ModelConfig was not found" << endl;
153 if (nSigmaNuisance > 0) {
156 std::unique_ptr<RooFitResult> res{
162 for (
int i = 0; i < nuisPar.getSize(); ++i) {
165 v->setMin(
TMath::Max(
v->getMin(),
v->getVal() - nSigmaNuisance *
v->getError()));
166 v->setMax(
TMath::Min(
v->getMax(),
v->getVal() + nSigmaNuisance *
v->getError()));
167 std::cout <<
"setting interval for nuisance " <<
v->GetName() <<
" : [ " <<
v->getMin() <<
" , "
168 <<
v->getMax() <<
" ]" << std::endl;
173 bayesianCalc.SetConfidenceLevel(confLevel);
177 if (intervalType == 0)
178 bayesianCalc.SetShortestInterval();
179 if (intervalType == 1)
180 bayesianCalc.SetLeftSideTailFraction(0.5);
181 if (intervalType == 2)
182 bayesianCalc.SetLeftSideTailFraction(0.);
184 if (!integrationType.
IsNull()) {
185 bayesianCalc.SetIntegrationType(integrationType);
186 bayesianCalc.SetNumIters(nToys);
190 if (integrationType.
Contains(
"TOYMC")) {
192 cout <<
"using TOYMC integration: make nuisance pdf from the model " << std::endl;
194 bayesianCalc.ForceNuisancePdf(*nuisPdf);
195 scanPosterior =
true;
200 bayesianCalc.SetScanOfPosterior(nScanPoints);
203 if (maxPOI != -999 && maxPOI > poi->
getMin())
209 cout <<
"\n>>>> RESULT : " << confLevel * 100 <<
"% interval on " << poi->
GetName() <<
" is : ["
224 cout <<
"\nDrawing plot of posterior function....." << endl;
227 bayesianCalc.SetScanOfPosterior(nScanPoints);
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
R__EXTERN TSystem * gSystem
static int DefaultPrintLevel()
static const std::string & DefaultMinimizerType()
void Print(Option_t *options=nullptr) const override
Print the object to the defaultPrintStream().
RooAbsArg * first() const
Abstract base class for binned and unbinned datasets.
Abstract interface for all probability density functions.
RooFit::OwningPtr< RooFitResult > fitTo(RooAbsData &data, CmdArgs_t const &... cmdArgs)
Fit PDF to given dataset.
virtual double getMin(const char *name=nullptr) const
Get minimum of currently defined range.
static void setEvalErrorLoggingMode(ErrorLoggingMode m)
Set evaluation error logging mode.
RooArgList is a container object that can hold multiple RooAbsArg objects.
Plot frame and a container for graphics objects within that frame.
Variable that can be changed from the outside.
void setMax(const char *name, double value)
Set maximum of name range to given value.
BayesianCalculator is a concrete implementation of IntervalCalculator, providing the computation of a...
ModelConfig is a simple class that holds configuration information specifying how a model should be u...
virtual void SetPriorPdf(const RooAbsPdf &pdf)
Set the Prior Pdf, add to the workspace if not already there.
const RooArgSet * GetParametersOfInterest() const
get RooArgSet containing the parameter of interest (return nullptr if not existing)
const RooArgSet * GetNuisanceParameters() const
get RooArgSet containing the nuisance parameters (return nullptr if not existing)
RooAbsPdf * GetPdf() const
get model PDF (return nullptr if pdf has not been specified or does not exist)
SimpleInterval is a concrete implementation of the ConfInterval interface.
virtual double UpperLimit()
return the interval upper limit
virtual double LowerLimit()
return the interval lower limit
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.
const char * GetName() const override
Returns name of object.
virtual void Draw(Option_t *option="")
Default Draw method for all objects.
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
virtual Bool_t AccessPathName(const char *path, EAccessMode mode=kFileExists)
Returns FALSE if one can access a file using the specified access mode.
RooCmdArg Minimizer(const char *type, const char *alg=nullptr)
RooCmdArg Hesse(bool flag=true)
RooCmdArg Save(bool flag=true)
RooCmdArg PrintLevel(Int_t code)
The namespace RooFit contains mostly switches that change the behaviour of functions of PDFs (or othe...
Namespace for the RooStats classes.
RooAbsPdf * MakeNuisancePdf(RooAbsPdf &pdf, const RooArgSet &observables, const char *name)
extract constraint terms from pdf
Short_t Max(Short_t a, Short_t b)
Returns the largest of a and b.
Short_t Min(Short_t a, Short_t b)
Returns the smallest of a and b.