Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
MakeModelAndMeasurements.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\ingroup HistFactory
15
16BEGIN_HTML
17<p>
18This is a package that creates a RooFit probability density function from ROOT histograms
19of expected distributions and histograms that represent the +/- 1 sigma variations
20from systematic effects. The resulting probability density function can then be used
21with any of the statistical tools provided within RooStats, such as the profile
22likelihood ratio, Feldman-Cousins, etc. In this version, the model is directly
23fed to a likelihodo ratio test, but it needs to be further factorized.</p>
24
25<p>
26The user needs to provide histograms (in picobarns per bin) and configure the job
27with XML. The configuration XML is defined in the file config/Config.dtd, but essentially
28it is organized as follows (see config/Combination.xml and config/ee.xml for examples)</p>
29
30<ul>
31<li> - a top level 'Combination' that is composed of:</li>
32<ul>
33 <li>- several 'Channels' (eg. ee, emu, mumu), which are composed of:</li>
34 <ul>
35 <li>- several 'Samples' (eg. signal, bkg1, bkg2, ...), each of which has:</li>
36 <ul>
37 <li> - a name</li>
38 <li> - if the sample is normalized by theory (eg N = L*sigma) or not (eg. data driven)</li>
39 <li> - a nominal expectation histogram</li>
40 <li> - a named 'Normalization Factor' (which can be fixed or allowed to float in a fit)</li>
41 <li> - several 'Overall Systematics' in normalization with:</li>
42 <ul>
43 <li> - a name</li>
44 <li> - +/- 1 sigma variations (eg. 1.05 and 0.95 for a 5% uncertainty)</li>
45 </ul>
46 <li>- several 'Histogram Systematics' in shape with:</li>
47 <ul>
48 <li>- a name (which can be shared with the OverallSyst if correlated)</li>
49 <li>- +/- 1 sigma variational histograms</li>
50 </ul>
51 </ul>
52 </ul>
53 <li>- several 'Measurements' (corresponding to a full fit of the model) each of which specifies</li>
54 <ul>
55 <li>- a name for this fit to be used in tables and files</li>
56 <ul>
57 <li> - what is the luminosity associated to the measurement in picobarns</li>
58 <li> - which bins of the histogram should be used</li>
59 <li> - what is the relative uncertainty on the luminosity </li>
60 <li> - what is (are) the parameter(s) of interest that will be measured</li>
61 <li> - which parameters should be fixed/floating (eg. nuisance parameters)</li>
62 </ul>
63 </ul>
64</ul>
65END_HTML
66*/
67//
68
69
70// from std
71#include <string>
72#include <vector>
73#include <map>
74#include <iostream>
75#include <sstream>
76
77// from root
78#include "TFile.h"
79#include "TH1F.h"
80#include "TString.h"
81
82// from roofit
84
85// from this package
86#include "Helper.h"
91
92
93using namespace RooFit;
94using namespace RooStats;
95using namespace HistFactory;
96
97using namespace std;
98
99void topDriver(string input);
100// void fastDriver(string input); // in MakeModelAndMeasurementsFast
101
102/*
103//_____________________________batch only_____________________
104#ifndef __CINT__
105
106int main(int argc, char** argv) {
107
108 if(! (argc>1)) {
109 cerr << "need input file" << endl;
110 exit(1);
111 }
112
113 if(argc==2){
114 string input(argv[1]);
115 try {
116 fastDriver(input);
117 }
118 catch (std::string str) {
119 cerr << "caught exception: " << str << endl ;
120 }
121 catch( const exception& e ) {
122 cerr << "Caught Exception: " << e.what() << endl;
123 }
124 }
125
126 if(argc==3){
127 string flag(argv[1]);
128 string input(argv[2]);
129 if(flag=="-standard_form")
130 try {
131 fastDriver(input);
132 }
133 catch (std::string str) {
134 cerr << "caught exception: " << str << endl ;
135 }
136 catch( const exception& e ) {
137 cerr << "Caught Exception: " << e.what() << endl;
138 }
139 else if(flag=="-number_counting_form")
140 try {
141 topDriver(input);
142 }
143 catch (std::string str) {
144 cerr << "caught exception: " << str << endl ;
145 }
146 catch( const exception& e ) {
147 cerr << "Caught Exception: " << e.what() << endl;
148 }
149
150 else
151 cerr <<"unrecognized flag. Options are -standard_form or -number_counting_form"<<endl;
152
153 }
154 return 0;
155}
156
157#endif
158*/
159
160void topDriver( string input ) {
161
162
163 // Make the list of measurements and channels
164 std::vector< HistFactory::Measurement > measurement_list;
165 //std::vector< HistFactory::Channel > channel_list;
166
167
169
170 // Fill them using the XML parser
171 //xmlParser.FillMeasurementsAndChannelsFromXML( input, measurement_list, channel_list );
172
173 measurement_list = xmlParser.GetMeasurementsFromXML( input );
174
175 // At this point, we have all the information we need
176 // from the xml files.
177
178
179 // We will make the measurements 1-by-1
180 // This part will be migrated to the
181 // MakeModelAndMeasurements function,
182 // but is here for now.
183
184
185 for(unsigned int i = 0; i < measurement_list.size(); ++i) {
186
187 HistFactory::Measurement measurement = measurement_list.at(i);
188
189 // Add the channels to this measurement
190 //for( unsigned int chanItr = 0; chanItr < channel_list.size(); ++chanItr ) {
191 // measurement.channels.push_back( channel_list.at( chanItr ) );
192 //}
193
194 // This part (OF COURSE) needs to be added:
195
196
197 std::string rowTitle = measurement.GetName();
198 std::string outputFileName = measurement.GetOutputFilePrefix() + "_" + measurement.GetName() + ".root";
199
200 double lumiError = measurement.GetLumi()*measurement.GetLumiRelErr();
201
202 TFile* outFile = new TFile(outputFileName.c_str(), "recreate");
203 HistoToWorkspaceFactory factory(measurement.GetOutputFilePrefix(), rowTitle, measurement.GetConstantParams(),
204 measurement.GetLumi(), lumiError,
205 measurement.GetBinLow(), measurement.GetBinHigh(), outFile);
206
207 // Create the workspaces for the channels
208 vector<RooWorkspace*> channel_workspaces;
209 vector<string> channel_names;
210
211
212 // Loop over channels and make the individual
213 // channel fits:
214
215
216 // read the xml for each channel and combine
217
218 for( unsigned int chanItr = 0; chanItr < measurement.GetChannels().size(); ++chanItr ) {
219
220 HistFactory::Channel& channel = measurement.GetChannels().at( chanItr );
221
222
223 string ch_name=channel.GetName();
224 channel_names.push_back(ch_name);
225
226 std::vector< EstimateSummary > dummy;
227 RooWorkspace* ws = factory.MakeSingleChannelModel( dummy, measurement.GetConstantParams() );
228 if( ws==NULL ) {
229 std::cout << "Failed to create SingleChannelModel for channel: " << channel.GetName()
230 << " and measurement: " << measurement.GetName() << std::endl;
231 throw hf_exc();
232 }
233 //RooWorkspace* ws = factory.MakeSingleChannelModel( channel );
234 channel_workspaces.push_back(ws);
235
236 // set poi in ModelConfig
237 ModelConfig* proto_config = (ModelConfig *) ws->obj("ModelConfig");
238
239 std::cout << "Setting Parameter of Interest as :" << measurement.GetPOI() << endl;
240 RooRealVar* poi = (RooRealVar*) ws->var( (measurement.GetPOI()).c_str() );
241 RooArgSet * params= new RooArgSet;
242 if(poi){
243 params->add(*poi);
244 }
245 proto_config->SetParametersOfInterest(*params);
246
247
248 // Gamma/Uniform Constraints:
249 // turn some Gaussian constraints into Gamma/Uniform/LogNorm constraints, rename model newSimPdf
250 if( measurement.GetGammaSyst().size()>0 || measurement.GetUniformSyst().size()>0 || measurement.GetLogNormSyst().size()>0) {
251 factory.EditSyst( ws, ("model_"+ch_name).c_str(), measurement.GetGammaSyst(), measurement.GetUniformSyst(), measurement.GetLogNormSyst());
252 proto_config->SetPdf( *ws->pdf("newSimPdf") );
253 }
254
255 // fill out ModelConfig and export
256 RooAbsData* expData = ws->data("expData");
257 if(poi){
258 proto_config->GuessObsAndNuisance(*expData);
259 }
260 std::string ChannelFileName = measurement.GetOutputFilePrefix() + "_" + ch_name + "_" + rowTitle + "_model.root";
261 ws->writeToFile( ChannelFileName.c_str() );
262
263 // Now, write the measurement to the file
264 // Make a new measurement for only this channel
265 RooStats::HistFactory::Measurement meas_chan( measurement );
266 meas_chan.GetChannels().clear();
267 meas_chan.GetChannels().push_back( channel );
268 TFile* chanFile = TFile::Open( ChannelFileName.c_str(), "UPDATE" );
269 meas_chan.writeToFile( chanFile );
270 chanFile->Close();
271
272 // do fit unless exportOnly requested
273 if(! measurement.GetExportOnly() ){
274 if(!poi){
275 cout <<"can't do fit for this channel, no parameter of interest"<<endl;
276 } else{
277 factory.FitModel(ws, ch_name, "newSimPdf", "expData", false);
278 }
279 }
280 fprintf(factory.pFile, " & " );
281 }
282
283
284 // Now, combine the channels
285 RooWorkspace* ws=factory.MakeCombinedModel(channel_names, channel_workspaces);
286 if( ws == NULL ) {
287 std::cout << "Error: Failed to create workspace" << std::endl;
288 throw hf_exc();
289 }
290 // Gamma/Uniform Constraints:
291 // turn some Gaussian constraints into Gamma/Uniform/logNormal constraints, rename model newSimPdf
292 if( measurement.GetGammaSyst().size()>0 || measurement.GetUniformSyst().size()>0 || measurement.GetLogNormSyst().size()>0)
293 factory.EditSyst(ws, "simPdf", measurement.GetGammaSyst(), measurement.GetUniformSyst(), measurement.GetLogNormSyst());
294 //
295 // set parameter of interest according to the configuration
296 //
297 ModelConfig * combined_config = (ModelConfig *) ws->obj("ModelConfig");
298 cout << "Setting Parameter of Interest as :" << measurement.GetPOI() << endl;
299 RooRealVar* poi = (RooRealVar*) ws->var( (measurement.GetPOI()).c_str() );
300 //RooRealVar* poi = (RooRealVar*) ws->var((POI+"_comb").c_str());
301 RooArgSet * params= new RooArgSet;
302 cout << poi << endl;
303 if(poi){
304 params->add(*poi);
305 }
306 combined_config->SetParametersOfInterest(*params);
307 ws->Print();
308
309 // Set new PDF if there are gamma/uniform constraint terms
310 if( measurement.GetGammaSyst().size()>0 || measurement.GetUniformSyst().size()>0 || measurement.GetLogNormSyst().size()>0)
311 combined_config->SetPdf(*ws->pdf("newSimPdf"));
312
313 RooAbsData* simData = ws->data("simData");
314 combined_config->GuessObsAndNuisance(*simData);
315 // ws->writeToFile(("results/model_combined_edited.root").c_str());
316 std::string CombinedFileName = measurement.GetOutputFilePrefix()+"_combined_"+rowTitle+"_model.root";
317 ws->writeToFile( CombinedFileName.c_str() );
318 TFile* combFile = TFile::Open( CombinedFileName.c_str(), "UPDATE" );
319 measurement.writeToFile( combFile );
320 combFile->Close();
321
322
323
324 // TO DO:
325 // Totally factorize the statistical test in "fit Model" to a different area
326 if(! measurement.GetExportOnly() ){
327 if(!poi){
328 cout <<"can't do fit for this channel, no parameter of interest"<<endl;
329 } else{
330 factory.FitModel(ws, "combined", "simPdf", "simData", false);
331 }
332 }
333
334
335 } // End Loop over measurement_list
336
337 // Done
338
339}
340
341/*
342
343void topDriver(string input ){
344
345 // TO DO:
346 // would like to fully factorize the XML parsing.
347 // No clear need to have some here and some in ConfigParser
348
349 / *** read in the input xml *** /
350 TDOMParser xmlparser;
351 Int_t parseError = xmlparser.ParseFile( input.c_str() );
352 if( parseError ) {
353 std::cerr << "Loading of xml document \"" << input
354 << "\" failed" << std::endl;
355 }
356
357 cout << "reading input : " << input << endl;
358 TXMLDocument* xmldoc = xmlparser.GetXMLDocument();
359 TXMLNode* rootNode = xmldoc->GetRootNode();
360
361 if( rootNode->GetNodeName() == TString( "Combination" ) ){
362 string outputFileName, outputFileNamePrefix;
363 vector<string> xml_input;
364
365 TListIter attribIt = rootNode->GetAttributes();
366 TXMLAttr* curAttr = 0;
367 while( ( curAttr = dynamic_cast< TXMLAttr* >( attribIt() ) ) != 0 ) {
368 if( curAttr->GetName() == TString( "OutputFilePrefix" ) ) {
369 outputFileNamePrefix=string(curAttr->GetValue());
370 cout << "output file is : " << outputFileName << endl;
371 }
372 }
373
374 TXMLNode* node = rootNode->GetChildren();
375 while( node != 0 ) {
376 if( node->GetNodeName() == TString( "Input" ) ) {
377 xml_input.push_back(node->GetText());
378 }
379 node = node->GetNextNode();
380 }
381 node = rootNode->GetChildren();
382 while( node != 0 ) {
383 if( node->GetNodeName() == TString( "Measurement" ) ) {
384
385 Double_t nominalLumi=0, lumiRelError=0, lumiError=0;
386 Int_t lowBin=0, highBin=0;
387 string rowTitle, POI, mode;
388 vector<string> systToFix;
389 map<string,double> gammaSyst;
390 map<string,double> uniformSyst;
391 map<string,double> logNormSyst;
392 bool exportOnly = false;
393
394 // TListIter attribIt = node->GetAttributes();
395 // TXMLAttr* curAttr = 0;
396 attribIt = node->GetAttributes();
397 curAttr = 0;
398 while( ( curAttr = dynamic_cast< TXMLAttr* >( attribIt() ) ) != 0 ) {
399
400 if( curAttr->GetName() == TString( "Lumi" ) ) {
401 nominalLumi=atof(curAttr->GetValue());
402 }
403 if( curAttr->GetName() == TString( "LumiRelErr" ) ) {
404 lumiRelError=atof(curAttr->GetValue());
405 }
406 if( curAttr->GetName() == TString( "BinLow" ) ) {
407 lowBin=atoi(curAttr->GetValue());
408 }
409 if( curAttr->GetName() == TString( "BinHigh" ) ) {
410 highBin=atoi(curAttr->GetValue());
411 }
412 if( curAttr->GetName() == TString( "Name" ) ) {
413 rowTitle=curAttr->GetValue();
414 outputFileName=outputFileNamePrefix+"_"+rowTitle+".root";
415 }
416 if( curAttr->GetName() == TString( "Mode" ) ) {
417 cout <<"\n INFO: Mode attribute is deprecated, will ignore\n"<<endl;
418 mode=curAttr->GetValue();
419 }
420 if( curAttr->GetName() == TString( "ExportOnly" ) ) {
421 if(curAttr->GetValue() == TString( "True" ) )
422 exportOnly = true;
423 else
424 exportOnly = false;
425 }
426 }
427
428 if(highBin==0){
429 cout <<"\nERROR: In -number_counting_form must specify BinLow and BinHigh\n"<<endl;
430 return;
431 }
432
433 lumiError=nominalLumi*lumiRelError;
434
435 TXMLNode* mnode = node->GetChildren();
436 while( mnode != 0 ) {
437 if( mnode->GetNodeName() == TString( "POI" ) ) {
438 POI=mnode->GetText();
439 }
440 if( mnode->GetNodeName() == TString( "ParamSetting" ) ) {
441 // TListIter attribIt = mnode->GetAttributes();
442 //TXMLAttr* curAttr = 0;
443 attribIt = mnode->GetAttributes();
444 curAttr = 0;
445 while( ( curAttr = dynamic_cast< TXMLAttr* >( attribIt() ) ) != 0 ) {
446 if( curAttr->GetName() == TString( "Const" ) ) {
447 if(curAttr->GetValue()==TString("True")){
448 AddSubStrings(systToFix, mnode->GetText());
449 }
450 }
451 }
452 }
453 if( mnode->GetNodeName() == TString( "ConstraintTerm" ) ) {
454 vector<string> syst; string type = ""; double rel = 0;
455 AddSubStrings(syst,mnode->GetText());
456 // TListIter attribIt = mnode->GetAttributes();
457 // TXMLAttr* curAttr = 0;
458 attribIt = mnode->GetAttributes();
459 curAttr = 0;
460 while( ( curAttr = dynamic_cast< TXMLAttr* >( attribIt() ) ) != 0 ) {
461 if( curAttr->GetName() == TString( "Type" ) ) {
462 type = curAttr->GetValue();
463 }
464 if( curAttr->GetName() == TString( "RelativeUncertainty" ) ) {
465 rel = atof(curAttr->GetValue());
466 }
467 }
468 if (type=="Gamma" && rel!=0) {
469 for (vector<string>::const_iterator it=syst.begin(); it!=syst.end(); it++) gammaSyst[(*it).c_str()] = rel;
470 }
471 if (type=="Uniform" && rel!=0) {
472 for (vector<string>::const_iterator it=syst.begin(); it!=syst.end(); it++) uniformSyst[(*it).c_str()] = rel;
473 }
474 if (type=="LogNormal" && rel!=0) {
475 for (vector<string>::const_iterator it=syst.begin(); it!=syst.end(); it++) logNormSyst[(*it).c_str()] = rel;
476 }
477 }
478 mnode = mnode->GetNextNode();
479 }
480
481 / * Do measurement * /
482 cout << "using lumi = " << nominalLumi << " and lumiError = " << lumiError
483 << " including bins between " << lowBin << " and " << highBin << endl;
484 cout << "fixing the following parameters:" << endl;
485 for(vector<string>::iterator itr=systToFix.begin(); itr!=systToFix.end(); ++itr){
486 cout << " " << *itr << endl;
487 }
488
489 / ***
490 Construction of Model. Only requirement is that they return vector<vector<EstimateSummary> >
491 This is where we use the factory.
492 *** /
493
494 vector<vector<EstimateSummary> > summaries;
495 if(xml_input.empty()){
496 cerr << "no input channels found" << endl;
497 exit(1);
498 }
499
500
501 vector<RooWorkspace*> chs;
502 vector<string> ch_names;
503 TFile* outFile = new TFile(outputFileName.c_str(), "recreate");
504 HistoToWorkspaceFactory factory(outputFileNamePrefix, rowTitle, systToFix, nominalLumi, lumiError, lowBin, highBin , outFile);
505
506
507 // for results tables
508 fprintf(factory.pFile, " %s &", rowTitle.c_str() );
509
510 // read the xml for each channel and combine
511 for(vector<string>::iterator itr=xml_input.begin(); itr!=xml_input.end(); ++itr){
512 vector<EstimateSummary> oneChannel;
513 // read xml
514 ReadXmlConfig(*itr, oneChannel, nominalLumi);
515 // not really needed anymore
516 summaries.push_back(oneChannel);
517 // use factory to create the workspace
518 string ch_name=oneChannel[0].channel;
519 ch_names.push_back(ch_name);
520 RooWorkspace * ws = factory.MakeSingleChannelModel(oneChannel, systToFix);
521 chs.push_back(ws);
522 // set poi in ModelConfig
523 ModelConfig * proto_config = (ModelConfig *) ws->obj("ModelConfig");
524 cout << "Setting Parameter of Interest as :" << POI << endl;
525 RooRealVar* poi = (RooRealVar*) ws->var(POI.c_str());
526 RooArgSet * params= new RooArgSet;
527 if(poi){
528 params->add(*poi);
529 }
530 proto_config->SetParametersOfInterest(*params);
531
532
533 // Gamma/Uniform Constraints:
534 // turn some Gaussian constraints into Gamma/Uniform/LogNorm constraints, rename model newSimPdf
535 if(gammaSyst.size()>0 || uniformSyst.size()>0 || logNormSyst.size()>0) {
536 factory.EditSyst(ws,("model_"+oneChannel[0].channel).c_str(),gammaSyst,uniformSyst,logNormSyst);
537 proto_config->SetPdf(*ws->pdf("newSimPdf"));
538 }
539
540 // fill out ModelConfig and export
541 RooAbsData* expData = ws->data("expData");
542 if(poi){
543 proto_config->GuessObsAndNuisance(*expData);
544 }
545 ws->writeToFile((outputFileNamePrefix+"_"+ch_name+"_"+rowTitle+"_model.root").c_str());
546
547 // do fit unless exportOnly requested
548 if(!exportOnly){
549 if(!poi){
550 cout <<"can't do fit for this channel, no parameter of interest"<<endl;
551 } else{
552 factory.FitModel(ws, ch_name, "newSimPdf", "expData", false);
553 }
554 }
555 fprintf(factory.pFile, " & " );
556 }
557
558 / ***
559 Make the combined model:
560 If you want output histograms in root format, create and pass it to the combine routine.
561 "combine" : will do the individual cross-section measurements plus combination
562
563 *** /
564
565
566
567 if(true || mode.find("comb")!=string::npos){ //KC: deprecating Mode="Comb"
568 RooWorkspace* ws=factory.MakeCombinedModel(ch_names,chs);
569 // Gamma/Uniform Constraints:
570 // turn some Gaussian constraints into Gamma/Uniform/logNormal constraints, rename model newSimPdf
571 if(gammaSyst.size()>0 || uniformSyst.size()>0 || logNormSyst.size()>0)
572 factory.EditSyst(ws,"simPdf",gammaSyst,uniformSyst,logNormSyst);
573 //
574 // set parameter of interest according to the configuration
575 //
576 ModelConfig * combined_config = (ModelConfig *) ws->obj("ModelConfig");
577 cout << "Setting Parameter of Interest as :" << POI << endl;
578 RooRealVar* poi = (RooRealVar*) ws->var((POI).c_str());
579 //RooRealVar* poi = (RooRealVar*) ws->var((POI+"_comb").c_str());
580 RooArgSet * params= new RooArgSet;
581 cout << poi << endl;
582 if(poi){
583 params->add(*poi);
584 }
585 combined_config->SetParametersOfInterest(*params);
586 ws->Print();
587
588 // Set new PDF if there are gamma/uniform constraint terms
589 if(gammaSyst.size()>0 || uniformSyst.size()>0 || logNormSyst.size()>0)
590 combined_config->SetPdf(*ws->pdf("newSimPdf"));
591
592 RooAbsData* simData = ws->data("simData");
593 combined_config->GuessObsAndNuisance(*simData);
594 // ws->writeToFile(("results/model_combined_edited.root").c_str());
595 ws->writeToFile((outputFileNamePrefix+"_combined_"+rowTitle+"_model.root").c_str());
596
597 // TO DO:
598 // Totally factorize the statistical test in "fit Model" to a different area
599 if(!exportOnly){
600 if(!poi){
601 cout <<"can't do fit for this channel, no parameter of interest"<<endl;
602 } else{
603 factory.FitModel(ws, "combined", "simPdf", "simData", false);
604 }
605 }
606
607 }
608
609
610 fprintf(factory.pFile, " \\\\ \n");
611
612 outFile->Close();
613 delete outFile;
614
615 }
616 node = node->GetNextNode(); // next measurement
617 }
618 }
619}
620
621
622
623*/
void topDriver(string input)
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
virtual Bool_t add(const RooAbsArg &var, Bool_t silent=kFALSE)
Add the specified argument to list.
RooAbsData is the common abstract base class for binned and unbinned datasets.
Definition RooAbsData.h:82
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition RooArgSet.h:35
RooRealVar represents a variable that can be changed from the outside.
Definition RooRealVar.h:39
This class encapsulates all information for the statistical interpretation of one experiment.
Definition Channel.h:30
std::string GetName() const
get name of channel
Definition Channel.h:43
std::vector< RooStats::HistFactory::Measurement > GetMeasurementsFromXML(std::string input)
The "main" method.
void EditSyst(RooWorkspace *proto, const char *pdfNameChar, std::map< std::string, double > gammaSyst, std::map< std::string, double > uniformSyst, std::map< std::string, double > logNormSyst)
cout << "in edit, gammamap.size = " << gammaSyst.size() << ", unimap.size = " << uniformSyst....
void FitModel(RooWorkspace *, std::string, std::string, std::string, bool=false)
RooWorkspace * MakeCombinedModel(std::vector< std::string >, std::vector< RooWorkspace * >)
RooWorkspace * MakeSingleChannelModel(std::vector< RooStats::HistFactory::EstimateSummary > summary, std::vector< std::string > systToFix, bool doRatio=false)
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.
std::map< std::string, double > & GetGammaSyst()
std::map< std::string, double > & GetLogNormSyst()
double GetLumiRelErr()
retrieve relative uncertainty on luminosity
Definition Measurement.h:90
std::map< std::string, double > & GetUniformSyst()
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
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
void GuessObsAndNuisance(const RooAbsData &data, bool printModelConfig=true)
Makes sensible guesses of observables, parameters of interest and nuisance parameters if one or multi...
virtual void SetParametersOfInterest(const RooArgSet &set)
Specify parameters of interest.
virtual void SetPdf(const RooAbsPdf &pdf)
Set the Pdf, add to the the workspace if not already there.
Definition ModelConfig.h:81
The RooWorkspace is a persistable container for RooFit projects.
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
virtual const char * GetName() const
Returns name of object.
Definition TNamed.h:47
The namespace RooFit contains mostly switches that change the behaviour of functions of PDFs (or othe...
Definition Common.h:18
Namespace for the RooStats classes.
Definition Asimov.h:19
void ws()
Definition ws.C:66