Logo ROOT  
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 #include <vector>
19 
20 #include "TNamed.h"
21 #include "TFile.h"
22 
23 #include "PreprocessFunction.h"
26 
27 namespace RooStats{
28 namespace HistFactory {
29 
30 class Measurement : public TNamed {
31 
32 public:
33 
34  Measurement();
35  /// Measurement( const Measurement& other ); // Copy
36  Measurement(const char* Name, const char* Title="");
37 
38  /// set output prefix
39  void SetOutputFilePrefix( const std::string& prefix ) { fOutputFilePrefix = prefix; }
40  /// retrieve prefix for output files
41  std::string GetOutputFilePrefix() { return fOutputFilePrefix; }
42 
43  /// insert PoI at beginning of vector of PoIs
44  void SetPOI( const std::string& POI ) { fPOI.insert( fPOI.begin(), POI ); }
45  /// append parameter to vector of PoIs
46  void AddPOI( const std::string& POI ) { fPOI.push_back(POI); }
47  /// get name of PoI at given index
48  std::string GetPOI(unsigned int i=0) { return fPOI.at(i); }
49  /// get vector of PoI names
50  std::vector<std::string>& GetPOIList() { return fPOI; }
51 
52 
53  /// Add a parameter to be set as constant
54  /// (Similar to ParamSetting method below)
55  void AddConstantParam( const std::string& param );
56  /// empty vector of constant parameters
58  /// get vector of all constant parameters
59  std::vector< std::string >& GetConstantParams() { return fConstantParams; }
60 
61  /// Set a parameter to a specific value
62  /// (And optionally fix it)
63  void SetParamValue( const std::string& param, double value);
64  /// get map: parameter name <--> parameter value
65  std::map<std::string, double>& GetParamValues() { return fParamValues; }
66  /// clear map of parameter values
67  void ClearParamValues() { fParamValues.clear(); }
68 
69  void AddPreprocessFunction( std::string name, std::string expression, std::string dependencies );
70  /// add a preprocess function object
71  void AddFunctionObject( const RooStats::HistFactory::PreprocessFunction function) { fFunctionObjects.push_back( function ); }
72  void SetFunctionObjects( std::vector< RooStats::HistFactory::PreprocessFunction > objects ) { fFunctionObjects = objects; }
73  /// get vector of defined function objects
74  std::vector< RooStats::HistFactory::PreprocessFunction >& GetFunctionObjects() { return fFunctionObjects; }
75  const std::vector< RooStats::HistFactory::PreprocessFunction >& GetFunctionObjects() const { return fFunctionObjects; }
76  std::vector< std::string > GetPreprocessFunctions() const;
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  void PrintTree( std::ostream& = std::cout ); /// Print to a stream
102  void PrintXML( std::string Directory="", std::string NewOutputPrefix="" );
103 
104  std::vector< RooStats::HistFactory::Channel >& GetChannels() { return fChannels; }
105  const std::vector< RooStats::HistFactory::Channel >& GetChannels() const { 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 
127 
128 private:
129 
130  /// Configurables of this measurement
131  std::string fOutputFilePrefix;
132  std::vector<std::string> fPOI;
133  double fLumi;
134  double fLumiRelErr;
135  int fBinLow;
136  int fBinHigh;
138  std::string fInterpolationScheme;
139 
140  /// Channels that make up this measurement
141  std::vector< RooStats::HistFactory::Channel > fChannels;
142 
143  /// List of Parameters to be set constant
144  std::vector< std::string > fConstantParams;
145 
146  /// Map of parameter names to inital values to be set
147  std::map< std::string, double > fParamValues;
148 
149  /// List of Preprocess Function objects
150  std::vector< RooStats::HistFactory::PreprocessFunction > fFunctionObjects;
151 
152  /// List of Asimov datasets to generate
153  std::vector< RooStats::HistFactory::Asimov > fAsimovDatasets;
154 
155  /// List of Alternate constraint terms
156  std::map< std::string, double > fGammaSyst;
157  std::map< std::string, double > fUniformSyst;
158  std::map< std::string, double > fLogNormSyst;
159  std::map< std::string, double > fNoSyst;
160 
161  std::string GetDirPath( TDirectory* dir );
162 
164 
165 };
166 
167 } // namespace HistFactory
168 } // namespace RooStats
169 
170 #endif
Asimov.h
RooStats::HistFactory::Measurement::fInterpolationScheme
std::string fInterpolationScheme
Definition: Measurement.h:138
RooStats::HistFactory::Measurement::SetLumi
void SetLumi(double Lumi)
set integrated luminosity used to normalise histograms (if NormalizeByTheory is true for this sample)
Definition: Measurement.h:84
RooStats::HistFactory::Measurement::PrintXML
void PrintXML(std::string Directory="", std::string NewOutputPrefix="")
Print to a stream.
Definition: Measurement.cxx:263
RooStats::HistFactory::Measurement::GetNoSyst
std::map< std::string, double > & GetNoSyst()
Definition: Measurement.h:124
RooStats::HistFactory::Measurement::fLumiRelErr
double fLumiRelErr
Definition: Measurement.h:134
RooStats::HistFactory::Measurement::AddChannel
void AddChannel(RooStats::HistFactory::Channel chan)
add a completely configured channel
Definition: Measurement.h:108
RooStats::HistFactory::Measurement::GetLumiRelErr
double GetLumiRelErr()
retrieve relative uncertainty on luminosity
Definition: Measurement.h:90
RooStats::HistFactory::Measurement::AddNoSyst
void AddNoSyst(std::string syst)
Define given systematics to have no external constraint.
Definition: Measurement.cxx:155
RooStats::HistFactory::Measurement::PrintTree
void PrintTree(std::ostream &=std::cout)
Print information about measurement object in tree-like structure to given stream.
Definition: Measurement.cxx:212
RooStats::HistFactory::Measurement::fFunctionObjects
std::vector< RooStats::HistFactory::PreprocessFunction > fFunctionObjects
List of Preprocess Function objects.
Definition: Measurement.h:150
TNamed.h
RooStats::HistFactory::Measurement::GetGammaSyst
std::map< std::string, double > & GetGammaSyst()
Definition: Measurement.h:121
RooStats::HistFactory::Measurement::ClearParamValues
void ClearParamValues()
clear map of parameter values
Definition: Measurement.h:67
RooStats::HistFactory::Measurement::GetBinHigh
int GetBinHigh()
Definition: Measurement.h:95
RooStats::HistFactory::Measurement::GetBinLow
int GetBinLow()
Definition: Measurement.h:94
xmlio::Title
const char * Title
Definition: TXMLSetup.cxx:68
RooStats::HistFactory::Measurement::GetParamValues
std::map< std::string, double > & GetParamValues()
get map: parameter name <--> parameter value
Definition: Measurement.h:65
RooStats::HistFactory::Measurement::SetPOI
void SetPOI(const std::string &POI)
insert PoI at beginning of vector of PoIs
Definition: Measurement.h:44
RooStats::HistFactory::Measurement::fGammaSyst
std::map< std::string, double > fGammaSyst
List of Alternate constraint terms.
Definition: Measurement.h:156
Channel.h
RooStats::HistFactory::Measurement::SetOutputFilePrefix
void SetOutputFilePrefix(const std::string &prefix)
set output prefix
Definition: Measurement.h:39
RooFit::HistFactory
@ HistFactory
Definition: RooGlobalFunc.h:69
TFile.h
RooStats::HistFactory::Measurement::SetExportOnly
void SetExportOnly(bool ExportOnly)
do not produce any plots or tables, just save the model
Definition: Measurement.h:98
RooStats::HistFactory::Measurement::SetBinHigh
void SetBinHigh(int BinHigh)
Definition: Measurement.h:93
RooStats::HistFactory::Measurement::fParamValues
std::map< std::string, double > fParamValues
Map of parameter names to inital values to be set.
Definition: Measurement.h:147
RooStats::HistFactory::Measurement::GetInterpolationScheme
std::string GetInterpolationScheme()
Definition: Measurement.h:126
RooStats::HistFactory::Channel
This class encapsulates all information for the statistical interpretation of one experiment.
Definition: Channel.h:30
RooStats::HistFactory::Measurement::GetChannels
std::vector< RooStats::HistFactory::Channel > & GetChannels()
Definition: Measurement.h:104
RooStats::HistFactory::Measurement::GetDirPath
std::string GetDirPath(TDirectory *dir)
Return the directory's path, stripped of unnecessary prefixes.
Definition: Measurement.cxx:613
RooStats::HistFactory::Measurement::AddGammaSyst
void AddGammaSyst(std::string syst, double uncert)
Set constraint term for given systematic to Gamma distribution.
Definition: Measurement.cxx:137
RooStats::HistFactory::Asimov
TODO Here, we are missing some documentation.
Definition: Asimov.h:22
RooStats::HistFactory::Measurement::fExportOnly
bool fExportOnly
Definition: Measurement.h:137
RooStats::HistFactory::Measurement::GetOutputFilePrefix
std::string GetOutputFilePrefix()
retrieve prefix for output files
Definition: Measurement.h:41
RooStats::HistFactory::Measurement
The RooStats::HistFactory::Measurement class can be used to construct a model by combining multiple R...
Definition: Measurement.h:30
PreprocessFunction.h
RooStats::HistFactory::Measurement::GetUniformSyst
std::map< std::string, double > & GetUniformSyst()
Definition: Measurement.h:122
RooStats::HistFactory::Measurement::fAsimovDatasets
std::vector< RooStats::HistFactory::Asimov > fAsimovDatasets
List of Asimov datasets to generate.
Definition: Measurement.h:153
RooStats::HistFactory::Measurement::AddLogNormSyst
void AddLogNormSyst(std::string syst, double uncert)
Set constraint term for given systematic to LogNormal distribution.
Definition: Measurement.cxx:143
RooStats::HistFactory::Measurement::GetPreprocessFunctions
std::vector< std::string > GetPreprocessFunctions() const
Returns a list of defined preprocess function expressions.
Definition: Measurement.cxx:124
RooStats::HistFactory::Measurement::GetExportOnly
bool GetExportOnly()
Definition: Measurement.h:99
RooStats::HistFactory::Measurement::AddPreprocessFunction
void AddPreprocessFunction(std::string name, std::string expression, std::string dependencies)
Add a preprocessed function by giving the function a name, a functional expression,...
Definition: Measurement.cxx:114
TNamed
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:29
RooStats::HistFactory::Measurement::AddPOI
void AddPOI(const std::string &POI)
append parameter to vector of PoIs
Definition: Measurement.h:46
RooStats::HistFactory::Measurement::AddFunctionObject
void AddFunctionObject(const RooStats::HistFactory::PreprocessFunction function)
add a preprocess function object
Definition: Measurement.h:71
RooStats::HistFactory::Measurement::GetLumi
double GetLumi()
retrieve integrated luminosity
Definition: Measurement.h:88
RooStats::HistFactory::Measurement::fConstantParams
std::vector< std::string > fConstantParams
List of Parameters to be set constant.
Definition: Measurement.h:144
RooStats::HistFactory::Measurement::GetConstantParams
std::vector< std::string > & GetConstantParams()
get vector of all constant parameters
Definition: Measurement.h:59
RooStats::HistFactory::Measurement::fPOI
std::vector< std::string > fPOI
Definition: Measurement.h:132
RooStats::HistFactory::Measurement::HasChannel
bool HasChannel(std::string)
Check if the given channel is part of this measurement.
Definition: Measurement.cxx:161
RooStats::HistFactory::Measurement::GetLogNormSyst
std::map< std::string, double > & GetLogNormSyst()
Definition: Measurement.h:123
RooStats::HistFactory::Measurement::AddConstantParam
void AddConstantParam(const std::string &param)
Add a parameter to be set as constant (Similar to ParamSetting method below)
Definition: Measurement.cxx:71
RooStats::HistFactory::Measurement::SetBinLow
void SetBinLow(int BinLow)
Definition: Measurement.h:92
RooStats::HistFactory::Measurement::ClearConstantParams
void ClearConstantParams()
empty vector of constant parameters
Definition: Measurement.h:57
TFile
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format.
Definition: TFile.h:54
RooStats::HistFactory::Measurement::SetParamValue
void SetParamValue(const std::string &param, double value)
Set a parameter to a specific value (And optionally fix it)
Definition: Measurement.cxx:89
RooStats::HistFactory::Measurement::AddAsimovDataset
void AddAsimovDataset(RooStats::HistFactory::Asimov dataset)
add an Asimov Dataset
Definition: Measurement.h:81
RooStats::HistFactory::Measurement::fNoSyst
std::map< std::string, double > fNoSyst
Definition: Measurement.h:159
RooStats::HistFactory::Measurement::writeToFile
void writeToFile(TFile *file)
A measurement, once fully configured, can be saved into a ROOT file.
Definition: Measurement.cxx:441
RooStats::HistFactory::Measurement::GetChannel
RooStats::HistFactory::Channel & GetChannel(std::string)
Get channel with given name from this measurement throws an exception in case the channel is not foun...
Definition: Measurement.cxx:181
RooStats::HistFactory::Measurement::SetLumiRelErr
void SetLumiRelErr(double RelErr)
set relative uncertainty on luminosity
Definition: Measurement.h:86
xmlio::Name
const char * Name
Definition: TXMLSetup.cxx:67
RooStats::HistFactory::Measurement::GetChannels
const std::vector< RooStats::HistFactory::Channel > & GetChannels() const
Definition: Measurement.h:105
RooStats::HistFactory::Measurement::fBinHigh
int fBinHigh
Definition: Measurement.h:136
RooStats::HistFactory::Measurement::GetFunctionObjects
std::vector< RooStats::HistFactory::PreprocessFunction > & GetFunctionObjects()
get vector of defined function objects
Definition: Measurement.h:74
RooStats::HistFactory::Measurement::GetAsimovDatasets
std::vector< RooStats::HistFactory::Asimov > & GetAsimovDatasets()
get vector of defined Asimov Datasets
Definition: Measurement.h:79
RooStats
Namespace for the RooStats classes.
Definition: Asimov.h:19
RooStats::HistFactory::Measurement::fBinLow
int fBinLow
Definition: Measurement.h:135
file
Definition: file.py:1
ClassDef
#define ClassDef(name, id)
Definition: Rtypes.h:325
RooStats::HistFactory::Measurement::GetFunctionObjects
const std::vector< RooStats::HistFactory::PreprocessFunction > & GetFunctionObjects() const
Definition: Measurement.h:75
RooStats::HistFactory::Measurement::GetPOI
std::string GetPOI(unsigned int i=0)
get name of PoI at given index
Definition: Measurement.h:48
name
char name[80]
Definition: TGX11.cxx:110
TDirectory
Describe directory structure in memory.
Definition: TDirectory.h:40
RooStats::HistFactory::PreprocessFunction
Definition: PreprocessFunction.h:11
RooStats::HistFactory::Measurement::GetPOIList
std::vector< std::string > & GetPOIList()
get vector of PoI names
Definition: Measurement.h:50
RooStats::HistFactory::Measurement::CollectHistograms
void CollectHistograms()
The most common way to add histograms to channels is to have them stored in ROOT files and to give Hi...
Definition: Measurement.cxx:648
RooStats::HistFactory::Measurement::fOutputFilePrefix
std::string fOutputFilePrefix
Configurables of this measurement.
Definition: Measurement.h:131
RooStats::HistFactory::Measurement::fLogNormSyst
std::map< std::string, double > fLogNormSyst
Definition: Measurement.h:158
RooStats::HistFactory::Measurement::fUniformSyst
std::map< std::string, double > fUniformSyst
Definition: Measurement.h:157
RooStats::HistFactory::Measurement::Measurement
Measurement()
Standard constructor.
Definition: Measurement.cxx:38
RooStats::HistFactory::Measurement::fLumi
double fLumi
Definition: Measurement.h:133
RooStats::HistFactory::Measurement::fChannels
std::vector< RooStats::HistFactory::Channel > fChannels
Channels that make up this measurement.
Definition: Measurement.h:141
RooStats::HistFactory::Measurement::AddUniformSyst
void AddUniformSyst(std::string syst)
Set constraint term for given systematic to uniform distribution.
Definition: Measurement.cxx:149
RooStats::HistFactory::Measurement::SetFunctionObjects
void SetFunctionObjects(std::vector< RooStats::HistFactory::PreprocessFunction > objects)
Definition: Measurement.h:72