ROOT  6.06/09
Reference Guide
Systematics.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_SYSTEMATICS_H
12 #define HISTFACTORY_SYSTEMATICS_H
13 
14 #include <string>
15 #include <fstream>
16 #include <iostream>
17 
18 #include "TH1.h"
20 
21 namespace RooStats{
22 namespace HistFactory {
23 
24  namespace Constraint {
25  enum Type{ Gaussian, Poisson };
26  std::string Name( Type type );
27  Type GetType( const std::string& Name );
28  }
29 
30 
31  // Base class for common functions
32  /*
33  class Systematic {
34 
35  public:
36 
37  virtual void Print(std::ostream& = std::cout);
38  virtual void writeToFile(const std::string& FileName,
39  const std::string& Directory);
40 
41 
42  };
43  */
44 
45  class OverallSys {
46 
47  public:
48 
49  OverallSys() : fLow(0), fHigh(0) {}
50 
51  void SetName( const std::string& Name ) { fName = Name; }
52  std::string GetName() { return fName; }
53 
54  void SetLow( double Low ) { fLow = Low; }
55  void SetHigh( double High ) { fHigh = High; }
56  double GetLow() { return fLow; }
57  double GetHigh() { return fHigh; }
58 
59  void Print(std::ostream& = std::cout);
60  void PrintXML(std::ostream&);
61 
62  protected:
63  std::string fName;
64  double fLow;
65  double fHigh;
66 
67  };
68 
69 
70  class NormFactor {
71 
72  public:
73 
74  NormFactor();
75 
76  void SetName( const std::string& Name ) { fName = Name; }
77  std::string GetName() { return fName; }
78 
79  void SetVal( double Val ) { fVal = Val; }
80  double GetVal() { return fVal; }
81 
82  void SetConst( bool Const=true ) { fConst = Const; }
83  bool GetConst() { return fConst; }
84 
85  void SetLow( double Low ) { fLow = Low; }
86  void SetHigh( double High ) { fHigh = High; }
87  double GetLow() { return fLow; }
88  double GetHigh() { return fHigh; }
89 
90  void Print(std::ostream& = std::cout);
91  void PrintXML(std::ostream&);
92 
93  protected:
94 
95  std::string fName;
96  double fVal;
97  double fLow;
98  double fHigh;
99  bool fConst;
100 
101  };
102 
103 
104  class HistoSys {
105 
106  public:
107 
109  HistoSys(const std::string& Name) : fName(Name), fhLow(NULL), fhHigh(NULL) {;}
110 
111  void Print(std::ostream& = std::cout);
112  void PrintXML(std::ostream&);
113  void writeToFile( const std::string& FileName, const std::string& DirName );
114 
115  void SetHistoLow( TH1* Low ) { fhLow = Low; }
116  void SetHistoHigh( TH1* High ) { fhHigh = High; }
117 
118  TH1* GetHistoLow();
119  TH1* GetHistoHigh();
120 
121  void SetName( const std::string& Name ) { fName = Name; }
122  std::string GetName() { return fName; }
123 
124  void SetInputFileLow( const std::string& InputFileLow ) { fInputFileLow = InputFileLow; }
125  void SetInputFileHigh( const std::string& InputFileHigh ) { fInputFileHigh = InputFileHigh; }
126 
127  std::string GetInputFileLow() { return fInputFileLow; }
128  std::string GetInputFileHigh() { return fInputFileHigh; }
129 
130  void SetHistoNameLow( const std::string& HistoNameLow ) { fHistoNameLow = HistoNameLow; }
131  void SetHistoNameHigh( const std::string& HistoNameHigh ) { fHistoNameHigh = HistoNameHigh; }
132 
133  std::string GetHistoNameLow() { return fHistoNameLow; }
134  std::string GetHistoNameHigh() { return fHistoNameHigh; }
135 
136  void SetHistoPathLow( const std::string& HistoPathLow ) { fHistoPathLow = HistoPathLow; }
137  void SetHistoPathHigh( const std::string& HistoPathHigh ) { fHistoPathHigh = HistoPathHigh; }
138 
139  std::string GetHistoPathLow() { return fHistoPathLow; }
140  std::string GetHistoPathHigh() { return fHistoPathHigh; }
141 
142  protected:
143 
144  std::string fName;
145 
146  std::string fInputFileLow;
147  std::string fHistoNameLow;
148  std::string fHistoPathLow;
149 
150  std::string fInputFileHigh;
151  std::string fHistoNameHigh;
152  std::string fHistoPathHigh;
153 
154  // The Low and High Histograms
157 
158  };
159 
160 
161  class HistoFactor {
162 
163  public:
164 
166 
167  void SetName( const std::string& Name ) { fName = Name; }
168  std::string GetName() { return fName; }
169 
170  void SetInputFileLow( const std::string& InputFileLow ) { fInputFileLow = InputFileLow; }
171  void SetInputFileHigh( const std::string& InputFileHigh ) { fInputFileHigh = InputFileHigh; }
172 
173  std::string GetInputFileLow() { return fInputFileLow; }
174  std::string GetInputFileHigh() { return fInputFileHigh; }
175 
176  void SetHistoNameLow( const std::string& HistoNameLow ) { fHistoNameLow = HistoNameLow; }
177  void SetHistoNameHigh( const std::string& HistoNameHigh ) { fHistoNameHigh = HistoNameHigh; }
178 
179  std::string GetHistoNameLow() { return fHistoNameLow; }
180  std::string GetHistoNameHigh() { return fHistoNameHigh; }
181 
182  void SetHistoPathLow( const std::string& HistoPathLow ) { fHistoPathLow = HistoPathLow; }
183  void SetHistoPathHigh( const std::string& HistoPathHigh ) { fHistoPathHigh = HistoPathHigh; }
184 
185  std::string GetHistoPathLow() { return fHistoPathLow; }
186  std::string GetHistoPathHigh() { return fHistoPathHigh; }
187 
188  void Print(std::ostream& = std::cout);
189  void writeToFile( const std::string& FileName, const std::string& DirName );
190  void PrintXML(std::ostream&);
191 
192  TH1* GetHistoLow();
193  TH1* GetHistoHigh();
194  void SetHistoLow( TH1* Low ) { fhLow = Low; }
195  void SetHistoHigh( TH1* High ) { fhHigh = High; }
196 
197  protected:
198 
199  std::string fName;
200 
201  std::string fInputFileLow;
202  std::string fHistoNameLow;
203  std::string fHistoPathLow;
204 
205  std::string fInputFileHigh;
206  std::string fHistoNameHigh;
207  std::string fHistoPathHigh;
208 
209  // The Low and High Histograms
212 
213  };
214 
215 
216  class ShapeSys {
217 
218  public:
219 
221 
222  void SetName( const std::string& Name ) { fName = Name; }
223  std::string GetName() { return fName; }
224 
225  void SetInputFile( const std::string& InputFile ) { fInputFile = InputFile; }
226  std::string GetInputFile() { return fInputFile; }
227 
228  void SetHistoName( const std::string& HistoName ) { fHistoName = HistoName; }
229  std::string GetHistoName() { return fHistoName; }
230 
231  void SetHistoPath( const std::string& HistoPath ) { fHistoPath = HistoPath; }
232  std::string GetHistoPath() { return fHistoPath; }
233 
234  void Print(std::ostream& = std::cout);
235  void PrintXML(std::ostream&);
236  void writeToFile( const std::string& FileName, const std::string& DirName );
237 
238  TH1* GetErrorHist();
239  void SetErrorHist(TH1* hError) { fhError = hError; }
240 
241  void SetConstraintType( Constraint::Type ConstrType ) { fConstraintType = ConstrType; }
243 
244  protected:
245 
246  std::string fName;
247  std::string fInputFile;
248  std::string fHistoName;
249  std::string fHistoPath;
251 
252  // The histogram holding the error
254 
255  };
256 
257 
258  class ShapeFactor {
259 
260  public:
261 
262  ShapeFactor();
263 
264  void SetName( const std::string& Name ) { fName = Name; }
265  std::string GetName() { return fName; }
266 
267  void Print(std::ostream& = std::cout);
268  void PrintXML(std::ostream&);
269  void writeToFile( const std::string& FileName, const std::string& DirName);
270 
271  void SetInitialShape(TH1* shape) { fhInitialShape = shape; }
273 
274  void SetConstant(bool constant) { fConstant = constant; }
275  bool IsConstant() { return fConstant; }
276 
278 
279  void SetInputFile( const std::string& InputFile ) {
280  fInputFile = InputFile;
281  fHasInitialShape=true;
282  }
283  std::string GetInputFile() { return fInputFile; }
284 
285  void SetHistoName( const std::string& HistoName ) {
286  fHistoName = HistoName;
287  fHasInitialShape=true;
288  }
289  std::string GetHistoName() { return fHistoName; }
290 
291  void SetHistoPath( const std::string& HistoPath ) {
292  fHistoPath = HistoPath;
293  fHasInitialShape=true;
294  }
295  std::string GetHistoPath() { return fHistoPath; }
296 
297  protected:
298  std::string fName;
299 
300  bool fConstant;
301 
302  // A histogram representing
303  // the initial shape
305  std::string fHistoName;
306  std::string fHistoPath;
307  std::string fInputFile;
309 
310  };
311 
312 
313  class StatError {
314 
315  public:
316 
318 
319  void Print(std::ostream& = std::cout);
320  void PrintXML(std::ostream&);
321  void writeToFile( const std::string& FileName, const std::string& DirName );
322 
323  void Activate( bool IsActive=true ) { fActivate = IsActive; }
324  bool GetActivate() { return fActivate; }
325 
326  void SetUseHisto( bool UseHisto=true ) { fUseHisto = UseHisto; }
327  bool GetUseHisto() { return fUseHisto; }
328 
329  void SetInputFile( const std::string& InputFile ) { fInputFile = InputFile; }
330  std::string GetInputFile() { return fInputFile; }
331 
332  void SetHistoName( const std::string& HistoName ) { fHistoName = HistoName; }
333  std::string GetHistoName() { return fHistoName; }
334 
335  void SetHistoPath( const std::string& HistoPath ) { fHistoPath = HistoPath; }
336  std::string GetHistoPath() { return fHistoPath; }
337 
338 
339  TH1* GetErrorHist();
341 
342  protected:
343 
344  bool fActivate;
345  bool fUseHisto; // Use an external histogram for the errors
346  std::string fInputFile;
347  std::string fHistoName;
348  std::string fHistoPath;
349 
350  // The histogram holding the error
352 
353  };
354 
356 
357  public:
358 
360  void Print(std::ostream& = std::cout);
361  void PrintXML(std::ostream&);
362 
363  void SetRelErrorThreshold( double Threshold ) { fRelErrorThreshold = Threshold; }
365 
366  void SetConstraintType( Constraint::Type ConstrType ) { fConstraintType = ConstrType; }
368 
369  protected:
370 
373 
374  };
375 
376 
377 }
378 }
379 
380 #endif
void SetName(const std::string &Name)
Definition: Systematics.h:51
void SetConstraintType(Constraint::Type ConstrType)
Definition: Systematics.h:241
void SetHistoNameHigh(const std::string &HistoNameHigh)
Definition: Systematics.h:131
void Print(std::ostream &=std::cout)
void PrintXML(std::ostream &)
void SetHistoPathLow(const std::string &HistoPathLow)
Definition: Systematics.h:182
void SetHistoPathHigh(const std::string &HistoPathHigh)
Definition: Systematics.h:137
void Print(std::ostream &=std::cout)
void SetConstraintType(Constraint::Type ConstrType)
Definition: Systematics.h:366
Type GetType(const std::string &Name)
Definition: Systematics.cxx:34
void SetConstant(bool constant)
Definition: Systematics.h:274
ClassImp(TIterator) Bool_t TIterator return false
Compare two iterator objects.
Definition: TIterator.cxx:20
void SetHistoPath(const std::string &HistoPath)
Definition: Systematics.h:291
void SetInputFileLow(const std::string &InputFileLow)
Definition: Systematics.h:124
void writeToFile(const std::string &FileName, const std::string &DirName)
void Error(const char *location, const char *msgfmt,...)
void Print(std::ostream &=std::cout)
void PrintXML(std::ostream &)
Definition: Systematics.cxx:87
void SetHistoNameLow(const std::string &HistoNameLow)
Definition: Systematics.h:176
void SetHistoPathLow(const std::string &HistoPathLow)
Definition: Systematics.h:136
void Print(std::ostream &=std::cout)
void SetName(const std::string &Name)
Definition: Systematics.h:76
void SetHistoName(const std::string &HistoName)
Definition: Systematics.h:228
void writeToFile(const std::string &FileName, const std::string &DirName)
void SetName(const std::string &Name)
Definition: Systematics.h:264
void SetName(const std::string &Name)
Definition: Systematics.h:167
void SetConst(bool Const=true)
Definition: Systematics.h:82
void SetHistoName(const std::string &HistoName)
Definition: Systematics.h:332
void SetInputFileLow(const std::string &InputFileLow)
Definition: Systematics.h:170
void SetHistoNameLow(const std::string &HistoNameLow)
Definition: Systematics.h:130
void Print(std::ostream &=std::cout)
Definition: Systematics.cxx:80
void writeToFile(const std::string &FileName, const std::string &DirName)
void SetHistoPathHigh(const std::string &HistoPathHigh)
Definition: Systematics.h:183
HistoSys(const std::string &Name)
Definition: Systematics.h:109
void SetHistoPath(const std::string &HistoPath)
Definition: Systematics.h:335
void Activate(bool IsActive=true)
Definition: Systematics.h:323
void PrintXML(std::ostream &)
Definition: Systematics.cxx:70
void Print(std::ostream &=std::cout)
Definition: Systematics.cxx:61
void SetHistoNameHigh(const std::string &HistoNameHigh)
Definition: Systematics.h:177
Namespace for the RooStats classes.
Definition: Asimov.h:20
Constraint::Type fConstraintType
Definition: Systematics.h:250
Constraint::Type GetConstraintType()
Definition: Systematics.h:242
int type
Definition: TGX11.cxx:120
void PrintXML(std::ostream &)
The TH1 histogram class.
Definition: TH1.h:80
void SetName(const std::string &Name)
Definition: Systematics.h:121
void SetHistoName(const std::string &HistoName)
Definition: Systematics.h:285
std::string Name(Type type)
Definition: Systematics.cxx:27
void writeToFile(const std::string &FileName, const std::string &DirName)
void writeToFile(const std::string &FileName, const std::string &DirName)
#define NULL
Definition: Rtypes.h:82
void SetUseHisto(bool UseHisto=true)
Definition: Systematics.h:326
void SetHistoPath(const std::string &HistoPath)
Definition: Systematics.h:231
void Print(std::ostream &=std::cout)
void SetInputFile(const std::string &InputFile)
Definition: Systematics.h:279
void SetName(const std::string &Name)
Definition: Systematics.h:222
void PrintXML(std::ostream &)
void SetRelErrorThreshold(double Threshold)
Definition: Systematics.h:363
void SetErrorHist(TH1 *hError)
Definition: Systematics.h:239
void SetInputFile(const std::string &InputFile)
Definition: Systematics.h:225
void SetInputFileHigh(const std::string &InputFileHigh)
Definition: Systematics.h:125
void Print(std::ostream &=std::cout)
void SetInputFile(const std::string &InputFile)
Definition: Systematics.h:329
void SetInputFileHigh(const std::string &InputFileHigh)
Definition: Systematics.h:171