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