SystematicDef.h
Go to the documentation of this file.
1 #pragma once
2 
4 #include "CAFAna/Core/Cut.h"
6 #include "CAFAna/Core/HistAxis.h"
7 
8 class TString;
9 class TDirectory;
10 class TObjString;
11 
12 namespace ana
13 {
14  template<typename W>
15  struct UpDownPair {
16  W * up = NULL;
17  W * down = NULL;
18  bool IsTwoSided() const { return down; }
19  };
20 
21  template<class SRType>
23  {
24  public:
25  enum Type_t {
27  kTwoSided
28  };
29 
31  : fName(name), fType(type)
32  {}
33 
34  // one sided, one multiloader
36  std::vector<SpectrumLoaderBase*> loaders,
37  const _HistAxis<_Var<SRType> > * histaxis,
38  const _Var<SRType> * weight,
39  const SystShifts * shift = &kNoShift)
40  : GenericSystematicDef(name, loaders, {}, histaxis, {weight}, {shift}, kOneSided)
41  {}
42  // one sided, one monoloader
45  const _HistAxis<_Var<SRType>> * histaxis,
46  const _Var<SRType> * weight,
47  const SystShifts * shift = &kNoShift)
48  : GenericSystematicDef(name, {loader}, {}, histaxis, {weight}, {shift}, kOneSided)
49  {}
50 
51 
52  // two sided, two multiloader
54  std::vector<SpectrumLoaderBase*> loaders_up,
55  std::vector<SpectrumLoaderBase*> loaders_down,
56  const _HistAxis<_Var<SRType> > * histaxis,
57  const _Var<SRType> * weight,
58  const SystShifts * shift = &kNoShift)
59  : GenericSystematicDef(name, loaders_up, loaders_down, histaxis, {weight, weight}, {shift, shift}, kTwoSided)
60  {}
61 
62  // two sided, two monooader
64  SpectrumLoaderBase* loader_up,
65  SpectrumLoaderBase* loader_down,
66  const _HistAxis<_Var<SRType> > * histaxis,
67  const _Var<SRType> * weight,
68  const SystShifts * shift = &kNoShift)
69  : GenericSystematicDef(name, {loader_up}, {loader_down}, histaxis, {weight, weight}, {shift, shift}, kTwoSided)
70  {}
71 
72  // two sided two weight one monoloader
75  const _HistAxis<_Var<SRType> > * histaxis,
76  const _Var<SRType> * weight_up,
77  const _Var<SRType> * weight_down,
78  const SystShifts * shift = &kNoShift)
79  : GenericSystematicDef(name, {loader}, {}, histaxis, {weight_up, weight_down}, {shift, shift}, kTwoSided)
80  {}
81  // two sided two weight one multiloader
83  std::vector<SpectrumLoaderBase*> loaders,
84  const _HistAxis<_Var<SRType> > * histaxis,
85  const _Var<SRType> * weight_up,
86  const _Var<SRType> * weight_down,
87  const SystShifts * shift = &kNoShift)
88  : GenericSystematicDef(name, loaders, {}, histaxis, {weight_up, weight_down}, {shift, shift}, kTwoSided)
89  {}
90 
91  // two sided two shift one monoloader
94  const _HistAxis<_Var<SRType> > * histaxis,
95  const _Var<SRType> * weight,
96  const SystShifts * shift_up,
97  const SystShifts * shift_down)
98  : GenericSystematicDef(name, {loader}, {}, histaxis, {weight, weight}, {shift_up, shift_down}, kTwoSided)
99  {}
100 
101  // two sided two shift one multiloader
103  std::vector<SpectrumLoaderBase*> loaders,
104  const _HistAxis<_Var<SRType> > * histaxis,
105  const _Var<SRType> * weight,
106  const SystShifts * shift_up,
107  const SystShifts * shift_down)
108  : GenericSystematicDef(name, loaders, {}, histaxis, {weight, weight}, {shift_up, shift_down}, kTwoSided)
109  {}
110 
111  Spectrum * BuildSpectrumUp(const _Cut<SRType> cut);
112  Spectrum * BuildSpectrumDown(const _Cut<SRType> cut);
113  Spectrum * BuildSpectrum(const _Cut<SRType> cut);
114 
115  void Go();
116 
117  const _HistAxis<_Var<SRType> > * HistAxis() const {return fHistAxis;}
118  const _Var<SRType> * WeightUp() const {return fWeight.up;}
119  const _Var<SRType> * WeightDown() const {return fWeight.down;}
120  const _Var<SRType> * Weight() const {return fWeight.up;}
121 
122  const SystShifts * ShiftsUp() const {return fSystShifts.up;}
123  const SystShifts * ShiftsDown() const {return fSystShifts.down;}
124  const SystShifts * Shifts() const {return fSystShifts.up;}
125 
126  std::vector<SpectrumLoaderBase *> LoadersUp() const {return fLoadersUp;}
127  std::vector<SpectrumLoaderBase *> LoadersDown() const {return fLoadersDown;}
128  std::vector<SpectrumLoaderBase *> Loaders() const {return fLoadersUp;}
129 
130  std::string GetName() const {return fName;}
131  bool IsTwoSided() { return fType == kTwoSided; }
132 
135 
136  void SaveTo(TDirectory * dir, const std::string& name) const;
137  static std::unique_ptr<GenericSystematicDef<SRType> > LoadFrom(TDirectory * dir, const std::string& name);
138  private:
139  // one ring to rule them all
141  std::vector<SpectrumLoaderBase*> loaders_up,
142  std::vector<SpectrumLoaderBase*> loaders_down,
143  const _HistAxis<_Var<SRType> > * hist_axis,
144  const UpDownPair<const _Var<SRType> > weights,
145  const UpDownPair<const SystShifts> shifts,
146  Type_t type = kTwoSided);
147 
148  std::vector<SpectrumLoaderBase *> fLoadersUp;
149  std::vector<SpectrumLoaderBase *> fLoadersDown;
150 
152 
155 
157  const Type_t fType;
158 
159  };
160 
163 
164 }
GenericSystematicDef(std::string name, std::vector< SpectrumLoaderBase * > loaders_up, std::vector< SpectrumLoaderBase * > loaders_down, const _HistAxis< _Var< SRType > > *histaxis, const _Var< SRType > *weight, const SystShifts *shift=&kNoShift)
Definition: SystematicDef.h:53
const XML_Char * name
Definition: expat.h:151
Cuts and Vars for the 2020 FD DiF Study.
Definition: vars.h:6
const SystShifts * Shifts() const
bool IsTwoSided() const
Definition: SystematicDef.h:18
void SaveTo(const osc::IOscCalc &x, TDirectory *dir, const std::string &name)
GenericSystematicDef(std::string name, std::vector< SpectrumLoaderBase * > loaders, const _HistAxis< _Var< SRType > > *histaxis, const _Var< SRType > *weight, const SystShifts *shift=&kNoShift)
Definition: SystematicDef.h:35
GenericSystematicDef(std::string name, SpectrumLoaderBase *loader, const _HistAxis< _Var< SRType > > *histaxis, const _Var< SRType > *weight_up, const _Var< SRType > *weight_down, const SystShifts *shift=&kNoShift)
Definition: SystematicDef.h:73
const Var weight
Simple record of shifts applied to systematic parameters.
Definition: SystShifts.h:20
std::vector< SpectrumLoaderBase * > Loaders() const
std::string GetName() const
const _HistAxis< _Var< SRType > > * HistAxis() const
const _Var< SRType > * Weight() const
const _Var< SRType > * WeightUp() const
const SystShifts * ShiftsDown() const
std::vector< SpectrumLoaderBase * > fLoadersUp
GenericSystematicDef(std::string name, SpectrumLoaderBase *loader_up, SpectrumLoaderBase *loader_down, const _HistAxis< _Var< SRType > > *histaxis, const _Var< SRType > *weight, const SystShifts *shift=&kNoShift)
Definition: SystematicDef.h:63
GenericSystematicDef(std::string name, std::vector< SpectrumLoaderBase * > loaders, const _HistAxis< _Var< SRType > > *histaxis, const _Var< SRType > *weight, const SystShifts *shift_up, const SystShifts *shift_down)
GenericSystematicDef< caf::SRProxy > SystematicDef
const std::string fName
std::unique_ptr< T > LoadFrom(TDirectory *dir, const std::string &label)
Definition: LoadFromFile.h:17
Representation of a spectrum in any variable, with associated POT.
Definition: Spectrum.h:40
void BuildSpectrum(void)
GenericSystematicDef(std::string name, SpectrumLoaderBase *loader, const _HistAxis< _Var< SRType > > *histaxis, const _Var< SRType > *weight, const SystShifts *shift_up, const SystShifts *shift_down)
Definition: SystematicDef.h:92
std::vector< SpectrumLoaderBase * > fLoadersDown
GenericSystematicDef< caf::SRNeutrinoProxy > NuTruthSystematicDef
Var weights
const _Var< SRType > * WeightDown() const
loader
Definition: demo0.py:10
const UpDownPair< const SystShifts > fSystShifts
const SystShifts kNoShift
Definition: SystShifts.cxx:22
Base class for the various types of spectrum loader.
GenericSystematicDef(std::string name, std::vector< SpectrumLoaderBase * > loaders, const _HistAxis< _Var< SRType > > *histaxis, const _Var< SRType > *weight_up, const _Var< SRType > *weight_down, const SystShifts *shift=&kNoShift)
Definition: SystematicDef.h:82
const Cut cut
Definition: exporter_fd.C:30
Collect information describing the x-axis of an analysis histogram.
Definition: HistAxis.h:18
TDirectory * dir
Definition: macro.C:5
GenericSystematicDef(std::string name, SpectrumLoaderBase *loader, const _HistAxis< _Var< SRType >> *histaxis, const _Var< SRType > *weight, const SystShifts *shift=&kNoShift)
Definition: SystematicDef.h:43
std::vector< Loaders * > loaders
Definition: syst_header.h:386
const _HistAxis< _Var< SRType > > * fHistAxis
std::vector< SpectrumLoaderBase * > LoadersDown() const
GenericSystematicDef(std::string name, Type_t type)
Definition: SystematicDef.h:30
Template for Cut and SpillCut.
Definition: Cut.h:15
#define W(x)
const UpDownPair< const _Var< SRType > > fWeight
std::vector< SpectrumLoaderBase * > LoadersUp() const
const SystShifts * ShiftsUp() const
enum BeamMode string