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
17
18#include <fstream>
19#include <iostream>
20#include <map>
21#include <memory>
22#include <string>
23#include <vector>
24
25class TFile;
26class TH1;
27
28class RooWorkspace;
29
30namespace RooStats::HistFactory {
31
32/** \class OverallSys
33 * \ingroup HistFactory
34 * Configuration for a constrained overall systematic to scale sample normalisations.
35 */
37
38public:
39 void SetName(const std::string &Name) { fName = Name; }
40 const std::string &GetName() const { return fName; }
41
42 void SetLow(double Low) { fLow = Low; }
43 void SetHigh(double High) { fHigh = High; }
44 double GetLow() const { return fLow; }
45 double GetHigh() const { return fHigh; }
46
47 void Print(std::ostream & = std::cout) const;
48 void PrintXML(std::ostream &) const;
49
50protected:
51 std::string fName;
52 double fLow = 0.0;
53 double fHigh = 0.0;
54};
55
56/** \class NormFactor
57 * \ingroup HistFactory
58 * Configuration for an \a un- constrained overall systematic to scale sample normalisations.
59 */
61
62public:
63 void SetName(const std::string &Name) { fName = Name; }
64 std::string GetName() const { return fName; }
65
66 void SetVal(double Val) { fVal = Val; }
67 double GetVal() const { return fVal; }
68
69 void SetLow(double Low) { fLow = Low; }
70 void SetHigh(double High) { fHigh = High; }
71 double GetLow() const { return fLow; }
72 double GetHigh() const { return fHigh; }
73
74 void Print(std::ostream & = std::cout) const;
75 void PrintXML(std::ostream &) const;
76
77protected:
78 std::string fName;
79 double fVal = 1.0;
80 double fLow = 1.0;
81 double fHigh = 1.0;
82};
83
84/** ////////////////////////////////////////////////////////////////////////////////////////////
85 * \class HistogramUncertaintyBase
86 * \ingroup HistFactory
87 * Base class to store the up and down variations for histogram uncertainties.
88 * Use the derived classes for actual models.
89 */
91
92public:
94 HistogramUncertaintyBase(const std::string &Name);
97
99
100 // Need deep copies because the class owns its histograms.
103
104 virtual void Print(std::ostream & = std::cout) const;
105 virtual void PrintXML(std::ostream &) const = 0;
106 virtual void writeToFile(const std::string &FileName, const std::string &DirName);
107
108 void SetHistoLow(TH1 *Low);
109 void SetHistoHigh(TH1 *High);
110
111 const TH1 *GetHistoLow() const { return fhLow.get(); }
112 const TH1 *GetHistoHigh() const { return fhHigh.get(); }
113
114 void SetName(const std::string &Name) { fName = Name; }
115 const std::string &GetName() const { return fName; }
116
119
120 const std::string &GetInputFileLow() const { return fInputFileLow; }
121 const std::string &GetInputFileHigh() const { return fInputFileHigh; }
122
125
126 const std::string &GetHistoNameLow() const { return fHistoNameLow; }
127 const std::string &GetHistoNameHigh() const { return fHistoNameHigh; }
128
131
132 const std::string &GetHistoPathLow() const { return fHistoPathLow; }
133 const std::string &GetHistoPathHigh() const { return fHistoPathHigh; }
134
135protected:
136 std::string fName;
137
138 std::string fInputFileLow;
139 std::string fHistoNameLow;
140 std::string fHistoPathLow;
141
142 std::string fInputFileHigh;
143 std::string fHistoNameHigh;
144 std::string fHistoPathHigh;
145
146 // The Low and High Histograms
147 std::unique_ptr<TH1> fhLow;
148 std::unique_ptr<TH1> fhHigh;
149};
150
151/** \class HistoSys
152 * \ingroup HistFactory
153 * Configuration for a constrained, coherent shape variation of affected samples.
154 */
156public:
157 void PrintXML(std::ostream &) const override;
158};
159
160/** \class HistoFactor
161 * \ingroup HistFactory
162 * Configuration for an *un*constrained, coherent shape variation of affected samples.
163 */
165public:
166 void PrintXML(std::ostream &) const override;
167};
168
169/** \class ShapeSys
170 * \ingroup HistFactory
171 * Constrained bin-by-bin variation of affected histogram.
172 */
174
175public:
176 ShapeSys() : fConstraintType(Constraint::Gaussian) {}
179 {
180 if (this == &oth)
181 return *this;
183 fConstraintType = oth.fConstraintType;
184 return *this;
185 }
187
188 void SetInputFile(const std::string &InputFile) { fInputFileHigh = InputFile; }
189 std::string GetInputFile() const { return fInputFileHigh; }
190
191 void SetHistoName(const std::string &HistoName) { fHistoNameHigh = HistoName; }
192 std::string GetHistoName() const { return fHistoNameHigh; }
193
194 void SetHistoPath(const std::string &HistoPath) { fHistoPathHigh = HistoPath; }
195 std::string GetHistoPath() const { return fHistoPathHigh; }
196
197 void Print(std::ostream & = std::cout) const override;
198 void PrintXML(std::ostream &) const override;
199 void writeToFile(const std::string &FileName, const std::string &DirName) override;
200
201 const TH1 *GetErrorHist() const { return fhHigh.get(); }
202 void SetErrorHist(TH1 *hError);
203
206
207protected:
209};
210
211/** \class ShapeFactor
212 * \ingroup HistFactory
213 * *Un*constrained bin-by-bin variation of affected histogram.
214 */
216
217public:
218 void Print(std::ostream & = std::cout) const override;
219 void PrintXML(std::ostream &) const override;
220 void writeToFile(const std::string &FileName, const std::string &DirName) override;
221
222 void SetInitialShape(TH1 *shape);
223 const TH1 *GetInitialShape() const { return fhHigh.get(); }
224
226 bool IsConstant() const { return fConstant; }
227
228 bool HasInitialShape() const { return fHasInitialShape; }
229
230 void SetInputFile(const std::string &InputFile)
231 {
233 fHasInitialShape = true;
234 }
235 const std::string &GetInputFile() const { return fInputFileHigh; }
236
237 void SetHistoName(const std::string &HistoName)
238 {
240 fHasInitialShape = true;
241 }
242 const std::string &GetHistoName() const { return fHistoNameHigh; }
243
244 void SetHistoPath(const std::string &HistoPath)
245 {
247 fHasInitialShape = true;
248 }
249 const std::string &GetHistoPath() const { return fHistoPathHigh; }
250
251 double GetVal() const { return fVal; }
252
253 double GetLow() const { return fLow; }
254 double GetHigh() const { return fHigh; }
255
256 void SetVal(double Val) { fVal = Val; }
257
258 void SetLow(double Low) { fLow = Low; }
259 void SetHigh(double High) { fHigh = High; }
260
261protected:
262 bool fConstant = false;
263 bool fHasInitialShape = false;
264 double fVal = 1.0;
265 // GHL: Again, we are putting hard ranges on the gammas by default.
266 // We should change this to range from 0 to /inf.
269};
270
271/** \class StatError
272 * \ingroup HistFactory
273 * Statistical error of Monte Carlo predictions.
274 */
276
277public:
278 void Print(std::ostream & = std::cout) const override;
279 void PrintXML(std::ostream &) const override;
280 void writeToFile(const std::string &FileName, const std::string &DirName) override;
281
282 void Activate(bool IsActive = true) { fActivate = IsActive; }
283 bool GetActivate() const { return fActivate; }
284
285 void SetUseHisto(bool UseHisto = true) { fUseHisto = UseHisto; }
286 bool GetUseHisto() const { return fUseHisto; }
287
288 void SetInputFile(const std::string &InputFile) { fInputFileHigh = InputFile; }
289 const std::string &GetInputFile() const { return fInputFileHigh; }
290
291 void SetHistoName(const std::string &HistoName) { fHistoNameHigh = HistoName; }
292 const std::string &GetHistoName() const { return fHistoNameHigh; }
293
294 void SetHistoPath(const std::string &HistoPath) { fHistoPathHigh = HistoPath; }
295 const std::string &GetHistoPath() const { return fHistoPathHigh; }
296
297 const TH1 *GetErrorHist() const { return fhHigh.get(); }
298 void SetErrorHist(TH1 *Error);
299
300protected:
301 bool fActivate = false;
302 bool fUseHisto = false; // Use an external histogram for the errors
303};
304
305/** \class StatErrorConfig
306 * \ingroup HistFactory
307 * Configuration to automatically assign nuisance parameters for the statistical
308 * error of the Monte Carlo simulations.
309 * The default is to assign a Poisson uncertainty to a bin when its statistical uncertainty
310 * is larger than 5% of the bin content.
311 */
313
314public:
315 void Print(std::ostream & = std::cout) const;
316 void PrintXML(std::ostream &) const;
317
319 double GetRelErrorThreshold() const { return fRelErrorThreshold; }
320
323
324protected:
325 double fRelErrorThreshold = 0.05;
327};
328
329// Internal class wrapping an histogram and managing its content.
330// conveninet for dealing with histogram pointers in the
331// HistFactory class
332class HistRef {
333
334public:
335 HistRef(TH1 *h = nullptr);
336
337 HistRef(const HistRef &other);
338
340
342
345
346 TH1 *GetObject() const;
347
348 void SetObject(TH1 *h);
349
350 void operator=(TH1 *h);
351
353
354private:
355 static TH1 *CopyObject(const TH1 *h);
356 std::unique_ptr<TH1> fHist; ///< pointer to contained histogram
357};
358
359class Asimov {
360
361public:
362 Asimov(std::string Name = "") : fName(Name) {}
363
365
366 std::string GetName() { return fName; }
367 void SetName(const std::string &name) { fName = name; }
368
369 void SetFixedParam(const std::string &param, bool constant = true) { fParamsToFix[param] = constant; }
370 void SetParamValue(const std::string &param, double value) { fParamValsToSet[param] = value; }
371
372 std::map<std::string, bool> &GetParamsToFix() { return fParamsToFix; }
373 std::map<std::string, double> &GetParamsToSet() { return fParamValsToSet; }
374
375protected:
376 std::string fName;
377
378 std::map<std::string, bool> fParamsToFix;
379 std::map<std::string, double> fParamValsToSet;
380};
381
383public:
385
386 PreprocessFunction(std::string const &name, std::string const &expression, std::string const &dependents);
387
388 void Print(std::ostream & = std::cout) const;
389 void PrintXML(std::ostream &) const;
390
391 void SetName(const std::string &name) { fName = name; }
392 std::string const &GetName() const { return fName; }
393
394 void SetExpression(const std::string &expression) { fExpression = expression; }
395 std::string const &GetExpression() const { return fExpression; }
396
397 void SetDependents(const std::string &dependents) { fDependents = dependents; }
398 std::string const &GetDependents() const { return fDependents; }
399
400 std::string GetCommand() const;
401
402private:
403 std::string fName;
404 std::string fExpression;
405 std::string fDependents;
406};
407
408class Data {
409
410public:
411 // friend class Channel;
412
413 Data() {}
414 /// constructor from name, file and path. Name of the histogram should not include the path
415 Data(std::string HistoName, std::string InputFile, std::string HistoPath = "");
416
417 std::string const &GetName() const { return fName; }
418 void SetName(const std::string &name) { fName = name; }
419
420 void SetInputFile(const std::string &InputFile) { fInputFile = InputFile; }
421 std::string const &GetInputFile() const { return fInputFile; }
422
423 void SetHistoName(const std::string &HistoName) { fHistoName = HistoName; }
424 std::string const &GetHistoName() const { return fHistoName; }
425
426 void SetHistoPath(const std::string &HistoPath) { fHistoPath = HistoPath; }
427 std::string const &GetHistoPath() const { return fHistoPath; }
428
429 void Print(std::ostream & = std::cout);
430 void PrintXML(std::ostream &) const;
431 void writeToFile(std::string FileName, std::string DirName);
432
433 TH1 *GetHisto();
434 const TH1 *GetHisto() const;
435 void SetHisto(TH1 *Hist);
436
437protected:
438 std::string fName;
439
440 std::string fInputFile;
441 std::string fHistoName;
442 std::string fHistoPath;
443
444 // The Data Histogram
446};
447
448class Sample {
449
450public:
453 Sample(std::string Name);
454 Sample(const Sample &other);
455 Sample &operator=(const Sample &other);
456 /// constructor from name, file and path. Name of the histogram should not include the path
457 Sample(std::string Name, std::string HistoName, std::string InputFile, std::string HistoPath = "");
458
459 void Print(std::ostream & = std::cout) const;
460 void PrintXML(std::ofstream &xml) const;
461 void writeToFile(std::string FileName, std::string DirName);
462
463 const TH1 *GetHisto() const;
464 // set histogram for this sample
465 void SetHisto(TH1 *histo);
466 void SetValue(double Val);
467
468 // Some helper functions
469 // Note that histogram name should not include the path of the histogram in the file.
470 // This has to be given separately
471
472 void ActivateStatError();
473 void ActivateStatError(std::string HistoName, std::string InputFile, std::string HistoPath = "");
474
475 void AddOverallSys(std::string Name, double Low, double High);
476 void AddOverallSys(const OverallSys &Sys);
477
478 void AddNormFactor(std::string const &Name, double Val, double Low, double High);
479 void AddNormFactor(const NormFactor &Factor);
480
481 void AddHistoSys(std::string Name, std::string HistoNameLow, std::string HistoFileLow, std::string HistoPathLow,
482 std::string HistoNameHigh, std::string HistoFileHigh, std::string HistoPathHigh);
483 void AddHistoSys(const HistoSys &Sys);
484
485 void AddHistoFactor(std::string Name, std::string HistoNameLow, std::string HistoFileLow, std::string HistoPathLow,
486 std::string HistoNameHigh, std::string HistoFileHigh, std::string HistoPathHigh);
487 void AddHistoFactor(const HistoFactor &Factor);
488
489 void AddShapeFactor(std::string Name);
490 void AddShapeFactor(std::string Name, double Val, double Low, double High);
491 void AddShapeFactor(const ShapeFactor &Factor);
492
493 void AddShapeSys(std::string Name, Constraint::Type ConstraintType, std::string HistoName, std::string HistoFile,
494 std::string HistoPath = "");
495 void AddShapeSys(const ShapeSys &Sys);
496
497 /// defines whether the normalization scale with luminosity
499 /// does the normalization scale with luminosity
501
502 /// get name of sample
503 std::string GetName() const { return fName; }
504 /// set name of sample
505 void SetName(const std::string &Name) { fName = Name; }
506
507 /// get input ROOT file
508 std::string GetInputFile() const { return fInputFile; }
509 /// set input ROOT file
510 void SetInputFile(const std::string &InputFile) { fInputFile = InputFile; }
511
512 /// get histogram name
513 std::string GetHistoName() const { return fHistoName; }
514 /// set histogram name
515 void SetHistoName(const std::string &HistoName) { fHistoName = HistoName; }
516
517 /// get histogram path
518 std::string GetHistoPath() const { return fHistoPath; }
519 /// set histogram path
520 void SetHistoPath(const std::string &HistoPath) { fHistoPath = HistoPath; }
521
522 /// get name of associated channel
523 std::string GetChannelName() const { return fChannelName; }
524 /// set name of associated channel
525 void SetChannelName(const std::string &ChannelName) { fChannelName = ChannelName; }
526
527 std::vector<RooStats::HistFactory::OverallSys> &GetOverallSysList() { return fOverallSysList; }
528 std::vector<RooStats::HistFactory::NormFactor> &GetNormFactorList() { return fNormFactorList; }
529 std::vector<RooStats::HistFactory::HistoSys> &GetHistoSysList() { return fHistoSysList; }
530 std::vector<RooStats::HistFactory::HistoFactor> &GetHistoFactorList() { return fHistoFactorList; }
531 std::vector<RooStats::HistFactory::ShapeSys> &GetShapeSysList() { return fShapeSysList; }
532 std::vector<RooStats::HistFactory::ShapeFactor> &GetShapeFactorList() { return fShapeFactorList; }
533
534 const std::vector<RooStats::HistFactory::OverallSys> &GetOverallSysList() const { return fOverallSysList; }
535 const std::vector<RooStats::HistFactory::NormFactor> &GetNormFactorList() const { return fNormFactorList; }
536 const std::vector<RooStats::HistFactory::HistoSys> &GetHistoSysList() const { return fHistoSysList; }
537 const std::vector<RooStats::HistFactory::HistoFactor> &GetHistoFactorList() const { return fHistoFactorList; }
538 const std::vector<RooStats::HistFactory::ShapeSys> &GetShapeSysList() const { return fShapeSysList; }
539 const std::vector<RooStats::HistFactory::ShapeFactor> &GetShapeFactorList() const { return fShapeFactorList; }
540
541 bool HasStatError() const { return fStatErrorActivate; }
545
546protected:
547 std::string fName;
548 std::string fInputFile;
549 std::string fHistoName;
550 std::string fHistoPath;
551
552 /// The Name of the parent channel
553 std::string fChannelName;
554
555 //
556 // Systematics
557 //
558
559 std::vector<RooStats::HistFactory::OverallSys> fOverallSysList;
560 std::vector<RooStats::HistFactory::NormFactor> fNormFactorList;
561
562 std::vector<RooStats::HistFactory::HistoSys> fHistoSysList;
563 std::vector<RooStats::HistFactory::HistoFactor> fHistoFactorList;
564
565 std::vector<RooStats::HistFactory::ShapeSys> fShapeSysList;
566 std::vector<RooStats::HistFactory::ShapeFactor> fShapeFactorList;
567
568 /// Properties
570
571 bool fNormalizeByTheory = false;
572 bool fStatErrorActivate = false;
573
574 /// The Nominal Shape
576 std::unique_ptr<TH1> fhCountingHist;
577};
578
579class Channel {
580
581public:
582 friend class Measurement;
583
584 Channel() = default;
585 Channel(std::string Name, std::string InputFile = "");
586
587 /// set name of channel
588 void SetName(const std::string &Name) { fName = Name; }
589 /// get name of channel
590 std::string GetName() const { return fName; }
591 /// set name of input file containing histograms
592 void SetInputFile(const std::string &file) { fInputFile = file; }
593 /// get name of input file
594 std::string GetInputFile() const { return fInputFile; }
595 /// set path for histograms in input file
596 void SetHistoPath(const std::string &file) { fHistoPath = file; }
597 /// get path to histograms in input file
598 std::string GetHistoPath() const { return fHistoPath; }
599
600 /// set data object
602 void SetData(std::string HistoName, std::string InputFile, std::string HistoPath = "");
603 void SetData(double Val);
604 void SetData(TH1 *hData);
605 /// get data object
607 const RooStats::HistFactory::Data &GetData() const { return fData; }
608
609 /// add additional data object
611 /// retrieve vector of additional data objects
612 std::vector<RooStats::HistFactory::Data> &GetAdditionalData() { return fAdditionalData; }
613
615 void SetStatErrorConfig(double RelErrorThreshold, std::string ConstraintType);
616 /// define treatment of statistical uncertainties
618 /// get information about threshold for statistical uncertainties and constraint term
621
623 /// get vector of samples for this channel
624 std::vector<RooStats::HistFactory::Sample> &GetSamples() { return fSamples; }
625 const std::vector<RooStats::HistFactory::Sample> &GetSamples() const { return fSamples; }
626
627 void Print(std::ostream & = std::cout);
628 void PrintXML(std::string const &directory, std::string const &prefix = "") const;
629
630 void CollectHistograms();
631 bool CheckHistograms() const;
632
633protected:
634 std::string fName;
635 std::string fInputFile;
636 std::string fHistoPath;
637
639
640 /// One can add additional datasets
641 /// These are simply added to the xml under a different name
642 std::vector<RooStats::HistFactory::Data> fAdditionalData;
643
645
646 std::vector<RooStats::HistFactory::Sample> fSamples;
647
648 TH1 *GetHistogram(std::string InputFile, std::string HistoPath, std::string HistoName,
649 std::map<std::string, std::unique_ptr<TFile>> &lsof);
650};
651
652extern Channel BadChannel;
653
654class Measurement : public TNamed {
655
656public:
657 Measurement() = default;
658 /// Constructor specifying name and title of measurement
659 Measurement(const char *Name, const char *Title = "") : TNamed(Name, Title) {}
660
661 /// set output prefix
662 void SetOutputFilePrefix(const std::string &prefix) { fOutputFilePrefix = prefix; }
663 /// retrieve prefix for output files
664 std::string GetOutputFilePrefix() { return fOutputFilePrefix; }
665
666 /// insert PoI at beginning of vector of PoIs
667 void SetPOI(const std::string &POI) { fPOI.insert(fPOI.begin(), POI); }
668 /// append parameter to vector of PoIs
669 void AddPOI(const std::string &POI) { fPOI.push_back(POI); }
670 /// get name of PoI at given index
671 std::string GetPOI(unsigned int i = 0) { return fPOI.at(i); }
672 /// get vector of PoI names
673 std::vector<std::string> &GetPOIList() { return fPOI; }
674
675 /// Add a parameter to be set as constant
676 /// (Similar to ParamSetting method below)
677 void AddConstantParam(const std::string &param);
678 /// empty vector of constant parameters
680 /// get vector of all constant parameters
681 std::vector<std::string> &GetConstantParams() { return fConstantParams; }
682
683 /// Set a parameter to a specific value
684 /// (And optionally fix it)
685 void SetParamValue(const std::string &param, double value);
686 /// get map: parameter name <--> parameter value
687 std::map<std::string, double> &GetParamValues() { return fParamValues; }
688 /// clear map of parameter values
689 void ClearParamValues() { fParamValues.clear(); }
690
691 void AddPreprocessFunction(std::string name, std::string expression, std::string dependencies);
692 /// add a preprocess function object
694 {
695 fFunctionObjects.push_back(function);
696 }
697 void SetFunctionObjects(std::vector<RooStats::HistFactory::PreprocessFunction> objects)
698 {
700 }
701 /// get vector of defined function objects
702 std::vector<RooStats::HistFactory::PreprocessFunction> &GetFunctionObjects() { return fFunctionObjects; }
703 const std::vector<RooStats::HistFactory::PreprocessFunction> &GetFunctionObjects() const { return fFunctionObjects; }
704 std::vector<std::string> GetPreprocessFunctions() const;
705
706 /// get vector of defined Asimov Datasets
707 std::vector<RooStats::HistFactory::Asimov> &GetAsimovDatasets() { return fAsimovDatasets; }
708 /// add an Asimov Dataset
710
711 /// set integrated luminosity used to normalise histograms (if NormalizeByTheory is true for this sample)
712 void SetLumi(double Lumi) { fLumi = Lumi; }
713 /// set relative uncertainty on luminosity
715 /// retrieve integrated luminosity
716 double GetLumi() { return fLumi; }
717 /// retrieve relative uncertainty on luminosity
718 double GetLumiRelErr() { return fLumiRelErr; }
719
722 int GetBinLow() { return fBinLow; }
723 int GetBinHigh() { return fBinHigh; }
724
725 void PrintTree(std::ostream & = std::cout); /// Print to a stream
726 void PrintXML(std::string Directory = "", std::string NewOutputPrefix = "");
727
728 std::vector<RooStats::HistFactory::Channel> &GetChannels() { return fChannels; }
729 const std::vector<RooStats::HistFactory::Channel> &GetChannels() const { return fChannels; }
731 /// Add a completely configured channel.
733
734 bool HasChannel(std::string);
735 void writeToFile(TFile *file);
736
737 void CollectHistograms();
738
739 void AddGammaSyst(std::string syst, double uncert);
740 void AddLogNormSyst(std::string syst, double uncert);
741 void AddUniformSyst(std::string syst);
742 void AddNoSyst(std::string syst);
743
744 std::map<std::string, double> &GetGammaSyst() { return fGammaSyst; }
745 std::map<std::string, double> &GetUniformSyst() { return fUniformSyst; }
746 std::map<std::string, double> &GetLogNormSyst() { return fLogNormSyst; }
747 std::map<std::string, double> &GetNoSyst() { return fNoSyst; }
748
749 std::map<std::string, double> const &GetGammaSyst() const { return fGammaSyst; }
750 std::map<std::string, double> const &GetUniformSyst() const { return fUniformSyst; }
751 std::map<std::string, double> const &GetLogNormSyst() const { return fLogNormSyst; }
752 std::map<std::string, double> const &GetNoSyst() const { return fNoSyst; }
753
755
756private:
757 /// Configurables of this measurement
758 std::string fOutputFilePrefix;
759 std::vector<std::string> fPOI;
760 double fLumi = 1.0;
761 double fLumiRelErr = 0.1;
762 int fBinLow = 0;
763 int fBinHigh = 1;
764 bool fExportOnly = true;
766
767 /// Channels that make up this measurement
768 std::vector<RooStats::HistFactory::Channel> fChannels;
769
770 /// List of Parameters to be set constant
771 std::vector<std::string> fConstantParams;
772
773 /// Map of parameter names to initial values to be set
774 std::map<std::string, double> fParamValues;
775
776 /// List of Preprocess Function objects
777 std::vector<RooStats::HistFactory::PreprocessFunction> fFunctionObjects;
778
779 /// List of Asimov datasets to generate
780 std::vector<RooStats::HistFactory::Asimov> fAsimovDatasets;
781
782 /// List of Alternate constraint terms
783 std::map<std::string, double> fGammaSyst;
784 std::map<std::string, double> fUniformSyst;
785 std::map<std::string, double> fLogNormSyst;
786 std::map<std::string, double> fNoSyst;
787
788 std::string GetDirPath(TDirectory *dir);
789
791};
792
793} // namespace RooStats::HistFactory
794
795#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
char name[80]
Definition TGX11.cxx:145
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:90
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()
Measurement(const char *Name, const char *Title="")
Constructor specifying name and title of measurement.
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
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:60
void Print(std::ostream &=std::cout) const
void PrintXML(std::ostream &) const
void SetName(const std::string &Name)
Definition Measurement.h:63
Configuration for a constrained overall systematic to scale sample normalisations.
Definition Measurement.h:36
void SetName(const std::string &Name)
Definition Measurement.h:39
const std::string & GetName() const
Definition Measurement.h:40
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 file, usually with extension .root, that stores data and code in the form of serialized objects in ...
Definition TFile.h:130
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