48 struct BayesianNumericalOptions {
50 double confLevel = 0.95 ;
51 TString integrationType =
"";
55 bool scanPosterior =
false;
59 double nSigmaNuisance = -1;
63 BayesianNumericalOptions optBayes;
65 void StandardBayesianNumericalDemo(
const char* infile =
"",
66 const char* workspaceName =
"combined",
67 const char* modelConfigName =
"ModelConfig",
68 const char* dataName =
"obsData") {
71 double confLevel = optBayes.confLevel;
72 TString integrationType = optBayes.integrationType;
73 int nToys = optBayes.nToys;
74 bool scanPosterior = optBayes.scanPosterior;
75 int nScanPoints = optBayes.nScanPoints;
76 int intervalType = optBayes.intervalType;
77 int maxPOI = optBayes.maxPOI;
78 double nSigmaNuisance = optBayes.nSigmaNuisance;
86 const char* filename =
"";
87 if (!strcmp(infile,
"")) {
88 filename =
"results/example_combined_GaussExample_model.root";
93 cout <<
"HistFactory file cannot be generated on Windows - exit" << endl;
97 cout <<
"will run standard hist2workspace example"<<endl;
98 gROOT->ProcessLine(
".! prepareHistFactory .");
99 gROOT->ProcessLine(
".! hist2workspace config/example.xml");
100 cout <<
"\n\n---------------------"<<endl;
101 cout <<
"Done creating example input"<<endl;
102 cout <<
"---------------------\n\n"<<endl;
114 cout <<
"StandardRooStatsDemoMacro: Input file " << filename <<
" is not found" << endl;
126 cout <<
"workspace not found" << endl;
139 cout <<
"data or ModelConfig was not found" <<endl;
158 if (nSigmaNuisance > 0) {
166 for (
int i = 0; i < nuisPar.getSize(); ++i) {
171 std::cout <<
"setting interval for nuisance " << v->
GetName() <<
" : [ " << v->
getMin() <<
" , " << v->
getMax() <<
" ]" << std::endl;
177 bayesianCalc.SetConfidenceLevel(confLevel);
181 if (intervalType == 0) bayesianCalc.SetShortestInterval();
182 if (intervalType == 1) bayesianCalc.SetLeftSideTailFraction(0.5);
183 if (intervalType == 2) bayesianCalc.SetLeftSideTailFraction(0.);
185 if (!integrationType.IsNull() ) {
186 bayesianCalc.SetIntegrationType(integrationType);
187 bayesianCalc.SetNumIters(nToys);
191 if (integrationType.Contains(
"TOYMC") ) {
193 cout <<
"using TOYMC integration: make nuisance pdf from the model " << std::endl;
195 bayesianCalc.ForceNuisancePdf(*nuisPdf);
196 scanPosterior =
true;
201 bayesianCalc.SetScanOfPosterior(nScanPoints);
204 if (maxPOI != -999 && maxPOI > poi->
getMin())
211 cout <<
"\n>>>> RESULT : " << confLevel*100 <<
"% interval on " << poi->
GetName()<<
" is : ["<<
225 cout <<
"\nDrawing plot of posterior function....." << endl;
228 bayesianCalc.SetScanOfPosterior(nScanPoints);
230 RooPlot * plot = bayesianCalc.GetPosteriorPlot();
virtual Double_t getMin(const char *name=0) const
virtual const char * GetName() const
Returns name of object.
virtual Bool_t AccessPathName(const char *path, EAccessMode mode=kFileExists)
Returns FALSE if one can access a file using the specified access mode.
ModelConfig is a simple class that holds configuration information specifying how a model should be u...
virtual Double_t getMax(const char *name=0) const
RooAbsPdf * MakeNuisancePdf(RooAbsPdf &pdf, const RooArgSet &observables, const char *name)
RooCmdArg PrintLevel(Int_t code)
Double_t getVal(const RooArgSet *set=0) const
Short_t Min(Short_t a, Short_t b)
void setMax(const char *name, Double_t value)
Set maximum of name range to given value.
virtual void Print(Option_t *options=0) const
Print TNamed name and title.
static TFile * Open(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=1, Int_t netopt=0)
Create / open a file.
static void setEvalErrorLoggingMode(ErrorLoggingMode m)
Set evaluation error logging mode.
virtual void Print(Option_t *options=0) const
Print TNamed name and title.
virtual Double_t LowerLimit()
RooRealVar represents a fundamental (non-derived) real valued object.
RooAbsData * data(const char *name) const
Retrieve dataset (binned or unbinned) with given name. A null pointer is returned if not found...
R__EXTERN TSystem * gSystem
static const std::string & DefaultMinimizerType()
RooAbsArg * first() const
RooCmdArg Minimizer(const char *type, const char *alg=0)
void setMin(const char *name, Double_t value)
Set minimum of name range to given value.
static int DefaultPrintLevel()
RooAbsData is the common abstract base class for binned and unbinned datasets.
TObject * obj(const char *name) const
Return any type of object (RooAbsArg, RooAbsData or generic object) with given name) ...
A RooPlot is a plot frame and a container for graphics objects within that frame. ...
Namespace for the RooStats classes.
RooAbsPdf * GetPdf() const
get model PDF (return NULL if pdf has not been specified or does not exist)
const RooArgSet * GetParametersOfInterest() const
get RooArgSet containing the parameter of interest (return NULL if not existing)
RooCmdArg Hesse(Bool_t flag=kTRUE)
RooAbsPdf * pdf(const char *name) const
Retrieve p.d.f (RooAbsPdf) with given name. A null pointer is returned if not found.
virtual void SetPriorPdf(const RooAbsPdf &pdf)
Set the Prior Pdf, add to the the workspace if not already there.
RooCmdArg Save(Bool_t flag=kTRUE)
virtual Double_t UpperLimit()
SimpleInterval is a concrete implementation of the ConfInterval interface.
RooAbsPdf is the abstract interface for all probability density functions The class provides hybrid a...
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.
const RooArgSet * GetNuisanceParameters() const
get RooArgSet containing the nuisance parameters (return NULL if not existing)
Short_t Max(Short_t a, Short_t b)
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.
Double_t getError() const
void Print(Option_t *opts=0) const
Print contents of the workspace.
BayesianCalculator is a concrete implementation of IntervalCalculator, providing the computation of a...
The RooWorkspace is a persistable container for RooFit projects.
virtual void Draw(Option_t *options=0)
Draw this plot and all of the elements it contains.