FDExtrap.cxx
Go to the documentation of this file.
1 
3 
4 #include <utility>
5 
7 #include "CAFAna/Core/Loaders.h"
9 #include "CAFAna/Cuts/Cuts.h"
10 #include "CAFAna/Cuts/TruthCuts.h"
11 
12 #include "TDirectory.h"
13 #include "TH1D.h"
14 #include "TObject.h"
15 #include "TObjString.h"
16 #include "TVectorD.h"
17 #include <cassert>
18 
19 namespace ana
20 {
21 
22  //---------------------------------------------------------------------------
25  const HistAxis& axis,
26  const Cut& selection,
27  const SystShifts& shiftMC,
28  const Var& weight
29  )
30  {
31  return FDExtrap::FDExtrap_c(
32  loaders.GetLoader(
34  loaders.GetLoader(
36  loaders.GetLoader(
38  axis,
39  selection,
40  shiftMC,
41  weight
42  );
43  }
44 
45 
46  //---------------------------------------------------------------------------
49  const HistAxis& axis,
50  const Cut& selection,
51  const SystShifts& shiftMC,
52  const Var& weight)
53  {
54  FDExtrap extrap(nonswap, swap, tau, axis, selection, shiftMC, weight);
55  return extrap;
56  }
57 
58  //----------------------------------------------------------------------
60  {
61  return *fNCCompSpec;
62  }
63 
64  //-----------------------------------------------------------------------
66  {
67  return *fEEComp;
68  }
69 
70  //---------------------------------------------------------------------
72  {
73  return *fAEAEComp;
74  }
75 
76  //---------------------------------------------------------------------
78  {
79  return *fEMComp;
80  }
81 
82  //---------------------------------------------------------------------
84  {
85  return *fAEAMComp;
86  }
87 
88  //---------------------------------------------------------------------
90  {
91  return *fMMComp;
92  }
93 
94  //---------------------------------------------------------------------
96  {
97  return *fAMAMComp;
98  }
99 
100  //---------------------------------------------------------------------
102  {
103  return *fMEComp;
104  }
105  //---------------------------------------------------------------------
107  {
108  return *fMTComp;
109  }
110  //---------------------------------------------------------------------
112  {
113  return *fAMATComp;
114  }
115  //---------------------------------------------------------------------
117  {
118  return *fETComp;
119  }
120  //---------------------------------------------------------------------
122  {
123  return *fAEATComp;
124  }
125  //---------------------------------------------------------------------
127  {
128  return *fAMAEComp;
129  }
130  //---------------------------------------------------------------------
132  {
133  return *fENCComp;
134  }
135  //---------------------------------------------------------------------
137  {
138  return *fMNCComp;
139  }
140  //---------------------------------------------------------------------
142  {
143  return *fTNCComp;
144  }
145  //---------------------------------------------------------------------
147  {
148  return *fAENCComp;
149  }
150  //---------------------------------------------------------------------
152  {
153  return *fAMNCComp;
154  }
155  //---------------------------------------------------------------------
157  {
158  return *fATNCComp;
159  }
160 
161  //---------------------------------------------------------------------
164  SpectrumLoaderBase& tau,
165  const HistAxis& axis,
166  const Cut& selection,
167  const SystShifts& shiftMC,
168  const Var& weight)
169 
170  :/* fPOT(0),*/
171  fEEComp( new OscillatableSpectrum(nonswap, axis, selection && kIsBeamNue && !kIsAntiNu, shiftMC, weight)),
172  fAEAEComp(new OscillatableSpectrum(nonswap, axis, selection && kIsBeamNue && kIsAntiNu, shiftMC, weight)),
173  fEMComp( new OscillatableSpectrum(swap, axis, selection && kIsNumuApp && !kIsAntiNu, shiftMC, weight)),
174  fAEAMComp(new OscillatableSpectrum(swap, axis, selection && kIsNumuApp && kIsAntiNu, shiftMC, weight)),
175  fETComp( new OscillatableSpectrum(tau, axis, selection && kIsTauFromE && !kIsAntiNu, shiftMC, weight)),
176  fAEATComp(new OscillatableSpectrum(tau, axis, selection && kIsTauFromE && kIsAntiNu, shiftMC, weight)),
177  fMEComp( new OscillatableSpectrum(swap, axis, selection && kIsSig && !kIsAntiNu, shiftMC, weight)),
178  fAMAEComp(new OscillatableSpectrum(swap, axis, selection && kIsSig && kIsAntiNu, shiftMC, weight)),
179  fMMComp( new OscillatableSpectrum(nonswap, axis, selection && kIsNumuCC && !kIsAntiNu, shiftMC, weight)),
180  fAMAMComp(new OscillatableSpectrum(nonswap, axis, selection && kIsNumuCC && kIsAntiNu, shiftMC, weight)),
181  fMTComp( new OscillatableSpectrum(tau, axis, selection && kIsTauFromMu && !kIsAntiNu, shiftMC, weight)),
182  fAMATComp(new OscillatableSpectrum(tau, axis, selection && kIsTauFromMu && kIsAntiNu, shiftMC, weight)),
183  fENCComp( new OscillatableSpectrum(nonswap, axis, selection && kIsNue && !kIsAntiNu && kIsNC, shiftMC, weight)),
184  fMNCComp( new OscillatableSpectrum(nonswap, axis, selection && kIsNumu && !kIsAntiNu && kIsNC, shiftMC, weight)),
185  fTNCComp( new OscillatableSpectrum(nonswap, axis, selection && kIsTau && !kIsAntiNu && kIsNC, shiftMC, weight)),
186  fAENCComp(new OscillatableSpectrum(nonswap, axis, selection && kIsNue && kIsAntiNu && kIsNC, shiftMC, weight)),
187  fAMNCComp(new OscillatableSpectrum(nonswap, axis, selection && kIsNumu && kIsAntiNu && kIsNC, shiftMC, weight)),
188  fATNCComp(new OscillatableSpectrum(nonswap, axis, selection && kIsTau && kIsAntiNu && kIsNC, shiftMC, weight)),
189  fNCCompSpec(new Spectrum(nonswap, axis, selection && kIsNC, shiftMC, weight)),
190  fSpecLoad(&nonswap),
191  fSpecLoadt(&tau)
192  {
193  }
194 
195  //---------------------------------------------------------------------
196  void FDExtrap::SaveTo(TDirectory* dir, const std::string& name) const
197  {
198  TDirectory* tmp = gDirectory;
199 
200  dir = dir->mkdir(name.c_str()); // switch to subdir
201  dir->cd();
202 
203  TObjString("FDExtrap").Write("type");
204 
205  // nue -> nue
206  fEEComp->SaveTo(dir, "EEComp");
207  fAEAEComp->SaveTo(dir, "AEAEComp");
208 
209  // nue -> numu
210  fEMComp->SaveTo(dir, "EMComp");
211  fAEAMComp->SaveTo(dir, "AEAMComp");
212 
213  // nue -> nutau
214  fETComp->SaveTo(dir, "ETComp");
215  fAEATComp->SaveTo(dir, "AEATComp");
216 
217  // numu -> nue
218  fMEComp->SaveTo(dir, "MEComp");
219  fAMAEComp->SaveTo(dir, "AMAEComp");
220 
221  // numu -> numu
222  fMMComp->SaveTo(dir, "MMComp");
223  fAMAMComp->SaveTo(dir, "AMAMComp");
224 
225  // numu -> nutau
226  fMTComp->SaveTo(dir, "MTComp");
227  fAMATComp->SaveTo(dir, "AMATComp");
228 
229  // nc components
230  fENCComp->SaveTo(dir, "ENCComp");
231  fMNCComp->SaveTo(dir, "MNCComp");
232  fTNCComp->SaveTo(dir, "TNCComp");
233  fATNCComp->SaveTo(dir, "ATNCComp");
234  fAENCComp->SaveTo(dir, "AENCComp");
235  fAMNCComp->SaveTo(dir, "AMNCComp");
236  fNCCompSpec->SaveTo(dir, "NCComp");
237 
238  dir->Write();
239  delete dir;
240 
241  tmp->cd();
242  }
243 
244  //----------------------------------------------------------------------
245  std::unique_ptr<FDExtrap> FDExtrap::LoadFrom(TDirectory* dir, const std::string& name)
246  {
247  dir = dir->GetDirectory(name.c_str()); // switch to subdir
248  assert(dir);
249 
250  std::unique_ptr<FDExtrap> ret(new FDExtrap);
251 
252  // nue -> nue
253 
254  ret->fEEComp = ana::LoadFrom<OscillatableSpectrum>(dir, "EEComp");
255 
256  ret->fAEAEComp = ana::LoadFrom<OscillatableSpectrum>(dir, "AEAEComp");
257 
258  // nue -> numu
259 
260  ret->fEMComp = ana::LoadFrom<OscillatableSpectrum>(dir, "EMComp");
261 
262  ret->fAEAMComp = ana::LoadFrom<OscillatableSpectrum>(dir, "AEAMComp");
263 
264  // nue -> nutau
265 
266  ret->fETComp = ana::LoadFrom<OscillatableSpectrum>(dir, "ETComp");
267 
268  ret->fAEATComp = ana::LoadFrom<OscillatableSpectrum>(dir, "AEATComp");
269 
270  // numu -> nue
271 
272  ret->fMEComp = ana::LoadFrom<OscillatableSpectrum>(dir, "MEComp");
273 
274  ret->fAMAEComp = ana::LoadFrom<OscillatableSpectrum>(dir, "AMAEComp");
275 
276  // numu -> numu
277 
278  ret->fMMComp = ana::LoadFrom<OscillatableSpectrum>(dir, "MMComp");
279 
280  ret->fAMAMComp = ana::LoadFrom<OscillatableSpectrum>(dir, "AMAMComp");
281 
282  // numu -> nutau
283 
284  ret->fMTComp = ana::LoadFrom<OscillatableSpectrum>(dir, "MTComp");
285 
286  ret->fAMATComp = ana::LoadFrom<OscillatableSpectrum>(dir, "AMATComp");
287 
288  // nc components
289 
290  ret->fENCComp = ana::LoadFrom<OscillatableSpectrum>(dir, "ENCComp");
291 
292  ret->fMNCComp = ana::LoadFrom<OscillatableSpectrum>(dir, "MNCComp");
293 
294  ret->fTNCComp = ana::LoadFrom<OscillatableSpectrum>(dir, "TNCComp");
295 
296  ret->fATNCComp = ana::LoadFrom<OscillatableSpectrum>(dir, "ATNCComp");
297 
298  ret->fAENCComp = ana::LoadFrom<OscillatableSpectrum>(dir, "AENCComp");
299 
300  ret->fAMNCComp = ana::LoadFrom<OscillatableSpectrum>(dir, "AMNCComp");
301 
302  ret->fNCCompSpec = ana::LoadFrom<Spectrum>(dir, "NCComp");
303 
304  delete dir;
305 
306  return ret;
307  }
308 }
const XML_Char * name
Definition: expat.h:151
OscillatableSpectrum TauNCComponent()
Definition: FDExtrap.cxx:141
const Cut kIsNumuCC(CCFlavSel(14, 14))
Select CC .
Far Detector at Ash River.
Definition: SREnums.h:11
Spectrum NCComponent()
Definition: FDExtrap.cxx:59
Cuts and Vars for the 2020 FD DiF Study.
Definition: vars.h:6
std::unique_ptr< OscillatableSpectrum > fAEAMComp
Definition: FDExtrap.h:87
std::unique_ptr< OscillatableSpectrum > fETComp
Definition: FDExtrap.h:88
std::unique_ptr< OscillatableSpectrum > fAEATComp
Definition: FDExtrap.h:89
static std::unique_ptr< FDExtrap > LoadFrom(TDirectory *dir, const std::string &name)
Definition: FDExtrap.cxx:245
OscillatableSpectrum AntiTauCCAppComponent()
Definition: FDExtrap.cxx:111
OscillatableSpectrum NueCCSurvComponent()
Definition: FDExtrap.cxx:65
const Var weight
Simple record of shifts applied to systematic parameters.
Definition: SystShifts.h:20
OscillatableSpectrum AntiNumuCCAppComponent()
Definition: FDExtrap.cxx:83
const Cut kIsNumu([](const caf::SRProxy *sr){return(sr->mc.nnu==1 &&abs(sr->mc.nu[0].pdg)==14);})
Definition: TruthCuts.h:10
std::unique_ptr< OscillatableSpectrum > fTNCComp
Definition: FDExtrap.h:99
Collection of SpectrumLoaders for many configurations.
Definition: Loaders.h:23
std::unique_ptr< Spectrum > fNCCompSpec
Definition: FDExtrap.h:103
std::unique_ptr< OscillatableSpectrum > fMTComp
Definition: FDExtrap.h:94
std::unique_ptr< OscillatableSpectrum > fAMATComp
Definition: FDExtrap.h:95
const Cut kIsAntiNu([](const caf::SRProxy *sr){if(sr->mc.nnu==0) return false;assert(sr->mc.nnu==1);return sr->mc.nu[0].pdg< 0;})
Is this truly an antineutrino?
Definition: TruthCuts.h:53
OscillatableSpectrum EAntiTauCCAppComponent()
Definition: FDExtrap.cxx:121
const Cut kIsBeamNue(CCFlavSel(12, 12))
Select CC .
const Cut kIsNumuApp(CCFlavSel(14, 12))
Select CC .
std::unique_ptr< OscillatableSpectrum > fATNCComp
Definition: FDExtrap.h:102
std::unique_ptr< OscillatableSpectrum > fMEComp
Definition: FDExtrap.h:90
const Cut kIsTau
Definition: TruthCuts.cxx:25
Float_t tmp
Definition: plot.C:36
OscillatableSpectrum AntiNumuCCSurvComponent()
Definition: FDExtrap.cxx:95
std::unique_ptr< OscillatableSpectrum > fEMComp
Definition: FDExtrap.h:86
std::unique_ptr< OscillatableSpectrum > fMMComp
Definition: FDExtrap.h:92
Representation of a spectrum in any variable, with associated POT.
Definition: Spectrum.h:40
std::unique_ptr< OscillatableSpectrum > fAMAEComp
Definition: FDExtrap.h:91
OscillatableSpectrum AntiNumuNCComponent()
Definition: FDExtrap.cxx:151
std::unique_ptr< OscillatableSpectrum > fAMAMComp
Definition: FDExtrap.h:93
std::unique_ptr< OscillatableSpectrum > fMNCComp
Definition: FDExtrap.h:98
const Cut kIsTauFromE(CCFlavSel(16, 12))
Select CC .
OscillatableSpectrum NumuCCSurvComponent()
Definition: FDExtrap.cxx:89
SpectrumLoaderBase * fSpecLoadt
Definition: FDExtrap.h:105
const Cut kIsTauFromMu(CCFlavSel(16, 14))
Select CC .
const Cut kIsNC([](const caf::SRProxy *sr){if(sr->mc.nnu==0) return false;assert(sr->mc.nnu==1);return!sr->mc.nu[0].iscc;})
Is this a Neutral Current event?
Definition: TruthCuts.h:8
OscillatableSpectrum TauCCAppComponent()
Definition: FDExtrap.cxx:106
SpectrumLoaderBase & GetLoader(caf::Det_t det, DataMC datamc, DataSource src=kBeam, SwappingConfig swap=kNonSwap)
Retrieve a specific loader.
Definition: Loaders.cxx:129
virtual void SaveTo(TDirectory *dir, const std::string &name) const
Definition: FDExtrap.cxx:196
std::unique_ptr< OscillatableSpectrum > fAMNCComp
Definition: FDExtrap.h:101
OscillatableSpectrum NumuCCAppComponent()
Definition: FDExtrap.cxx:77
OscillatableSpectrum AntiNueNCComponent()
Definition: FDExtrap.cxx:146
OscillatableSpectrum AntiNueCCSurvComponent()
Definition: FDExtrap.cxx:71
const Cut kIsSig(CCFlavSel(12, 14))
Select CC .
const Cut kIsNue([](const caf::SRProxy *sr){return(sr->mc.nnu==1 &&abs(sr->mc.nu[0].pdg)==12);})
Definition: TruthCuts.h:9
OscillatableSpectrum NueNCComponent()
Definition: FDExtrap.cxx:131
Base class for the various types of spectrum loader.
::xsd::cxx::tree::string< char, simple_type > string
Definition: Database.h:154
std::unique_ptr< OscillatableSpectrum > fAENCComp
Definition: FDExtrap.h:100
std::unique_ptr< OscillatableSpectrum > fEEComp
Definition: FDExtrap.h:84
TDirectory * dir
Definition: macro.C:5
OscillatableSpectrum ETauCCAppComponent()
Definition: FDExtrap.cxx:116
std::vector< Loaders * > loaders
Definition: syst_header.h:386
OscillatableSpectrum AntiNueCCAppComponent()
Definition: FDExtrap.cxx:126
assert(nhit_max >=nhit_nbins)
std::unique_ptr< OscillatableSpectrum > fENCComp
Definition: FDExtrap.h:97
OscillatableSpectrum NueCCAppComponent()
Definition: FDExtrap.cxx:101
Spectrum with true energy information, allowing it to be oscillated
std::unique_ptr< OscillatableSpectrum > fAEAEComp
Definition: FDExtrap.h:85
OscillatableSpectrum NumuNCComponent()
Definition: FDExtrap.cxx:136
SpectrumLoaderBase * fSpecLoad
Definition: FDExtrap.h:104
OscillatableSpectrum AntiTauNCComponent()
Definition: FDExtrap.cxx:156
static FDExtrap FDExtrap_c(Loaders &loaders, const HistAxis &axis, const Cut &selection, const SystShifts &shiftMC=kNoShift, const Var &weight=kUnweighted)
Definition: FDExtrap.cxx:23