NDExtrap.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 
18 #include <cassert>
19 #include <iostream>
20 
21 namespace ana
22 {
23 
24  //---------------------------------------------------------------------------
27  const HistAxis& axis,
28  const Cut& selection,
29  const SystShifts& shiftMC,
30  const Var& weight
31  )
32  {
33  return NDExtrap::NDExtrap_c(
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  NDExtrap extrap(nonswap, swap, axis, selection, shiftMC, weight);
55  return extrap;
56  }
57 
58  //---------------------------------------------------------------------
60  {
62  std::cout << "SetWeightedPOT: " << fPOT << ", specload->get..." << fSpecLoad->GetWeightedPOT() << std::endl;
63  return fPOT;
64 
65  }
66 
67  //----------------------------------------------------------------------
69  {
70  return *fNCCompSpec;
71  }
72 
73  //-----------------------------------------------------------------------
75  {
76  return *fEEComp;
77  }
78 
79  //---------------------------------------------------------------------
81  {
82  return *fAEAEComp;
83  }
84 
85  //---------------------------------------------------------------------
87  {
88  return *fEMComp;
89  }
90 
91  //---------------------------------------------------------------------
93  {
94  return *fAEAMComp;
95  }
96 
97  //---------------------------------------------------------------------
99  {
100  return *fMMComp;
101  }
102 
103  //---------------------------------------------------------------------
105  {
106  return *fAMAMComp;
107  }
108 
109  //---------------------------------------------------------------------
111  {
112  return *fMEComp;
113  }
114 
115  //---------------------------------------------------------------------
117  {
118  return *fAMAEComp;
119  }
120 
121  //---------------------------------------------------------------------
123  {
124  return *fENCComp;
125  }
126 
127  //---------------------------------------------------------------------
129  {
130  return *fMNCComp;
131  }
132 
133  //---------------------------------------------------------------------
135  {
136  return *fAENCComp;
137  }
138 
139  //---------------------------------------------------------------------
141  {
142  return *fAMNCComp;
143  }
144 
145  //---------------------------------------------------------------------
148  const HistAxis& axis,
149  const Cut& selection,
150  const SystShifts& shiftMC,
151  const Var& weight)
152 
153  : fPOT(0),
154  fEEComp( new NDOscillatableSpectrum(nonswap, axis, selection && kIsBeamNue && !kIsAntiNu, shiftMC, weight)),
155  fAEAEComp(new NDOscillatableSpectrum(nonswap, axis, selection && kIsBeamNue && kIsAntiNu, shiftMC, weight)),
156  fEMComp( new NDOscillatableSpectrum(swap, axis, selection && kIsNumuApp && !kIsAntiNu, shiftMC, weight)),
157  fAEAMComp(new NDOscillatableSpectrum(swap, axis, selection && kIsNumuApp && kIsAntiNu, shiftMC, weight)),
158  fMMComp( new NDOscillatableSpectrum(nonswap, axis, selection && kIsNumuCC && !kIsAntiNu, shiftMC, weight)),
159  fAMAMComp(new NDOscillatableSpectrum(nonswap, axis, selection && kIsNumuCC && kIsAntiNu, shiftMC, weight)),
160  fMEComp( new NDOscillatableSpectrum(swap, axis, selection && kIsSig && !kIsAntiNu, shiftMC, weight)),
161  fAMAEComp(new NDOscillatableSpectrum(swap, axis, selection && kIsSig && kIsAntiNu, shiftMC, weight)),
162  fENCComp( new NDOscillatableSpectrum(nonswap, axis, selection && kIsNue && !kIsAntiNu && kIsNC, shiftMC, weight)),
163  fMNCComp( new NDOscillatableSpectrum(nonswap, axis, selection && kIsNumu && !kIsAntiNu && kIsNC, shiftMC, weight)),
164  fAENCComp(new NDOscillatableSpectrum(nonswap, axis, selection && kIsNue && kIsAntiNu && kIsNC , shiftMC, weight)),
165  fAMNCComp(new NDOscillatableSpectrum(nonswap, axis, selection && kIsNumu && kIsAntiNu && kIsNC , shiftMC, weight)),
166  fNCCompSpec(new Spectrum(nonswap, axis, selection && kIsNC, shiftMC, weight)),
167  fSpecLoad(&nonswap)
168  {
169  }
170 
171  //---------------------------------------------------------------------
172  void NDExtrap::SaveTo(TDirectory* dir, const std::string& name) const
173  {
174  TDirectory* tmp = gDirectory;
175 
176  dir = dir->mkdir(name.c_str()); // switch to subdir
177  dir->cd();
178 
179  TObjString("NDExtrap").Write("type");
180 
181  // TVectorD weightedpot(1);
182  // weightedpot[0]= fSpecLoad->GetWeightedPOT();
183  // weightedpot.Write("weightedpot");
184 
185  fEEComp->SaveTo(dir, "EEComp");
186  fAEAEComp->SaveTo(dir, "AEAEComp");
187  fEMComp->SaveTo(dir, "EMComp");
188  fAEAMComp->SaveTo(dir, "AEAMComp");
189  fMMComp->SaveTo(dir, "MMComp");
190  fAMAMComp->SaveTo(dir, "AMAMComp");
191  fMEComp->SaveTo(dir, "MEComp");
192  fAMAEComp->SaveTo(dir, "AMAEComp");
193  fENCComp->SaveTo(dir, "ENCComp");
194  fMNCComp->SaveTo(dir, "MNCComp");
195  fAENCComp->SaveTo(dir, "AENCComp");
196  fAMNCComp->SaveTo(dir, "AMNCComp");
197  fNCCompSpec->SaveTo(dir, "NCComp");
198 
199  dir->Write();
200  delete dir;
201 
202  tmp->cd();
203  }
204 
205 
206  //----------------------------------------------------------------------
207  std::unique_ptr<NDExtrap> NDExtrap::LoadFrom(TDirectory* dir, const std::string& name)
208  {
209  dir = dir->GetDirectory(name.c_str()); // switch to subdir
210  assert(dir);
211 
212  std::unique_ptr<NDExtrap> ret(new NDExtrap);
213  //TVectorD *v = (TVectorD*)dir->Get("weightedpot");
214  //ret->fPOT=(*v)(0);
215 
216  ret->fEEComp = ana::LoadFrom<NDOscillatableSpectrum>(dir, "EEComp");
217 
218  ret->fAEAEComp = ana::LoadFrom<NDOscillatableSpectrum>(dir, "AEAEComp");
219 
220  ret->fEMComp = ana::LoadFrom<NDOscillatableSpectrum>(dir, "EMComp");
221 
222  ret->fAEAMComp = ana::LoadFrom<NDOscillatableSpectrum>(dir, "AEAMComp");
223 
224  ret->fMMComp = ana::LoadFrom<NDOscillatableSpectrum>(dir, "MMComp");
225 
226  ret->fAMAMComp = ana::LoadFrom<NDOscillatableSpectrum>(dir, "AMAMComp");
227 
228  ret->fMEComp = ana::LoadFrom<NDOscillatableSpectrum>(dir, "MEComp");
229 
230  ret->fAMAEComp = ana::LoadFrom<NDOscillatableSpectrum>(dir, "AMAEComp");
231 
232  ret->fENCComp = ana::LoadFrom<NDOscillatableSpectrum>(dir, "ENCComp");
233 
234  ret->fMNCComp = ana::LoadFrom<NDOscillatableSpectrum>(dir, "MNCComp");
235 
236  ret->fAENCComp = ana::LoadFrom<NDOscillatableSpectrum>(dir, "AENCComp");
237 
238  ret->fAMNCComp = ana::LoadFrom<NDOscillatableSpectrum>(dir, "AMNCComp");
239 
240  ret->fNCCompSpec = ana::LoadFrom<Spectrum>(dir, "NCComp");
241 
242  delete dir;
243 
244  return ret;
245  }
246 
247 } // end of namespace ana
Near Detector underground.
Definition: SREnums.h:10
const XML_Char * name
Definition: expat.h:151
const Cut kIsNumuCC(CCFlavSel(14, 14))
Select CC .
NDOscillatableSpectrum AntiNueCCSurvComponent()
Definition: NDExtrap.cxx:80
Cuts and Vars for the 2020 FD DiF Study.
Definition: vars.h:6
std::unique_ptr< NDOscillatableSpectrum > fAMAMComp
Definition: NDExtrap.h:87
NDOscillatableSpectrum NueCCSurvComponent()
Definition: NDExtrap.cxx:74
const Var weight
Simple record of shifts applied to systematic parameters.
Definition: SystShifts.h:20
std::unique_ptr< NDOscillatableSpectrum > fAEAMComp
Definition: NDExtrap.h:85
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< NDOscillatableSpectrum > fAMNCComp
Definition: NDExtrap.h:94
Collection of SpectrumLoaders for many configurations.
Definition: Loaders.h:23
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 .
double fPOT
Definition: NDExtrap.h:69
Float_t tmp
Definition: plot.C:36
NDOscillatableSpectrum AntiNumuNCComponent()
Definition: NDExtrap.cxx:140
Spectrum NCComponent()
Definition: NDExtrap.cxx:68
Representation of a spectrum in any variable, with associated POT.
Definition: Spectrum.h:40
virtual void SaveTo(TDirectory *dir, const std::string &name) const
Definition: NDExtrap.cxx:172
std::unique_ptr< NDOscillatableSpectrum > fAENCComp
Definition: NDExtrap.h:93
std::unique_ptr< NDOscillatableSpectrum > fEEComp
Definition: NDExtrap.h:82
static NDExtrap NDExtrap_c(Loaders &loaders, const HistAxis &axis, const Cut &selection, const SystShifts &shiftMC=kNoShift, const Var &weight=kUnweighted)
Definition: NDExtrap.cxx:25
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
static std::unique_ptr< NDExtrap > LoadFrom(TDirectory *dir, const std::string &name)
Definition: NDExtrap.cxx:207
SpectrumLoaderBase & GetLoader(caf::Det_t det, DataMC datamc, DataSource src=kBeam, SwappingConfig swap=kNonSwap)
Retrieve a specific loader.
Definition: Loaders.cxx:129
std::unique_ptr< NDOscillatableSpectrum > fEMComp
Definition: NDExtrap.h:84
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
std::unique_ptr< NDOscillatableSpectrum > fAEAEComp
Definition: NDExtrap.h:83
SpectrumLoaderBase * fSpecLoad
Definition: NDExtrap.h:97
NDOscillatableSpectrum NueCCAppComponent()
Definition: NDExtrap.cxx:110
NDOscillatableSpectrum AntiNueNCComponent()
Definition: NDExtrap.cxx:134
NDOscillatableSpectrum AntiNumuCCSurvComponent()
Definition: NDExtrap.cxx:104
OStream cout
Definition: OStream.cxx:6
Base class for the various types of spectrum loader.
std::unique_ptr< NDOscillatableSpectrum > fMEComp
Definition: NDExtrap.h:88
::xsd::cxx::tree::string< char, simple_type > string
Definition: Database.h:154
double GetWeightedPOT()
Definition: NDExtrap.cxx:59
TDirectory * dir
Definition: macro.C:5
std::unique_ptr< NDOscillatableSpectrum > fENCComp
Definition: NDExtrap.h:91
std::vector< Loaders * > loaders
Definition: syst_header.h:386
std::unique_ptr< NDOscillatableSpectrum > fMNCComp
Definition: NDExtrap.h:92
NDOscillatableSpectrum AntiNueCCAppComponent()
Definition: NDExtrap.cxx:116
NDOscillatableSpectrum NumuCCAppComponent()
Definition: NDExtrap.cxx:86
assert(nhit_max >=nhit_nbins)
NDOscillatableSpectrum AntiNumuCCAppComponent()
Definition: NDExtrap.cxx:92
NDOscillatableSpectrum NumuCCSurvComponent()
Definition: NDExtrap.cxx:98
NDOscillatableSpectrum NueNCComponent()
Definition: NDExtrap.cxx:122
std::unique_ptr< NDOscillatableSpectrum > fMMComp
Definition: NDExtrap.h:86
std::unique_ptr< Spectrum > fNCCompSpec
Definition: NDExtrap.h:96
std::unique_ptr< NDOscillatableSpectrum > fAMAEComp
Definition: NDExtrap.h:89
Spectrum with true L/E information, allowing it to be oscillated
NDOscillatableSpectrum NumuNCComponent()
Definition: NDExtrap.cxx:128