BENDecomp.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "CAFAna/Core/Cut.h"
4 #include "CAFAna/Core/HistAxis.h"
6 #include "CAFAna/Core/Spectrum.h"
8 #include "CAFAna/Vars/HistAxes.h"
10 
11 #include <memory>
12 #include <string>
13 #include "TH2.h"
14 #include "TString.h"
15 
16 class TDirectory;
17 
18 #include "StandardRecord/Proxy/FwdDeclare.h" // for Reduce function
19 
20 namespace ana
21 {
22 
23  class Binning;
24  class Loaders;
25  class SpectrumLoaderBase;
26 
27  class BENDecomp: public IDecomp
28  {
29 
30  public:
31 
34 
35  // Keep these for backward compatibility
36  BENDecomp(SpectrumLoaderBase& loaderMC,
37  SpectrumLoaderBase& loaderData,
38  const HistAxis& axis,
39  const Cut& cut,
40  const SystShifts& shiftMC = kNoShift,
41  const SystShifts& shiftData = kNoShift,
42  const Var& wei = kUnweighted,
43  const HistAxis& axisNumuPi = kNumuNonQEBENAxis,
44  const Cut& cutNumuPi = kBENPiNumuCut,
45  const double kaonNormalization=1.17
46  );
48  const HistAxis& axis,
49  const Cut& cut,
50  const SystShifts& shiftMC = kNoShift,
51  const SystShifts& shiftData = kNoShift,
52  const Var& wei = kUnweighted,
53  const HistAxis& axisNumuPi = kNumuNonQEBENAxis,
54  const Cut& cutNumuPi = kBENPiNumuCut,
55  const double kaonNormalization=1.17
56  );
57 
59  SpectrumLoaderBase& loaderMC,
60  SpectrumLoaderBase& loaderData,
61  const HistAxis& axis,
62  const Cut& cut,
63  const SystShifts& shiftMC = kNoShift,
64  const SystShifts& shiftData = kNoShift,
65  const Var& wei = kUnweighted,
66  const HistAxis& axisNumuPi = kNumuNonQEBENAxis,
67  const Cut& cutNumuPi = kBENPiNumuCut,
68  const HistAxis& axisNumuKa = kNumuCCAxisExtended,
69  const Cut& cutNumuKa = kBENKaNumuCut
70  );
71 
73  Loaders& loaders,
74  const HistAxis& axis,
75  const Cut& cut,
76  const SystShifts& shiftMC = kNoShift,
77  const SystShifts& shiftData = kNoShift,
78  const Var& wei = kUnweighted,
79  const HistAxis& axisNumuPi = kNumuNonQEBENAxis,
80  const Cut& cutNumuPi = kBENPiNumuCut,
81  const HistAxis& axisNumuKa = kNumuCCAxisExtended,
82  const Cut& cutNumuKa = kBENKaNumuCut
83  );
84 
85 
86  virtual ~BENDecomp();
87 
88  Spectrum NumuComponent() const override;
89  Spectrum AntiNumuComponent() const override;
90 
91  Spectrum NCTotalComponent() const override;
92  Spectrum NCComponent() const override;
93  Spectrum NCAntiComponent() const override;
94 
95  Spectrum NueComponent() const override;
96  Spectrum AntiNueComponent() const override;
97 
98  Spectrum Data_Component() const override;
99 
100  // Convenient for making decomposition blessed plots
101  Spectrum MC_NCTotalComponent() const override;
102  Spectrum MC_NumuComponent() const override;
103  Spectrum MC_AntiNumuComponent() const override;
104  Spectrum MC_NueComponent() const override;
105  Spectrum MC_AntiNueComponent() const override;
106 
107  void SaveTo(TDirectory* dir, const std::string& name) const override;
108  void SavePlotsPi(TDirectory * dir);
109  void SavePlotsKa(TDirectory * dir);
110  void SavePlots (TDirectory * dir);
111  static std::unique_ptr<BENDecomp> LoadFrom(TDirectory* dir, const std::string& name);
112  TH2 * GetPionWeights() const {Decompose(); return fNumuPiWeights;} //for debugging
113  double GetKaonScale() const {Decompose(); return fKaonNormalization;}
116 
117  // Reduction function for BEN 2017
119  const caf::SRProxy* srProxy);
120 
121 
122  protected:
124  : fData(Spectrum::Uninitialized()),
125  fNCTot(Spectrum::Uninitialized()),
126  fNue(Spectrum::Uninitialized()),
127  fAntiNue(Spectrum::Uninitialized()),
128  fNumu(Spectrum::Uninitialized()),
129  fAntiNumu(Spectrum::Uninitialized()),
130  fTotal(Spectrum::Uninitialized()),
131  fNotNue(Spectrum::Uninitialized()),
132 
133  fNueCCFromPi(Spectrum::Uninitialized()),
134  fNueCCFromKa(Spectrum::Uninitialized()),
135  fNueCCFromOther(Spectrum::Uninitialized()),
136  fNueCCFromPiPtPz(Spectrum::Uninitialized()),
137 
138  fNumuSelData(Spectrum::Uninitialized()),
139  fNumuSelBkg(Spectrum::Uninitialized()),
140  fNumuSelCCFromPi(Spectrum::Uninitialized()),
141  fNumuSelCCFromKa(Spectrum::Uninitialized()),
142  fNumuSelCCFromOther(Spectrum::Uninitialized()),
143  fNumuSelCCFromPiPtPz(Spectrum::Uninitialized()),
144 
145  fNumuUncontainData(Spectrum::Uninitialized()),
146  fNumuUncontainBkg(Spectrum::Uninitialized()),
147  fNumuUncontainCCFromPi(Spectrum::Uninitialized()),
148  fNumuUncontainCCFromKa(Spectrum::Uninitialized()),
149  fNumuUncontainCCFromOther(Spectrum::Uninitialized()),
150 
151  fNueCCFromPiEstim(Spectrum::Uninitialized()),
152  fNueCCFromKaEstim(Spectrum::Uninitialized()),
153  fIsDecomposed(0),
154  fIsFixedKaScale(0),
156  {};
157 
158  void Decompose () const;
159  void MakeWeightsNumuFromPion() const;
160  void MakeWeightsNumuFromKaon() const;
161 
162  virtual Spectrum NueEstimate() const;
163  void NueEstimateFromPi() const;
164  void NueEstimateFromKa() const;
165  void NueEstimateFromOther() const;
166 
175 
180 
187 
193 
196 
197  mutable bool fIsDecomposed;
198  mutable TH2 * fNumuPiWeights;
200  mutable double fKaonNormalization;
201  };
202 
203 }
Spectrum fNumuUncontainData
Definition: BENDecomp.h:188
const XML_Char * name
Definition: expat.h:151
Spectrum fNueCCFromPiPtPz
Definition: BENDecomp.h:179
void MakeWeightsNumuFromPion() const
Definition: BENDecomp.cxx:287
Spectrum fNueCCFromPi
Definition: BENDecomp.h:176
Spectrum MC_NCTotalComponent() const override
Definition: BENDecomp.cxx:739
bool fIsFixedKaScale
Definition: BENDecomp.h:199
Cuts and Vars for the 2020 FD DiF Study.
Definition: vars.h:6
void SavePlotsPi(TDirectory *dir)
Definition: BENDecomp.cxx:540
Spectrum fNumuUncontainCCFromPi
Definition: BENDecomp.h:190
const Cut kBENKaNumuCut
Definition: BeamNueCuts.h:18
Spectrum fAntiNumu
Definition: BENDecomp.h:172
Spectrum MC_AntiNueComponent() const override
Definition: BENDecomp.cxx:730
Simple record of shifts applied to systematic parameters.
Definition: SystShifts.h:20
Proxy for caf::StandardRecord.
Definition: SRProxy.h:2126
Collection of SpectrumLoaders for many configurations.
Definition: Loaders.h:23
TH2 * fNumuPiWeights
Definition: BENDecomp.h:198
void NueEstimateFromPi() const
Definition: BENDecomp.cxx:210
Spectrum fNueCCFromKa
Definition: BENDecomp.h:177
Spectrum fNueCCFromKaEstim
Definition: BENDecomp.h:195
bool fIsDecomposed
Definition: BENDecomp.h:197
static std::unique_ptr< BENDecomp > LoadFrom(TDirectory *dir, const std::string &name)
Definition: BENDecomp.cxx:436
Spectrum NCTotalComponent() const override
Definition: BENDecomp.cxx:346
Spectrum fNumuSelCCFromPi
Definition: BENDecomp.h:183
Spectrum NCComponent() const override
Definition: BENDecomp.cxx:354
Representation of a spectrum in any variable, with associated POT.
Definition: Spectrum.h:40
void NueEstimateFromOther() const
Spectrum NueComponent() const override
Definition: BENDecomp.cxx:370
Spectrum fNumuSelCCFromKa
Definition: BENDecomp.h:184
Spectrum fTotal
Definition: BENDecomp.h:173
Spectrum fData
Definition: BENDecomp.h:167
static void ReduceForBEN2020Decaf(caf::StandardRecord *sr, const caf::SRProxy *srProxy)
Definition: BENDecomp.cxx:746
Spectrum fNumuSelCCFromOther
Definition: BENDecomp.h:185
double GetKaonScale() const
Definition: BENDecomp.h:113
Spectrum NuePiEstimate()
Definition: BENDecomp.h:114
Spectrum MC_NumuComponent() const override
Definition: BENDecomp.cxx:733
Spectrum AntiNueComponent() const override
Definition: BENDecomp.cxx:377
Spectrum fNumuSelData
Definition: BENDecomp.h:181
virtual Spectrum NueEstimate() const
Definition: BENDecomp.cxx:177
TH2 * GetPionWeights() const
Definition: BENDecomp.h:112
virtual ~BENDecomp()
Definition: BENDecomp.cxx:205
void SaveTo(TDirectory *dir, const std::string &name) const override
Definition: BENDecomp.cxx:387
Spectrum NumuComponent() const override
Definition: BENDecomp.cxx:329
const Cut kBENPiNumuCut
Definition: BeamNueCuts.h:28
caf::StandardRecord * sr
const HistAxis kNumuCCAxisExtended("Reconstructed Neutrino Energy (GeV)", Binning::Simple(80, 0, 20), kCCE)
HistAxis with binning extended to 20 GeV.
Definition: HistAxes.h:18
Spectrum MC_NueComponent() const override
Definition: BENDecomp.cxx:727
void MakeWeightsNumuFromKaon() const
Definition: BENDecomp.cxx:242
const SystShifts kNoShift
Definition: SystShifts.cxx:22
void Decompose() const
Definition: BENDecomp.cxx:195
void NueEstimateFromKa() const
Definition: BENDecomp.cxx:237
Base class for the various types of spectrum loader.
Spectrum fNumuUncontainBkg
Definition: BENDecomp.h:189
The StandardRecord is the primary top-level object in the Common Analysis File trees.
const Cut cut
Definition: exporter_fd.C:30
const HistAxis kNumuNonQEBENAxis("Non-Quasielastic Energy Estimator (GeV)", kBEN2020Binning, kCCE)
Definition: HistAxes.h:11
void SavePlots(TDirectory *dir)
Definition: BENDecomp.cxx:647
void SavePlotsKa(TDirectory *dir)
Definition: BENDecomp.cxx:483
Spectrum fNueCCFromOther
Definition: BENDecomp.h:178
TDirectory * dir
Definition: macro.C:5
Spectrum AntiNumuComponent() const override
Definition: BENDecomp.cxx:337
Spectrum NCAntiComponent() const override
Definition: BENDecomp.cxx:361
std::vector< Loaders * > loaders
Definition: syst_header.h:386
Spectrum fNotNue
Definition: BENDecomp.h:174
Spectrum fNumuSelCCFromPiPtPz
Definition: BENDecomp.h:186
Standard interface to all decomposition techniques.
Definition: IDecomp.h:13
Spectrum fNumuSelBkg
Definition: BENDecomp.h:182
Spectrum fNueCCFromPiEstim
Definition: BENDecomp.h:194
double fKaonNormalization
Definition: BENDecomp.h:200
Spectrum NueKaEstimate()
Definition: BENDecomp.h:115
Spectrum fNumu
Definition: BENDecomp.h:171
Spectrum fNumuUncontainCCFromOther
Definition: BENDecomp.h:192
Spectrum fAntiNue
Definition: BENDecomp.h:170
Spectrum Data_Component() const override
Definition: BENDecomp.cxx:742
const Var kUnweighted
The simplest possible Var, always 1. Used as a default weight.
Definition: Var.h:96
Spectrum fNCTot
Definition: BENDecomp.h:168
Spectrum MC_AntiNumuComponent() const override
Definition: BENDecomp.cxx:736
Spectrum fNumuUncontainCCFromKa
Definition: BENDecomp.h:191
Spectrum fNue
Definition: BENDecomp.h:169
enum BeamMode string