PredictionExtrap.cxx
Go to the documentation of this file.
2 
5 #include "Utilities/func/Stan.h"
6 
7 #include "TDirectory.h"
8 #include "TObjString.h"
9 
10 
11 namespace ana
12 {
13  //----------------------------------------------------------------------
14  PredictionExtrap::PredictionExtrap(std::unique_ptr<IExtrap>&& extrap)
15  : fExtrap(std::move(extrap))
16  {
17  }
18 
19  //----------------------------------------------------------------------
21  {
22  return PredictComponent(calc,
25  Sign::kBoth);
26  }
27 
28  //----------------------------------------------------------------------
30  {
31  return PredictComponent(calc,
34  Sign::kBoth);
35  }
36 
37  //----------------------------------------------------------------------
38  // the actual implementation
39  template <typename U, typename T>
41  Flavors::Flavors_t flav,
43  Sign::Sign_t sign) const
44  {
45  U ret = fExtrap->NCTotalComponent(); // Get binning
46  ret.Clear();
47 
48  if(curr & Current::kCC){
49  if(flav & Flavors::kNuEToNuE && sign & Sign::kNu) ret += fExtrap->NueSurvComponent(). Oscillated(calc, +12, +12);
50  if(flav & Flavors::kNuEToNuE && sign & Sign::kAntiNu) ret += fExtrap->AntiNueSurvComponent().Oscillated(calc, -12, -12);
51 
52  if(flav & Flavors::kNuEToNuMu && sign & Sign::kNu) ret += fExtrap->NumuAppComponent(). Oscillated(calc, +12, +14);
53  if(flav & Flavors::kNuEToNuMu && sign & Sign::kAntiNu) ret += fExtrap->AntiNumuAppComponent().Oscillated(calc, -12, -14);
54 
55  if(flav & Flavors::kNuEToNuTau && sign & Sign::kNu) ret += fExtrap->TauFromEComponent(). Oscillated(calc, +12, +16);
56  if(flav & Flavors::kNuEToNuTau && sign & Sign::kAntiNu) ret += fExtrap->AntiTauFromEComponent().Oscillated(calc, -12, -16);
57 
58  if(flav & Flavors::kNuMuToNuE && sign & Sign::kNu) ret += fExtrap->NueAppComponent(). Oscillated(calc, +14, +12);
59  if(flav & Flavors::kNuMuToNuE && sign & Sign::kAntiNu) ret += fExtrap->AntiNueAppComponent().Oscillated(calc, -14, -12);
60 
61  if(flav & Flavors::kNuMuToNuMu && sign & Sign::kNu) ret += fExtrap->NumuSurvComponent(). Oscillated(calc, +14, +14);
62  if(flav & Flavors::kNuMuToNuMu && sign & Sign::kAntiNu) ret += fExtrap->AntiNumuSurvComponent().Oscillated(calc, -14, -14);
63 
64  if(flav & Flavors::kNuMuToNuTau && sign & Sign::kNu) ret += fExtrap->TauFromMuComponent(). Oscillated(calc, +14, +16);
65  if(flav & Flavors::kNuMuToNuTau && sign & Sign::kAntiNu) ret += fExtrap->AntiTauFromMuComponent().Oscillated(calc, -14, -16);
66  }
67  if(curr & Current::kNC){
68  assert(flav == Flavors::kAll); // Don't know how to calculate anything else
69 
70  if(sign & Sign::kNu) ret += fExtrap->NCComponent();
71  if(sign & Sign::kAntiNu) ret += fExtrap->NCAntiComponent();
72  }
73 
74  return ret;
75  }
76 
77  //----------------------------------------------------------------------
78  // just call the templated guy
80  Flavors::Flavors_t flav,
82  Sign::Sign_t sign) const
83  {
84  return _PredictComponent<Spectrum>(calc, flav, curr, sign);
85  }
86 
87  //----------------------------------------------------------------------
88  // just call the templated guy
90  Flavors::Flavors_t flav,
92  Sign::Sign_t sign) const
93  {
94  return _PredictComponent<SpectrumStan>(calc, flav, curr, sign);
95  }
96 
97  //----------------------------------------------------------------------
99  {
100  if(from == +12 && to == +12) return fExtrap->NueSurvComponent();
101  if(from == -12 && to == -12) return fExtrap->AntiNueSurvComponent();
102 
103  if(from == +12 && to == +14) return fExtrap->NumuAppComponent();
104  if(from == -12 && to == -14) return fExtrap->AntiNumuAppComponent();
105 
106  if(from == +12 && to == +16) return fExtrap->TauFromEComponent();
107  if(from == -12 && to == -16) return fExtrap->AntiTauFromEComponent();
108 
109  if(from == +14 && to == +12) return fExtrap->NueAppComponent();
110  if(from == -14 && to == -12) return fExtrap->AntiNueAppComponent();
111 
112  if(from == +14 && to == +14) return fExtrap->NumuSurvComponent();
113  if(from == -14 && to == -14) return fExtrap->AntiNumuSurvComponent();
114 
115  if(from == +14 && to == +16) return fExtrap->TauFromMuComponent();
116  if(from == -14 && to == -16) return fExtrap->AntiTauFromMuComponent();
117 
118  assert(0 && "Not reached");
119  }
120 
121  //----------------------------------------------------------------------
122  //nc
124  {
125  return fExtrap->NCTotalComponent();
126  }
128  {
129  return fExtrap->NCComponent();
130  }
132  {
133  return fExtrap->NCAntiComponent();
134  }
135  //end nc
136  //----------------------------------------------------------------------
137  void PredictionExtrap::SaveTo(TDirectory* dir) const
138  {
139  TDirectory* tmp = gDirectory;
140 
141  dir->cd();
142 
143  TObjString("PredictionExtrap").Write("type");
144 
145  fExtrap->SaveTo(dir->mkdir("extrap"));
146 
147  tmp->cd();
148  }
149 
150  //----------------------------------------------------------------------
151  std::unique_ptr<PredictionExtrap> PredictionExtrap::LoadFrom(TDirectory* dir)
152  {
153  assert(dir->GetDirectory("extrap"));
154  return std::unique_ptr<PredictionExtrap>(new PredictionExtrap(ana::LoadFrom<IExtrap>(dir->GetDirectory("extrap"))));
155  }
156 }
OscillatableSpectrum ComponentCC(int from, int to) const override
Spectrum ComponentNC() const override
Spectrum Predict(osc::IOscCalculator *calc) const override
Cuts and Vars for the 2020 FD DiF Study.
Definition: CutFlow_header.h:5
Spectrum ComponentNCTotal() const override
Antineutrinos-only.
Definition: IPrediction.h:50
(&#39; appearance&#39;)
Definition: IPrediction.h:18
U _PredictComponent(osc::_IOscCalculator< T > *calc, Flavors::Flavors_t flav, Current::Current_t curr, Sign::Sign_t sign) const
Templated helper function called by the non-templated versions.
Spectrum PredictComponent(osc::IOscCalculator *calc, Flavors::Flavors_t flav, Current::Current_t curr, Sign::Sign_t sign) const override
(&#39;beam &#39;)
Definition: IPrediction.h:15
std::unique_ptr< IExtrap > LoadFrom< IExtrap >(TDirectory *dir)
Definition: IExtrap.cxx:20
Float_t tmp
Definition: plot.C:36
Representation of a spectrum in any variable, with associated POT.
Definition: Spectrum.h:37
Charged-current interactions.
Definition: IPrediction.h:39
Interactions of both types.
Definition: IPrediction.h:42
virtual void SaveTo(TDirectory *dir) const override
osc::OscCalculatorDumb calc
Neutrinos-only.
Definition: IPrediction.h:49
(&#39; survival&#39;)
Definition: IPrediction.h:19
std::unique_ptr< IExtrap > fExtrap
TDirectory * dir
Definition: macro.C:5
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
static std::unique_ptr< PredictionExtrap > LoadFrom(TDirectory *dir)
Spectrum with true energy information, allowing it to be oscillated
def sign(x)
Definition: canMan.py:197