PredictionExtrap.cxx
Go to the documentation of this file.
2 
6 
7 #include "TDirectory.h"
8 #include "TObjString.h"
9 
10 
11 namespace ana
12 {
13  REGISTER_LOADFROM("PredictionExtrap", IPrediction, PredictionExtrap);
14 
15  //----------------------------------------------------------------------
16  PredictionExtrap::PredictionExtrap(std::unique_ptr<IExtrap>&& extrap)
17  : fExtrap(std::move(extrap))
18  {
19  }
20 
21  //----------------------------------------------------------------------
23  {
24  return PredictComponent(calc,
27  Sign::kBoth);
28  }
29 
30  //----------------------------------------------------------------------
32  {
33  return PredictComponent(calc,
36  Sign::kBoth);
37  }
38 
39  //----------------------------------------------------------------------
40  // the actual implementation
41  template<typename T>
43  Flavors::Flavors_t flav,
45  Sign::Sign_t sign) const
46  {
47  Spectrum ret = fExtrap->NCTotalComponent(); // Get binning
48  ret.Clear();
49 
50  if(curr & Current::kCC){
51  if(flav & Flavors::kNuEToNuE && sign & Sign::kNu) ret += fExtrap->NueSurvComponent(). Oscillated(calc, +12, +12);
52  if(flav & Flavors::kNuEToNuE && sign & Sign::kAntiNu) ret += fExtrap->AntiNueSurvComponent().Oscillated(calc, -12, -12);
53 
54  if(flav & Flavors::kNuEToNuMu && sign & Sign::kNu) ret += fExtrap->NumuAppComponent(). Oscillated(calc, +12, +14);
55  if(flav & Flavors::kNuEToNuMu && sign & Sign::kAntiNu) ret += fExtrap->AntiNumuAppComponent().Oscillated(calc, -12, -14);
56 
57  if(flav & Flavors::kNuEToNuTau && sign & Sign::kNu) ret += fExtrap->TauFromEComponent(). Oscillated(calc, +12, +16);
58  if(flav & Flavors::kNuEToNuTau && sign & Sign::kAntiNu) ret += fExtrap->AntiTauFromEComponent().Oscillated(calc, -12, -16);
59 
60  if(flav & Flavors::kNuMuToNuE && sign & Sign::kNu) ret += fExtrap->NueAppComponent(). Oscillated(calc, +14, +12);
61  if(flav & Flavors::kNuMuToNuE && sign & Sign::kAntiNu) ret += fExtrap->AntiNueAppComponent().Oscillated(calc, -14, -12);
62 
63  if(flav & Flavors::kNuMuToNuMu && sign & Sign::kNu) ret += fExtrap->NumuSurvComponent(). Oscillated(calc, +14, +14);
64  if(flav & Flavors::kNuMuToNuMu && sign & Sign::kAntiNu) ret += fExtrap->AntiNumuSurvComponent().Oscillated(calc, -14, -14);
65 
66  if(flav & Flavors::kNuMuToNuTau && sign & Sign::kNu) ret += fExtrap->TauFromMuComponent(). Oscillated(calc, +14, +16);
67  if(flav & Flavors::kNuMuToNuTau && sign & Sign::kAntiNu) ret += fExtrap->AntiTauFromMuComponent().Oscillated(calc, -14, -16);
68  }
69  if(curr & Current::kNC){
70  assert(flav == Flavors::kAll); // Don't know how to calculate anything else
71 
72  if(sign & Sign::kNu) ret += fExtrap->NCComponent();
73  if(sign & Sign::kAntiNu) ret += fExtrap->NCAntiComponent();
74  }
75 
76  return ret;
77  }
78 
79  //----------------------------------------------------------------------
80  // just call the templated guy
82  Flavors::Flavors_t flav,
84  Sign::Sign_t sign) const
85  {
86  return _PredictComponent(calc, flav, curr, sign);
87  }
88 
89  //----------------------------------------------------------------------
90  // just call the templated guy
92  Flavors::Flavors_t flav,
94  Sign::Sign_t sign) const
95  {
96  return _PredictComponent(calc, flav, curr, sign);
97  }
98 
99  //----------------------------------------------------------------------
101  {
102  if(from == +12 && to == +12) return fExtrap->NueSurvComponent();
103  if(from == -12 && to == -12) return fExtrap->AntiNueSurvComponent();
104 
105  if(from == +12 && to == +14) return fExtrap->NumuAppComponent();
106  if(from == -12 && to == -14) return fExtrap->AntiNumuAppComponent();
107 
108  if(from == +12 && to == +16) return fExtrap->TauFromEComponent();
109  if(from == -12 && to == -16) return fExtrap->AntiTauFromEComponent();
110 
111  if(from == +14 && to == +12) return fExtrap->NueAppComponent();
112  if(from == -14 && to == -12) return fExtrap->AntiNueAppComponent();
113 
114  if(from == +14 && to == +14) return fExtrap->NumuSurvComponent();
115  if(from == -14 && to == -14) return fExtrap->AntiNumuSurvComponent();
116 
117  if(from == +14 && to == +16) return fExtrap->TauFromMuComponent();
118  if(from == -14 && to == -16) return fExtrap->AntiTauFromMuComponent();
119 
120  assert(0 && "Not reached");
121  }
122 
123  //----------------------------------------------------------------------
124  //nc
126  {
127  return fExtrap->NCTotalComponent();
128  }
130  {
131  return fExtrap->NCComponent();
132  }
134  {
135  return fExtrap->NCAntiComponent();
136  }
137  //end nc
138  //----------------------------------------------------------------------
139  void PredictionExtrap::SaveTo(TDirectory* dir, const std::string& name) const
140  {
141  TDirectory* tmp = gDirectory;
142 
143  dir = dir->mkdir(name.c_str()); // switch to subdir
144  dir->cd();
145 
146  TObjString("PredictionExtrap").Write("type");
147 
148  fExtrap->SaveTo(dir, "extrap");
149 
150  dir->Write();
151  delete dir;
152 
153  tmp->cd();
154  }
155 
156  //----------------------------------------------------------------------
157  std::unique_ptr<PredictionExtrap> PredictionExtrap::LoadFrom(TDirectory* dir, const std::string& name)
158  {
159  dir = dir->GetDirectory(name.c_str()); // switch to subdir
160  assert(dir);
161 
162  std::unique_ptr<PredictionExtrap> ret(new PredictionExtrap(ana::LoadFrom<IExtrap>(dir, "extrap")));
163 
164  delete dir;
165 
166  return ret;
167  }
168 }
OscillatableSpectrum ComponentCC(int from, int to) const override
Spectrum PredictComponent(osc::IOscCalc *calc, Flavors::Flavors_t flav, Current::Current_t curr, Sign::Sign_t sign) const override
const XML_Char * name
Definition: expat.h:151
Spectrum ComponentNC() const override
Cuts and Vars for the 2020 FD DiF Study.
Definition: vars.h:6
Spectrum ComponentNCTotal() const override
Antineutrinos-only.
Definition: IPrediction.h:50
(&#39; appearance&#39;)
Definition: IPrediction.h:18
(&#39;beam &#39;)
Definition: IPrediction.h:15
General interface to oscillation calculators.
Definition: StanTypedefs.h:22
void Clear()
Definition: Spectrum.cxx:372
Float_t tmp
Definition: plot.C:36
osc::OscCalcDumb calc
Spectrum _PredictComponent(osc::_IOscCalc< T > *calc, Flavors::Flavors_t flav, Current::Current_t curr, Sign::Sign_t sign) const
Templated helper function called by the non-templated versions.
Representation of a spectrum in any variable, with associated POT.
Definition: Spectrum.h:40
std::unique_ptr< IExtrap > LoadFrom< IExtrap >(TDirectory *dir, const std::string &label)
Definition: IExtrap.cxx:15
Charged-current interactions.
Definition: IPrediction.h:39
Interactions of both types.
Definition: IPrediction.h:42
Spectrum Predict(osc::IOscCalc *calc) const override
static std::unique_ptr< PredictionExtrap > LoadFrom(TDirectory *dir, const std::string &name)
Neutrinos-only.
Definition: IPrediction.h:49
(&#39; survival&#39;)
Definition: IPrediction.h:19
::xsd::cxx::tree::string< char, simple_type > string
Definition: Database.h:154
virtual void SaveTo(TDirectory *dir, const std::string &name) const override
std::unique_ptr< IExtrap > fExtrap
TDirectory * dir
Definition: macro.C:5
REGISTER_LOADFROM("BENDecomp", IDecomp, BENDecomp)
Neutral-current interactions.
Definition: IPrediction.h:40
assert(nhit_max >=nhit_nbins)
Spectrum ComponentNCAnti() const override
Both neutrinos and antineutrinos.
Definition: IPrediction.h:52
All neutrinos, any flavor.
Definition: IPrediction.h:26
(&#39; appearance&#39;)
Definition: IPrediction.h:16
Spectrum with true energy information, allowing it to be oscillated
def sign(x)
Definition: canMan.py:197