46 using namespace RooFit;
 
   47 using namespace RooStats;
 
   49 void StandardFeldmanCousinsDemo(
const char *infile = 
"", 
const char *workspaceName = 
"combined",
 
   50                                 const char *modelConfigName = 
"ModelConfig", 
const char *dataName = 
"obsData")
 
   56    const char *filename = 
"";
 
   57    if (!strcmp(infile, 
"")) {
 
   58       filename = 
"results/example_combined_GaussExample_model.root";
 
   59       bool fileExist = !gSystem->AccessPathName(filename); 
 
   63          cout << 
"HistFactory file cannot be generated on Windows - exit" << endl;
 
   67          cout << 
"will run standard hist2workspace example" << endl;
 
   68          gROOT->ProcessLine(
".! prepareHistFactory .");
 
   69          gROOT->ProcessLine(
".! hist2workspace config/example.xml");
 
   70          cout << 
"\n\n---------------------" << endl;
 
   71          cout << 
"Done creating example input" << endl;
 
   72          cout << 
"---------------------\n\n" << endl;
 
   79    TFile *file = TFile::Open(filename);
 
   83       cout << 
"StandardRooStatsDemoMacro: Input file " << filename << 
" is not found" << endl;
 
   92    RooWorkspace *w = (RooWorkspace *)file->Get(workspaceName);
 
   94       cout << 
"workspace not found" << endl;
 
   99    ModelConfig *mc = (ModelConfig *)w->obj(modelConfigName);
 
  102    RooAbsData *data = w->data(dataName);
 
  107       cout << 
"data or ModelConfig was not found" << endl;
 
  116    FeldmanCousins fc(*data, *mc);
 
  117    fc.SetConfidenceLevel(0.95); 
 
  119    fc.UseAdaptiveSampling(
true); 
 
  121    fc.CreateConfBelt(
true);      
 
  130    if (!mc->GetPdf()->canBeExtended()) {
 
  131       if (data->numEntries() == 1)
 
  132          fc.FluctuateNumDataEntries(
false);
 
  134          cout << 
"Not sure what to do about this model" << endl;
 
  143    PointSetInterval *interval = fc.GetInterval();
 
  144    ConfidenceBelt *belt = fc.GetConfidenceBelt();
 
  147    RooRealVar *firstPOI = (RooRealVar *)mc->GetParametersOfInterest()->first();
 
  148    cout << 
"\n95% interval on " << firstPOI->GetName() << 
" is : [" << interval->LowerLimit(*firstPOI) << 
", " 
  149         << interval->UpperLimit(*firstPOI) << 
"] " << endl;
 
  155    RooDataSet *parameterScan = (RooDataSet *)fc.GetPointsToScan();
 
  159    TH1F *histOfThresholds =
 
  160       new TH1F(
"histOfThresholds", 
"", parameterScan->numEntries(), firstPOI->getMin(), firstPOI->getMax());
 
  165    for (Int_t i = 0; i < parameterScan->numEntries(); ++i) {
 
  166       tmpPoint = (RooArgSet *)parameterScan->get(i)->clone(
"temp");
 
  167       double arMax = belt->GetAcceptanceRegionMax(*tmpPoint);
 
  168       double arMin = belt->GetAcceptanceRegionMax(*tmpPoint);
 
  169       double poiVal = tmpPoint->getRealValue(firstPOI->GetName());
 
  170       histOfThresholds->Fill(poiVal, arMax);
 
  172    histOfThresholds->SetMinimum(0);
 
  173    histOfThresholds->Draw();