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