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
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 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 void PrintTree( std::ostream& = std::cout ); /// Print to a stream
99 void PrintXML( std::string Directory="", std::string NewOutputPrefix="" );
100
101 std::vector< RooStats::HistFactory::Channel >& GetChannels() { return fChannels; }
102 const std::vector< RooStats::HistFactory::Channel >& GetChannels() const { return fChannels; }
104 /// add a completely configured channel
105 void AddChannel( RooStats::HistFactory::Channel chan ) { fChannels.push_back( chan ); }
106
107 bool HasChannel( std::string );
108 void writeToFile( TFile* file );
109
110 void CollectHistograms();
111
112
113 void AddGammaSyst(std::string syst, double uncert);
114 void AddLogNormSyst(std::string syst, double uncert);
115 void AddUniformSyst(std::string syst);
116 void AddNoSyst(std::string syst);
117
118 std::map< std::string, double >& GetGammaSyst() { return fGammaSyst; }
119 std::map< std::string, double >& GetUniformSyst() { return fUniformSyst; }
120 std::map< std::string, double >& GetLogNormSyst() { return fLogNormSyst; }
121 std::map< std::string, double >& GetNoSyst() { return fNoSyst; }
122
123 std::map< std::string, double > const& GetGammaSyst() const { return fGammaSyst; }
124 std::map< std::string, double > const& GetUniformSyst() const { return fUniformSyst; }
125 std::map< std::string, double > const& GetLogNormSyst() const { return fLogNormSyst; }
126 std::map< std::string, double > const& GetNoSyst() const { return fNoSyst; }
127
129
130private:
131
132 /// Configurables of this measurement
133 std::string fOutputFilePrefix;
134 std::vector<std::string> fPOI;
135 double fLumi;
139 bool fExportOnly = true;
141
142 /// Channels that make up this measurement
143 std::vector< RooStats::HistFactory::Channel > fChannels;
144
145 /// List of Parameters to be set constant
146 std::vector< std::string > fConstantParams;
147
148 /// Map of parameter names to initial values to be set
149 std::map< std::string, double > fParamValues;
150
151 /// List of Preprocess Function objects
152 std::vector< RooStats::HistFactory::PreprocessFunction > fFunctionObjects;
153
154 /// List of Asimov datasets to generate
155 std::vector< RooStats::HistFactory::Asimov > fAsimovDatasets;
156
157 /// List of Alternate constraint terms
158 std::map< std::string, double > fGammaSyst;
159 std::map< std::string, double > fUniformSyst;
160 std::map< std::string, double > fLogNormSyst;
161 std::map< std::string, double > fNoSyst;
162
163 std::string GetDirPath( TDirectory* dir );
164
166
167};
168
169} // namespace HistFactory
170} // namespace RooStats
171
172#endif
#define ClassDefOverride(name, id)
Definition Rtypes.h:346
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()
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