Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
Measurement.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_MEASUREMENT_H
12#define HISTFACTORY_MEASUREMENT_H
13
14#include <TNamed.h>
15
16#include <fstream>
17#include <iostream>
18#include <map>
19#include <memory>
20#include <string>
21#include <vector>
22
23class TFile;
24class TH1;
25
26class RooWorkspace;
27
28namespace RooStats::HistFactory {
29
30namespace Constraint {
31
36std::string Name(Type type);
37Type GetType(const std::string &Name);
38
39} // namespace Constraint
40
41/** \class OverallSys
42 * \ingroup HistFactory
43 * Configuration for a constrained overall systematic to scale sample normalisations.
44 */
46
47public:
48 void SetName(const std::string &Name) { fName = Name; }
49 const std::string &GetName() const { return fName; }
50
51 void SetLow(double Low) { fLow = Low; }
52 void SetHigh(double High) { fHigh = High; }
53 double GetLow() const { return fLow; }
54 double GetHigh() const { return fHigh; }
55
56 void Print(std::ostream & = std::cout) const;
57 void PrintXML(std::ostream &) const;
58
59protected:
60 std::string fName;
61 double fLow = 0.0;
62 double fHigh = 0.0;
63};
64
65/** \class NormFactor
66 * \ingroup HistFactory
67 * Configuration for an \a un- constrained overall systematic to scale sample normalisations.
68 */
70
71public:
72 void SetName(const std::string &Name) { fName = Name; }
73 std::string GetName() const { return fName; }
74
75 void SetVal(double Val) { fVal = Val; }
76 double GetVal() const { return fVal; }
77
78 void SetLow(double Low) { fLow = Low; }
79 void SetHigh(double High) { fHigh = High; }
80 double GetLow() const { return fLow; }
81 double GetHigh() const { return fHigh; }
82
83 void Print(std::ostream & = std::cout) const;
84 void PrintXML(std::ostream &) const;
85
86protected:
87 std::string fName;
88 double fVal = 1.0;
89 double fLow = 1.0;
90 double fHigh = 1.0;
91};
92
93/** ////////////////////////////////////////////////////////////////////////////////////////////
94 * \class HistogramUncertaintyBase
95 * \ingroup HistFactory
96 * Base class to store the up and down variations for histogram uncertainties.
97 * Use the derived classes for actual models.
98 */
100
101public:
103 HistogramUncertaintyBase(const std::string &Name);
106
108
109 // Need deep copies because the class owns its histograms.
112
113 virtual void Print(std::ostream & = std::cout) const;
114 virtual void PrintXML(std::ostream &) const = 0;
115 virtual void writeToFile(const std::string &FileName, const std::string &DirName);
116
117 void SetHistoLow(TH1 *Low);
118 void SetHistoHigh(TH1 *High);
119
120 const TH1 *GetHistoLow() const { return fhLow.get(); }
121 const TH1 *GetHistoHigh() const { return fhHigh.get(); }
122
123 void SetName(const std::string &Name) { fName = Name; }
124 const std::string &GetName() const { return fName; }
125
128
129 const std::string &GetInputFileLow() const { return fInputFileLow; }
130 const std::string &GetInputFileHigh() const { return fInputFileHigh; }
131
134
135 const std::string &GetHistoNameLow() const { return fHistoNameLow; }
136 const std::string &GetHistoNameHigh() const { return fHistoNameHigh; }
137
140
141 const std::string &GetHistoPathLow() const { return fHistoPathLow; }
142 const std::string &GetHistoPathHigh() const { return fHistoPathHigh; }
143
144protected:
145 std::string fName;
146
147 std::string fInputFileLow;
148 std::string fHistoNameLow;
149 std::string fHistoPathLow;
150
151 std::string fInputFileHigh;
152 std::string fHistoNameHigh;
153 std::string fHistoPathHigh;
154
155 // The Low and High Histograms
156 std::unique_ptr<TH1> fhLow;
157 std::unique_ptr<TH1> fhHigh;
158};
159
160/** \class HistoSys
161 * \ingroup HistFactory
162 * Configuration for a constrained, coherent shape variation of affected samples.
163 */
165public:
166 void PrintXML(std::ostream &) const override;
167};
168
169/** \class HistoFactor
170 * \ingroup HistFactory
171 * Configuration for an *un*constrained, coherent shape variation of affected samples.
172 */
174public:
175 void PrintXML(std::ostream &) const override;
176};
177
178/** \class ShapeSys
179 * \ingroup HistFactory
180 * Constrained bin-by-bin variation of affected histogram.
181 */
183
184public:
185 ShapeSys() : fConstraintType(Constraint::Gaussian) {}
188 {
189 if (this == &oth)
190 return *this;
192 fConstraintType = oth.fConstraintType;
193 return *this;
194 }
196
197 void SetInputFile(const std::string &InputFile) { fInputFileHigh = InputFile; }
198 std::string GetInputFile() const { return fInputFileHigh; }
199
200 void SetHistoName(const std::string &HistoName) { fHistoNameHigh = HistoName; }
201 std::string GetHistoName() const { return fHistoNameHigh; }
202
203 void SetHistoPath(const std::string &HistoPath) { fHistoPathHigh = HistoPath; }
204 std::string GetHistoPath() const { return fHistoPathHigh; }
205
206 void Print(std::ostream & = std::cout) const override;
207 void PrintXML(std::ostream &) const override;
208 void writeToFile(const std::string &FileName, const std::string &DirName) override;
209
210 const TH1 *GetErrorHist() const { return fhHigh.get(); }
211 void SetErrorHist(TH1 *hError);
212
215
216protected:
218};
219
220/** \class ShapeFactor
221 * \ingroup HistFactory
222 * *Un*constrained bin-by-bin variation of affected histogram.
223 */
225
226public:
227 void Print(std::ostream & = std::cout) const override;
228 void PrintXML(std::ostream &) const override;
229 void writeToFile(const std::string &FileName, const std::string &DirName) override;
230
231 void SetInitialShape(TH1 *shape);
232 const TH1 *GetInitialShape() const { return fhHigh.get(); }
233
235 bool IsConstant() const { return fConstant; }
236
237 bool HasInitialShape() const { return fHasInitialShape; }
238
239 void SetInputFile(const std::string &InputFile)
240 {
242 fHasInitialShape = true;
243 }
244 const std::string &GetInputFile() const { return fInputFileHigh; }
245
246 void SetHistoName(const std::string &HistoName)
247 {
249 fHasInitialShape = true;
250 }
251 const std::string &GetHistoName() const { return fHistoNameHigh; }
252
253 void SetHistoPath(const std::string &HistoPath)
254 {
256 fHasInitialShape = true;
257 }
258 const std::string &GetHistoPath() const { return fHistoPathHigh; }
259
260protected:
261 bool fConstant = false;
262
263 // A histogram representing
264 // the initial shape
265 bool fHasInitialShape = false;
266};
267
268/** \class StatError
269 * \ingroup HistFactory
270 * Statistical error of Monte Carlo predictions.
271 */
273
274public:
275 void Print(std::ostream & = std::cout) const override;
276 void PrintXML(std::ostream &) const override;
277 void writeToFile(const std::string &FileName, const std::string &DirName) override;
278
279 void Activate(bool IsActive = true) { fActivate = IsActive; }
280 bool GetActivate() const { return fActivate; }
281
282 void SetUseHisto(bool UseHisto = true) { fUseHisto = UseHisto; }
283 bool GetUseHisto() const { return fUseHisto; }
284
285 void SetInputFile(const std::string &InputFile) { fInputFileHigh = InputFile; }
286 const std::string &GetInputFile() const { return fInputFileHigh; }
287
288 void SetHistoName(const std::string &HistoName) { fHistoNameHigh = HistoName; }
289 const std::string &GetHistoName() const { return fHistoNameHigh; }
290
291 void SetHistoPath(const std::string &HistoPath) { fHistoPathHigh = HistoPath; }
292 const std::string &GetHistoPath() const { return fHistoPathHigh; }
293
294 const TH1 *GetErrorHist() const { return fhHigh.get(); }
295 void SetErrorHist(TH1 *Error);
296
297protected:
298 bool fActivate = false;
299 bool fUseHisto = false; // Use an external histogram for the errors
300};
301
302/** \class StatErrorConfig
303 * \ingroup HistFactory
304 * Configuration to automatically assign nuisance parameters for the statistical
305 * error of the Monte Carlo simulations.
306 * The default is to assign a Poisson uncertainty to a bin when its statistical uncertainty
307 * is larger than 5% of the bin content.
308 */
310
311public:
312 void Print(std::ostream & = std::cout) const;
313 void PrintXML(std::ostream &) const;
314
316 double GetRelErrorThreshold() const { return fRelErrorThreshold; }
317
320
321protected:
322 double fRelErrorThreshold = 0.05;
324};
325
326// Internal class wrapping an histogram and managing its content.
327// conveninet for dealing with histogram pointers in the
328// HistFactory class
329class HistRef {
330
331public:
332 HistRef(TH1 *h = nullptr);
333
334 HistRef(const HistRef &other);
335
337
339
342
343 TH1 *GetObject() const;
344
345 void SetObject(TH1 *h);
346
347 void operator=(TH1 *h);
348
350
351private:
352 static TH1 *CopyObject(const TH1 *h);
353 std::unique_ptr<TH1> fHist; ///< pointer to contained histogram
354};
355
356class Asimov {
357
358public:
359 Asimov(std::string Name = "") : fName(Name) {}
360
362
363 std::string GetName() { return fName; }
364 void SetName(const std::string &name) { fName = name; }
365
366 void SetFixedParam(const std::string &param, bool constant = true) { fParamsToFix[param] = constant; }
367 void SetParamValue(const std::string &param, double value) { fParamValsToSet[param] = value; }
368
369 std::map<std::string, bool> &GetParamsToFix() { return fParamsToFix; }
370 std::map<std::string, double> &GetParamsToSet() { return fParamValsToSet; }
371
372protected:
373 std::string fName;
374
375 std::map<std::string, bool> fParamsToFix;
376 std::map<std::string, double> fParamValsToSet;
377};
378
380public:
382
383 PreprocessFunction(std::string const &name, std::string const &expression, std::string const &dependents);
384
385 void Print(std::ostream & = std::cout) const;
386 void PrintXML(std::ostream &) const;
387
388 void SetName(const std::string &name) { fName = name; }
389 std::string const &GetName() const { return fName; }
390
391 void SetExpression(const std::string &expression) { fExpression = expression; }
392 std::string const &GetExpression() const { return fExpression; }
393
394 void SetDependents(const std::string &dependents) { fDependents = dependents; }
395 std::string const &GetDependents() const { return fDependents; }
396
397 std::string GetCommand() const;
398
399private:
400 std::string fName;
401 std::string fExpression;
402 std::string fDependents;
403};
404
405class Data {
406
407public:
408 // friend class Channel;
409
410 Data() {}
411 /// constructor from name, file and path. Name of the histogram should not include the path
412 Data(std::string HistoName, std::string InputFile, std::string HistoPath = "");
413
414 std::string const &GetName() const { return fName; }
415 void SetName(const std::string &name) { fName = name; }
416
417 void SetInputFile(const std::string &InputFile) { fInputFile = InputFile; }
418 std::string const &GetInputFile() const { return fInputFile; }
419
420 void SetHistoName(const std::string &HistoName) { fHistoName = HistoName; }
421 std::string const &GetHistoName() const { return fHistoName; }
422
423 void SetHistoPath(const std::string &HistoPath) { fHistoPath = HistoPath; }
424 std::string const &GetHistoPath() const { return fHistoPath; }
425
426 void Print(std::ostream & = std::cout);
427 void PrintXML(std::ostream &) const;
428 void writeToFile(std::string FileName, std::string DirName);
429
430 TH1 *GetHisto();
431 const TH1 *GetHisto() const;
432 void SetHisto(TH1 *Hist);
433
434protected:
435 std::string fName;
436
437 std::string fInputFile;
438 std::string fHistoName;
439 std::string fHistoPath;
440
441 // The Data Histogram
443};
444
445class Sample {
446
447public:
450 Sample(std::string Name);
451 Sample(const Sample &other);
452 Sample &operator=(const Sample &other);
453 /// constructor from name, file and path. Name of the histogram should not include the path
454 Sample(std::string Name, std::string HistoName, std::string InputFile, std::string HistoPath = "");
455
456 void Print(std::ostream & = std::cout) const;
457 void PrintXML(std::ofstream &xml) const;
458 void writeToFile(std::string FileName, std::string DirName);
459
460 const TH1 *GetHisto() const;
461 // set histogram for this sample
462 void SetHisto(TH1 *histo);
463 void SetValue(double Val);
464
465 // Some helper functions
466 // Note that histogram name should not include the path of the histogram in the file.
467 // This has to be given separately
468
469 void ActivateStatError();
470 void ActivateStatError(std::string HistoName, std::string InputFile, std::string HistoPath = "");
471
472 void AddOverallSys(std::string Name, double Low, double High);
473 void AddOverallSys(const OverallSys &Sys);
474
475 void AddNormFactor(std::string const &Name, double Val, double Low, double High);
476 void AddNormFactor(const NormFactor &Factor);
477
478 void AddHistoSys(std::string Name, std::string HistoNameLow, std::string HistoFileLow, std::string HistoPathLow,
479 std::string HistoNameHigh, std::string HistoFileHigh, std::string HistoPathHigh);
480 void AddHistoSys(const HistoSys &Sys);
481
482 void AddHistoFactor(std::string Name, std::string HistoNameLow, std::string HistoFileLow, std::string HistoPathLow,
483 std::string HistoNameHigh, std::string HistoFileHigh, std::string HistoPathHigh);
484 void AddHistoFactor(const HistoFactor &Factor);
485
486 void AddShapeFactor(std::string Name);
487 void AddShapeFactor(const ShapeFactor &Factor);
488
489 void AddShapeSys(std::string Name, Constraint::Type ConstraintType, std::string HistoName, std::string HistoFile,
490 std::string HistoPath = "");
491 void AddShapeSys(const ShapeSys &Sys);
492
493 /// defines whether the normalization scale with luminosity
495 /// does the normalization scale with luminosity
497
498 /// get name of sample
499 std::string GetName() const { return fName; }
500 /// set name of sample
501 void SetName(const std::string &Name) { fName = Name; }
502
503 /// get input ROOT file
504 std::string GetInputFile() const { return fInputFile; }
505 /// set input ROOT file
506 void SetInputFile(const std::string &InputFile) { fInputFile = InputFile; }
507
508 /// get histogram name
509 std::string GetHistoName() const { return fHistoName; }
510 /// set histogram name
511 void SetHistoName(const std::string &HistoName) { fHistoName = HistoName; }
512
513 /// get histogram path
514 std::string GetHistoPath() const { return fHistoPath; }
515 /// set histogram path
516 void SetHistoPath(const std::string &HistoPath) { fHistoPath = HistoPath; }
517
518 /// get name of associated channel
519 std::string GetChannelName() const { return fChannelName; }
520 /// set name of associated channel
521 void SetChannelName(const std::string &ChannelName) { fChannelName = ChannelName; }
522
523 std::vector<RooStats::HistFactory::OverallSys> &GetOverallSysList() { return fOverallSysList; }
524 std::vector<RooStats::HistFactory::NormFactor> &GetNormFactorList() { return fNormFactorList; }
525 std::vector<RooStats::HistFactory::HistoSys> &GetHistoSysList() { return fHistoSysList; }
526 std::vector<RooStats::HistFactory::HistoFactor> &GetHistoFactorList() { return fHistoFactorList; }
527 std::vector<RooStats::HistFactory::ShapeSys> &GetShapeSysList() { return fShapeSysList; }
528 std::vector<RooStats::HistFactory::ShapeFactor> &GetShapeFactorList() { return fShapeFactorList; }
529
530 const std::vector<RooStats::HistFactory::OverallSys> &GetOverallSysList() const { return fOverallSysList; }
531 const std::vector<RooStats::HistFactory::NormFactor> &GetNormFactorList() const { return fNormFactorList; }
532 const std::vector<RooStats::HistFactory::HistoSys> &GetHistoSysList() const { return fHistoSysList; }
533 const std::vector<RooStats::HistFactory::HistoFactor> &GetHistoFactorList() const { return fHistoFactorList; }
534 const std::vector<RooStats::HistFactory::ShapeSys> &GetShapeSysList() const { return fShapeSysList; }
535 const std::vector<RooStats::HistFactory::ShapeFactor> &GetShapeFactorList() const { return fShapeFactorList; }
536
537 bool HasStatError() const { return fStatErrorActivate; }
541
542protected:
543 std::string fName;
544 std::string fInputFile;
545 std::string fHistoName;
546 std::string fHistoPath;
547
548 /// The Name of the parent channel
549 std::string fChannelName;
550
551 //
552 // Systematics
553 //
554
555 std::vector<RooStats::HistFactory::OverallSys> fOverallSysList;
556 std::vector<RooStats::HistFactory::NormFactor> fNormFactorList;
557
558 std::vector<RooStats::HistFactory::HistoSys> fHistoSysList;
559 std::vector<RooStats::HistFactory::HistoFactor> fHistoFactorList;
560
561 std::vector<RooStats::HistFactory::ShapeSys> fShapeSysList;
562 std::vector<RooStats::HistFactory::ShapeFactor> fShapeFactorList;
563
564 /// Properties
566
567 bool fNormalizeByTheory = false;
568 bool fStatErrorActivate = false;
569
570 /// The Nominal Shape
572 std::unique_ptr<TH1> fhCountingHist;
573};
574
575class Channel {
576
577public:
578 friend class Measurement;
579
580 Channel() = default;
581 Channel(std::string Name, std::string InputFile = "");
582
583 /// set name of channel
584 void SetName(const std::string &Name) { fName = Name; }
585 /// get name of channel
586 std::string GetName() const { return fName; }
587 /// set name of input file containing histograms
588 void SetInputFile(const std::string &file) { fInputFile = file; }
589 /// get name of input file
590 std::string GetInputFile() const { return fInputFile; }
591 /// set path for histograms in input file
592 void SetHistoPath(const std::string &file) { fHistoPath = file; }
593 /// get path to histograms in input file
594 std::string GetHistoPath() const { return fHistoPath; }
595
596 /// set data object
598 void SetData(std::string HistoName, std::string InputFile, std::string HistoPath = "");
599 void SetData(double Val);
600 void SetData(TH1 *hData);
601 /// get data object
603 const RooStats::HistFactory::Data &GetData() const { return fData; }
604
605 /// add additional data object
607 /// retrieve vector of additional data objects
608 std::vector<RooStats::HistFactory::Data> &GetAdditionalData() { return fAdditionalData; }
609
611 void SetStatErrorConfig(double RelErrorThreshold, std::string ConstraintType);
612 /// define treatment of statistical uncertainties
614 /// get information about threshold for statistical uncertainties and constraint term
617
619 /// get vector of samples for this channel
620 std::vector<RooStats::HistFactory::Sample> &GetSamples() { return fSamples; }
621 const std::vector<RooStats::HistFactory::Sample> &GetSamples() const { return fSamples; }
622
623 void Print(std::ostream & = std::cout);
624 void PrintXML(std::string const &directory, std::string const &prefix = "") const;
625
626 void CollectHistograms();
627 bool CheckHistograms() const;
628
629protected:
630 std::string fName;
631 std::string fInputFile;
632 std::string fHistoPath;
633
635
636 /// One can add additional datasets
637 /// These are simply added to the xml under a different name
638 std::vector<RooStats::HistFactory::Data> fAdditionalData;
639
641
642 std::vector<RooStats::HistFactory::Sample> fSamples;
643
644 TH1 *GetHistogram(std::string InputFile, std::string HistoPath, std::string HistoName,
645 std::map<std::string, std::unique_ptr<TFile>> &lsof);
646};
647
648extern Channel BadChannel;
649
650class Measurement : public TNamed {
651
652public:
653 Measurement();
654 /// Measurement( const Measurement& other ); // Copy
655 Measurement(const char *Name, const char *Title = "");
656
657 /// set output prefix
658 void SetOutputFilePrefix(const std::string &prefix) { fOutputFilePrefix = prefix; }
659 /// retrieve prefix for output files
660 std::string GetOutputFilePrefix() { return fOutputFilePrefix; }
661
662 /// insert PoI at beginning of vector of PoIs
663 void SetPOI(const std::string &POI) { fPOI.insert(fPOI.begin(), POI); }
664 /// append parameter to vector of PoIs
665 void AddPOI(const std::string &POI) { fPOI.push_back(POI); }
666 /// get name of PoI at given index
667 std::string GetPOI(unsigned int i = 0) { return fPOI.at(i); }
668 /// get vector of PoI names
669 std::vector<std::string> &GetPOIList() { return fPOI; }
670
671 /// Add a parameter to be set as constant
672 /// (Similar to ParamSetting method below)
673 void AddConstantParam(const std::string &param);
674 /// empty vector of constant parameters
676 /// get vector of all constant parameters
677 std::vector<std::string> &GetConstantParams() { return fConstantParams; }
678
679 /// Set a parameter to a specific value
680 /// (And optionally fix it)
681 void SetParamValue(const std::string &param, double value);
682 /// get map: parameter name <--> parameter value
683 std::map<std::string, double> &GetParamValues() { return fParamValues; }
684 /// clear map of parameter values
685 void ClearParamValues() { fParamValues.clear(); }
686
687 void AddPreprocessFunction(std::string name, std::string expression, std::string dependencies);
688 /// add a preprocess function object
690 {
691 fFunctionObjects.push_back(function);
692 }
693 void SetFunctionObjects(std::vector<RooStats::HistFactory::PreprocessFunction> objects)
694 {
696 }
697 /// get vector of defined function objects
698 std::vector<RooStats::HistFactory::PreprocessFunction> &GetFunctionObjects() { return fFunctionObjects; }
699 const std::vector<RooStats::HistFactory::PreprocessFunction> &GetFunctionObjects() const { return fFunctionObjects; }
700 std::vector<std::string> GetPreprocessFunctions() const;
701
702 /// get vector of defined Asimov Datasets
703 std::vector<RooStats::HistFactory::Asimov> &GetAsimovDatasets() { return fAsimovDatasets; }
704 /// add an Asimov Dataset
706
707 /// set integrated luminosity used to normalise histograms (if NormalizeByTheory is true for this sample)
708 void SetLumi(double Lumi) { fLumi = Lumi; }
709 /// set relative uncertainty on luminosity
711 /// retrieve integrated luminosity
712 double GetLumi() { return fLumi; }
713 /// retrieve relative uncertainty on luminosity
714 double GetLumiRelErr() { return fLumiRelErr; }
715
718 int GetBinLow() { return fBinLow; }
719 int GetBinHigh() { return fBinHigh; }
720
721 void PrintTree(std::ostream & = std::cout); /// Print to a stream
722 void PrintXML(std::string Directory = "", std::string NewOutputPrefix = "");
723
724 std::vector<RooStats::HistFactory::Channel> &GetChannels() { return fChannels; }
725 const std::vector<RooStats::HistFactory::Channel> &GetChannels() const { return fChannels; }
728
729 bool HasChannel(std::string);
730 void writeToFile(TFile *file);
731
732 void CollectHistograms();
733
734 void AddGammaSyst(std::string syst, double uncert);
735 void AddLogNormSyst(std::string syst, double uncert);
736 void AddUniformSyst(std::string syst);
737 void AddNoSyst(std::string syst);
738
739 std::map<std::string, double> &GetGammaSyst() { return fGammaSyst; }
740 std::map<std::string, double> &GetUniformSyst() { return fUniformSyst; }
741 std::map<std::string, double> &GetLogNormSyst() { return fLogNormSyst; }
742 std::map<std::string, double> &GetNoSyst() { return fNoSyst; }
743
744 std::map<std::string, double> const &GetGammaSyst() const { return fGammaSyst; }
745 std::map<std::string, double> const &GetUniformSyst() const { return fUniformSyst; }
746 std::map<std::string, double> const &GetLogNormSyst() const { return fLogNormSyst; }
747 std::map<std::string, double> const &GetNoSyst() const { return fNoSyst; }
748
750
751private:
752 /// Configurables of this measurement
753 std::string fOutputFilePrefix;
754 std::vector<std::string> fPOI;
755 double fLumi;
759 bool fExportOnly = true;
761
762 /// Channels that make up this measurement
763 std::vector<RooStats::HistFactory::Channel> fChannels;
764
765 /// List of Parameters to be set constant
766 std::vector<std::string> fConstantParams;
767
768 /// Map of parameter names to initial values to be set
769 std::map<std::string, double> fParamValues;
770
771 /// List of Preprocess Function objects
772 std::vector<RooStats::HistFactory::PreprocessFunction> fFunctionObjects;
773
774 /// List of Asimov datasets to generate
775 std::vector<RooStats::HistFactory::Asimov> fAsimovDatasets;
776
777 /// List of Alternate constraint terms
778 std::map<std::string, double> fGammaSyst;
779 std::map<std::string, double> fUniformSyst;
780 std::map<std::string, double> fLogNormSyst;
781 std::map<std::string, double> fNoSyst;
782
783 std::string GetDirPath(TDirectory *dir);
784
786};
787
788} // namespace RooStats::HistFactory
789
790#endif
#define h(i)
Definition RSha256.hxx:106
#define ClassDefOverride(name, id)
Definition Rtypes.h:348
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
void Error(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
Definition TError.cxx:208
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
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
char name[80]
Definition TGX11.cxx:110
TODO Here, we are missing some documentation.
void SetName(const std::string &name)
void SetParamValue(const std::string &param, double value)
Asimov(std::string Name="")
std::map< std::string, double > fParamValsToSet
std::map< std::string, double > & GetParamsToSet()
void ConfigureWorkspace(RooWorkspace *)
std::map< std::string, bool > fParamsToFix
void SetFixedParam(const std::string &param, bool constant=true)
std::map< std::string, bool > & GetParamsToFix()
This class encapsulates all information for the statistical interpretation of one experiment.
void SetName(const std::string &Name)
set name of channel
std::vector< RooStats::HistFactory::Sample > fSamples
std::vector< RooStats::HistFactory::Data > fAdditionalData
One can add additional datasets These are simply added to the xml under a different name.
const RooStats::HistFactory::Data & GetData() const
std::vector< RooStats::HistFactory::Data > & GetAdditionalData()
retrieve vector of additional data objects
void Print(std::ostream &=std::cout)
const HistFactory::StatErrorConfig & GetStatErrorConfig() const
HistFactory::StatErrorConfig & GetStatErrorConfig()
get information about threshold for statistical uncertainties and constraint term
RooStats::HistFactory::Data & GetData()
get data object
void AddAdditionalData(const RooStats::HistFactory::Data &data)
add additional data object
std::string GetInputFile() const
get name of input file
HistFactory::StatErrorConfig fStatErrorConfig
std::string GetHistoPath() const
get path to histograms in input file
void SetData(const RooStats::HistFactory::Data &data)
set data object
void SetInputFile(const std::string &file)
set name of input file containing histograms
void AddSample(RooStats::HistFactory::Sample sample)
TH1 * GetHistogram(std::string InputFile, std::string HistoPath, std::string HistoName, std::map< std::string, std::unique_ptr< TFile > > &lsof)
Open a file and copy a histogram.
const std::vector< RooStats::HistFactory::Sample > & GetSamples() const
void SetStatErrorConfig(double RelErrorThreshold, Constraint::Type ConstraintType)
void PrintXML(std::string const &directory, std::string const &prefix="") const
std::vector< RooStats::HistFactory::Sample > & GetSamples()
get vector of samples for this channel
void SetHistoPath(const std::string &file)
set path for histograms in input file
void SetStatErrorConfig(RooStats::HistFactory::StatErrorConfig Config)
define treatment of statistical uncertainties
std::string GetName() const
get name of channel
void Print(std::ostream &=std::cout)
std::string const & GetInputFile() const
void PrintXML(std::ostream &) const
void SetInputFile(const std::string &InputFile)
void SetHistoPath(const std::string &HistoPath)
void writeToFile(std::string FileName, std::string DirName)
void SetName(const std::string &name)
std::string const & GetHistoName() const
void SetHistoName(const std::string &HistoName)
std::string const & GetHistoPath() const
std::string const & GetName() const
Internal class wrapping an histogram and managing its content.
HistRef(TH1 *h=nullptr)
constructor - use gives away ownerhip of the given pointer
HistRef & operator=(const HistRef &other)
assignment operator (delete previous contained histogram)
void SetObject(TH1 *h)
set the object - user gives away the ownerhisp
std::unique_ptr< TH1 > fHist
pointer to contained histogram
static TH1 * CopyObject(const TH1 *h)
TH1 * ReleaseObject()
Release ownership of object.
Configuration for an *un*constrained, coherent shape variation of affected samples.
void PrintXML(std::ostream &) const override
Configuration for a constrained, coherent shape variation of affected samples.
void PrintXML(std::ostream &) const override
////////////////////////////////////////////////////////////////////////////////////////////Base clas...
Definition Measurement.h:99
void SetInputFileHigh(const std::string &InputFileHigh)
virtual void writeToFile(const std::string &FileName, const std::string &DirName)
virtual void PrintXML(std::ostream &) const =0
void SetHistoPathHigh(const std::string &HistoPathHigh)
void SetInputFileLow(const std::string &InputFileLow)
const std::string & GetHistoNameHigh() const
const std::string & GetHistoNameLow() const
void SetHistoNameHigh(const std::string &HistoNameHigh)
void SetHistoNameLow(const std::string &HistoNameLow)
virtual void Print(std::ostream &=std::cout) const
HistogramUncertaintyBase & operator=(const HistogramUncertaintyBase &oth)
const std::string & GetHistoPathLow() const
HistogramUncertaintyBase & operator=(HistogramUncertaintyBase &&)
const std::string & GetInputFileHigh() const
const std::string & GetInputFileLow() const
void SetHistoPathLow(const std::string &HistoPathLow)
const std::string & GetHistoPathHigh() const
HistogramUncertaintyBase(HistogramUncertaintyBase &&)
The RooStats::HistFactory::Measurement class can be used to construct a model by combining multiple R...
void writeToFile(TFile *file)
A measurement, once fully configured, can be saved into a ROOT file.
std::map< std::string, double > fUniformSyst
std::map< std::string, double > const & GetNoSyst() const
std::map< std::string, double > const & GetGammaSyst() const
std::string fOutputFilePrefix
Configurables of this measurement.
void AddGammaSyst(std::string syst, double uncert)
Set constraint term for given systematic to Gamma distribution.
void ClearParamValues()
clear map of parameter values
std::map< std::string, double > & GetGammaSyst()
std::map< std::string, double > & GetLogNormSyst()
std::string GetDirPath(TDirectory *dir)
Return the directory's path, stripped of unnecessary prefixes.
std::map< std::string, double > const & GetLogNormSyst() const
std::map< std::string, double > & GetParamValues()
get map: parameter name <--> parameter value
std::map< std::string, double > fNoSyst
std::map< std::string, double > & GetNoSyst()
const std::vector< RooStats::HistFactory::PreprocessFunction > & GetFunctionObjects() const
std::vector< RooStats::HistFactory::Channel > fChannels
Channels that make up this measurement.
void AddPOI(const std::string &POI)
append parameter to vector of PoIs
std::vector< std::string > & GetPOIList()
get vector of PoI names
void AddLogNormSyst(std::string syst, double uncert)
Set constraint term for given systematic to LogNormal distribution.
void PrintXML(std::string Directory="", std::string NewOutputPrefix="")
Print to a stream.
void SetLumi(double Lumi)
set integrated luminosity used to normalise histograms (if NormalizeByTheory is true for this sample)
void SetParamValue(const std::string &param, double value)
Set a parameter to a specific value (And optionally fix it)
std::map< std::string, double > fGammaSyst
List of Alternate constraint terms.
double GetLumiRelErr()
retrieve relative uncertainty on luminosity
std::map< std::string, double > fParamValues
Map of parameter names to initial values to be set.
std::map< std::string, double > & GetUniformSyst()
std::vector< std::string > & GetConstantParams()
get vector of all constant parameters
void CollectHistograms()
The most common way to add histograms to channels is to have them stored in ROOT files and to give Hi...
const std::vector< RooStats::HistFactory::Channel > & GetChannels() const
std::vector< RooStats::HistFactory::PreprocessFunction > fFunctionObjects
List of Preprocess Function objects.
RooStats::HistFactory::Channel & GetChannel(std::string)
Get channel with given name from this measurement throws an exception in case the channel is not foun...
std::vector< RooStats::HistFactory::Asimov > fAsimovDatasets
List of Asimov datasets to generate.
void AddChannel(RooStats::HistFactory::Channel chan)
add a completely configured channel
void SetOutputFilePrefix(const std::string &prefix)
set output prefix
bool HasChannel(std::string)
Check if the given channel is part of this measurement.
void AddUniformSyst(std::string syst)
Set constraint term for given systematic to uniform distribution.
void PrintTree(std::ostream &=std::cout)
Print information about measurement object in tree-like structure to given stream.
std::vector< RooStats::HistFactory::Channel > & GetChannels()
std::vector< RooStats::HistFactory::Asimov > & GetAsimovDatasets()
get vector of defined Asimov Datasets
Measurement()
Standard constructor.
void AddNoSyst(std::string syst)
Define given systematics to have no external constraint.
void SetPOI(const std::string &POI)
insert PoI at beginning of vector of PoIs
std::string GetOutputFilePrefix()
retrieve prefix for output files
void AddConstantParam(const std::string &param)
Add a parameter to be set as constant (Similar to ParamSetting method below)
void AddFunctionObject(const RooStats::HistFactory::PreprocessFunction function)
add a preprocess function object
void ClearConstantParams()
empty vector of constant parameters
std::vector< RooStats::HistFactory::PreprocessFunction > & GetFunctionObjects()
get vector of defined function objects
void SetFunctionObjects(std::vector< RooStats::HistFactory::PreprocessFunction > objects)
void AddPreprocessFunction(std::string name, std::string expression, std::string dependencies)
Add a preprocessed function by giving the function a name, a functional expression,...
std::vector< std::string > GetPreprocessFunctions() const
Returns a list of defined preprocess function expressions.
std::map< std::string, double > fLogNormSyst
void SetLumiRelErr(double RelErr)
set relative uncertainty on luminosity
std::vector< std::string > fPOI
std::map< std::string, double > const & GetUniformSyst() const
double GetLumi()
retrieve integrated luminosity
void AddAsimovDataset(RooStats::HistFactory::Asimov dataset)
add an Asimov Dataset
std::vector< std::string > fConstantParams
List of Parameters to be set constant.
std::string GetPOI(unsigned int i=0)
get name of PoI at given index
Configuration for an un- constrained overall systematic to scale sample normalisations.
Definition Measurement.h:69
void Print(std::ostream &=std::cout) const
void PrintXML(std::ostream &) const
void SetName(const std::string &Name)
Definition Measurement.h:72
Configuration for a constrained overall systematic to scale sample normalisations.
Definition Measurement.h:45
void SetName(const std::string &Name)
Definition Measurement.h:48
const std::string & GetName() const
Definition Measurement.h:49
void PrintXML(std::ostream &) const
void Print(std::ostream &=std::cout) const
void SetName(const std::string &name)
void Print(std::ostream &=std::cout) const
std::string const & GetExpression() const
std::string const & GetDependents() const
void SetExpression(const std::string &expression)
void SetDependents(const std::string &dependents)
std::string const & GetName() const
std::vector< RooStats::HistFactory::ShapeFactor > fShapeFactorList
std::unique_ptr< TH1 > fhCountingHist
std::vector< RooStats::HistFactory::OverallSys > & GetOverallSysList()
std::string GetHistoName() const
get histogram name
void SetStatError(RooStats::HistFactory::StatError Error)
void AddShapeSys(std::string Name, Constraint::Type ConstraintType, std::string HistoName, std::string HistoFile, std::string HistoPath="")
void AddOverallSys(std::string Name, double Low, double High)
std::string GetName() const
get name of sample
void writeToFile(std::string FileName, std::string DirName)
const TH1 * GetHisto() const
void SetInputFile(const std::string &InputFile)
set input ROOT file
RooStats::HistFactory::StatError fStatError
Properties.
void SetChannelName(const std::string &ChannelName)
set name of associated channel
std::vector< RooStats::HistFactory::NormFactor > fNormFactorList
void AddNormFactor(std::string const &Name, double Val, double Low, double High)
const RooStats::HistFactory::StatError & GetStatError() const
void SetHistoName(const std::string &HistoName)
set histogram name
Sample & operator=(const Sample &other)
std::string fChannelName
The Name of the parent channel.
std::vector< RooStats::HistFactory::OverallSys > fOverallSysList
void Print(std::ostream &=std::cout) const
const std::vector< RooStats::HistFactory::HistoFactor > & GetHistoFactorList() const
const std::vector< RooStats::HistFactory::HistoSys > & GetHistoSysList() const
std::vector< RooStats::HistFactory::HistoSys > fHistoSysList
std::string GetHistoPath() const
get histogram path
void SetNormalizeByTheory(bool norm)
defines whether the normalization scale with luminosity
const std::vector< RooStats::HistFactory::ShapeFactor > & GetShapeFactorList() const
RooStats::HistFactory::StatError & GetStatError()
void AddHistoFactor(std::string Name, std::string HistoNameLow, std::string HistoFileLow, std::string HistoPathLow, std::string HistoNameHigh, std::string HistoFileHigh, std::string HistoPathHigh)
std::vector< RooStats::HistFactory::ShapeFactor > & GetShapeFactorList()
void SetName(const std::string &Name)
set name of sample
std::vector< RooStats::HistFactory::HistoFactor > & GetHistoFactorList()
void SetHistoPath(const std::string &HistoPath)
set histogram path
std::string GetChannelName() const
get name of associated channel
std::vector< RooStats::HistFactory::NormFactor > & GetNormFactorList()
std::string GetInputFile() const
get input ROOT file
const std::vector< RooStats::HistFactory::OverallSys > & GetOverallSysList() const
std::vector< RooStats::HistFactory::HistoSys > & GetHistoSysList()
std::vector< RooStats::HistFactory::HistoFactor > fHistoFactorList
bool GetNormalizeByTheory() const
does the normalization scale with luminosity
std::vector< RooStats::HistFactory::ShapeSys > fShapeSysList
HistRef fhNominal
The Nominal Shape.
void AddShapeFactor(std::string Name)
const std::vector< RooStats::HistFactory::NormFactor > & GetNormFactorList() const
std::vector< RooStats::HistFactory::ShapeSys > & GetShapeSysList()
void AddHistoSys(std::string Name, std::string HistoNameLow, std::string HistoFileLow, std::string HistoPathLow, std::string HistoNameHigh, std::string HistoFileHigh, std::string HistoPathHigh)
void PrintXML(std::ofstream &xml) const
const std::vector< RooStats::HistFactory::ShapeSys > & GetShapeSysList() const
*Un*constrained bin-by-bin variation of affected histogram.
void PrintXML(std::ostream &) const override
const std::string & GetHistoPath() const
const TH1 * GetInitialShape() const
void SetInputFile(const std::string &InputFile)
void SetHistoName(const std::string &HistoName)
void writeToFile(const std::string &FileName, const std::string &DirName) override
void Print(std::ostream &=std::cout) const override
const std::string & GetInputFile() const
void SetHistoPath(const std::string &HistoPath)
const std::string & GetHistoName() const
Constrained bin-by-bin variation of affected histogram.
std::string GetHistoPath() const
void PrintXML(std::ostream &) const override
Constraint::Type GetConstraintType() const
const TH1 * GetErrorHist() const
std::string GetHistoName() const
ShapeSys & operator=(ShapeSys &&)=default
ShapeSys(const ShapeSys &other)
void SetInputFile(const std::string &InputFile)
void writeToFile(const std::string &FileName, const std::string &DirName) override
void Print(std::ostream &=std::cout) const override
ShapeSys & operator=(const ShapeSys &oth)
void SetHistoName(const std::string &HistoName)
void SetConstraintType(Constraint::Type ConstrType)
std::string GetInputFile() const
void SetHistoPath(const std::string &HistoPath)
Configuration to automatically assign nuisance parameters for the statistical error of the Monte Carl...
void PrintXML(std::ostream &) const
void SetConstraintType(Constraint::Type ConstrType)
void SetRelErrorThreshold(double Threshold)
Constraint::Type GetConstraintType() const
void Print(std::ostream &=std::cout) const
Statistical error of Monte Carlo predictions.
const std::string & GetHistoPath() const
void Activate(bool IsActive=true)
void SetHistoPath(const std::string &HistoPath)
void SetInputFile(const std::string &InputFile)
const TH1 * GetErrorHist() const
const std::string & GetInputFile() const
void SetHistoName(const std::string &HistoName)
const std::string & GetHistoName() const
void SetUseHisto(bool UseHisto=true)
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
Persistable container for RooFit projects.
Describe directory structure in memory.
Definition TDirectory.h:45
A ROOT file is an on-disk file, usually with extension .root, that stores objects in a file-system-li...
Definition TFile.h:131
TH1 is the base class of all histogram classes in ROOT.
Definition TH1.h:109
The TNamed class is the base class for all named ROOT classes.
Definition TNamed.h:29
Type GetType(const std::string &Name)