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