Logo ROOT   6.10/09
Reference Guide
Measurement.h
Go to the documentation of this file.
1 // @(#)root/roostats:$Id$
2 // Author: George Lewis, Kyle Cranmer
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 #ifndef HISTFACTORY_MEASUREMENT_H
12 #define HISTFACTORY_MEASUREMENT_H
13 
14 #include <string>
15 #include <map>
16 #include <fstream>
17 #include <iostream>
18 
19 #include "TObject.h"
20 #include "TFile.h"
21 
22 
23 #include "PreprocessFunction.h"
26 
27 namespace RooStats{
28 namespace HistFactory {
29 
30 class Measurement : public TNamed {
31 
32 
33 public:
34 
35  Measurement();
36  // Measurement( const Measurement& other ); // Copy
37  Measurement(const char* Name, const char* Title="");
38 
39  // set output prefix
40  void SetOutputFilePrefix( const std::string& prefix ) { fOutputFilePrefix = prefix; }
41  // retrieve prefix for output files
42  std::string GetOutputFilePrefix() { return fOutputFilePrefix; }
43 
44  // insert PoI at beginning of vector of PoIs
45  void SetPOI( const std::string& POI ) { fPOI.insert( fPOI.begin(), POI ); }
46  // append parameter to vector of PoIs
47  void AddPOI( const std::string& POI ) { fPOI.push_back(POI); }
48  // get name of PoI at given index
49  std::string GetPOI(unsigned int i=0) { return fPOI.at(i); }
50  // get vector of PoI names
51  std::vector<std::string>& GetPOIList() { return fPOI; }
52 
53 
54  // Add a parameter to be set as constant
55  // (Similar to ParamSetting method below)
56  void AddConstantParam( const std::string& param );
57  // empty vector of constant parameters
59  // get vector of all constant parameters
60  std::vector< std::string >& GetConstantParams() { return fConstantParams; }
61 
62  // Set a parameter to a specific value
63  // (And optionally fix it)
64  void SetParamValue( const std::string& param, double value);
65  // get map: parameter name <--> parameter value
66  std::map<std::string, double>& GetParamValues() { return fParamValues; }
67  // clear map of parameter values
68  void ClearParamValues() { fParamValues.clear(); }
69 
70  void AddPreprocessFunction( std::string name, std::string expression, std::string dependencies );
71  // add a preprocess function object
72  void AddFunctionObject( const RooStats::HistFactory::PreprocessFunction function) { fFunctionObjects.push_back( function ); }
73  void SetFunctionObjects( std::vector< RooStats::HistFactory::PreprocessFunction > objects ) { fFunctionObjects = objects; }
74  // get vector of defined function objects
75  std::vector< RooStats::HistFactory::PreprocessFunction >& GetFunctionObjects() { return fFunctionObjects; }
76  std::vector< std::string > GetPreprocessFunctions();
77 
78  // get vector of defined Asimov Datasets
79  std::vector< RooStats::HistFactory::Asimov >& GetAsimovDatasets() { return fAsimovDatasets; }
80  // add an Asimov Dataset
81  void AddAsimovDataset( RooStats::HistFactory::Asimov dataset ) { fAsimovDatasets.push_back(dataset); }
82 
83  // set integrated luminosity used to normalise histograms (if NormalizeByTheory is true for this sample)
84  void SetLumi(double Lumi ) { fLumi = Lumi; }
85  // set relative uncertainty on luminosity
86  void SetLumiRelErr( double RelErr ) { fLumiRelErr = RelErr; }
87  // retrieve integrated luminosity
88  double GetLumi() { return fLumi; }
89  // retrieve relative uncertainty on luminosity
90  double GetLumiRelErr() { return fLumiRelErr; }
91 
92  void SetBinLow( int BinLow ) { fBinLow = BinLow; }
93  void SetBinHigh ( int BinHigh ) { fBinHigh = BinHigh; }
94  int GetBinLow() { return fBinLow; }
95  int GetBinHigh() { return fBinHigh; }
96 
97  // do not produce any plots or tables, just save the model
98  void SetExportOnly( bool ExportOnly ) { fExportOnly = ExportOnly; }
99  bool GetExportOnly() { return fExportOnly; }
100 
101 
102  void PrintTree( std::ostream& = std::cout ); // Print to a stream
103  void PrintXML( std::string Directory="", std::string NewOutputPrefix="" );
104 
105  std::vector< RooStats::HistFactory::Channel >& GetChannels() { return fChannels; }
107  // add a completely configured channel
108  void AddChannel( RooStats::HistFactory::Channel chan ) { fChannels.push_back( chan ); }
109 
110  bool HasChannel( std::string );
111  void writeToFile( TFile* file );
112 
113  void CollectHistograms();
114 
115 
116  void AddGammaSyst(std::string syst, double uncert);
117  void AddLogNormSyst(std::string syst, double uncert);
118  void AddUniformSyst(std::string syst);
119  void AddNoSyst(std::string syst);
120 
121  std::map< std::string, double >& GetGammaSyst() { return fGammaSyst; }
122  std::map< std::string, double >& GetUniformSyst() { return fUniformSyst; }
123  std::map< std::string, double >& GetLogNormSyst() { return fLogNormSyst; }
124  std::map< std::string, double >& GetNoSyst() { return fNoSyst; }
125 
126 
127 private:
128 
129  // Configurables of this measurement
130  std::string fOutputFilePrefix;
131  std::vector<std::string> fPOI;
132  double fLumi;
133  double fLumiRelErr;
134  int fBinLow;
135  int fBinHigh;
137  std::string fInterpolationScheme;
138 
139  // Channels that make up this measurement
140  std::vector< RooStats::HistFactory::Channel > fChannels;
141 
142  // List of Parameters to be set constant
143  std::vector< std::string > fConstantParams;
144 
145  // Map of parameter names to inital values to be set
146  std::map< std::string, double > fParamValues;
147 
148  // List of Preprocess Function objects
149  std::vector< RooStats::HistFactory::PreprocessFunction > fFunctionObjects;
150 
151  // List of Asimov datasets to generate
152  std::vector< RooStats::HistFactory::Asimov > fAsimovDatasets;
153 
154  // List of Alternate constraint terms
155  std::map< std::string, double > fGammaSyst;
156  std::map< std::string, double > fUniformSyst;
157  std::map< std::string, double > fLogNormSyst;
158  std::map< std::string, double > fNoSyst;
159 
160  std::string GetDirPath( TDirectory* dir );
161 
163 
164 };
165 
166 } // namespace HistFactory
167 } // namespace RooStats
168 
169 #endif
void AddUniformSyst(std::string syst)
std::vector< RooStats::HistFactory::Asimov > & GetAsimovDatasets()
Definition: Measurement.h:79
void SetPOI(const std::string &POI)
Definition: Measurement.h:45
std::map< std::string, double > & GetNoSyst()
Definition: Measurement.h:124
void SetFunctionObjects(std::vector< RooStats::HistFactory::PreprocessFunction > objects)
Definition: Measurement.h:73
std::map< std::string, double > fGammaSyst
Definition: Measurement.h:155
void PrintXML(std::string Directory="", std::string NewOutputPrefix="")
const char * Title
Definition: TXMLSetup.cxx:68
std::string GetPOI(unsigned int i=0)
Definition: Measurement.h:49
void SetOutputFilePrefix(const std::string &prefix)
Definition: Measurement.h:40
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format...
Definition: TFile.h:46
void AddPreprocessFunction(std::string name, std::string expression, std::string dependencies)
std::vector< std::string > & GetPOIList()
Definition: Measurement.h:51
void SetExportOnly(bool ExportOnly)
Definition: Measurement.h:98
void AddPOI(const std::string &POI)
Definition: Measurement.h:47
void AddChannel(RooStats::HistFactory::Channel chan)
Definition: Measurement.h:108
const char * Name
Definition: TXMLSetup.cxx:67
std::vector< std::string > GetPreprocessFunctions()
std::vector< RooStats::HistFactory::Channel > fChannels
Definition: Measurement.h:140
std::map< std::string, double > fParamValues
Definition: Measurement.h:146
void AddFunctionObject(const RooStats::HistFactory::PreprocessFunction function)
Definition: Measurement.h:72
#define ClassDef(name, id)
Definition: Rtypes.h:297
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:29
std::vector< RooStats::HistFactory::Channel > & GetChannels()
Definition: Measurement.h:105
std::string GetDirPath(TDirectory *dir)
std::map< std::string, double > & GetUniformSyst()
Definition: Measurement.h:122
std::vector< std::string > fConstantParams
Definition: Measurement.h:143
std::map< std::string, double > & GetParamValues()
Definition: Measurement.h:66
void AddGammaSyst(std::string syst, double uncert)
void AddConstantParam(const std::string &param)
Definition: Measurement.cxx:65
std::vector< std::string > fPOI
Definition: Measurement.h:131
std::vector< RooStats::HistFactory::Asimov > fAsimovDatasets
Definition: Measurement.h:152
std::vector< std::string > & GetConstantParams()
Definition: Measurement.h:60
Namespace for the RooStats classes.
Definition: Asimov.h:20
Describe directory structure in memory.
Definition: TDirectory.h:34
void AddNoSyst(std::string syst)
std::map< std::string, double > & GetLogNormSyst()
Definition: Measurement.h:123
RooStats::HistFactory::Channel & GetChannel(std::string)
void SetParamValue(const std::string &param, double value)
Definition: Measurement.cxx:88
std::map< std::string, double > fLogNormSyst
Definition: Measurement.h:157
std::map< std::string, double > fUniformSyst
Definition: Measurement.h:156
std::vector< RooStats::HistFactory::PreprocessFunction > & GetFunctionObjects()
Definition: Measurement.h:75
std::map< std::string, double > fNoSyst
Definition: Measurement.h:158
void SetLumiRelErr(double RelErr)
Definition: Measurement.h:86
Definition: file.py:1
void AddLogNormSyst(std::string syst, double uncert)
void PrintTree(std::ostream &=std::cout)
std::vector< RooStats::HistFactory::PreprocessFunction > fFunctionObjects
Definition: Measurement.h:149
void AddAsimovDataset(RooStats::HistFactory::Asimov dataset)
Definition: Measurement.h:81
std::map< std::string, double > & GetGammaSyst()
Definition: Measurement.h:121