11 #ifndef HISTFACTORY_SYSTEMATICS_H
12 #define HISTFACTORY_SYSTEMATICS_H
22 namespace HistFactory {
24 namespace Constraint {
25 enum Type{ Gaussian, Poisson };
26 std::string Name( Type type );
27 Type GetType(
const std::string& Name );
53 OverallSys() : fLow(0), fHigh(0) {}
55 void SetName(
const std::string& Name ) { fName = Name; }
56 std::string GetName()
const {
return fName; }
58 void SetLow(
double Low ) { fLow = Low; }
59 void SetHigh(
double High ) { fHigh = High; }
60 double GetLow()
const {
return fLow; }
61 double GetHigh()
const {
return fHigh; }
63 void Print(std::ostream& = std::cout)
const;
64 void PrintXML(std::ostream&)
const;
83 void SetName(
const std::string& Name ) { fName = Name; }
84 std::string GetName()
const {
return fName; }
86 void SetVal(
double Val ) { fVal = Val; }
87 double GetVal()
const {
return fVal; }
89 void SetConst(
bool Const=
true ) { fConst = Const; }
90 bool GetConst()
const {
return fConst; }
92 void SetLow(
double Low ) { fLow = Low; }
93 void SetHigh(
double High ) { fHigh = High; }
94 double GetLow()
const {
return fLow; }
95 double GetHigh()
const {
return fHigh; }
97 void Print(std::ostream& = std::cout)
const;
98 void PrintXML(std::ostream&)
const;
117 class HistogramUncertaintyBase {
121 HistogramUncertaintyBase() : fhLow(nullptr), fhHigh(nullptr) {}
122 HistogramUncertaintyBase(
const std::string& Name) : fName(Name), fhLow(nullptr), fhHigh(nullptr) {}
123 HistogramUncertaintyBase(
const HistogramUncertaintyBase& oth) :
125 fInputFileLow{oth.fInputFileLow}, fHistoNameLow{oth.fHistoNameLow}, fHistoPathLow{oth.fHistoPathLow},
126 fInputFileHigh{oth.fInputFileHigh}, fHistoNameHigh{oth.fHistoNameHigh}, fHistoPathHigh{oth.fHistoPathHigh},
127 fhLow{oth.fhLow ?
static_cast<TH1*
>(oth.fhLow->Clone()) :
nullptr},
128 fhHigh{oth.fhHigh ?
static_cast<TH1*
>(oth.fhHigh->Clone()) :
nullptr} {
131 HistogramUncertaintyBase(HistogramUncertaintyBase&&) =
default;
133 virtual ~HistogramUncertaintyBase() {};
137 HistogramUncertaintyBase& operator=(
const HistogramUncertaintyBase& oth) {
139 fInputFileLow = oth.fInputFileLow;
140 fHistoNameLow = oth.fHistoNameLow;
141 fHistoPathLow = oth.fHistoPathLow;
142 fInputFileHigh = oth.fInputFileHigh;
143 fHistoNameHigh = oth.fHistoNameHigh;
144 fHistoPathHigh = oth.fHistoPathHigh;
145 fhLow.reset(oth.fhLow ? static_cast<TH1*>(oth.fhLow->Clone()) :
nullptr);
146 fhHigh.reset(oth.fhHigh ? static_cast<TH1*>(oth.fhHigh->Clone()) :
nullptr);
150 HistogramUncertaintyBase& operator=(HistogramUncertaintyBase&&) =
default;
152 virtual void Print(std::ostream& = std::cout)
const;
153 virtual void PrintXML(std::ostream&)
const = 0;
154 virtual void writeToFile(
const std::string& FileName,
const std::string& DirName );
156 void SetHistoLow(TH1* Low ) {Low->SetDirectory(
nullptr); fhLow.reset(Low);}
157 void SetHistoHigh(TH1* High ) {High->SetDirectory(
nullptr); fhHigh.reset(High);}
159 const TH1* GetHistoLow()
const {
return fhLow.get();}
160 const TH1* GetHistoHigh()
const {
return fhHigh.get();}
162 void SetName(
const std::string& Name ) { fName = Name; }
163 const std::string& GetName()
const {
return fName; }
165 void SetInputFileLow(
const std::string& InputFileLow ) { fInputFileLow = InputFileLow; }
166 void SetInputFileHigh(
const std::string& InputFileHigh ) { fInputFileHigh = InputFileHigh; }
168 const std::string& GetInputFileLow()
const {
return fInputFileLow; }
169 const std::string& GetInputFileHigh()
const {
return fInputFileHigh; }
171 void SetHistoNameLow(
const std::string& HistoNameLow ) { fHistoNameLow = HistoNameLow; }
172 void SetHistoNameHigh(
const std::string& HistoNameHigh ) { fHistoNameHigh = HistoNameHigh; }
174 const std::string& GetHistoNameLow()
const {
return fHistoNameLow; }
175 const std::string& GetHistoNameHigh()
const {
return fHistoNameHigh; }
177 void SetHistoPathLow(
const std::string& HistoPathLow ) { fHistoPathLow = HistoPathLow; }
178 void SetHistoPathHigh(
const std::string& HistoPathHigh ) { fHistoPathHigh = HistoPathHigh; }
180 const std::string& GetHistoPathLow()
const {
return fHistoPathLow; }
181 const std::string& GetHistoPathHigh()
const {
return fHistoPathHigh; }
187 std::string fInputFileLow;
188 std::string fHistoNameLow;
189 std::string fHistoPathLow;
191 std::string fInputFileHigh;
192 std::string fHistoNameHigh;
193 std::string fHistoPathHigh;
196 std::unique_ptr<TH1> fhLow;
197 std::unique_ptr<TH1> fhHigh;
205 class HistoSys final :
public HistogramUncertaintyBase {
207 virtual ~HistoSys() {}
208 virtual void PrintXML(std::ostream&)
const override;
215 class HistoFactor final :
public HistogramUncertaintyBase {
217 virtual ~HistoFactor() {}
218 void PrintXML(std::ostream&)
const override;
225 class ShapeSys final :
public HistogramUncertaintyBase {
230 HistogramUncertaintyBase(),
231 fConstraintType(Constraint::Gaussian) {}
232 ShapeSys(
const ShapeSys& other) :
233 HistogramUncertaintyBase(other),
234 fConstraintType(other.fConstraintType) {}
236 void SetInputFile(
const std::string& InputFile ) { fInputFileHigh = InputFile; }
237 std::string GetInputFile()
const {
return fInputFileHigh; }
239 void SetHistoName(
const std::string& HistoName ) { fHistoNameHigh = HistoName; }
240 std::string GetHistoName()
const {
return fHistoNameHigh; }
242 void SetHistoPath(
const std::string& HistoPath ) { fHistoPathHigh = HistoPath; }
243 std::string GetHistoPath()
const {
return fHistoPathHigh; }
245 void Print(std::ostream& = std::cout)
const override;
246 void PrintXML(std::ostream&)
const override;
247 void writeToFile(
const std::string& FileName,
const std::string& DirName )
override;
249 const TH1* GetErrorHist()
const {
252 void SetErrorHist(TH1* hError) {
253 fhHigh.reset(hError);
256 void SetConstraintType( Constraint::Type ConstrType ) { fConstraintType = ConstrType; }
257 Constraint::Type GetConstraintType()
const {
return fConstraintType; }
260 Constraint::Type fConstraintType;
267 class ShapeFactor :
public HistogramUncertaintyBase {
272 HistogramUncertaintyBase(),
274 fHasInitialShape{
false} {}
276 void Print(std::ostream& = std::cout)
const override;
277 void PrintXML(std::ostream&)
const override;
278 void writeToFile(
const std::string& FileName,
const std::string& DirName)
override;
280 void SetInitialShape(TH1* shape) {
283 const TH1* GetInitialShape()
const {
return fhHigh.get(); }
285 void SetConstant(
bool constant) { fConstant = constant; }
286 bool IsConstant()
const {
return fConstant; }
288 bool HasInitialShape()
const {
return fHasInitialShape; }
290 void SetInputFile(
const std::string& InputFile ) {
291 fInputFileHigh = InputFile;
292 fHasInitialShape=
true;
294 const std::string& GetInputFile()
const {
return fInputFileHigh; }
296 void SetHistoName(
const std::string& HistoName ) {
297 fHistoNameHigh = HistoName;
298 fHasInitialShape=
true;
300 const std::string& GetHistoName()
const {
return fHistoNameHigh; }
302 void SetHistoPath(
const std::string& HistoPath ) {
303 fHistoPathHigh = HistoPath;
304 fHasInitialShape=
true;
306 const std::string& GetHistoPath()
const {
return fHistoPathHigh; }
314 bool fHasInitialShape;
321 class StatError :
public HistogramUncertaintyBase {
326 HistogramUncertaintyBase(),
327 fActivate(false), fUseHisto(false) {}
329 void Print(std::ostream& = std::cout)
const override;
330 void PrintXML(std::ostream&)
const override;
331 void writeToFile(
const std::string& FileName,
const std::string& DirName )
override;
333 void Activate(
bool IsActive=
true ) { fActivate = IsActive; }
334 bool GetActivate()
const {
return fActivate; }
336 void SetUseHisto(
bool UseHisto=
true ) { fUseHisto = UseHisto; }
337 bool GetUseHisto()
const {
return fUseHisto; }
339 void SetInputFile(
const std::string& InputFile ) { fInputFileHigh = InputFile; }
340 const std::string& GetInputFile()
const {
return fInputFileHigh; }
342 void SetHistoName(
const std::string& HistoName ) { fHistoNameHigh = HistoName; }
343 const std::string& GetHistoName()
const {
return fHistoNameHigh; }
345 void SetHistoPath(
const std::string& HistoPath ) { fHistoPathHigh = HistoPath; }
346 const std::string& GetHistoPath()
const {
return fHistoPathHigh; }
349 const TH1* GetErrorHist()
const {
352 void SetErrorHist(TH1* Error) {
367 class StatErrorConfig {
371 StatErrorConfig() : fRelErrorThreshold( .05 ), fConstraintType( Constraint::Gaussian ) {;}
372 void Print(std::ostream& = std::cout)
const;
373 void PrintXML(std::ostream&)
const;
375 void SetRelErrorThreshold(
double Threshold ) { fRelErrorThreshold = Threshold; }
376 double GetRelErrorThreshold()
const {
return fRelErrorThreshold; }
378 void SetConstraintType( Constraint::Type ConstrType ) { fConstraintType = ConstrType; }
379 Constraint::Type GetConstraintType()
const {
return fConstraintType; }
383 double fRelErrorThreshold;
384 Constraint::Type fConstraintType;