Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
Sample.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_SAMPLE_H
12#define HISTFACTORY_SAMPLE_H
13
14#include <string>
15#include <fstream>
16#include <vector>
17#include <iostream>
18
19class TH1;
20
23
24namespace RooStats{
25namespace HistFactory {
26
27class Sample {
28
29
30public:
31
32 Sample();
33 Sample(std::string Name);
34 Sample(const Sample& other);
35 Sample& operator=(const Sample& other);
36 /// constructor from name, file and path. Name of the histogram should not include the path
37 Sample(std::string Name, std::string HistoName, std::string InputFile, std::string HistoPath="");
38
39 void Print(std::ostream& = std::cout) const;
40 void PrintXML( std::ofstream& xml ) const;
41 void writeToFile( std::string FileName, std::string DirName );
42
43 const TH1* GetHisto() const;
44 // set histogram for this sample
45 void SetHisto( TH1* histo ) { fhNominal = histo; fHistoName=histo->GetName(); }
46 void SetValue( double Val ) ;
47
48 // Some helper functions
49 // Note that histogram name should not include the path of the histogram in the file.
50 // This has to be given separately
51
52 void ActivateStatError();
53 void ActivateStatError( std::string HistoName, std::string InputFile, std::string HistoPath="" );
54
55 void AddOverallSys( std::string Name, double Low, double High );
56 void AddOverallSys( const OverallSys& Sys );
57
58 void AddNormFactor( std::string const& Name, double Val, double Low, double High );
59 void AddNormFactor( const NormFactor& Factor );
60
61 void AddHistoSys( std::string Name, std::string HistoNameLow, std::string HistoFileLow, std::string HistoPathLow,
62 std::string HistoNameHigh, std::string HistoFileHigh, std::string HistoPathHigh );
63 void AddHistoSys( const HistoSys& Sys );
64
65 void AddHistoFactor( std::string Name, std::string HistoNameLow, std::string HistoFileLow, std::string HistoPathLow,
66 std::string HistoNameHigh, std::string HistoFileHigh, std::string HistoPathHigh );
67 void AddHistoFactor( const HistoFactor& Factor );
68
69 void AddShapeFactor( std::string Name );
70 void AddShapeFactor( const ShapeFactor& Factor );
71
72 void AddShapeSys( std::string Name, Constraint::Type ConstraintType, std::string HistoName, std::string HistoFile, std::string HistoPath="" );
73 void AddShapeSys( const ShapeSys& Sys );
74
75 /// defines whether the normalization scale with luminosity
76 void SetNormalizeByTheory( bool norm ) { fNormalizeByTheory = norm; }
77 /// does the normalization scale with luminosity
79
80
81 /// get name of sample
82 std::string GetName() const { return fName; }
83 /// set name of sample
84 void SetName(const std::string& Name) { fName = Name; }
85
86 /// get input ROOT file
87 std::string GetInputFile() const { return fInputFile; }
88 /// set input ROOT file
89 void SetInputFile(const std::string& InputFile) { fInputFile = InputFile; }
90
91 /// get histogram name
92 std::string GetHistoName() const { return fHistoName; }
93 /// set histogram name
94 void SetHistoName(const std::string& HistoName) { fHistoName = HistoName; }
95
96 /// get histogram path
97 std::string GetHistoPath() const { return fHistoPath; }
98 /// set histogram path
99 void SetHistoPath(const std::string& HistoPath) { fHistoPath = HistoPath; }
100
101 /// get name of associated channel
102 std::string GetChannelName() const { return fChannelName; }
103 /// set name of associated channel
104 void SetChannelName(const std::string& ChannelName) { fChannelName = ChannelName; }
105
106
107
108 std::vector< RooStats::HistFactory::OverallSys >& GetOverallSysList() { return fOverallSysList; }
109 std::vector< RooStats::HistFactory::NormFactor >& GetNormFactorList() { return fNormFactorList; }
110 std::vector< RooStats::HistFactory::HistoSys >& GetHistoSysList() { return fHistoSysList; }
111 std::vector< RooStats::HistFactory::HistoFactor >& GetHistoFactorList() { return fHistoFactorList; }
112 std::vector< RooStats::HistFactory::ShapeSys >& GetShapeSysList() { return fShapeSysList; }
113 std::vector< RooStats::HistFactory::ShapeFactor >& GetShapeFactorList() { return fShapeFactorList; }
114
115 const std::vector< RooStats::HistFactory::OverallSys >& GetOverallSysList() const { return fOverallSysList; }
116 const std::vector< RooStats::HistFactory::NormFactor >& GetNormFactorList() const { return fNormFactorList; }
117 const std::vector< RooStats::HistFactory::HistoSys >& GetHistoSysList() const { return fHistoSysList; }
118 const std::vector< RooStats::HistFactory::HistoFactor >& GetHistoFactorList() const { return fHistoFactorList; }
119 const std::vector< RooStats::HistFactory::ShapeSys >& GetShapeSysList() const { return fShapeSysList; }
120 const std::vector< RooStats::HistFactory::ShapeFactor >& GetShapeFactorList() const { return fShapeFactorList; }
121
122
123 bool HasStatError() const { return fStatErrorActivate; }
127 fStatError = std::move(Error);
128 }
129
130protected:
131
132 std::string fName;
133 std::string fInputFile;
134 std::string fHistoName;
135 std::string fHistoPath;
136
137 /// The Name of the parent channel
138 std::string fChannelName;
139
140 //
141 // Systematics
142 //
143
144 std::vector< RooStats::HistFactory::OverallSys > fOverallSysList;
145 std::vector< RooStats::HistFactory::NormFactor > fNormFactorList;
146
147 std::vector< RooStats::HistFactory::HistoSys > fHistoSysList;
148 std::vector< RooStats::HistFactory::HistoFactor > fHistoFactorList;
149
150 std::vector< RooStats::HistFactory::ShapeSys > fShapeSysList;
151 std::vector< RooStats::HistFactory::ShapeFactor > fShapeFactorList;
152
153
154 /// Properties
156
157 bool fNormalizeByTheory = false;
158 bool fStatErrorActivate = false;
159
160
161 /// The Nominal Shape
163 std::unique_ptr<TH1> fhCountingHist;
164
165};
166
167
168} // namespace HistFactory
169} // namespace RooStats
170
171#endif
void Error(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
Definition TError.cxx:185
Internal class wrapping an histogram and managing its content.
Definition HistRef.h:25
Configuration for an *un*constrained, coherent shape variation of affected samples.
Configuration for a constrained, coherent shape variation of affected samples.
Configuration for an un- constrained overall systematic to scale sample normalisations.
Definition Systematics.h:62
Configuration for a constrained overall systematic to scale sample normalisations.
Definition Systematics.h:34
std::unique_ptr< TH1 > fhCountingHist
Definition Sample.h:163
std::vector< RooStats::HistFactory::OverallSys > & GetOverallSysList()
Definition Sample.h:108
std::vector< RooStats::HistFactory::OverallSys > fOverallSysList
Definition Sample.h:144
std::string GetHistoName() const
get histogram name
Definition Sample.h:92
void SetStatError(RooStats::HistFactory::StatError Error)
Definition Sample.h:126
void AddShapeSys(std::string Name, Constraint::Type ConstraintType, std::string HistoName, std::string HistoFile, std::string HistoPath="")
Definition Sample.cxx:420
void AddOverallSys(std::string Name, double Low, double High)
Definition Sample.cxx:326
std::string GetName() const
get name of sample
Definition Sample.h:82
void writeToFile(std::string FileName, std::string DirName)
Definition Sample.cxx:95
const TH1 * GetHisto() const
Definition Sample.cxx:89
std::vector< RooStats::HistFactory::HistoFactor > fHistoFactorList
Definition Sample.h:148
void SetInputFile(const std::string &InputFile)
set input ROOT file
Definition Sample.h:89
void SetValue(double Val)
Definition Sample.cxx:130
RooStats::HistFactory::StatError fStatError
Properties.
Definition Sample.h:155
void SetChannelName(const std::string &ChannelName)
set name of associated channel
Definition Sample.h:104
void AddNormFactor(std::string const &Name, double Val, double Low, double High)
Definition Sample.cxx:341
const RooStats::HistFactory::StatError & GetStatError() const
Definition Sample.h:125
void SetHistoName(const std::string &HistoName)
set histogram name
Definition Sample.h:94
std::vector< RooStats::HistFactory::NormFactor > fNormFactorList
Definition Sample.h:145
std::vector< RooStats::HistFactory::HistoSys > fHistoSysList
Definition Sample.h:147
std::string fChannelName
The Name of the parent channel.
Definition Sample.h:138
void SetHisto(TH1 *histo)
Definition Sample.h:45
void Print(std::ostream &=std::cout) const
Definition Sample.cxx:153
const std::vector< RooStats::HistFactory::HistoFactor > & GetHistoFactorList() const
Definition Sample.h:118
const std::vector< RooStats::HistFactory::HistoSys > & GetHistoSysList() const
Definition Sample.h:117
Sample & operator=(const Sample &other)
Definition Sample.cxx:47
std::string GetHistoPath() const
get histogram path
Definition Sample.h:97
std::vector< RooStats::HistFactory::ShapeSys > fShapeSysList
Definition Sample.h:150
void SetNormalizeByTheory(bool norm)
defines whether the normalization scale with luminosity
Definition Sample.h:76
const std::vector< RooStats::HistFactory::ShapeFactor > & GetShapeFactorList() const
Definition Sample.h:120
RooStats::HistFactory::StatError & GetStatError()
Definition Sample.h:124
void AddHistoFactor(std::string Name, std::string HistoNameLow, std::string HistoFileLow, std::string HistoPathLow, std::string HistoNameHigh, std::string HistoFileHigh, std::string HistoPathHigh)
Definition Sample.cxx:383
std::vector< RooStats::HistFactory::ShapeFactor > & GetShapeFactorList()
Definition Sample.h:113
void SetName(const std::string &Name)
set name of sample
Definition Sample.h:84
std::vector< RooStats::HistFactory::HistoFactor > & GetHistoFactorList()
Definition Sample.h:111
void SetHistoPath(const std::string &HistoPath)
set histogram path
Definition Sample.h:99
std::string GetChannelName() const
get name of associated channel
Definition Sample.h:102
std::vector< RooStats::HistFactory::NormFactor > & GetNormFactorList()
Definition Sample.h:109
std::string GetInputFile() const
get input ROOT file
Definition Sample.h:87
const std::vector< RooStats::HistFactory::OverallSys > & GetOverallSysList() const
Definition Sample.h:115
std::vector< RooStats::HistFactory::HistoSys > & GetHistoSysList()
Definition Sample.h:110
bool GetNormalizeByTheory() const
does the normalization scale with luminosity
Definition Sample.h:78
HistRef fhNominal
The Nominal Shape.
Definition Sample.h:162
void AddShapeFactor(std::string Name)
Definition Sample.cxx:406
std::vector< RooStats::HistFactory::ShapeFactor > fShapeFactorList
Definition Sample.h:151
const std::vector< RooStats::HistFactory::NormFactor > & GetNormFactorList() const
Definition Sample.h:116
std::vector< RooStats::HistFactory::ShapeSys > & GetShapeSysList()
Definition Sample.h:112
void AddHistoSys(std::string Name, std::string HistoNameLow, std::string HistoFileLow, std::string HistoPathLow, std::string HistoNameHigh, std::string HistoFileHigh, std::string HistoPathHigh)
Definition Sample.cxx:359
void PrintXML(std::ofstream &xml) const
Definition Sample.cxx:193
const std::vector< RooStats::HistFactory::ShapeSys > & GetShapeSysList() const
Definition Sample.h:119
*Un*constrained bin-by-bin variation of affected histogram.
Constrained bin-by-bin variation of affected histogram.
Statistical error of Monte Carlo predictions.
TH1 is the base class of all histogram classes in ROOT.
Definition TH1.h:59
const char * GetName() const override
Returns name of object.
Definition TNamed.h:47
Namespace for the RooStats classes.
Definition Asimov.h:19