Logo ROOT   6.12/07
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  /// constructor from name, file and path. Name of the histogram should not include the path
36  Sample(std::string Name, std::string HistoName, std::string InputFile, std::string HistoPath="");
37  ~Sample();
38 
39  void Print(std::ostream& = std::cout);
40  void PrintXML( std::ofstream& xml );
41  void writeToFile( std::string FileName, std::string DirName );
42 
43  TH1* GetHisto();
44  // set histogram for this sample
45  void SetHisto( TH1* histo ) { fhNominal = histo; fHistoName=histo->GetName(); }
46  void SetValue( Double_t 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 separatly
51 
52  void ActivateStatError();
53  void ActivateStatError( std::string HistoName, std::string InputFile, std::string HistoPath="" );
54 
55  void AddOverallSys( std::string Name, Double_t Low, Double_t High );
56  void AddOverallSys( const OverallSys& Sys );
57 
58  void AddNormFactor( std::string Name, Double_t Val, Double_t Low, Double_t High, bool Const=false );
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() { 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() { 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() { return fHistoName; }
93  // set histogram name
94  void SetHistoName(const std::string& HistoName) { fHistoName = HistoName; }
95 
96  // get histogram path
97  std::string GetHistoPath() { 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() { 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 
111  std::vector< RooStats::HistFactory::HistoSys >& GetHistoSysList() { return fHistoSysList; }
112  std::vector< RooStats::HistFactory::HistoFactor >& GetHistoFactorList() { return fHistoFactorList; }
113 
114  std::vector< RooStats::HistFactory::ShapeSys >& GetShapeSysList() { return fShapeSysList; }
115  std::vector< RooStats::HistFactory::ShapeFactor >& GetShapeFactorList() { return fShapeFactorList; }
116 
119 
120 
121 protected:
122 
123  std::string fName;
124  std::string fInputFile;
125  std::string fHistoName;
126  std::string fHistoPath;
127 
128  // The Name of the parent channel
129  std::string fChannelName;
130 
131  //
132  // Systematics
133  //
134 
135  std::vector< RooStats::HistFactory::OverallSys > fOverallSysList;
136  std::vector< RooStats::HistFactory::NormFactor > fNormFactorList;
137 
138  std::vector< RooStats::HistFactory::HistoSys > fHistoSysList;
139  std::vector< RooStats::HistFactory::HistoFactor > fHistoFactorList;
140 
141  std::vector< RooStats::HistFactory::ShapeSys > fShapeSysList;
142  std::vector< RooStats::HistFactory::ShapeFactor > fShapeFactorList;
143 
144 
145  // Properties
147 
150 
151 
152  // The Nominal Shape
155 
156 };
157 
158 
159 } // namespace HistFactory
160 } // namespace RooStats
161 
162 #endif
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:47
RooStats::HistFactory::StatError & GetStatError()
Definition: Sample.h:117
std::string GetChannelName()
Definition: Sample.h:102
void ActivateStatError()
Note that histogram name should not include the path of the histogram in the file.
Definition: Sample.cxx:293
std::vector< RooStats::HistFactory::NormFactor > & GetNormFactorList()
Definition: Sample.h:109
std::string GetHistoPath()
Definition: Sample.h:97
std::vector< RooStats::HistFactory::ShapeFactor > fShapeFactorList
Definition: Sample.h:142
void SetHistoName(const std::string &HistoName)
Definition: Sample.h:94
std::vector< RooStats::HistFactory::NormFactor > fNormFactorList
Definition: Sample.h:136
void SetNormalizeByTheory(bool norm)
Definition: Sample.h:76
RooStats::HistFactory::StatError fStatError
Definition: Sample.h:146
std::vector< RooStats::HistFactory::HistoSys > & GetHistoSysList()
Definition: Sample.h:111
const char * Name
Definition: TXMLSetup.cxx:66
void SetStatError(RooStats::HistFactory::StatError Error)
Definition: Sample.h:118
void AddShapeFactor(std::string Name)
Definition: Sample.cxx:395
std::vector< RooStats::HistFactory::HistoFactor > fHistoFactorList
Definition: Sample.h:139
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:372
void SetChannelName(const std::string &ChannelName)
Definition: Sample.h:104
std::string GetInputFile()
Definition: Sample.h:87
void AddShapeSys(std::string Name, Constraint::Type ConstraintType, std::string HistoName, std::string HistoFile, std::string HistoPath="")
Definition: Sample.cxx:409
void Print(std::ostream &=std::cout)
Definition: Sample.cxx:139
std::string GetName()
Definition: Sample.h:82
void Error(const char *location, const char *msgfmt,...)
void writeToFile(std::string FileName, std::string DirName)
Definition: Sample.cxx:80
void SetValue(Double_t Val)
Definition: Sample.cxx:115
void SetName(const std::string &Name)
Definition: Sample.h:84
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:348
std::vector< RooStats::HistFactory::ShapeSys > & GetShapeSysList()
Definition: Sample.h:114
void SetInputFile(const std::string &InputFile)
Definition: Sample.h:89
std::vector< RooStats::HistFactory::HistoFactor > & GetHistoFactorList()
Definition: Sample.h:112
std::vector< RooStats::HistFactory::ShapeSys > fShapeSysList
Definition: Sample.h:141
std::vector< RooStats::HistFactory::OverallSys > & GetOverallSysList()
Definition: Sample.h:108
void AddOverallSys(std::string Name, Double_t Low, Double_t High)
Definition: Sample.cxx:314
void AddNormFactor(std::string Name, Double_t Val, Double_t Low, Double_t High, bool Const=false)
Definition: Sample.cxx:329
Namespace for the RooStats classes.
Definition: Asimov.h:20
void SetHistoPath(const std::string &HistoPath)
Definition: Sample.h:99
double Double_t
Definition: RtypesCore.h:55
The TH1 histogram class.
Definition: TH1.h:56
std::vector< RooStats::HistFactory::OverallSys > fOverallSysList
Definition: Sample.h:135
std::string GetHistoName()
Definition: Sample.h:92
void SetHisto(TH1 *histo)
Definition: Sample.h:45
std::vector< RooStats::HistFactory::HistoSys > fHistoSysList
Definition: Sample.h:138
void PrintXML(std::ofstream &xml)
Definition: Sample.cxx:179
std::vector< RooStats::HistFactory::ShapeFactor > & GetShapeFactorList()
Definition: Sample.h:115