45 struct ProfileLikelihoodOptions {
47 double confLevel = 0.95;
49 bool plotAsTF1 =
false;
50 double poiMinPlot = 1;
51 double poiMaxPlot = 0;
52 bool doHypoTest =
false;
57 ProfileLikelihoodOptions optPL;
59 void StandardProfileLikelihoodDemo(
const char* infile =
"",
60 const char* workspaceName =
"combined",
61 const char* modelConfigName =
"ModelConfig",
62 const char* dataName =
"obsData"){
64 double confLevel = optPL.confLevel;
65 double nScanPoints = optPL.nScanPoints;
66 bool plotAsTF1 = optPL.plotAsTF1;
67 double poiXMin = optPL.poiMinPlot;
68 double poiXMax = optPL.poiMaxPlot;
69 bool doHypoTest = optPL.doHypoTest;
70 double nullParamValue = optPL.nullValue;
75 const char* filename =
"";
76 if (!strcmp(infile,
"")) {
77 filename =
"results/example_combined_GaussExample_model.root";
82 cout <<
"HistFactory file cannot be generated on Windows - exit" << endl;
86 cout <<
"will run standard hist2workspace example"<<endl;
87 gROOT->ProcessLine(
".! prepareHistFactory .");
88 gROOT->ProcessLine(
".! hist2workspace config/example.xml");
89 cout <<
"\n\n---------------------"<<endl;
90 cout <<
"Done creating example input"<<endl;
91 cout <<
"---------------------\n\n"<<endl;
103 cout <<
"StandardRooStatsDemoMacro: Input file " << filename <<
" is not found" << endl;
114 cout <<
"workspace not found" << endl;
127 cout <<
"data or ModelConfig was not found" <<endl;
137 pl.SetConfidenceLevel(confLevel);
142 cout <<
"\n>>>> RESULT : " << confLevel*100 <<
"% interval on " <<firstPOI->
GetName()<<
" is : ["<<
144 interval->
UpperLimit(*firstPOI) <<
"]\n "<<endl;
148 cout <<
"making a plot of the profile likelihood function ....(if it is taking a lot of time use less points or the TF1 drawing option)\n";
150 plot.SetNPoints(nScanPoints);
151 if (poiXMin < poiXMax) plot.SetRange(poiXMin, poiXMax);
153 if (plotAsTF1) opt += TString(
"tf1");
160 nullparams.addClone(*firstPOI);
161 nullparams.setRealValue(firstPOI->
GetName(), nullParamValue);
162 pl.SetNullParameters(nullparams);
163 std::cout <<
"Perform Test of Hypothesis : null Hypothesis is " << firstPOI->
GetName() << nullParamValue << std::endl;
164 auto result = pl.GetHypoTest();
165 std::cout <<
"\n>>>> Hypotheis Test Result \n";
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...
LikelihoodInterval is a concrete implementation of the RooStats::ConfInterval interface.
This class provides simple and straightforward utilities to plot a LikelihoodInterval object...
ProfileLikelihoodCalculator is a concrete implementation of CombinedCalculator (the interface class f...
Double_t LowerLimit(const RooRealVar ¶m)
return the lower bound of the interval on a given parameter
static TFile * Open(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=1, Int_t netopt=0)
Create / open a file.
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...
Double_t UpperLimit(const RooRealVar ¶m)
return the upper bound of the interval on a given parameter
R__EXTERN TSystem * gSystem
RooAbsArg * first() const
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) ...
Namespace for the RooStats classes.
const RooArgSet * GetParametersOfInterest() const
get RooArgSet containing the parameter of interest (return NULL if not existing)
void Print(Option_t *opts=0) const
Print contents of the workspace.
The RooWorkspace is a persistable container for RooFit projects.