Logo ROOT  
Reference Guide
MakeModelAndMeasurementsFast.cxx
Go to the documentation of this file.
1 // @(#)root/roostats:$Id: cranmer $
2 // Author: Kyle Cranmer, Akira Shibata
3 /*************************************************************************
4  * Copyright (C) 1995-2008, Rene Brun and Fons Rademakers. *
5  * All rights reserved. *
6  * *
7  * For the licensing terms see $ROOTSYS/LICENSE. *
8  * For the list of contributors see $ROOTSYS/README/CREDITS. *
9  *************************************************************************/
10 
11 
12 
13 
14 // from std
15 #include <string>
16 #include <vector>
17 #include <map>
18 #include <iostream>
19 #include <sstream>
20 
21 // from root
22 #include "TFile.h"
23 #include "TH1F.h"
24 #include "TDOMParser.h"
25 #include "TXMLAttr.h"
26 #include "TString.h"
27 #include "TCanvas.h"
28 #include "TStyle.h"
29 #include "TLine.h"
30 #include "TSystem.h"
31 
32 
33 // from roofit
34 #include "RooStats/ModelConfig.h"
35 
36 // from this package
37 #include "Helper.h"
42 
44 #include "HFMsgService.h"
45 
46 using namespace RooFit;
47 //using namespace RooStats;
48 //using namespace HistFactory;
49 
50 //using namespace std;
51 
52 
53 /** ********************************************************************************************
54  \ingroup HistFactory
55 
56  <p>
57  This is a package that creates a RooFit probability density function from ROOT histograms
58  of expected distributions and histograms that represent the +/- 1 sigma variations
59  from systematic effects. The resulting probability density function can then be used
60  with any of the statistical tools provided within RooStats, such as the profile
61  likelihood ratio, Feldman-Cousins, etc. In this version, the model is directly
62  fed to a likelihood ratio test, but it needs to be further factorized.</p>
63 
64  <p>
65  The user needs to provide histograms (in picobarns per bin) and configure the job
66  with XML. The configuration XML is defined in the file `$ROOTSYS/config/HistFactorySchema.dtd`, but essentially
67  it is organized as follows (see the examples in `${ROOTSYS}/tutorials/histfactory/`)</p>
68 
69  <ul>
70  <li> a top level 'Combination' that is composed of:</li>
71  <ul>
72  <li> several 'Channels' (eg. ee, emu, mumu), which are composed of:</li>
73  <ul>
74  <li> several 'Samples' (eg. signal, bkg1, bkg2, ...), each of which has:</li>
75  <ul>
76  <li> a name</li>
77  <li> if the sample is normalized by theory (eg N = L*sigma) or not (eg. data driven)</li>
78  <li> a nominal expectation histogram</li>
79  <li> a named 'Normalization Factor' (which can be fixed or allowed to float in a fit)</li>
80  <li> several 'Overall Systematics' in normalization with:</li>
81  <ul>
82  <li> a name</li>
83  <li> +/- 1 sigma variations (eg. 1.05 and 0.95 for a 5% uncertainty)</li>
84  </ul>
85  <li> several 'Histogram Systematics' in shape with:</li>
86  <ul>
87  <li> a name (which can be shared with the OverallSyst if correlated)</li>
88  <li> +/- 1 sigma variational histograms</li>
89  </ul>
90  </ul>
91  </ul>
92  <li> several 'Measurements' (corresponding to a full fit of the model) each of which specifies</li>
93  <ul>
94  <li> a name for this fit to be used in tables and files</li>
95  <li> what is the luminosity associated to the measurement in picobarns</li>
96  <li> which bins of the histogram should be used</li>
97  <li> what is the relative uncertainty on the luminosity </li>
98  <li> what is (are) the parameter(s) of interest that will be measured</li>
99  <li> which parameters should be fixed/floating (eg. nuisance parameters)</li>
100  </ul>
101  </ul>
102  </ul>
103 */
105 
106  // This will be returned
107  RooWorkspace* ws = NULL;
108  TFile* outFile = NULL;
109  FILE* tableFile=NULL;
110 
111  auto& msgSvc = RooMsgService::instance();
112  msgSvc.getStream(1).removeTopic(RooFit::ObjectHandling);
113 
114  try {
115 
116  cxcoutIHF << "Making Model and Measurements (Fast) for measurement: " << measurement.GetName() << std::endl;
117 
118  double lumiError = measurement.GetLumi()*measurement.GetLumiRelErr();
119 
120  cxcoutIHF << "using lumi = " << measurement.GetLumi() << " and lumiError = " << lumiError
121  << " including bins between " << measurement.GetBinLow() << " and " << measurement.GetBinHigh() << std::endl;
122 
123  std::ostringstream parameterMessage;
124  parameterMessage << "fixing the following parameters:" << std::endl;
125 
126  for(std::vector<std::string>::iterator itr=measurement.GetConstantParams().begin(); itr!=measurement.GetConstantParams().end(); ++itr){
127  parameterMessage << " " << *itr << '\n';
128  }
129  cxcoutIHF << parameterMessage.str();
130 
131  std::string rowTitle = measurement.GetName();
132 
133  std::vector<std::unique_ptr<RooWorkspace>> channel_workspaces;
134  std::vector<std::string> channel_names;
135 
136  // Create the outFile - first check if the outputfile exists
137  std::string prefix = measurement.GetOutputFilePrefix();
138  // parse prefix to find output directory -
139  // assume there is a file prefix after the last "/" that we remove
140  // to get the directory name.
141  // We do by finding last occurrence of "/" and using as directory name what is before
142  // if we do not have a "/" in the prefix there is no output directory to be checked or created
143  size_t pos = prefix.rfind("/");
144  if (pos != std::string::npos) {
145  std::string outputDir = prefix.substr(0,pos);
146  cxcoutDHF << "Checking if output directory : " << outputDir << " - exists" << std::endl;
147  if (gSystem->OpenDirectory( outputDir.c_str() ) == 0 ) {
148  cxcoutDHF << "Output directory : " << outputDir << " - does not exist, try to create" << std::endl;
149  int success = gSystem->MakeDirectory( outputDir.c_str() );
150  if( success != 0 ) {
151  std::string fullOutputDir = std::string(gSystem->pwd()) + std::string("/") + outputDir;
152  cxcoutEHF << "Error: Failed to make output directory: " << fullOutputDir << std::endl;
153  throw hf_exc();
154  }
155  }
156  }
157 
158  // This holds the TGraphs that are created during the fit
159  std::string outputFileName = measurement.GetOutputFilePrefix() + "_" + measurement.GetName() + ".root";
160  cxcoutIHF << "Creating the output file: " << outputFileName << std::endl;
161  outFile = new TFile(outputFileName.c_str(), "recreate");
162 
163  // Create the table file
164  // This holds the table of fitted values and errors
165  std::string tableFileName = measurement.GetOutputFilePrefix() + "_results.table";
166  cxcoutIHF << "Creating the table file: " << tableFileName << std::endl;
167  tableFile = fopen( tableFileName.c_str(), "a");
168 
169  cxcoutIHF << "Creating the HistoToWorkspaceFactoryFast factory" << std::endl;
170  HistoToWorkspaceFactoryFast factory( measurement );
171 
172  // Make the factory, and do some preprocessing
173  // HistoToWorkspaceFactoryFast factory(measurement, rowTitle, outFile);
174  cxcoutIHF << "Setting preprocess functions" << std::endl;
175  factory.SetFunctionsToPreprocess( measurement.GetPreprocessFunctions() );
176 
177  // for results tables
178  fprintf(tableFile, " %s &", rowTitle.c_str() );
179 
180  // First: Loop to make the individual channels
181  for( unsigned int chanItr = 0; chanItr < measurement.GetChannels().size(); ++chanItr ) {
182 
183  HistFactory::Channel& channel = measurement.GetChannels().at( chanItr );
184  if( ! channel.CheckHistograms() ) {
185  cxcoutEHF << "MakeModelAndMeasurementsFast: Channel: " << channel.GetName()
186  << " has uninitialized histogram pointers" << std::endl;
187  throw hf_exc();
188  }
189 
190  // Make the workspace for this individual channel
191  std::string ch_name = channel.GetName();
192  cxcoutPHF << "Starting to process channel: " << ch_name << std::endl;
193  channel_names.push_back(ch_name);
194  RooWorkspace* ws_single = factory.MakeSingleChannelModel( measurement, channel );
195  channel_workspaces.emplace_back(ws_single);
196 
197  // Make the output
198  std::string ChannelFileName = measurement.GetOutputFilePrefix() + "_"
199  + ch_name + "_" + rowTitle + "_model.root";
200  ws_single->writeToFile( ChannelFileName.c_str() );
201 
202  // Now, write the measurement to the file
203  // Make a new measurement for only this channel
204  RooStats::HistFactory::Measurement meas_chan( measurement );
205  meas_chan.GetChannels().clear();
206  meas_chan.GetChannels().push_back( channel );
207  cxcoutIHF << "Opening File to hold channel: " << ChannelFileName << std::endl;
208  TFile* chanFile = TFile::Open( ChannelFileName.c_str(), "UPDATE" );
209  cxcoutIHF << "About to write channel measurement to file" << std::endl;
210  meas_chan.writeToFile( chanFile );
211  cxcoutPHF << "Successfully wrote channel to file" << std::endl;
212  chanFile->Close();
213 
214  // Get the Paramater of Interest as a RooRealVar
215  RooRealVar* poi = dynamic_cast<RooRealVar*>( ws_single->var( (measurement.GetPOI()).c_str() ) );
216 
217  // do fit unless exportOnly requested
218  if(! measurement.GetExportOnly()){
219  if(!poi) {
220  cxcoutWHF << "Can't do fit for: " << measurement.GetName()
221  << ", no parameter of interest" << std::endl;
222  } else {
223  if(ws_single->data("obsData")) {
224  FitModelAndPlot(measurement.GetName(), measurement.GetOutputFilePrefix(), ws_single,
225  ch_name, "obsData", outFile, tableFile);
226  } else {
227  FitModelAndPlot(measurement.GetName(), measurement.GetOutputFilePrefix(), ws_single,
228  ch_name, "asimovData", outFile, tableFile);
229  }
230  }
231  }
232 
233  fprintf(tableFile, " & " );
234  } // End loop over channels
235 
236  /***
237  Second: Make the combined model:
238  If you want output histograms in root format, create and pass it to the combine routine.
239  "combine" : will do the individual cross-section measurements plus combination
240  ***/
241 
242  // Use HistFactory to combine the individual channel workspaces
243  ws = factory.MakeCombinedModel(channel_names, channel_workspaces);
244 
245  // Configure that workspace
246  HistoToWorkspaceFactoryFast::ConfigureWorkspaceForMeasurement( "simPdf", ws, measurement );
247 
248  // Get the Parameter of interest as a RooRealVar
249  RooRealVar* poi = dynamic_cast<RooRealVar*>( ws->var( (measurement.GetPOI()).c_str() ) );
250 
251  std::string CombinedFileName = measurement.GetOutputFilePrefix() + "_combined_"
252  + rowTitle + "_model.root";
253  cxcoutPHF << "Writing combined workspace to file: " << CombinedFileName << std::endl;
254  ws->writeToFile( CombinedFileName.c_str() );
255  cxcoutPHF << "Writing combined measurement to file: " << CombinedFileName << std::endl;
256  TFile* combFile = TFile::Open( CombinedFileName.c_str(), "UPDATE" );
257  if( combFile == NULL ) {
258  cxcoutEHF << "Error: Failed to open file " << CombinedFileName << std::endl;
259  throw hf_exc();
260  }
261  measurement.writeToFile( combFile );
262  combFile->Close();
263 
264  // Fit the combined model
265  if(! measurement.GetExportOnly()){
266  if(!poi) {
267  cxcoutWHF << "Can't do fit for: " << measurement.GetName()
268  << ", no parameter of interest" << std::endl;
269  }
270  else {
271  if(ws->data("obsData")){
272  FitModelAndPlot(measurement.GetName(), measurement.GetOutputFilePrefix(), ws,"combined",
273  "obsData", outFile, tableFile);
274  }
275  else {
276  FitModelAndPlot(measurement.GetName(), measurement.GetOutputFilePrefix(), ws,"combined",
277  "asimovData", outFile, tableFile);
278  }
279  }
280  }
281 
282  fprintf(tableFile, " \\\\ \n");
283 
284  outFile->Close();
285  delete outFile;
286 
287  fclose( tableFile );
288 
289  }
290  catch(...) {
291  if( tableFile ) fclose(tableFile);
292  if(outFile) outFile->Close();
293  throw;
294  }
295 
296  msgSvc.getStream(1).addTopic(RooFit::ObjectHandling);
297 
298  return ws;
299 
300 }
301 
302 
303 ///////////////////////////////////////////////
304 void RooStats::HistFactory::FitModelAndPlot(const std::string& MeasurementName,
305  const std::string& FileNamePrefix,
306  RooWorkspace * combined, std::string channel,
307  std::string data_name,
308  TFile* outFile, FILE* tableFile ) {
309 
310  if( outFile == NULL ) {
311  cxcoutEHF << "Error: Output File in FitModelAndPlot is NULL" << std::endl;
312  throw hf_exc();
313  }
314 
315  if( tableFile == NULL ) {
316  cxcoutEHF << "Error: tableFile in FitModelAndPlot is NULL" << std::endl;
317  throw hf_exc();
318  }
319 
320  if( combined == NULL ) {
321  cxcoutEHF << "Error: Supplied workspace in FitModelAndPlot is NULL" << std::endl;
322  throw hf_exc();
323  }
324 
325  ModelConfig* combined_config = (ModelConfig *) combined->obj("ModelConfig");
326  if(!combined_config){
327  cxcoutEHF << "Error: no ModelConfig found in Measurement: "
328  << MeasurementName << std::endl;
329  throw hf_exc();
330  }
331 
332  RooAbsData* simData = combined->data(data_name.c_str());
333  if(!simData){
334  cxcoutEHF << "Error: Failed to get dataset: " << data_name
335  << " in measurement: " << MeasurementName << std::endl;
336  throw hf_exc();
337  }
338 
339  const RooArgSet* POIs = combined_config->GetParametersOfInterest();
340  if(!POIs) {
341  cxcoutEHF << "Not Fitting Model for measurement: " << MeasurementName
342  << ", no poi found" << std::endl;
343  // Should I throw an exception here?
344  return;
345  }
346 
347  RooAbsPdf* model = combined_config->GetPdf();
348  if( model==NULL ) {
349  cxcoutEHF << "Error: Failed to find pdf in ModelConfig: " << combined_config->GetName()
350  << std::endl;
351  throw hf_exc();
352  }
353 
354  // Save a Snapshot
355  RooArgSet PoiPlusNuisance;
356  if( combined_config->GetNuisanceParameters() ) {
357  PoiPlusNuisance.add( *combined_config->GetNuisanceParameters() );
358  }
359  PoiPlusNuisance.add( *combined_config->GetParametersOfInterest() );
360  combined->saveSnapshot("InitialValues", PoiPlusNuisance);
361 
362  ///////////////////////////////////////
363  // Do the fit
364  cxcoutPHF << "\n---------------"
365  << "\nDoing "<< channel << " Fit"
366  << "\n---------------\n\n" << std::endl;
367  model->fitTo(*simData, Minos(kTRUE), PrintLevel(RooMsgService::instance().isActive(static_cast<TObject*>(nullptr), RooFit::HistFactory, RooFit::DEBUG) ? 1 : -1));
368 
369  // If there are no parameters of interest,
370  // we exit the function here
371  if( POIs->getSize()==0 ) {
372  cxcoutWHF << "WARNING: No POIs found in measurement: " << MeasurementName << std::endl;
373  return;
374  }
375 
376  // Loop over all POIs and print their fitted values
377  RooRealVar* poi = NULL; // (RooRealVar*) POIs->first();
378  TIter params_itr = POIs->createIterator();
379  TObject* poi_obj=NULL;
380  while( (poi_obj=params_itr.Next()) ) {
381  //poi = (RooRealVar*) poi_obj;
382  poi = dynamic_cast<RooRealVar*>(poi_obj);
383  cxcoutIHF << "printing results for " << poi->GetName()
384  << " at " << poi->getVal()<< " high "
385  << poi->getErrorLo() << " low "
386  << poi->getErrorHi() << std::endl;
387  }
388 
389  // But we only make detailed plots and tables
390  // for the 'first' POI
391  poi = dynamic_cast<RooRealVar*>(POIs->first());
392 
393  // Print the MINOS errors to the TableFile
394  fprintf(tableFile, " %.4f / %.4f ", poi->getErrorLo(), poi->getErrorHi());
395 
396  // Make the Profile Likelihood Plot
397  RooAbsReal* nll = model->createNLL(*simData);
398  RooAbsReal* profile = nll->createProfile(*poi);
399  if( profile==NULL ) {
400  cxcoutEHF << "Error: Failed to make ProfileLikelihood for: " << poi->GetName()
401  << " using model: " << model->GetName()
402  << " and data: " << simData->GetName()
403  << std::endl;
404  throw hf_exc();
405  }
406 
407  RooPlot* frame = poi->frame();
408  if( frame == NULL ) {
409  cxcoutEHF << "Error: Failed to create RooPlot frame for: " << poi->GetName() << std::endl;
410  throw hf_exc();
411  }
412 
413  // Draw the likelihood curve
415  TCanvas* ProfileLikelihoodCanvas = new TCanvas( channel.c_str(), "",800,600);
416  nll->plotOn(frame, ShiftToZero(), LineColor(kRed), LineStyle(kDashed));
417  profile->plotOn(frame);
418  frame->SetMinimum(0);
419  frame->SetMaximum(2.);
420  frame->Draw();
421  std::string ProfilePlotName = FileNamePrefix+"_"+channel+"_"+MeasurementName+"_profileLR.eps";
422  ProfileLikelihoodCanvas->SaveAs( ProfilePlotName.c_str() );
423  delete ProfileLikelihoodCanvas;
424 
425  // Now, we save our results to the 'output' file
426  // (I'm not sure if users actually look into this file,
427  // but adding additional information and useful plots
428  // may make it more attractive)
429 
430  // Save to the output file
431  TDirectory* channel_dir = outFile->mkdir(channel.c_str());
432  if( channel_dir == NULL ) {
433  cxcoutEHF << "Error: Failed to make channel directory: " << channel << std::endl;
434  throw hf_exc();
435  }
436  TDirectory* summary_dir = channel_dir->mkdir("Summary");
437  if( summary_dir == NULL ) {
438  cxcoutEHF << "Error: Failed to make Summary directory for channel: "
439  << channel << std::endl;
440  throw hf_exc();
441  }
442  summary_dir->cd();
443 
444  // Save a graph of the profile likelihood curve
445  RooCurve* curve=frame->getCurve();
446  Int_t curve_N=curve->GetN();
447  Double_t* curve_x=curve->GetX();
448 
449  Double_t * x_arr = new Double_t[curve_N];
450  Double_t * y_arr_nll = new Double_t[curve_N];
451 
452  for(int i=0; i<curve_N; i++){
453  double f=curve_x[i];
454  poi->setVal(f);
455  x_arr[i]=f;
456  y_arr_nll[i]=nll->getVal();
457  }
458 
459  delete frame;
460 
461  TGraph* g = new TGraph(curve_N, x_arr, y_arr_nll);
462  g->SetName( (FileNamePrefix +"_nll").c_str() );
463  g->Write();
464  delete g;
465  delete [] x_arr;
466  delete [] y_arr_nll;
467 
468  // Finally, restore the initial values
469  combined->loadSnapshot("InitialValues");
470 
471 }
472 
473 
474 void RooStats::HistFactory::FitModel(RooWorkspace * combined, std::string data_name ) {
475 
476  cxcoutIHF << "In Fit Model" << std::endl;
477  ModelConfig * combined_config = (ModelConfig *) combined->obj("ModelConfig");
478  if(!combined_config){
479  cxcoutEHF << "no model config " << "ModelConfig" << " exiting" << std::endl;
480  return;
481  }
482 
483  RooAbsData* simData = combined->data(data_name.c_str());
484  if(!simData){
485  cxcoutEHF << "no data " << data_name << " exiting" << std::endl;
486  return;
487  }
488 
489  const RooArgSet * POIs=combined_config->GetParametersOfInterest();
490  if(!POIs){
491  cxcoutEHF << "no poi " << data_name << " exiting" << std::endl;
492  return;
493  }
494 
495  RooAbsPdf* model=combined_config->GetPdf();
496  model->fitTo(*simData, Minos(kTRUE), PrintLevel(1));
497 
498  }
499 
500 
501 void RooStats::HistFactory::FormatFrameForLikelihood(RooPlot* frame, std::string /*XTitle*/,
502  std::string YTitle){
503 
506  // gStyle->SetPadColor(0);
507  // gStyle->SetCanvasColor(255);
508  // gStyle->SetTitleFillColor(255);
509  // gStyle->SetFrameFillColor(0);
510  // gStyle->SetStatColor(255);
511 
512  RooAbsRealLValue* var = frame->getPlotVar();
513  double xmin = var->getMin();
514  double xmax = var->getMax();
515 
516  frame->SetTitle("");
517  // frame->GetXaxis()->SetTitle(XTitle.c_str());
518  frame->GetXaxis()->SetTitle(var->GetTitle());
519  frame->GetYaxis()->SetTitle(YTitle.c_str());
520  frame->SetMaximum(2.);
521  frame->SetMinimum(0.);
522  TLine * line = new TLine(xmin,.5,xmax,.5);
524  TLine * line90 = new TLine(xmin,2.71/2.,xmax,2.71/2.);
525  line90->SetLineColor(kGreen);
526  TLine * line95 = new TLine(xmin,3.84/2.,xmax,3.84/2.);
527  line95->SetLineColor(kGreen);
528  frame->addObject(line);
529  frame->addObject(line90);
530  frame->addObject(line95);
531 }
532 
533 
RooWorkspace::data
RooAbsData * data(const char *name) const
Retrieve dataset (binned or unbinned) with given name. A null pointer is returned if not found.
Definition: RooWorkspace.cxx:1368
RooAbsRealLValue::frame
RooPlot * frame(const RooCmdArg &arg1, 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()) const
Create a new RooPlot on the heap with a drawing frame initialized for this object,...
Definition: RooAbsRealLValue.cxx:199
RooStats::HistFactory::FitModel
void FitModel(RooWorkspace *, std::string data_name="obsData")
Definition: MakeModelAndMeasurementsFast.cxx:474
RooPlot::Draw
virtual void Draw(Option_t *options=0)
Draw this plot and all of the elements it contains.
Definition: RooPlot.cxx:691
RooRealVar::setVal
virtual void setVal(Double_t value)
Set value of variable to 'value'.
Definition: RooRealVar.cxx:257
kTRUE
const Bool_t kTRUE
Definition: RtypesCore.h:100
TH1F.h
TLine.h
TDirectory::mkdir
virtual TDirectory * mkdir(const char *name, const char *title="", Bool_t returnExistingDirectory=kFALSE)
Create a sub-directory "a" or a hierarchy of sub-directories "a/b/c/...".
Definition: TDirectory.cxx:1050
f
#define f(i)
Definition: RSha256.hxx:104
RooAbsCollection::first
RooAbsArg * first() const
Definition: RooAbsCollection.h:236
TLine
A simple line.
Definition: TLine.h:22
RooStats::HistFactory::HistoToWorkspaceFactoryFast
This class provides helper functions for creating likelihood models from histograms.
Definition: HistoToWorkspaceFactoryFast.h:44
RooWorkspace::writeToFile
Bool_t writeToFile(const char *fileName, Bool_t recreate=kTRUE)
Save this current workspace into given file.
Definition: RooWorkspace.cxx:2154
RooStats::HistFactory::FormatFrameForLikelihood
void FormatFrameForLikelihood(RooPlot *frame, std::string xTitle=std::string("#sigma / #sigma_{SM}"), std::string yTitle=std::string("-log likelihood"))
Definition: MakeModelAndMeasurementsFast.cxx:501
RooStats::HistFactory::Measurement::GetLumiRelErr
double GetLumiRelErr()
retrieve relative uncertainty on luminosity
Definition: Measurement.h:90
RooAbsData
RooAbsData is the common abstract base class for binned and unbinned datasets.
Definition: RooAbsData.h:49
RooAbsRealLValue::getMax
virtual Double_t getMax(const char *name=0) const
Get maximum of currently defined range.
Definition: RooAbsRealLValue.h:89
kGreen
@ kGreen
Definition: Rtypes.h:66
RooFit::PrintLevel
RooCmdArg PrintLevel(Int_t code)
Definition: RooGlobalFunc.cxx:213
RooFit::DEBUG
@ DEBUG
Definition: RooGlobalFunc.h:58
TDOMParser.h
TNamed::GetTitle
virtual const char * GetTitle() const
Returns title of object.
Definition: TNamed.h:48
RooStats::HistFactory::HistoToWorkspaceFactoryFast::SetFunctionsToPreprocess
void SetFunctionsToPreprocess(std::vector< std::string > lines)
Definition: HistoToWorkspaceFactoryFast.h:64
xmax
float xmax
Definition: THbookFile.cxx:95
RooWorkspace::loadSnapshot
Bool_t loadSnapshot(const char *name)
Load the values and attributes of the parameters in the snapshot saved with the given name.
Definition: RooWorkspace.cxx:1208
HFMsgService.h
RooPlot::getCurve
RooCurve * getCurve(const char *name=0) const
Return a RooCurve pointer of the named object in this plot, or zero if the named object does not exis...
Definition: RooPlot.cxx:907
RooAbsReal::getVal
Double_t getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
Definition: RooAbsReal.h:91
RooStats::HistFactory::Measurement::GetBinHigh
int GetBinHigh()
Definition: Measurement.h:95
cxcoutIHF
#define cxcoutIHF
Definition: HFMsgService.h:17
TStyle.h
TFile::Open
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.
Definition: TFile.cxx:3998
RooFit::Minos
RooCmdArg Minos(Bool_t flag=kTRUE)
Definition: RooGlobalFunc.cxx:218
RooFit::ShiftToZero
RooCmdArg ShiftToZero()
Definition: RooGlobalFunc.cxx:89
RooStats::HistFactory::Measurement::GetBinLow
int GetBinLow()
Definition: Measurement.h:94
HistFactoryException.h
RooPlot::SetMaximum
virtual void SetMaximum(Double_t maximum=-1111)
Set maximum value of Y axis.
Definition: RooPlot.cxx:1081
RooStats::HistFactory::hf_exc
Definition: HistFactoryException.h:23
TSystem::MakeDirectory
virtual int MakeDirectory(const char *name)
Make a directory.
Definition: TSystem.cxx:827
RooAbsReal
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
Definition: RooAbsReal.h:61
TDirectory::cd
virtual Bool_t cd(const char *path=nullptr)
Change current directory to "this" directory.
Definition: TDirectory.cxx:504
TAttLine::SetLineColor
virtual void SetLineColor(Color_t lcolor)
Set the line color.
Definition: TAttLine.h:40
TCanvas.h
TStyle::SetPadBorderMode
void SetPadBorderMode(Int_t mode=1)
Definition: TStyle.h:340
RooStats::HistFactory::HistoToWorkspaceFactoryFast::MakeCombinedModel
RooWorkspace * MakeCombinedModel(std::vector< std::string >, std::vector< std::unique_ptr< RooWorkspace >> &)
Definition: HistoToWorkspaceFactoryFast.cxx:1930
RooFit::HistFactory
@ HistFactory
Definition: RooGlobalFunc.h:62
TString.h
TFile.h
RooStats::HistFactory::FitModelAndPlot
void FitModelAndPlot(const std::string &measurementName, const std::string &fileNamePrefix, RooWorkspace *, std::string, std::string, TFile *, FILE *)
Definition: MakeModelAndMeasurementsFast.cxx:304
RooAbsRealLValue::getMin
virtual Double_t getMin(const char *name=0) const
Get miniminum of currently defined range.
Definition: RooAbsRealLValue.h:86
MakeModelAndMeasurementsFast.h
RooStats::HistFactory::Channel
This class encapsulates all information for the statistical interpretation of one experiment.
Definition: Channel.h:30
RooStats::HistFactory::Measurement::GetChannels
std::vector< RooStats::HistFactory::Channel > & GetChannels()
Definition: Measurement.h:104
cxcoutWHF
#define cxcoutWHF
Definition: HFMsgService.h:19
RooPlot::addObject
void addObject(TObject *obj, Option_t *drawOptions="", Bool_t invisible=kFALSE)
Add a generic object to this plot.
Definition: RooPlot.cxx:422
cxcoutEHF
#define cxcoutEHF
Definition: HFMsgService.h:20
RooStats::HistFactory::Measurement::GetOutputFilePrefix
std::string GetOutputFilePrefix()
retrieve prefix for output files
Definition: Measurement.h:41
RooStats::HistFactory::Measurement
The RooStats::HistFactory::Measurement class can be used to construct a model by combining multiple R...
Definition: Measurement.h:30
EstimateSummary.h
TGraph::GetX
Double_t * GetX() const
Definition: TGraph.h:131
ws
void ws()
Definition: ws.C:66
gStyle
R__EXTERN TStyle * gStyle
Definition: TStyle.h:412
TSystem.h
Measurement.h
RooRealVar::getErrorHi
Double_t getErrorHi() const
Definition: RooRealVar.h:70
xmin
float xmin
Definition: THbookFile.cxx:95
RooStats::HistFactory::Measurement::GetPreprocessFunctions
std::vector< std::string > GetPreprocessFunctions() const
Returns a list of defined preprocess function expressions.
Definition: Measurement.cxx:124
ModelConfig.h
RooFit
The namespace RooFit contains mostly switches that change the behaviour of functions of PDFs (or othe...
Definition: RooCFunction1Binding.h:29
cxcoutPHF
#define cxcoutPHF
Definition: HFMsgService.h:18
size
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
RooStats::HistFactory::Measurement::GetExportOnly
bool GetExportOnly()
Definition: Measurement.h:99
Double_t
RooStats::HistFactory::HistoToWorkspaceFactoryFast::MakeSingleChannelModel
RooWorkspace * MakeSingleChannelModel(Measurement &measurement, Channel &channel)
Definition: HistoToWorkspaceFactoryFast.cxx:239
RooAbsPdf::createNLL
virtual RooAbsReal * createNLL(RooAbsData &data, const RooLinkedList &cmdList)
Construct representation of -log(L) of PDFwith given dataset.
Definition: RooAbsPdf.cxx:976
RooStats::HistFactory::Measurement::GetLumi
double GetLumi()
retrieve integrated luminosity
Definition: Measurement.h:88
RooAbsCollection::createIterator
TIterator * createIterator(Bool_t dir=kIterForward) const
TIterator-style iteration over contained elements.
Definition: RooAbsCollection.h:178
RooPlot::GetYaxis
TAxis * GetYaxis() const
Definition: RooPlot.cxx:1272
TXMLAttr.h
RooStats::HistFactory::Measurement::GetConstantParams
std::vector< std::string > & GetConstantParams()
get vector of all constant parameters
Definition: Measurement.h:59
RooWorkspace::saveSnapshot
Bool_t saveSnapshot(const char *name, const char *paramNames)
Save snapshot of values and attributes (including "Constant") of given parameters.
Definition: RooWorkspace.cxx:1162
RooWorkspace::obj
TObject * obj(const char *name) const
Return any type of object (RooAbsArg, RooAbsData or generic object) with given name)
Definition: RooWorkspace.cxx:2106
RooPlot
A RooPlot is a plot frame and a container for graphics objects within that frame.
Definition: RooPlot.h:44
RooAbsCollection::add
virtual Bool_t add(const RooAbsArg &var, Bool_t silent=kFALSE)
Add the specified argument to list.
Definition: RooAbsCollection.cxx:455
RooCurve
A RooCurve is a one-dimensional graphical representation of a real-valued function.
Definition: RooCurve.h:32
RooStats::HistFactory::Channel::GetName
std::string GetName() const
get name of channel
Definition: Channel.h:43
RooFit::ObjectHandling
@ ObjectHandling
Definition: RooGlobalFunc.h:61
kRed
@ kRed
Definition: Rtypes.h:66
TNamed::SetTitle
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
Definition: TNamed.cxx:164
line
TLine * line
Definition: entrylistblock_figure1.C:235
TFile
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format.
Definition: TFile.h:54
RooStats::ModelConfig::GetPdf
RooAbsPdf * GetPdf() const
get model PDF (return NULL if pdf has not been specified or does not exist)
Definition: ModelConfig.h:234
RooAbsReal::plotOn
virtual RooPlot * plotOn(RooPlot *frame, 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(), const RooCmdArg &arg10=RooCmdArg()) const
Plot (project) PDF on specified frame.
Definition: RooAbsReal.cxx:1692
RooStats::HistFactory::MakeModelAndMeasurementFast
RooWorkspace * MakeModelAndMeasurementFast(RooStats::HistFactory::Measurement &measurement)
Definition: MakeModelAndMeasurementsFast.cxx:104
RooAbsReal::createProfile
virtual RooAbsReal * createProfile(const RooArgSet &paramsOfInterest)
Create a RooProfileLL object that eliminates all nuisance parameters in the present function.
Definition: RooAbsReal.cxx:506
gSystem
R__EXTERN TSystem * gSystem
Definition: TSystem.h:559
RooStats::HistFactory::Measurement::writeToFile
void writeToFile(TFile *file)
A measurement, once fully configured, can be saved into a ROOT file.
Definition: Measurement.cxx:441
RooStats::ModelConfig::GetParametersOfInterest
const RooArgSet * GetParametersOfInterest() const
get RooArgSet containing the parameter of interest (return NULL if not existing)
Definition: ModelConfig.h:237
TIter::Next
TObject * Next()
Definition: TCollection.h:249
RooWorkspace
The RooWorkspace is a persistable container for RooFit projects.
Definition: RooWorkspace.h:43
RooFit::LineColor
RooCmdArg LineColor(Color_t color)
Definition: RooGlobalFunc.cxx:95
TStyle::SetCanvasBorderMode
void SetCanvasBorderMode(Int_t mode=1)
Definition: TStyle.h:329
TGraph
A TGraph is an object made of two arrays X and Y with npoints each.
Definition: TGraph.h:41
TSystem::OpenDirectory
virtual void * OpenDirectory(const char *name)
Open a directory. Returns 0 if directory does not exist.
Definition: TSystem.cxx:836
RooPlot::SetTitle
void SetTitle(const char *name)
Set the title of the RooPlot to 'title'.
Definition: RooPlot.cxx:1251
TCanvas
The Canvas class.
Definition: TCanvas.h:23
TObject
Mother of all ROOT objects.
Definition: TObject.h:37
TFile::Close
void Close(Option_t *option="") override
Close a file.
Definition: TFile.cxx:880
RooStats::HistFactory::Measurement::GetPOI
std::string GetPOI(unsigned int i=0)
get name of PoI at given index
Definition: Measurement.h:48
TGraph::GetN
Int_t GetN() const
Definition: TGraph.h:124
RooPlot::SetMinimum
virtual void SetMinimum(Double_t minimum=-1111)
Set minimum value of Y axis.
Definition: RooPlot.cxx:1091
HistoToWorkspaceFactoryFast.h
TDirectory
Describe directory structure in memory.
Definition: TDirectory.h:45
kDashed
@ kDashed
Definition: TAttLine.h:48
Helper.h
RooWorkspace::var
RooRealVar * var(const char *name) const
Retrieve real-valued variable (RooRealVar) with given name. A null pointer is returned if not found.
Definition: RooWorkspace.cxx:1295
TIter
Definition: TCollection.h:233
RooAbsPdf
Definition: RooAbsPdf.h:41
TNamed::GetName
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:47
RooRealVar::getErrorLo
Double_t getErrorLo() const
Definition: RooRealVar.h:69
RooStats::ModelConfig::GetNuisanceParameters
const RooArgSet * GetNuisanceParameters() const
get RooArgSet containing the nuisance parameters (return NULL if not existing)
Definition: ModelConfig.h:240
RooFit::LineStyle
RooCmdArg LineStyle(Style_t style)
Definition: RooGlobalFunc.cxx:96
RooRealVar
RooRealVar represents a variable that can be changed from the outside.
Definition: RooRealVar.h:39
TPad::SaveAs
void SaveAs(const char *filename="", Option_t *option="") const override
Save Pad contents in a file in one of various formats.
Definition: TPad.cxx:5632
RooAbsRealLValue
RooAbsRealLValue is the common abstract base class for objects that represent a real value that may a...
Definition: RooAbsRealLValue.h:31
RooStats::ModelConfig
ModelConfig is a simple class that holds configuration information specifying how a model should be u...
Definition: ModelConfig.h:30
RooMsgService::instance
static RooMsgService & instance()
Return reference to singleton instance.
Definition: RooMsgService.cxx:366
RooPlot::getPlotVar
RooAbsRealLValue * getPlotVar() const
Definition: RooPlot.h:139
RooStats::HistFactory::Channel::CheckHistograms
bool CheckHistograms() const
Definition: Channel.cxx:332
TSystem::pwd
const char * pwd()
Definition: TSystem.h:422
RooAbsCollection::getSize
Int_t getSize() const
Definition: RooAbsCollection.h:231
cxcoutDHF
#define cxcoutDHF
Definition: HFMsgService.h:16
RooArgSet
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition: RooArgSet.h:33
RooPlot::GetXaxis
TAxis * GetXaxis() const
Definition: RooPlot.cxx:1270
TDirectoryFile::mkdir
TDirectory * mkdir(const char *name, const char *title="", Bool_t returnExistingDirectory=kFALSE) override
Create a sub-directory "a" or a hierarchy of sub-directories "a/b/c/...".
Definition: TDirectoryFile.cxx:1210
int
RooAbsPdf::fitTo
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.
Definition: RooAbsPdf.cxx:1486
g
#define g(i)
Definition: RSha256.hxx:105