122 using namespace RooFit;
123 using namespace RooStats;
132 const char* workspaceName =
"combined",
133 const char* modelConfigName =
"ModelConfig",
134 const char* dataName =
"obsData") {
138 cout <<
"DO NOT RUN WITH CINT: we are using a custom test statistic ";
139 cout <<
"which requires that this tutorial must be compiled ";
140 cout <<
"with ACLIC" << endl;
145 int nPointsToScan = 20;
154 filename =
"results/example_combined_GaussExample_model.root";
159 cout <<
"HistFactory file cannot be generated on Windows - exit" << endl;
163 cout <<
"will run standard hist2workspace example"<<endl;
164 gROOT->ProcessLine(
".! prepareHistFactory .");
165 gROOT->ProcessLine(
".! hist2workspace config/example.xml");
166 cout <<
"\n\n---------------------"<<endl;
167 cout <<
"Done creating example input"<<endl;
168 cout <<
"---------------------\n\n"<<endl;
180 cout <<
"StandardRooStatsDemoMacro: Input file " << filename <<
" is not found" << endl;
192 cout <<
"workspace not found" << endl;
205 cout <<
"data or ModelConfig was not found" <<endl;
255 cout <<
"Not sure what to do about this model" <<endl;
270 cout <<
"will use global observables for unconditional ensemble"<<endl;
281 cout <<
"\n95% interval on " <<firstPOI->
GetName()<<
" is : ["<<
287 double observedUL = interval->
UpperLimit(*firstPOI);
288 firstPOI->
setVal(observedUL);
297 TH1F* histOfThresholds =
new TH1F(
"histOfThresholds",
"",
301 histOfThresholds->GetXaxis()->SetTitle(firstPOI->
GetName());
302 histOfThresholds->GetYaxis()->SetTitle(
"Threshold");
312 histOfThresholds->Fill(poiVal,arMax);
314 TCanvas*
c1 =
new TCanvas();
317 histOfThresholds->SetMinimum(0);
318 histOfThresholds->Draw();
334 w->
saveSnapshot(
"paramsToGenerateData",*poiAndNuisance);
336 cout <<
"\nWill use these parameter points to generate pseudo data for bkg only" << endl;
337 paramsToGenerateData->
Print(
"v");
345 double CLbinclusive=0;
348 TH1F* histOfUL =
new TH1F(
"histOfUL",
"",100,0,firstPOI->
getMax());
349 histOfUL->GetXaxis()->SetTitle(
"Upper Limit (background only)");
350 histOfUL->GetYaxis()->SetTitle(
"Entries");
351 for(
int imc=0; imc<nToyMC; ++imc){
364 cout <<
"Not sure what to do about this model" <<endl;
398 *globtmp = *tmp->
get(0) ;
414 firstPOI->
setVal(observedUL);
418 if(obsTSatObsUL < toyTSatObsUL)
420 if(obsTSatObsUL <= toyTSatObsUL)
421 CLbinclusive+= (1.)/nToyMC;
437 thisUL = firstPOI->
getVal();
475 histOfUL->Fill(thisUL);
483 c1->SaveAs(
"one-sided_upper_limit_output.pdf");
499 TH1F* cumulative = (TH1F*) histOfUL->
Clone(
"cumulative");
500 cumulative->SetContent(bins);
501 double band2sigDown, band1sigDown, bandMedian, band1sigUp,band2sigUp;
502 for(
int i=1; i<=cumulative->GetNbinsX(); ++i){
504 band2sigDown=cumulative->GetBinCenter(i);
506 band1sigDown=cumulative->GetBinCenter(i);
508 bandMedian=cumulative->GetBinCenter(i);
510 band1sigUp=cumulative->GetBinCenter(i);
512 band2sigUp=cumulative->GetBinCenter(i);
514 cout <<
"-2 sigma band " << band2sigDown << endl;
515 cout <<
"-1 sigma band " << band1sigDown <<
" [Power Constriant)]" << endl;
516 cout <<
"median of band " << bandMedian << endl;
517 cout <<
"+1 sigma band " << band1sigUp << endl;
518 cout <<
"+2 sigma band " << band2sigUp << endl;
521 cout <<
"\nobserved 95% upper-limit "<< interval->
UpperLimit(*firstPOI) <<endl;
522 cout <<
"CLb strict [P(toy>obs|0)] for observed 95% upper-limit "<< CLb <<endl;
523 cout <<
"CLb inclusive [P(toy>=obs|0)] for observed 95% upper-limit "<< CLbinclusive <<endl;
virtual RooAbsReal * createNLL(RooAbsData &data, const RooLinkedList &cmdList)
Construct representation of -log(L) of PDFwith given dataset.
virtual Bool_t AccessPathName(const char *path, EAccessMode mode=kFileExists)
Returns FALSE if one can access a file using the specified access mode.
Bool_t saveSnapshot(const char *name, const char *paramNames)
Save snapshot of values and attributes (including "Constant") of parameters 'params' If importValue...
Holds configuration options for proof and proof-lite.
RooAbsCollection * snapshot(Bool_t deepCopy=kTRUE) const
Take a snap shot of current collection contents: An owning collection is returned containing clones o...
ModelConfig is a simple class that holds configuration information specifying how a model should be u...
RooAbsPdf * GetPdf() const
get model PDF (return NULL if pdf has not been specified or does not exist)
RooAbsData * data(const char *name) const
Retrieve dataset (binned or unbinned) with given name. A null pointer is returned if not found...
virtual void SetGlobalObservables(const RooArgSet &o)
ConfidenceBelt * GetConfidenceBelt()
const RooArgSet * GetGlobalObservables() const
get RooArgSet for global observables (return NULL if not existing)
void SetOneSided(Bool_t flag=true)
RooArgSet * getObservables(const RooArgSet &set, Bool_t valueOnly=kTRUE) const
std::vector< double > values
const RooAbsCategoryLValue & indexCat() const
static const char * filename()
virtual Double_t getMin(const char *name=0) const
void OneSidedFrequentistUpperLimitWithBands(const char *infile="", const char *workspaceName="combined", const char *modelConfigName="ModelConfig", const char *dataName="obsData")
const TKDTreeBinning * bins
RooAbsPdf * getPdf(const char *catName) const
Return the p.d.f associated with the given index category name.
RooCmdArg Extended(Bool_t flag=kTRUE)
const RooArgSet * GetNuisanceParameters() const
get RooArgSet containing the nuisance parameters (return NULL if not existing)
Iterator abstract base class.
static TFile * Open(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=1, Int_t netopt=0)
Create / open a file.
RooAbsData * GetPointsToScan()
RooAbsArg * first() const
static struct mg_connection * fc(struct mg_context *ctx)
virtual TObject * Clone(const char *newname="") const
Make a clone of an object using the Streamer facility.
virtual void SetConfidenceLevel(Double_t cl)
set the confidence level for the interval (eg. 0.95 for a 95% Confidence Interval) ...
RooArgSet * getVariables(Bool_t stripDisconnected=kTRUE) const
Return RooArgSet with all variables (tree leaf nodes of expresssion tree)
std::map< std::string, std::string >::const_iterator iter
virtual void Draw(Option_t *option="")
Forward draw command to data store.
ConfidenceBelt is a concrete implementation of the ConfInterval interface.
RooCatType is an auxilary class for RooAbsCategory and defines a a single category state...
Double_t getVal(const RooArgSet *set=0) const
Double_t SignificanceToPValue(Double_t Z)
RooRealVar represents a fundamental (non-derived) real valued object.
virtual void setVal(Double_t value)
Set value of variable to 'value'.
virtual TestStatistic * GetTestStatistic(unsigned int i) const
Double_t LowerLimit(RooRealVar ¶m)
return lower limit on a given parameter
R__EXTERN TSystem * gSystem
void SetNBins(Int_t bins)
virtual void Print(Option_t *options=0) const
This method must be overridden when a class wants to print itself.
virtual Int_t numEntries() const
void FluctuateNumDataEntries(bool flag=true)
void SetProofConfig(ProofConfig *pc=NULL)
virtual const char * GetName() const
Returns name of object.
RooAbsData is the common abstract base class for binned and unbinned datasets.
Bool_t loadSnapshot(const char *name)
Load the values and attributes of the parameters in the snapshot saved with the given name...
ProfileLikelihoodTestStat is an implementation of the TestStatistic interface that calculates the pro...
ToyMCSampler is an implementation of the TestStatSampler interface.
RooDataSet is a container class to hold unbinned data.
Double_t UpperLimit(RooRealVar ¶m)
return upper limit on a given parameter
The FeldmanCousins class (like the Feldman-Cousins technique) is essentially a specific configuration...
const RooArgSet * GetObservables() const
get RooArgSet for observables (return NULL if not existing)
TestStatSampler * GetTestStatSampler() const
Returns instance of TestStatSampler.
virtual TObject * clone(const char *newname) const
PointSetInterval is a concrete implementation of the ConfInterval interface.
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
Bool_t canBeExtended() const
virtual PointSetInterval * GetInterval() const
Main interface to get a ConfInterval (will be a PointSetInterval)
TObject * obj(const char *name) const
Return any type of object (RooAbsArg, RooAbsData or generic object) with given name) ...
virtual Double_t getMax(const char *name=0) const
RooAbsPdf is the abstract interface for all probability density functions The class provides hybrid a...
virtual Double_t EvaluateTestStatistic(RooAbsData &data, RooArgSet ¶msOfInterest)=0
void Print(Option_t *opts=0) const
Print contents of the workspace.
RooDataSet * generate(const RooArgSet &whatVars, Int_t nEvents, const RooCmdArg &arg1, const RooCmdArg &arg2=RooCmdArg::none(), const RooCmdArg &arg3=RooCmdArg::none(), const RooCmdArg &arg4=RooCmdArg::none(), const RooCmdArg &arg5=RooCmdArg::none())
Generate a new dataset containing the specified variables with events sampled from our distribution...
virtual RooAbsReal * createProfile(const RooArgSet ¶msOfInterest)
Create a RooProfileLL object that eliminates all nuisance parameters in the present function...
virtual TObject * Next()=0
void CreateConfBelt(bool flag=true)
const RooArgSet * GetParametersOfInterest() const
get RooArgSet containing the parameter of interest (return NULL if not existing)
Double_t GetAcceptanceRegionMax(RooArgSet &, Double_t cl=-1., Double_t leftside=-1.)
RooSimultaneous facilitates simultaneous fitting of multiple PDFs to subsets of a given dataset...
virtual const RooArgSet * get(Int_t index) const
Return RooArgSet with coordinates of event 'index'.
virtual const Text_t * GetName() const
Returns name of object.
TIterator * typeIterator() const
Return iterator over all defined states.
virtual Bool_t add(const RooAbsArg &var, Bool_t silent=kFALSE)
Add element to non-owning set.
The RooWorkspace is a persistable container for RooFit projects.
Double_t getRealValue(const char *name, Double_t defVal=0, Bool_t verbose=kFALSE) const
Get value of a RooAbsReal stored in set with given name.