Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
Systematics.cxx
Go to the documentation of this file.
1// @(#)root/roostats:$Id$
2// Author: Kyle Cranmer, George Lewis
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////////////////////////////////////////////////////////////////////////////////
12
13/*
14BEGIN_HTML
15<p>
16</p>
17END_HTML
18*/
19//
20
21
24
25
26// Constraints
28
29 if( type == Constraint::Gaussian ) return "Gaussian";
30 if( type == Constraint::Poisson ) return "Poisson";
31 return "";
32}
33
35
36 if( Name.empty() ) {
37 std::cout << "Error: Given empty name for ConstraintType" << std::endl;
38 throw hf_exc();
39 }
40
41 else if ( Name == "Gaussian" || Name == "Gauss" ) {
42 return Constraint::Gaussian;
43 }
44
45 else if ( Name == "Poisson" || Name == "Pois" ) {
46 return Constraint::Poisson;
47 }
48
49 else {
50 std::cout << "Error: Unknown name given for Constraint Type: " << Name << std::endl;
51 throw hf_exc();
52 }
53
54}
55
56// Norm Factor
58 fLow(1.0), fHigh(1.0) {}
59
60void RooStats::HistFactory::NormFactor::Print( std::ostream& stream ) const {
61 stream << "\t \t Name: " << fName
62 << "\t Val: " << fVal
63 << "\t Low: " << fLow
64 << "\t High: " << fHigh
65 << std::endl;
66}
67
68void RooStats::HistFactory::NormFactor::PrintXML( std::ostream& xml ) const {
69 xml << " <NormFactor Name=\"" << GetName() << "\" "
70 << " Val=\"" << GetVal() << "\" "
71 << " High=\"" << GetHigh() << "\" "
72 << " Low=\"" << GetLow() << "\" "
73 << " /> " << std::endl;
74}
75
76// Overall Sys
77void RooStats::HistFactory::OverallSys::Print( std::ostream& stream ) const {
78 stream << "\t \t Name: " << fName
79 << "\t Low: " << fLow
80 << "\t High: " << fHigh
81 << std::endl;
82}
83
84void RooStats::HistFactory::OverallSys::PrintXML( std::ostream& xml ) const {
85 xml << " <OverallSys Name=\"" << GetName() << "\" "
86 << " High=\"" << GetHigh() << "\" "
87 << " Low=\"" << GetLow() << "\" "
88 << " /> " << std::endl;
89}
90
91
93 stream << "\t \t Name: " << fName
94 << "\t HistoFileLow: " << fInputFileLow
95 << "\t HistoNameLow: " << fHistoNameLow
96 << "\t HistoPathLow: " << fHistoPathLow
97 << "\t HistoFileHigh: " << fInputFileHigh
98 << "\t HistoNameHigh: " << fHistoNameHigh
99 << "\t HistoPathHigh: " << fHistoPathHigh
100 << std::endl;
101}
102
104 const std::string& DirName ) {
105
106 // This saves the histograms to a file and
107 // changes the name of the local file and histograms
108
109 auto histLow = GetHistoLow();
110 if( histLow==nullptr ) {
111 std::cout << "Error: Cannot write " << GetName()
112 << " to file: " << FileName
113 << " HistoLow is nullptr"
114 << std::endl;
115 throw hf_exc();
116 }
117 histLow->Write();
118 fInputFileLow = FileName;
119 fHistoPathLow = DirName;
120 fHistoNameLow = histLow->GetName();
121
122 auto histHigh = GetHistoHigh();
123 if( histHigh==nullptr ) {
124 std::cout << "Error: Cannot write " << GetName()
125 << " to file: " << FileName
126 << " HistoHigh is nullptr"
127 << std::endl;
128 throw hf_exc();
129 }
130 histHigh->Write();
131 fInputFileHigh = FileName;
132 fHistoPathHigh = DirName;
133 fHistoNameHigh = histHigh->GetName();
134
135 return;
136
137}
138
139
140void RooStats::HistFactory::HistoSys::PrintXML( std::ostream& xml ) const {
141 xml << " <HistoSys Name=\"" << GetName() << "\" "
142 << " HistoFileLow=\"" << GetInputFileLow() << "\" "
143 << " HistoNameLow=\"" << GetHistoNameLow() << "\" "
144 << " HistoPathLow=\"" << GetHistoPathLow() << "\" "
145
146 << " HistoFileHigh=\"" << GetInputFileHigh() << "\" "
147 << " HistoNameHigh=\"" << GetHistoNameHigh() << "\" "
148 << " HistoPathHigh=\"" << GetHistoPathHigh() << "\" "
149 << " /> " << std::endl;
150}
151
152// Shape Sys
153
154void RooStats::HistFactory::ShapeSys::Print( std::ostream& stream ) const {
155 stream << "\t \t Name: " << fName
156 << "\t InputFile: " << fInputFileHigh
157 << "\t HistoName: " << fHistoNameHigh
158 << "\t HistoPath: " << fHistoPathHigh
159 << std::endl;
160}
161
162
163void RooStats::HistFactory::ShapeSys::PrintXML( std::ostream& xml ) const {
164 xml << " <ShapeSys Name=\"" << GetName() << "\" "
165 << " InputFile=\"" << GetInputFile() << "\" "
166 << " HistoName=\"" << GetHistoName() << "\" "
167 << " HistoPath=\"" << GetHistoPath() << "\" "
168 << " ConstraintType=\"" << std::string(Constraint::Name(GetConstraintType())) << "\" "
169 << " /> " << std::endl;
170}
171
172
173void RooStats::HistFactory::ShapeSys::writeToFile( const std::string& FileName,
174 const std::string& DirName ) {
175
176 auto histError = GetErrorHist();
177 if( histError==nullptr ) {
178 std::cout << "Error: Cannot write " << GetName()
179 << " to file: " << FileName
180 << " ErrorHist is nullptr"
181 << std::endl;
182 throw hf_exc();
183 }
184 histError->Write();
185 fInputFileHigh = FileName;
186 fHistoPathHigh = DirName;
187 fHistoNameHigh = histError->GetName();
188
189 return;
190
191}
192
193
194
195
196// HistoFactor
197
198void RooStats::HistFactory::HistoFactor::PrintXML( std::ostream& xml ) const {
199 xml << " <HistoFactor Name=\"" << GetName() << "\" "
200
201 << " InputFileLow=\"" << GetInputFileLow() << "\" "
202 << " HistoNameLow=\"" << GetHistoNameLow() << "\" "
203 << " HistoPathLow=\"" << GetHistoPathLow() << "\" "
204
205 << " InputFileHigh=\"" << GetInputFileHigh() << "\" "
206 << " HistoNameHigh=\"" << GetHistoNameHigh() << "\" "
207 << " HistoPathHigh=\"" << GetHistoPathHigh() << "\" "
208 << " /> " << std::endl;
209}
210
211
212// Shape Factor
213void RooStats::HistFactory::ShapeFactor::Print( std::ostream& stream ) const {
214
215 stream << "\t \t Name: " << fName << std::endl;
216
217 if( !fHistoNameHigh.empty() ) {
218 stream << "\t \t "
219 << " Shape Hist Name: " << fHistoNameHigh
220 << " Shape Hist Path Name: " << fHistoPathHigh
221 << " Shape Hist FileName: " << fInputFileHigh
222 << std::endl;
223 }
224
225 if( fConstant ) { stream << "\t \t ( Constant ): " << std::endl; }
226
227}
228
229
230void RooStats::HistFactory::ShapeFactor::writeToFile( const std::string& FileName,
231 const std::string& DirName ) {
232
233 if( HasInitialShape() ) {
234 auto histInitialShape = GetInitialShape();
235 if( histInitialShape==nullptr ) {
236 std::cout << "Error: Cannot write " << GetName()
237 << " to file: " << FileName
238 << " InitialShape is nullptr"
239 << std::endl;
240 throw hf_exc();
241 }
242 histInitialShape->Write();
243 fInputFileHigh = FileName;
244 fHistoPathHigh = DirName;
245 fHistoNameHigh = histInitialShape->GetName();
246 }
247
248 return;
249
250}
251
252
253void RooStats::HistFactory::ShapeFactor::PrintXML( std::ostream& xml ) const {
254 xml << " <ShapeFactor Name=\"" << GetName() << "\" ";
255 if( fHasInitialShape ) {
256 xml << " InputFile=\"" << GetInputFile() << "\" "
257 << " HistoName=\"" << GetHistoName() << "\" "
258 << " HistoPath=\"" << GetHistoPath() << "\" ";
259 }
260 xml << " /> " << std::endl;
261}
262
263
264// Stat Error Config
265void RooStats::HistFactory::StatErrorConfig::Print( std::ostream& stream ) const {
266 stream << "\t \t RelErrorThreshold: " << fRelErrorThreshold
267 << "\t ConstraintType: " << Constraint::Name( fConstraintType )
268 << std::endl;
269}
270
272 xml << " <StatErrorConfig RelErrorThreshold=\"" << GetRelErrorThreshold()
273 << "\" "
274 << "ConstraintType=\"" << Constraint::Name( GetConstraintType() )
275 << "\" "
276 << "/> " << std::endl << std::endl;
277
278}
279
280
281// Stat Error
282void RooStats::HistFactory::StatError::Print( std::ostream& stream ) const {
283 stream << "\t \t Activate: " << fActivate
284 << "\t InputFile: " << fInputFileHigh
285 << "\t HistoName: " << fHistoNameHigh
286 << "\t histoPath: " << fHistoPathHigh
287 << std::endl;
288}
289
290void RooStats::HistFactory::StatError::PrintXML( std::ostream& xml ) const {
291
292 if( GetActivate() ) {
293 xml << " <StatError Activate=\""
294 << (GetActivate() ? std::string("True") : std::string("False"))
295 << "\" "
296 << " InputFile=\"" << GetInputFile() << "\" "
297 << " HistoName=\"" << GetHistoName() << "\" "
298 << " HistoPath=\"" << GetHistoPath() << "\" "
299 << " /> " << std::endl;
300 }
301
302}
303
304
305void RooStats::HistFactory::StatError::writeToFile( const std::string& OutputFileName,
306 const std::string& DirName ) {
307
308 if( fUseHisto ) {
309
310 std::string statErrorHistName = "statisticalErrors";
311
312 auto hStatError = GetErrorHist();
313 if( hStatError == nullptr ) {
314 std::cout << "Error: Stat Error error hist is nullptr" << std::endl;
315 throw hf_exc();
316 }
317 hStatError->Write(statErrorHistName.c_str());
318
319 fInputFileHigh = OutputFileName;
320 fHistoNameHigh = statErrorHistName;
321 fHistoPathHigh = DirName;
322
323 }
324
325 return;
326
327}
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
void PrintXML(std::ostream &) const override
void PrintXML(std::ostream &) const override
virtual void writeToFile(const std::string &FileName, const std::string &DirName)
virtual void Print(std::ostream &=std::cout) const
void Print(std::ostream &=std::cout) const
void PrintXML(std::ostream &) const
void PrintXML(std::ostream &) const
void Print(std::ostream &=std::cout) const
void PrintXML(std::ostream &) const override
void writeToFile(const std::string &FileName, const std::string &DirName) override
void Print(std::ostream &=std::cout) const override
void PrintXML(std::ostream &) const override
void writeToFile(const std::string &FileName, const std::string &DirName) override
void Print(std::ostream &=std::cout) const override
void PrintXML(std::ostream &) const
void Print(std::ostream &=std::cout) const
void Print(std::ostream &=std::cout) const override
void PrintXML(std::ostream &) const override
void writeToFile(const std::string &FileName, const std::string &DirName) override
Type GetType(const std::string &Name)
std::string Name(Type type)