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;
87 const char *filename =
"";
88 if (!strcmp(infile,
"")) {
89 filename =
"results/example_combined_GaussExample_model.root";
94 cout <<
"HistFactory file cannot be generated on Windows - exit" << endl;
98 cout <<
"will run standard hist2workspace example" << endl;
99 gROOT->ProcessLine(
".! prepareHistFactory .");
100 gROOT->ProcessLine(
".! hist2workspace config/example.xml");
101 cout <<
"\n\n---------------------" << endl;
102 cout <<
"Done creating example input" << endl;
103 cout <<
"---------------------\n\n" << endl;
114 cout <<
"StandardRooStatsDemoMacro: Input file " << filename <<
" is not found" << endl;
125 cout <<
"workspace not found" << endl;
138 cout <<
"data or ModelConfig was not found" << endl;
157 if (nSigmaNuisance > 0) {
166 for (
int i = 0; i < nuisPar.getSize(); ++i) {
169 v->setMin(
TMath::Max(
v->getMin(),
v->getVal() - nSigmaNuisance *
v->getError()));
170 v->setMax(
TMath::Min(
v->getMax(),
v->getVal() + nSigmaNuisance *
v->getError()));
171 std::cout <<
"setting interval for nuisance " <<
v->GetName() <<
" : [ " <<
v->getMin() <<
" , "
172 <<
v->getMax() <<
" ]" << std::endl;
177 bayesianCalc.SetConfidenceLevel(confLevel);
181 if (intervalType == 0)
182 bayesianCalc.SetShortestInterval();
183 if (intervalType == 1)
184 bayesianCalc.SetLeftSideTailFraction(0.5);
185 if (intervalType == 2)
186 bayesianCalc.SetLeftSideTailFraction(0.);
188 if (!integrationType.
IsNull()) {
189 bayesianCalc.SetIntegrationType(integrationType);
190 bayesianCalc.SetNumIters(nToys);
194 if (integrationType.
Contains(
"TOYMC")) {
196 cout <<
"using TOYMC integration: make nuisance pdf from the model " << std::endl;
198 bayesianCalc.ForceNuisancePdf(*nuisPdf);
199 scanPosterior =
true;
204 bayesianCalc.SetScanOfPosterior(nScanPoints);
207 if (maxPOI != -999 && maxPOI > poi->
getMin())
213 cout <<
"\n>>>> RESULT : " << confLevel * 100 <<
"% interval on " << poi->
GetName() <<
" is : ["
228 cout <<
"\nDrawing plot of posterior function....." << endl;
231 bayesianCalc.SetScanOfPosterior(nScanPoints);
233 RooPlot *plot = bayesianCalc.GetPosteriorPlot();
R__EXTERN TSystem * gSystem
static int DefaultPrintLevel()
static const std::string & DefaultMinimizerType()
virtual void Print(Option_t *options=0) const
Print the object to the defaultPrintStream().
RooAbsArg * first() const
RooAbsData is the common abstract base class for binned and unbinned datasets.
virtual RooFitResult * fitTo(RooAbsData &data, const RooCmdArg &arg1=RooCmdArg::none(), const RooCmdArg &arg2=RooCmdArg::none(), const RooCmdArg &arg3=RooCmdArg::none(), const RooCmdArg &arg4=RooCmdArg::none(), const RooCmdArg &arg5=RooCmdArg::none(), const RooCmdArg &arg6=RooCmdArg::none(), const RooCmdArg &arg7=RooCmdArg::none(), const RooCmdArg &arg8=RooCmdArg::none())
Fit PDF to given dataset.
virtual Double_t getMin(const char *name=0) const
Get miniminum 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.
RooFitResult is a container class to hold the input and output of a PDF fit to a dataset.
virtual void Print(Option_t *options=0) const
Print TNamed name and title.
A RooPlot is a plot frame and a container for graphics objects within that frame.
virtual void Draw(Option_t *options=0)
Draw this plot and all of the elements it contains.
RooRealVar represents a variable that can be changed from the outside.
void setMax(const char *name, Double_t 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 the workspace if not already there.
const RooArgSet * GetParametersOfInterest() const
get RooArgSet containing the parameter of interest (return NULL if not existing)
const RooArgSet * GetNuisanceParameters() const
get RooArgSet containing the nuisance parameters (return NULL if not existing)
RooAbsPdf * GetPdf() const
get model PDF (return NULL if pdf has not been specified or does not exist)
SimpleInterval is a concrete implementation of the ConfInterval interface.
virtual Double_t UpperLimit()
virtual Double_t LowerLimit()
The RooWorkspace is a persistable container for RooFit projects.
RooAbsData * data(const char *name) const
Retrieve dataset (binned or unbinned) with given name. A null pointer is returned if not found.
void Print(Option_t *opts=0) const
Print contents of the workspace.
Bool_t import(const RooAbsArg &arg, const RooCmdArg &arg1=RooCmdArg(), const RooCmdArg &arg2=RooCmdArg(), const RooCmdArg &arg3=RooCmdArg(), const RooCmdArg &arg4=RooCmdArg(), const RooCmdArg &arg5=RooCmdArg(), const RooCmdArg &arg6=RooCmdArg(), const RooCmdArg &arg7=RooCmdArg(), const RooCmdArg &arg8=RooCmdArg(), const RooCmdArg &arg9=RooCmdArg())
Import a RooAbsArg object, e.g.
TObject * obj(const char *name) const
Return any type of object (RooAbsArg, RooAbsData or generic object) with given name)
RooAbsPdf * pdf(const char *name) const
Retrieve p.d.f (RooAbsPdf) with given name. A null pointer is returned if not found.
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format.
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.
virtual const char * GetName() const
Returns name of object.
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 Hesse(Bool_t flag=kTRUE)
RooCmdArg Save(Bool_t flag=kTRUE)
RooCmdArg PrintLevel(Int_t code)
RooCmdArg Minimizer(const char *type, const char *alg=0)
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)
Short_t Max(Short_t a, Short_t b)
Short_t Min(Short_t a, Short_t b)