Multiverse.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "CAFAna/Core/Spectrum.h"
4 #include "CAFAna/Core/Var.h"
5 
6 namespace ana {
7  typedef TH1 * (TransformFunc_t)(TH1 *);
8  typedef TH1 * (ProductFunc_t)(TH1 *, TH1 *);
10  class Multiverse {
11  public:
12 
14  const HistAxis &,
15  const Cut &,
16  std::vector<SystShifts>,
17  const Var &);
19  const NuTruthHistAxis &,
20  const NuTruthCut &,
21  std::vector<SystShifts>,
22  const NuTruthVar &);
24  const NuTruthHistAxis &,
25  const NuTruthCut &,
26  const SystShifts &,
27  std::vector<NuTruthVar>,
28  const NuTruthVar &);
30  const HistAxis &,
31  const Cut &,
32  const SystShifts &,
33  std::vector<Var>,
34  const Var &);
35  // support for multiple loaders, eg. nominal + nue enhanced sample
36  Multiverse(std::vector<SpectrumLoaderBase*>,
37  const HistAxis &,
38  const Cut &,
39  std::vector<SystShifts>,
40  const Var &);
41  Multiverse(std::vector<SpectrumLoaderBase*>,
42  const NuTruthHistAxis &,
43  const NuTruthCut &,
44  std::vector<SystShifts>,
45  const NuTruthVar &);
46  Multiverse(std::vector<SpectrumLoaderBase*>,
47  const NuTruthHistAxis &,
48  const NuTruthCut &,
49  const SystShifts &,
50  std::vector<NuTruthVar>,
51  const NuTruthVar &);
52  Multiverse(std::vector<SpectrumLoaderBase*>,
53  const HistAxis &,
54  const Cut &,
55  const SystShifts &,
56  std::vector<Var>,
57  const Var &);
58 
59  Multiverse(std::vector<Spectrum*>);
60  Multiverse(std::vector<TH1*>,
61  int);
62 
63  static Multiverse CopyAndTransform(const Multiverse & rhs,
64  const std::function<TransformFunc_t>& transform);
65  void Transform(const Multiverse & rhs,
66  const std::function<ProductFunc_t>& transform);
67  void Transform(const std::function<TransformFunc_t>& transform);
68  void Transform(const std::function<TransformSpectraFunc_t>& transform);
69 
72  Spectrum * GetNSigmaShift(const Spectrum*, double);
73  TH1 * GetPlusOneSigmaShift(const TH1*);
74  TH1 * GetMinusOneSigmaShift(const TH1*);
75  TH1 * GetNSigmaShift(const TH1*, double);
76 
77  const std::vector<TH1 *> GetUniversesHist();
78  const std::vector<TH1 *> GetUniversesHist(int line_color,
79  int line_style = kSolid);
80 
81  void SaveTo(TDirectory * dir, const std::string& name) const;
82  static std::unique_ptr<Multiverse> LoadFrom(TDirectory * dir, const std::string& name);
83 
84  Multiverse(const Multiverse &);
86  Multiverse & operator=(const Multiverse &);
88  ~Multiverse();
89 
90  void Divide(Multiverse &,bool = false);
91  void Scale(double scale);
92  Multiverse & operator*=(const Multiverse &);
93  Multiverse operator*(const Multiverse &) const;
94 
95  Multiverse & operator/=(const Spectrum &);
96  Multiverse operator/(const Spectrum &) const;
97  Multiverse & operator*=(const Spectrum &);
98  Multiverse operator*(const Spectrum &) const;
99 
100  Multiverse & operator/=(const TH1 &);
101  Multiverse operator/(const TH1 &) const;
102  Multiverse & operator*=(const TH1 &);
103  Multiverse operator*(const TH1 &) const;
104 
105  int GetNUniverses() const { return fNUniverses; }
106 
107  private:
108 
109  void DivisionHelper(TH1*, TH1*, bool);
110 
111  double BinSigma(std::vector<double>, double, double);
112  void InitFromSpectra();
113  TH1 * ToHist(const Spectrum *, double = -1);
114  Spectrum * ToSpectrum(TH1 * h, double POT = 1, double livetime = 0);
115  std::vector<Spectrum*> fSpectra;
116  std::vector<Binning> fBinning;
117  std::vector<std::string> fLabels;
118 
119  std::vector<TH1 *> fHists;
120 
122  };
123 }
const XML_Char * name
Definition: expat.h:151
Cuts and Vars for the 2020 FD DiF Study.
Definition: vars.h:6
void SaveTo(TDirectory *dir, const std::string &name) const
Definition: Multiverse.cxx:550
Spectrum * GetPlusOneSigmaShift(const Spectrum *)
Definition: Multiverse.cxx:443
Multiverse operator/(const Spectrum &) const
Definition: Multiverse.cxx:193
Simple record of shifts applied to systematic parameters.
Definition: SystShifts.h:20
std::vector< std::string > fLabels
Definition: Multiverse.h:117
TH1 * ToHist(const Spectrum *, double=-1)
Definition: Multiverse.cxx:707
std::vector< Binning > fBinning
Definition: Multiverse.h:116
std::vector< Spectrum * > fSpectra
Definition: Multiverse.h:115
Spectrum * GetMinusOneSigmaShift(const Spectrum *)
Definition: Multiverse.cxx:450
double BinSigma(std::vector< double >, double, double)
Definition: Multiverse.cxx:520
Representation of a spectrum in any variable, with associated POT.
Definition: Spectrum.h:40
Double_t scale
Definition: plot.C:25
Multiverse & operator/=(const Spectrum &)
Definition: Multiverse.cxx:179
std::vector< TH1 * > fHists
Definition: Multiverse.h:119
TH1 *( ProductFunc_t)(TH1 *, TH1 *)
Definition: Multiverse.h:8
Multiverse & operator=(const Multiverse &)
Definition: Multiverse.cxx:600
Multiverse operator*(const Multiverse &) const
Definition: Multiverse.cxx:167
static Multiverse CopyAndTransform(const Multiverse &rhs, const std::function< TransformFunc_t > &transform)
Definition: Multiverse.cxx:29
Multiverse & operator*=(const Multiverse &)
Definition: Multiverse.cxx:154
void InitFromSpectra()
Definition: Multiverse.cxx:694
static std::unique_ptr< Multiverse > LoadFrom(TDirectory *dir, const std::string &name)
Definition: Multiverse.cxx:573
std::vector< double > POT
Base class for the various types of spectrum loader.
TDirectory * dir
Definition: macro.C:5
double livetime
Definition: saveFDMCHists.C:21
void Scale(double scale)
Definition: Multiverse.cxx:19
TH1 *( TransformFunc_t)(TH1 *)
Definition: Multiverse.h:7
const std::vector< TH1 * > GetUniversesHist()
Definition: Multiverse.cxx:120
void Transform(const Multiverse &rhs, const std::function< ProductFunc_t > &transform)
Definition: Multiverse.cxx:72
Spectrum *( TransformSpectraFunc_t)(Spectrum *)
Definition: Multiverse.h:9
Spectrum * ToSpectrum(TH1 *h, double POT=1, double livetime=0)
Definition: Multiverse.cxx:733
int GetNUniverses() const
Definition: Multiverse.h:105
Spectrum * GetNSigmaShift(const Spectrum *, double)
Definition: Multiverse.cxx:471
void Divide(Multiverse &, bool=false)
Definition: Multiverse.cxx:139
Multiverse(SpectrumLoaderBase &, const HistAxis &, const Cut &, std::vector< SystShifts >, const Var &)
Definition: Multiverse.cxx:315
void DivisionHelper(TH1 *, TH1 *, bool)
Definition: Multiverse.cxx:129
enum BeamMode string