TrivialExtrap.cxx
Go to the documentation of this file.
2 
5 #include "CAFAna/Core/Loaders.h"
6 
7 #include "TDirectory.h"
8 #include "TObjString.h"
9 
10 namespace ana
11 {
12  REGISTER_LOADFROM("TrivialExtrap", IExtrap, TrivialExtrap);
13 
14  //----------------------------------------------------------------------
17  const Binning& bins,
18  const Var& var,
19  const Cut& cut,
20  const SystShifts& shift,
21  const Var& wei)
22  : TrivialExtrap(loaders, HistAxis(label, bins, var), cut, shift, wei)
23  {
24  }
25 
26  //----------------------------------------------------------------------
28  const HistAxis& axis,
29  const Cut& cut,
30  const SystShifts& shift,
31  const Var& wei)
32  : TrivialExtrap(loaders.GetLoader(caf::kFARDET, Loaders::kMC, ana::kBeam, Loaders::kNonSwap),
33  loaders.GetLoader(caf::kFARDET, Loaders::kMC, ana::kBeam, Loaders::kFluxSwap),
34  loaders.GetLoader(caf::kFARDET, Loaders::kMC, ana::kBeam, Loaders::kTauSwap),
35  axis, cut, shift, wei)
36  {
37  }
38 
39  //----------------------------------------------------------------------
42  SpectrumLoaderBase& loaderTau,
43  const HistAxis& axis,
44  const Cut& cut,
45  const SystShifts& shift,
46  const Var& wei) :
47  fNueApp (loaderSwap, axis, cut && kIsSig && !kIsAntiNu, shift, wei),
48  fNueAppAnti (loaderSwap, axis, cut && kIsSig && kIsAntiNu, shift, wei),
49  fNumuSurv (loader, axis, cut && kIsNumuCC && !kIsAntiNu, shift, wei),
50  fNumuSurvAnti (loader, axis, cut && kIsNumuCC && kIsAntiNu, shift, wei),
51  fNumuApp (loaderSwap, axis, cut && kIsNumuApp && !kIsAntiNu, shift, wei),
52  fNumuAppAnti (loaderSwap, axis, cut && kIsNumuApp && kIsAntiNu, shift, wei),
53  fNueSurv (loader, axis, cut && kIsBeamNue && !kIsAntiNu, shift, wei),
54  fNueSurvAnti (loader, axis, cut && kIsBeamNue && kIsAntiNu, shift, wei),
55  fTauFromE (loaderTau, axis, cut && kIsTauFromE && !kIsAntiNu, shift, wei),
56  fTauFromEAnti (loaderTau, axis, cut && kIsTauFromE && kIsAntiNu, shift, wei),
57  fTauFromMu (loaderTau, axis, cut && kIsTauFromMu && !kIsAntiNu, shift, wei),
58  fTauFromMuAnti(loaderTau, axis, cut && kIsTauFromMu && kIsAntiNu, shift, wei),
59  fNCTot (loader, axis, cut && kIsNC, shift, wei),
60  fNC (loader, axis, cut && kIsNC && !kIsAntiNu, shift, wei),
61  fNCAnti (loader, axis, cut && kIsNC && kIsAntiNu, shift, wei)
62  {
63  // Swapped files are just as valid a source of NCs as unswapped. This
64  // approximately doubles our statistics. SpectrumLoader just adds events
65  // and POT for both cases, which is the right thing to do.
66  loaderSwap.AddSpectrum(fNCTot, axis.GetVar1D(), cut && kIsNC, shift, wei);
67  loaderSwap.AddSpectrum(fNC, axis.GetVar1D(), cut && kIsNC && !kIsAntiNu, shift, wei);
68  loaderSwap.AddSpectrum(fNCAnti,axis.GetVar1D(), cut && kIsNC && kIsAntiNu, shift, wei);
69  loaderTau .AddSpectrum(fNCTot, axis.GetVar1D(), cut && kIsNC, shift, wei);
70  loaderTau .AddSpectrum(fNC, axis.GetVar1D(), cut && kIsNC && !kIsAntiNu, shift, wei);
71  loaderTau .AddSpectrum(fNCAnti,axis.GetVar1D(), cut && kIsNC && kIsAntiNu, shift, wei);
72  }
73 
74  //----------------------------------------------------------------------
77  SpectrumLoaderBase& loaderTau,
79  const Binning& bins,
80  const Var& var,
81  const Cut& cut,
82  const SystShifts& shift,
83  const Var& wei) :
84  TrivialExtrap(loader, loaderSwap, loaderTau,
85  HistAxis(label, bins, var),
86  cut, shift, wei)
87  {
88  }
89 
90  //----------------------------------------------------------------------
94  const Binning& bins,
95  const Var& var,
96  const Cut& cut,
97  const SystShifts& shift,
98  const Var& wei)
99  : TrivialExtrap(loader, loaderSwap, kNullLoader,
100  label, bins, var, cut, shift, wei)
101  {
102  }
103 
104  //----------------------------------------------------------------------
105  void TrivialExtrap::SaveTo(TDirectory* dir, const std::string& name) const
106  {
107  TDirectory* tmp = gDirectory;
108 
109  dir = dir->mkdir(name.c_str()); // switch to subdir
110  dir->cd();
111 
112  TObjString("TrivialExtrap").Write("type");
113 
114  fNueApp.SaveTo(dir, "nue_app");
115  fNueAppAnti.SaveTo(dir, "nue_app_anti");
116  fNCTot.SaveTo(dir, "nc_tot");
117  fNC.SaveTo(dir, "nc");
118  fNCAnti.SaveTo(dir, "nc_anti");
119  fNumuSurv.SaveTo(dir, "numu_surv");
120  fNumuSurvAnti.SaveTo(dir, "numu_surv_anti");
121  fNumuApp.SaveTo(dir, "numu_app");
122  fNumuAppAnti.SaveTo(dir, "numu_app_anti");
123  fNueSurv.SaveTo(dir, "nue_surv");
124  fNueSurvAnti.SaveTo(dir, "nue_surv_anti");
125  fTauFromE.SaveTo(dir, "nutau_from_nue");
126  fTauFromEAnti.SaveTo(dir, "nutau_from_nue_anti");
127  fTauFromMu.SaveTo(dir, "nutau_from_numu");
128  fTauFromMuAnti.SaveTo(dir, "nutau_from_numu_anti");
129 
130  dir->Write();
131  delete dir;
132 
133  tmp->cd();
134  }
135 
136  //----------------------------------------------------------------------
137  std::unique_ptr<TrivialExtrap> TrivialExtrap::LoadFrom(TDirectory* dir, const std::string& name)
138  {
139  dir = dir->GetDirectory(name.c_str()); // switch to subdir
140  assert(dir);
141 
142  std::unique_ptr<TrivialExtrap> ret(new TrivialExtrap);
143 
144  ret->fNueApp = *OscillatableSpectrum::LoadFrom(dir, "nue_app");
145  ret->fNueAppAnti = *OscillatableSpectrum::LoadFrom(dir, "nue_app_anti");
146  ret->fNumuSurv = *OscillatableSpectrum::LoadFrom(dir, "numu_surv");
147  ret->fNumuSurvAnti = *OscillatableSpectrum::LoadFrom(dir, "numu_surv_anti");
148  ret->fNumuApp = *OscillatableSpectrum::LoadFrom(dir, "numu_app");
149  ret->fNumuAppAnti = *OscillatableSpectrum::LoadFrom(dir, "numu_app_anti");
150  ret->fNueSurv = *OscillatableSpectrum::LoadFrom(dir, "nue_surv");
151  ret->fNueSurvAnti = *OscillatableSpectrum::LoadFrom(dir, "nue_surv_anti");
152  ret->fTauFromE = *OscillatableSpectrum::LoadFrom(dir, "nutau_from_nue");
153  ret->fTauFromEAnti = *OscillatableSpectrum::LoadFrom(dir, "nutau_from_nue_anti");
154  ret->fTauFromMu = *OscillatableSpectrum::LoadFrom(dir, "nutau_from_numu");
155  ret->fTauFromMuAnti = *OscillatableSpectrum::LoadFrom(dir, "nutau_from_numu_anti");
156 
157  ret->fNCTot = *Spectrum::LoadFrom(dir, "nc_tot");
158  ret->fNC = *Spectrum::LoadFrom(dir, "nc");
159  ret->fNCAnti = *Spectrum::LoadFrom(dir, "nc_anti");
160 
161  delete dir;
162 
163  return ret;
164  }
165 }
static std::unique_ptr< OscillatableSpectrum > LoadFrom(TDirectory *dir, const std::string &name)
const XML_Char * name
Definition: expat.h:151
OscillatableSpectrum fTauFromMuAnti
Definition: TrivialExtrap.h:96
const Cut kIsNumuCC(CCFlavSel(14, 14))
Select CC .
OscillatableSpectrum fNueAppAnti
Definition: TrivialExtrap.h:91
OscillatableSpectrum fNueSurvAnti
Definition: TrivialExtrap.h:94
Represent the binning of a Spectrum&#39;s x-axis.
Definition: Binning.h:16
Cuts and Vars for the 2020 FD DiF Study.
Definition: vars.h:6
virtual void AddSpectrum(Spectrum &spect, const Var &var, const Cut &cut, const SystShifts &shift, const Var &wei=kUnweighted)
For use by the Spectrum constructor.
Simple record of shifts applied to systematic parameters.
Definition: SystShifts.h:20
OscillatableSpectrum fTauFromE
Definition: TrivialExtrap.h:95
Collection of SpectrumLoaders for many configurations.
Definition: Loaders.h:23
const Color_t kMC
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
const Cut kIsBeamNue(CCFlavSel(12, 12))
Select CC .
const Cut kIsNumuApp(CCFlavSel(14, 12))
Select CC .
OscillatableSpectrum fNueApp
Definition: TrivialExtrap.h:91
Float_t tmp
Definition: plot.C:36
OscillatableSpectrum fNumuAppAnti
Definition: TrivialExtrap.h:93
OscillatableSpectrum fNumuSurvAnti
Definition: TrivialExtrap.h:92
"Extrapolation" that simply returns the FD MC prediction
Definition: TrivialExtrap.h:10
const char * label
const Cut kIsTauFromE(CCFlavSel(16, 12))
Select CC .
const Cut kIsTauFromMu(CCFlavSel(16, 14))
Select CC .
static std::unique_ptr< Spectrum > LoadFrom(TDirectory *dir, const std::string &name)
Definition: Spectrum.cxx:546
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 fTauFromMu
Definition: TrivialExtrap.h:96
OscillatableSpectrum fNueSurv
Definition: TrivialExtrap.h:94
const Cut kIsSig(CCFlavSel(12, 14))
Select CC .
OscillatableSpectrum fNumuApp
Definition: TrivialExtrap.h:93
virtual void SaveTo(TDirectory *dir, const std::string &name) const override
OscillatableSpectrum fTauFromEAnti
Definition: TrivialExtrap.h:95
void SaveTo(TDirectory *dir, const std::string &name) const
Definition: Spectrum.cxx:517
loader
Definition: demo0.py:10
Base class for the various types of spectrum loader.
const Binning bins
Definition: NumuCC_CPiBin.h:8
::xsd::cxx::tree::string< char, simple_type > string
Definition: Database.h:154
const Cut cut
Definition: exporter_fd.C:30
OscillatableSpectrum fNumuSurv
Definition: TrivialExtrap.h:92
TDirectory * dir
Definition: macro.C:5
REGISTER_LOADFROM("BENDecomp", IDecomp, BENDecomp)
std::vector< Loaders * > loaders
Definition: syst_header.h:386
assert(nhit_max >=nhit_nbins)
This module creates Common Analysis Files.
Definition: FileReducer.h:10
loaderSwap
Definition: demo4.py:9
static std::unique_ptr< TrivialExtrap > LoadFrom(TDirectory *dir, const std::string &name)
void SaveTo(TDirectory *dir, const std::string &name) const
static NullLoader kNullLoader
Dummy loader that doesn&#39;t load any files.
T GetVar1D() const
Definition: HistAxis.cxx:43