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
35
36// from this package
37#include "Helper.h"
42
44#include "HFMsgService.h"
45
46using 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 <ul>
96 <li> what is the luminosity associated to the measurement in picobarns</li>
97 <li> which bins of the histogram should be used</li>
98 <li> what is the relative uncertainty on the luminosity </li>
99 <li> what is (are) the parameter(s) of interest that will be measured</li>
100 <li> which parameters should be fixed/floating (eg. nuisance parameters)</li>
101 </ul>
102 </ul>
103 </ul>
104*/
106
107 // This will be returned
108 RooWorkspace* ws = NULL;
109 TFile* outFile = NULL;
110 FILE* tableFile=NULL;
111
112 auto& msgSvc = RooMsgService::instance();
113 msgSvc.getStream(1).removeTopic(RooFit::ObjectHandling);
114
115 try {
116
117 cxcoutIHF << "Making Model and Measurements (Fast) for measurement: " << measurement.GetName() << std::endl;
118
119 double lumiError = measurement.GetLumi()*measurement.GetLumiRelErr();
120
121 cxcoutIHF << "using lumi = " << measurement.GetLumi() << " and lumiError = " << lumiError
122 << " including bins between " << measurement.GetBinLow() << " and " << measurement.GetBinHigh() << std::endl;
123
124 std::ostringstream parameterMessage;
125 parameterMessage << "fixing the following parameters:" << std::endl;
126
127 for(std::vector<std::string>::iterator itr=measurement.GetConstantParams().begin(); itr!=measurement.GetConstantParams().end(); ++itr){
128 parameterMessage << " " << *itr << '\n';
129 }
130 cxcoutIHF << parameterMessage.str();
131
132 std::string rowTitle = measurement.GetName();
133
134 std::vector<RooWorkspace*> channel_workspaces;
135 std::vector<std::string> channel_names;
136
137 // Create the outFile - first check if the outputfile exists
138 std::string prefix = measurement.GetOutputFilePrefix();
139 // parse prefix to find output directory -
140 // assume there is a file prefix after the last "/" that we remove
141 // to get the directory name.
142 // We do by finding last occurrence of "/" and using as directory name what is before
143 // if we do not have a "/" in the prefix there is no output directory to be checked or created
144 size_t pos = prefix.rfind("/");
145 if (pos != std::string::npos) {
146 std::string outputDir = prefix.substr(0,pos);
147 cxcoutDHF << "Checking if output directory : " << outputDir << " - exists" << std::endl;
148 if (gSystem->OpenDirectory( outputDir.c_str() ) == 0 ) {
149 cxcoutDHF << "Output directory : " << outputDir << " - does not exist, try to create" << std::endl;
150 int success = gSystem->MakeDirectory( outputDir.c_str() );
151 if( success != 0 ) {
152 std::string fullOutputDir = std::string(gSystem->pwd()) + std::string("/") + outputDir;
153 cxcoutEHF << "Error: Failed to make output directory: " << fullOutputDir << std::endl;
154 throw hf_exc();
155 }
156 }
157 }
158
159 // This holds the TGraphs that are created during the fit
160 std::string outputFileName = measurement.GetOutputFilePrefix() + "_" + measurement.GetName() + ".root";
161 cxcoutIHF << "Creating the output file: " << outputFileName << std::endl;
162 outFile = new TFile(outputFileName.c_str(), "recreate");
163
164 // Create the table file
165 // This holds the table of fitted values and errors
166 std::string tableFileName = measurement.GetOutputFilePrefix() + "_results.table";
167 cxcoutIHF << "Creating the table file: " << tableFileName << std::endl;
168 tableFile = fopen( tableFileName.c_str(), "a");
169
170 cxcoutIHF << "Creating the HistoToWorkspaceFactoryFast factory" << std::endl;
171 HistoToWorkspaceFactoryFast factory( measurement );
172
173 // Make the factory, and do some preprocessing
174 // HistoToWorkspaceFactoryFast factory(measurement, rowTitle, outFile);
175 cxcoutIHF << "Setting preprocess functions" << std::endl;
176 factory.SetFunctionsToPreprocess( measurement.GetPreprocessFunctions() );
177
178 // for results tables
179 fprintf(tableFile, " %s &", rowTitle.c_str() );
180
181 // First: Loop to make the individual channels
182 for( unsigned int chanItr = 0; chanItr < measurement.GetChannels().size(); ++chanItr ) {
183
184 HistFactory::Channel& channel = measurement.GetChannels().at( chanItr );
185 if( ! channel.CheckHistograms() ) {
186 cxcoutEHF << "MakeModelAndMeasurementsFast: Channel: " << channel.GetName()
187 << " has uninitialized histogram pointers" << std::endl;
188 throw hf_exc();
189 }
190
191 // Make the workspace for this individual channel
192 std::string ch_name = channel.GetName();
193 cxcoutPHF << "Starting to process channel: " << ch_name << std::endl;
194 channel_names.push_back(ch_name);
195 RooWorkspace* ws_single = factory.MakeSingleChannelModel( measurement, channel );
196 channel_workspaces.push_back(ws_single);
197
198 // Make the output
199 std::string ChannelFileName = measurement.GetOutputFilePrefix() + "_"
200 + ch_name + "_" + rowTitle + "_model.root";
201 ws_single->writeToFile( ChannelFileName.c_str() );
202
203 // Now, write the measurement to the file
204 // Make a new measurement for only this channel
205 RooStats::HistFactory::Measurement meas_chan( measurement );
206 meas_chan.GetChannels().clear();
207 meas_chan.GetChannels().push_back( channel );
208 cxcoutIHF << "Opening File to hold channel: " << ChannelFileName << std::endl;
209 TFile* chanFile = TFile::Open( ChannelFileName.c_str(), "UPDATE" );
210 cxcoutIHF << "About to write channel measurement to file" << std::endl;
211 meas_chan.writeToFile( chanFile );
212 cxcoutPHF << "Successfully wrote channel to file" << std::endl;
213 chanFile->Close();
214
215 // Get the Paramater of Interest as a RooRealVar
216 RooRealVar* poi = dynamic_cast<RooRealVar*>( ws_single->var( (measurement.GetPOI()).c_str() ) );
217
218 // do fit unless exportOnly requested
219 if(! measurement.GetExportOnly()){
220 if(!poi) {
221 cxcoutWHF << "Can't do fit for: " << measurement.GetName()
222 << ", no parameter of interest" << std::endl;
223 } else {
224 if(ws_single->data("obsData")) {
225 FitModelAndPlot(measurement.GetName(), measurement.GetOutputFilePrefix(), ws_single,
226 ch_name, "obsData", outFile, tableFile);
227 } else {
228 FitModelAndPlot(measurement.GetName(), measurement.GetOutputFilePrefix(), ws_single,
229 ch_name, "asimovData", outFile, tableFile);
230 }
231 }
232 }
233
234 fprintf(tableFile, " & " );
235 } // End loop over channels
236
237 /***
238 Second: Make the combined model:
239 If you want output histograms in root format, create and pass it to the combine routine.
240 "combine" : will do the individual cross-section measurements plus combination
241 ***/
242
243 // Use HistFactory to combine the individual channel workspaces
244 ws = factory.MakeCombinedModel(channel_names, channel_workspaces);
245
246 // Configure that workspace
247 HistoToWorkspaceFactoryFast::ConfigureWorkspaceForMeasurement( "simPdf", ws, measurement );
248
249 // Get the Parameter of interest as a RooRealVar
250 RooRealVar* poi = dynamic_cast<RooRealVar*>( ws->var( (measurement.GetPOI()).c_str() ) );
251
252 std::string CombinedFileName = measurement.GetOutputFilePrefix() + "_combined_"
253 + rowTitle + "_model.root";
254 cxcoutPHF << "Writing combined workspace to file: " << CombinedFileName << std::endl;
255 ws->writeToFile( CombinedFileName.c_str() );
256 cxcoutPHF << "Writing combined measurement to file: " << CombinedFileName << std::endl;
257 TFile* combFile = TFile::Open( CombinedFileName.c_str(), "UPDATE" );
258 if( combFile == NULL ) {
259 cxcoutEHF << "Error: Failed to open file " << CombinedFileName << std::endl;
260 throw hf_exc();
261 }
262 measurement.writeToFile( combFile );
263 combFile->Close();
264
265 // Fit the combined model
266 if(! measurement.GetExportOnly()){
267 if(!poi) {
268 cxcoutWHF << "Can't do fit for: " << measurement.GetName()
269 << ", no parameter of interest" << std::endl;
270 }
271 else {
272 if(ws->data("obsData")){
273 FitModelAndPlot(measurement.GetName(), measurement.GetOutputFilePrefix(), ws,"combined",
274 "obsData", outFile, tableFile);
275 }
276 else {
277 FitModelAndPlot(measurement.GetName(), measurement.GetOutputFilePrefix(), ws,"combined",
278 "asimovData", outFile, tableFile);
279 }
280 }
281 }
282
283 fprintf(tableFile, " \\\\ \n");
284
285 outFile->Close();
286 delete outFile;
287
288 fclose( tableFile );
289
290 }
291 catch(...) {
292 if( tableFile ) fclose(tableFile);
293 if(outFile) outFile->Close();
294 throw;
295 }
296
297 msgSvc.getStream(1).addTopic(RooFit::ObjectHandling);
298
299 return ws;
300
301}
302
303
304///////////////////////////////////////////////
305void RooStats::HistFactory::FitModelAndPlot(const std::string& MeasurementName,
306 const std::string& FileNamePrefix,
307 RooWorkspace * combined, std::string channel,
308 std::string data_name,
309 TFile* outFile, FILE* tableFile ) {
310
311 if( outFile == NULL ) {
312 cxcoutEHF << "Error: Output File in FitModelAndPlot is NULL" << std::endl;
313 throw hf_exc();
314 }
315
316 if( tableFile == NULL ) {
317 cxcoutEHF << "Error: tableFile in FitModelAndPlot is NULL" << std::endl;
318 throw hf_exc();
319 }
320
321 if( combined == NULL ) {
322 cxcoutEHF << "Error: Supplied workspace in FitModelAndPlot is NULL" << std::endl;
323 throw hf_exc();
324 }
325
326 ModelConfig* combined_config = (ModelConfig *) combined->obj("ModelConfig");
327 if(!combined_config){
328 cxcoutEHF << "Error: no ModelConfig found in Measurement: "
329 << MeasurementName << std::endl;
330 throw hf_exc();
331 }
332
333 RooAbsData* simData = combined->data(data_name.c_str());
334 if(!simData){
335 cxcoutEHF << "Error: Failed to get dataset: " << data_name
336 << " in measurement: " << MeasurementName << std::endl;
337 throw hf_exc();
338 }
339
340 const RooArgSet* POIs = combined_config->GetParametersOfInterest();
341 if(!POIs) {
342 cxcoutEHF << "Not Fitting Model for measurement: " << MeasurementName
343 << ", no poi found" << std::endl;
344 // Should I throw an exception here?
345 return;
346 }
347
348 RooAbsPdf* model = combined_config->GetPdf();
349 if( model==NULL ) {
350 cxcoutEHF << "Error: Failed to find pdf in ModelConfig: " << combined_config->GetName()
351 << std::endl;
352 throw hf_exc();
353 }
354
355 // Save a Snapshot
356 RooArgSet PoiPlusNuisance;
357 if( combined_config->GetNuisanceParameters() ) {
358 PoiPlusNuisance.add( *combined_config->GetNuisanceParameters() );
359 }
360 PoiPlusNuisance.add( *combined_config->GetParametersOfInterest() );
361 combined->saveSnapshot("InitialValues", PoiPlusNuisance);
362
363 ///////////////////////////////////////
364 // Do the fit
365 cxcoutPHF << "\n---------------"
366 << "\nDoing "<< channel << " Fit"
367 << "\n---------------\n\n" << std::endl;
368 model->fitTo(*simData, Minos(kTRUE), PrintLevel(RooMsgService::instance().isActive(static_cast<TObject*>(nullptr), RooFit::HistFactory, RooFit::DEBUG) ? 1 : -1));
369
370 // If there are no parameters of interest,
371 // we exit the function here
372 if( POIs->getSize()==0 ) {
373 cxcoutWHF << "WARNING: No POIs found in measurement: " << MeasurementName << std::endl;
374 return;
375 }
376
377 // Loop over all POIs and print their fitted values
378 RooRealVar* poi = NULL; // (RooRealVar*) POIs->first();
379 TIterator* params_itr = POIs->createIterator();
380 TObject* poi_obj=NULL;
381 while( (poi_obj=params_itr->Next()) ) {
382 //poi = (RooRealVar*) poi_obj;
383 poi = dynamic_cast<RooRealVar*>(poi_obj);
384 cxcoutIHF << "printing results for " << poi->GetName()
385 << " at " << poi->getVal()<< " high "
386 << poi->getErrorLo() << " low "
387 << poi->getErrorHi() << std::endl;
388 }
389
390 // But we only make detailed plots and tables
391 // for the 'first' POI
392 poi = dynamic_cast<RooRealVar*>(POIs->first());
393
394 // Print the MINOS errors to the TableFile
395 fprintf(tableFile, " %.4f / %.4f ", poi->getErrorLo(), poi->getErrorHi());
396
397 // Make the Profile Likelihood Plot
398 RooAbsReal* nll = model->createNLL(*simData);
399 RooAbsReal* profile = nll->createProfile(*poi);
400 if( profile==NULL ) {
401 cxcoutEHF << "Error: Failed to make ProfileLikelihood for: " << poi->GetName()
402 << " using model: " << model->GetName()
403 << " and data: " << simData->GetName()
404 << std::endl;
405 throw hf_exc();
406 }
407
408 RooPlot* frame = poi->frame();
409 if( frame == NULL ) {
410 cxcoutEHF << "Error: Failed to create RooPlot frame for: " << poi->GetName() << std::endl;
411 throw hf_exc();
412 }
413
414 // Draw the likelihood curve
416 TCanvas* ProfileLikelihoodCanvas = new TCanvas( channel.c_str(), "",800,600);
418 profile->plotOn(frame);
419 frame->SetMinimum(0);
420 frame->SetMaximum(2.);
421 frame->Draw();
422 std::string ProfilePlotName = FileNamePrefix+"_"+channel+"_"+MeasurementName+"_profileLR.eps";
423 ProfileLikelihoodCanvas->SaveAs( ProfilePlotName.c_str() );
424 delete ProfileLikelihoodCanvas;
425
426 // Now, we save our results to the 'output' file
427 // (I'm not sure if users actually look into this file,
428 // but adding additional information and useful plots
429 // may make it more attractive)
430
431 // Save to the output file
432 TDirectory* channel_dir = outFile->mkdir(channel.c_str());
433 if( channel_dir == NULL ) {
434 cxcoutEHF << "Error: Failed to make channel directory: " << channel << std::endl;
435 throw hf_exc();
436 }
437 TDirectory* summary_dir = channel_dir->mkdir("Summary");
438 if( summary_dir == NULL ) {
439 cxcoutEHF << "Error: Failed to make Summary directory for channel: "
440 << channel << std::endl;
441 throw hf_exc();
442 }
443 summary_dir->cd();
444
445 // Save a graph of the profile likelihood curve
446 RooCurve* curve=frame->getCurve();
447 Int_t curve_N=curve->GetN();
448 Double_t* curve_x=curve->GetX();
449
450 Double_t * x_arr = new Double_t[curve_N];
451 Double_t * y_arr_nll = new Double_t[curve_N];
452
453 for(int i=0; i<curve_N; i++){
454 double f=curve_x[i];
455 poi->setVal(f);
456 x_arr[i]=f;
457 y_arr_nll[i]=nll->getVal();
458 }
459
460 delete frame;
461
462 TGraph* g = new TGraph(curve_N, x_arr, y_arr_nll);
463 g->SetName( (FileNamePrefix +"_nll").c_str() );
464 g->Write();
465 delete g;
466 delete [] x_arr;
467 delete [] y_arr_nll;
468
469 // Finally, restore the initial values
470 combined->loadSnapshot("InitialValues");
471
472}
473
474
475void RooStats::HistFactory::FitModel(RooWorkspace * combined, std::string data_name ) {
476
477 cxcoutIHF << "In Fit Model" << std::endl;
478 ModelConfig * combined_config = (ModelConfig *) combined->obj("ModelConfig");
479 if(!combined_config){
480 cxcoutEHF << "no model config " << "ModelConfig" << " exiting" << std::endl;
481 return;
482 }
483
484 RooAbsData* simData = combined->data(data_name.c_str());
485 if(!simData){
486 cxcoutEHF << "no data " << data_name << " exiting" << std::endl;
487 return;
488 }
489
490 const RooArgSet * POIs=combined_config->GetParametersOfInterest();
491 if(!POIs){
492 cxcoutEHF << "no poi " << data_name << " exiting" << std::endl;
493 return;
494 }
495
496 RooAbsPdf* model=combined_config->GetPdf();
497 model->fitTo(*simData, Minos(kTRUE), PrintLevel(1));
498
499 }
500
501
502void RooStats::HistFactory::FormatFrameForLikelihood(RooPlot* frame, std::string /*XTitle*/,
503 std::string YTitle){
504
507 // gStyle->SetPadColor(0);
508 // gStyle->SetCanvasColor(255);
509 // gStyle->SetTitleFillColor(255);
510 // gStyle->SetFrameFillColor(0);
511 // gStyle->SetStatColor(255);
512
513 RooAbsRealLValue* var = frame->getPlotVar();
514 double xmin = var->getMin();
515 double xmax = var->getMax();
516
517 frame->SetTitle("");
518 // frame->GetXaxis()->SetTitle(XTitle.c_str());
519 frame->GetXaxis()->SetTitle(var->GetTitle());
520 frame->GetYaxis()->SetTitle(YTitle.c_str());
521 frame->SetMaximum(2.);
522 frame->SetMinimum(0.);
523 TLine * line = new TLine(xmin,.5,xmax,.5);
525 TLine * line90 = new TLine(xmin,2.71/2.,xmax,2.71/2.);
526 line90->SetLineColor(kGreen);
527 TLine * line95 = new TLine(xmin,3.84/2.,xmax,3.84/2.);
528 line95->SetLineColor(kGreen);
529 frame->addObject(line);
530 frame->addObject(line90);
531 frame->addObject(line95);
532}
533
534
#define cxcoutPHF
Definition: HFMsgService.h:18
#define cxcoutDHF
Definition: HFMsgService.h:16
#define cxcoutIHF
Definition: HFMsgService.h:17
#define cxcoutWHF
Definition: HFMsgService.h:19
#define cxcoutEHF
Definition: HFMsgService.h:20
#define f(i)
Definition: RSha256.hxx:104
#define g(i)
Definition: RSha256.hxx:105
const Bool_t kTRUE
Definition: RtypesCore.h:89
@ kRed
Definition: Rtypes.h:64
@ kGreen
Definition: Rtypes.h:64
@ kDashed
Definition: TAttLine.h:48
float xmin
Definition: THbookFile.cxx:93
float xmax
Definition: THbookFile.cxx:93
R__EXTERN TStyle * gStyle
Definition: TStyle.h:410
R__EXTERN TSystem * gSystem
Definition: TSystem.h:556
Int_t getSize() const
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:44
virtual RooAbsReal * createNLL(RooAbsData &data, const RooLinkedList &cmdList)
Construct representation of -log(L) of PDFwith given dataset.
Definition: RooAbsPdf.cxx:918
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:1254
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:60
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.
virtual RooAbsReal * createProfile(const RooArgSet &paramsOfInterest)
Create a RooProfileLL object that eliminates all nuisance parameters in the present function.
Definition: RooAbsReal.cxx:515
Double_t getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
Definition: RooAbsReal.h:90
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition: RooArgSet.h:28
virtual Bool_t add(const RooAbsCollection &col, Bool_t silent=kFALSE)
Add a collection of arguments to this collection by calling add() for each element in the source coll...
Definition: RooArgSet.h:88
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:443
void SetTitle(const char *name)
Set the title of the RooPlot to 'title'.
Definition: RooPlot.cxx:1258
virtual void SetMinimum(Double_t minimum=-1111)
Set minimum value of Y axis.
Definition: RooPlot.cxx:1112
TAxis * GetYaxis() const
Definition: RooPlot.cxx:1277
RooAbsRealLValue * getPlotVar() const
Definition: RooPlot.h:139
TAxis * GetXaxis() const
Definition: RooPlot.cxx:1276
virtual void SetMaximum(Double_t maximum=-1111)
Set maximum value of Y axis.
Definition: RooPlot.cxx:1102
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:928
virtual void Draw(Option_t *options=0)
Draw this plot and all of the elements it contains.
Definition: RooPlot.cxx:712
RooRealVar represents a variable that can be changed from the outside.
Definition: RooRealVar.h:35
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'.
Definition: RooRealVar.cxx:261
This class encapsulates all information for the statistical interpretation of one experiment.
Definition: Channel.h:29
std::string GetName()
get name of channel
Definition: Channel.h:42
This class provides helper functions for creating likelihood models from histograms.
RooWorkspace * MakeSingleChannelModel(Measurement &measurement, Channel &channel)
void SetFunctionsToPreprocess(std::vector< std::string > lines)
RooWorkspace * MakeCombinedModel(std::vector< std::string >, std::vector< RooWorkspace * >)
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:60
std::vector< RooStats::HistFactory::Channel > & GetChannels()
Definition: Measurement.h:105
std::string GetOutputFilePrefix()
retrieve prefix for output files
Definition: Measurement.h:42
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:49
std::vector< std::string > GetPreprocessFunctions()
Returns a list of defined preprocess function expressions.
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)
Definition: ModelConfig.h:237
const RooArgSet * GetNuisanceParameters() const
get RooArgSet containing the nuisance parameters (return NULL if not existing)
Definition: ModelConfig.h:240
RooAbsPdf * GetPdf() const
get model PDF (return NULL if pdf has not been specified or does not exist)
Definition: ModelConfig.h:234
The RooWorkspace is a persistable container for RooFit projects.
Definition: RooWorkspace.h:43
RooAbsData * data(const char *name) const
Retrieve dataset (binned or unbinned) with given name. A null pointer is returned if not found.
Bool_t writeToFile(const char *fileName, Bool_t recreate=kTRUE)
Save this current workspace into given file.
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:27
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/...".
Describe directory structure in memory.
Definition: TDirectory.h:40
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/...".
virtual Bool_t cd(const char *path=nullptr)
Change current directory to "this" directory.
Definition: TDirectory.cxx:498
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format.
Definition: TFile.h:53
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:3942
void Close(Option_t *option="") override
Close a file.
Definition: TFile.cxx:873
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:123
Double_t * GetX() const
Definition: TGraph.h:130
Iterator abstract base class.
Definition: TIterator.h:30
virtual TObject * Next()=0
A simple line.
Definition: TLine.h:23
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:37
virtual void SaveAs(const char *filename="", Option_t *option="") const
Save Pad contents in a file in one of various formats.
Definition: TPad.cxx:5592
void SetPadBorderMode(Int_t mode=1)
Definition: TStyle.h:338
void SetCanvasBorderMode(Int_t mode=1)
Definition: TStyle.h:327
const char * pwd()
Definition: TSystem.h:420
virtual void * OpenDirectory(const char *name)
Open a directory. Returns 0 if directory does not exist.
Definition: TSystem.cxx:832
virtual int MakeDirectory(const char *name)
Make a directory.
Definition: TSystem.cxx:823
TLine * line
RooCmdArg PrintLevel(Int_t code)
RooCmdArg Minos(Bool_t flag=kTRUE)
RooWorkspace * MakeModelAndMeasurementFast(RooStats::HistFactory::Measurement &measurement)
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...
@ HistFactory
Definition: RooGlobalFunc.h:69
@ ObjectHandling
Definition: RooGlobalFunc.h:68
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 *)
void ws()
Definition: ws.C:66