Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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
22#include "PreprocessFunction.h"
25
26class TFile;
27
28namespace RooStats{
29namespace HistFactory {
30
31class Measurement : public TNamed {
32
33public:
34
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
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 const std::vector< RooStats::HistFactory::PreprocessFunction >& GetFunctionObjects() const { return fFunctionObjects; }
77 std::vector< std::string > GetPreprocessFunctions() const;
78
79 /// get vector of defined Asimov Datasets
80 std::vector< RooStats::HistFactory::Asimov >& GetAsimovDatasets() { return fAsimovDatasets; }
81 /// add an Asimov Dataset
82 void AddAsimovDataset( RooStats::HistFactory::Asimov dataset ) { fAsimovDatasets.push_back(dataset); }
83
84 /// set integrated luminosity used to normalise histograms (if NormalizeByTheory is true for this sample)
85 void SetLumi(double Lumi ) { fLumi = Lumi; }
86 /// set relative uncertainty on luminosity
87 void SetLumiRelErr( double RelErr ) { fLumiRelErr = RelErr; }
88 /// retrieve integrated luminosity
89 double GetLumi() { return fLumi; }
90 /// retrieve relative uncertainty on luminosity
91 double GetLumiRelErr() { return fLumiRelErr; }
92
93 void SetBinLow( int BinLow ) { fBinLow = BinLow; }
94 void SetBinHigh ( int BinHigh ) { fBinHigh = BinHigh; }
95 int GetBinLow() { return fBinLow; }
96 int GetBinHigh() { return fBinHigh; }
97
98 /// do not produce any plots or tables, just save the model
99 void SetExportOnly( bool ExportOnly ) { fExportOnly = ExportOnly; }
100 bool GetExportOnly() { return fExportOnly; }
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; }
106 const std::vector< RooStats::HistFactory::Channel >& GetChannels() const { return fChannels; }
108 /// add a completely configured channel
109 void AddChannel( RooStats::HistFactory::Channel chan ) { fChannels.push_back( chan ); }
110
111 bool HasChannel( std::string );
112 void writeToFile( TFile* file );
113
114 void CollectHistograms();
115
116
117 void AddGammaSyst(std::string syst, double uncert);
118 void AddLogNormSyst(std::string syst, double uncert);
119 void AddUniformSyst(std::string syst);
120 void AddNoSyst(std::string syst);
121
122 std::map< std::string, double >& GetGammaSyst() { return fGammaSyst; }
123 std::map< std::string, double >& GetUniformSyst() { return fUniformSyst; }
124 std::map< std::string, double >& GetLogNormSyst() { return fLogNormSyst; }
125 std::map< std::string, double >& GetNoSyst() { return fNoSyst; }
126
127 std::map< std::string, double > const& GetGammaSyst() const { return fGammaSyst; }
128 std::map< std::string, double > const& GetUniformSyst() const { return fUniformSyst; }
129 std::map< std::string, double > const& GetLogNormSyst() const { return fLogNormSyst; }
130 std::map< std::string, double > const& GetNoSyst() const { return fNoSyst; }
131
133
134private:
135
136 /// Configurables of this measurement
137 std::string fOutputFilePrefix;
138 std::vector<std::string> fPOI;
139 double fLumi;
145
146 /// Channels that make up this measurement
147 std::vector< RooStats::HistFactory::Channel > fChannels;
148
149 /// List of Parameters to be set constant
150 std::vector< std::string > fConstantParams;
151
152 /// Map of parameter names to initial values to be set
153 std::map< std::string, double > fParamValues;
154
155 /// List of Preprocess Function objects
156 std::vector< RooStats::HistFactory::PreprocessFunction > fFunctionObjects;
157
158 /// List of Asimov datasets to generate
159 std::vector< RooStats::HistFactory::Asimov > fAsimovDatasets;
160
161 /// List of Alternate constraint terms
162 std::map< std::string, double > fGammaSyst;
163 std::map< std::string, double > fUniformSyst;
164 std::map< std::string, double > fLogNormSyst;
165 std::map< std::string, double > fNoSyst;
166
167 std::string GetDirPath( TDirectory* dir );
168
170
171};
172
173} // namespace HistFactory
174} // namespace RooStats
175
176#endif
RooAbsReal & function()
#define ClassDefOverride(name, id)
Definition Rtypes.h:341
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
char name[80]
Definition TGX11.cxx:110
TODO Here, we are missing some documentation.
Definition Asimov.h:22
This class encapsulates all information for the statistical interpretation of one experiment.
Definition Channel.h:30
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.
std::map< std::string, double > const & GetNoSyst() const
std::map< std::string, double > const & GetGammaSyst() const
std::string fOutputFilePrefix
Configurables of this measurement.
void AddGammaSyst(std::string syst, double uncert)
Set constraint term for given systematic to Gamma distribution.
std::map< std::string, double > fGammaSyst
List of Alternate constraint terms.
void ClearParamValues()
clear map of parameter values
Definition Measurement.h:68
std::map< std::string, double > & GetGammaSyst()
std::map< std::string, double > & GetLogNormSyst()
std::string GetDirPath(TDirectory *dir)
Return the directory's path, stripped of unnecessary prefixes.
std::map< std::string, double > const & GetLogNormSyst() const
std::map< std::string, double > & GetParamValues()
get map: parameter name <--> parameter value
Definition Measurement.h:66
std::map< std::string, double > & GetNoSyst()
void SetExportOnly(bool ExportOnly)
do not produce any plots or tables, just save the model
Definition Measurement.h:99
const std::vector< RooStats::HistFactory::PreprocessFunction > & GetFunctionObjects() const
Definition Measurement.h:76
void AddPOI(const std::string &POI)
append parameter to vector of PoIs
Definition Measurement.h:47
std::vector< std::string > & GetPOIList()
get vector of PoI names
Definition Measurement.h:51
void AddLogNormSyst(std::string syst, double uncert)
Set constraint term for given systematic to LogNormal distribution.
void PrintXML(std::string Directory="", std::string NewOutputPrefix="")
Print to a stream.
void SetLumi(double Lumi)
set integrated luminosity used to normalise histograms (if NormalizeByTheory is true for this sample)
Definition Measurement.h:85
RooStats::HistFactory::Channel & GetChannel(std::string)
Get channel with given name from this measurement throws an exception in case the channel is not foun...
void SetParamValue(const std::string &param, double value)
Set a parameter to a specific value (And optionally fix it)
double GetLumiRelErr()
retrieve relative uncertainty on luminosity
Definition Measurement.h:91
std::map< std::string, double > fLogNormSyst
std::map< std::string, double > & GetUniformSyst()
std::map< std::string, double > fNoSyst
std::vector< std::string > & GetConstantParams()
get vector of all constant parameters
Definition Measurement.h:60
void CollectHistograms()
The most common way to add histograms to channels is to have them stored in ROOT files and to give Hi...
const std::vector< RooStats::HistFactory::Channel > & GetChannels() const
void AddChannel(RooStats::HistFactory::Channel chan)
add a completely configured channel
void SetOutputFilePrefix(const std::string &prefix)
set output prefix
Definition Measurement.h:40
bool HasChannel(std::string)
Check if the given channel is part of this measurement.
std::vector< std::string > fConstantParams
List of Parameters to be set constant.
void AddUniformSyst(std::string syst)
Set constraint term for given systematic to uniform distribution.
std::vector< RooStats::HistFactory::PreprocessFunction > fFunctionObjects
List of Preprocess Function objects.
std::map< std::string, double > fParamValues
Map of parameter names to initial values to be set.
void PrintTree(std::ostream &=std::cout)
Print information about measurement object in tree-like structure to given stream.
std::vector< RooStats::HistFactory::Channel > & GetChannels()
std::vector< RooStats::HistFactory::Asimov > & GetAsimovDatasets()
get vector of defined Asimov Datasets
Definition Measurement.h:80
Measurement()
Standard constructor.
void AddNoSyst(std::string syst)
Define given systematics to have no external constraint.
void SetPOI(const std::string &POI)
insert PoI at beginning of vector of PoIs
Definition Measurement.h:45
std::string GetOutputFilePrefix()
retrieve prefix for output files
Definition Measurement.h:42
void AddConstantParam(const std::string &param)
Add a parameter to be set as constant (Similar to ParamSetting method below)
std::vector< RooStats::HistFactory::Asimov > fAsimovDatasets
List of Asimov datasets to generate.
void AddFunctionObject(const RooStats::HistFactory::PreprocessFunction function)
add a preprocess function object
Definition Measurement.h:72
void ClearConstantParams()
empty vector of constant parameters
Definition Measurement.h:58
std::vector< RooStats::HistFactory::PreprocessFunction > & GetFunctionObjects()
get vector of defined function objects
Definition Measurement.h:75
void SetFunctionObjects(std::vector< RooStats::HistFactory::PreprocessFunction > objects)
Definition Measurement.h:73
void AddPreprocessFunction(std::string name, std::string expression, std::string dependencies)
Add a preprocessed function by giving the function a name, a functional expression,...
std::vector< std::string > GetPreprocessFunctions() const
Returns a list of defined preprocess function expressions.
void SetLumiRelErr(double RelErr)
set relative uncertainty on luminosity
Definition Measurement.h:87
std::vector< std::string > fPOI
std::map< std::string, double > const & GetUniformSyst() const
double GetLumi()
retrieve integrated luminosity
Definition Measurement.h:89
void AddAsimovDataset(RooStats::HistFactory::Asimov dataset)
add an Asimov Dataset
Definition Measurement.h:82
std::map< std::string, double > fUniformSyst
std::string GetPOI(unsigned int i=0)
get name of PoI at given index
Definition Measurement.h:49
std::vector< RooStats::HistFactory::Channel > fChannels
Channels that make up this measurement.
Describe directory structure in memory.
Definition TDirectory.h:45
A ROOT file is an on-disk file, usually with extension .root, that stores objects in a file-system-li...
Definition TFile.h:53
The TNamed class is the base class for all named ROOT classes.
Definition TNamed.h:29
Namespace for the RooStats classes.
Definition Asimov.h:19