IPrediction.cxx
Go to the documentation of this file.
2 
4 #include "Utilities/func/Stan.h"
6 
8 
9 #include <cassert>
10 #include <iostream>
11 
12 #include "TDirectory.h"
13 #include "TObjString.h"
14 
15 // To implement LoadFrom()
32 
33 namespace ana
34 {
35  //----------------------------------------------------------------------
36  // Definition to satisfy declaration in Core/LoadFromFile.h
37  template <>
38  std::unique_ptr<IPrediction> LoadFrom<IPrediction>(TDirectory* dir)
39  {
40  TObjString* ptag = (TObjString*)dir->Get("type");
41  assert(ptag);
42 
43  const TString tag = ptag->GetString();
44 
45  if(tag == "PredictionNoExtrap") return PredictionNoExtrap::LoadFrom(dir);
46  if(tag == "PredictionExtrap") return PredictionExtrap::LoadFrom(dir);
47 
48  // Backwards compatibility
49  if(tag == "PredictionInterp" ||
50  tag == "PredictionInterp2") return PredictionInterp::LoadFrom(dir);
51 
52  if(tag == "PredictionNoOsc") return PredictionNoOsc::LoadFrom(dir);
53 
54  if(tag == "PredictionNumuFAHadE") return PredictionNumuFAHadE::LoadFrom(dir);
55 
56  if(tag == "PredictionCombinePeriods") return PredictionCombinePeriods::LoadFrom(dir);
57 
58  if(tag == "PredictionTemplateShift") return PredictionTemplateShift::LoadFrom(dir);
59 
60  if(tag == "PredictionSterile") return PredictionSterile::LoadFrom(dir);
61 
62  if(tag == "PredictionNueRebinSA") return PredictionNueRebinSA::LoadFrom(dir);
63 
64  if(tag == "PredictionSystNueSecondAna") return PredictionSystNueSecondAna::LoadFrom(dir);
65 
66  if(tag == "PredictionSystNue2017") return PredictionSystNue2017::LoadFrom(dir);
67 
68  if(tag == "PredictionExtendToPeripheral") return PredictionExtendToPeripheral::LoadFrom(dir);
69 
70  if(tag == "PredictionAddRock") return PredictionAddRock::LoadFrom(dir);
71 
72  if(tag == "NDPredictionSterile") return NDPredictionSterile::LoadFrom(dir);
73  if(tag == "FDPredictionSterile") return FDPredictionSterile::LoadFrom(dir);
74 
75  if(tag == "PredictionXSecTuning") return PredictionXSecTuning::LoadFrom(dir);
76 
77  std::cerr << "Unknown Prediction type '" << tag << "'" << std::endl;
78  abort();
79  }
80 
81  //----------------------------------------------------------------------
83  {
84  // Default implementation
86  return Predict(&noosc);
87  }
88 
89 
90  //----------------------------------------------------------------------
91  // placeholder method that should be overridden by Stan-aware concrete Prediction classes
93  {
94  assert(0 && "This Prediction hasn't implemented a Stan-aware Predict()!");
95  }
96 
97  //----------------------------------------------------------------------
99  const SystShifts& syst) const
100  {
101  assert(syst.IsNominal() && "This Prediction doesn't support PredictSyst(). Did you just mean Predict()?");
102 
103  // Default implementation: no treatment of systematics
104  return Predict(calc);
105  }
106 
107  //----------------------------------------------------------------------
109  const SystShifts& syst) const
110  {
111  assert(syst.IsNominal() && "This Prediction doesn't support PredictSyst(). Did you just mean Predict()?");
112 
113  // Default implementation: no treatment of systematics
114  return Predict(calc);
115  }
116 
117  //----------------------------------------------------------------------
118  // placeholder method that should be overridden by Stan-aware concrete Prediction classes
120  Flavors::Flavors_t flav,
122  Sign::Sign_t sign) const
123  {
124  assert(0 && "This Prediction hasn't implemented a Stan-aware PredictComponent()!");
125  }
126 
127  //----------------------------------------------------------------------
129  const SystShifts& syst,
130  Flavors::Flavors_t flav,
132  Sign::Sign_t sign) const
133  {
134  assert(syst.IsNominal() && "This Prediction doesn't support PredictSyst(). Did you just mean Predict()?");
135 
136  // Default implementation: no treatment of systematics
137  return PredictComponent(calc, flav, curr, sign);
138  }
139 
140 
141  //----------------------------------------------------------------------
143  const SystShifts& syst,
144  Flavors::Flavors_t flav,
146  Sign::Sign_t sign) const
147  {
148  assert(syst.IsNominal() && "This Prediction doesn't support PredictSyst(). Did you just mean Predict()?");
149 
150  // Default implementation: no treatment of systematics
151  return PredictComponent(calc, flav, curr, sign);
152  }
153 
154  //----------------------------------------------------------------------
155  void IPrediction::SaveTo(TDirectory*) const
156  {
157  assert(0 && "Not implemented");
158  }
159 
160 }
static std::unique_ptr< FDPredictionSterile > LoadFrom(TDirectory *dir)
Pass neutrinos through unchanged.
Cuts and Vars for the 2020 FD DiF Study.
Definition: CutFlow_header.h:5
General interface to oscillation calculators.
Definition: FwdDeclare.h:15
bool IsNominal() const
Definition: SystShifts.h:43
virtual Spectrum PredictComponent(osc::IOscCalculator *calc, Flavors::Flavors_t flav, Current::Current_t curr, Sign::Sign_t sign) const =0
virtual void SaveTo(TDirectory *dir) const
Simple record of shifts applied to systematic parameters.
Definition: SystShifts.h:20
static std::unique_ptr< NDPredictionSterile > LoadFrom(TDirectory *dir)
static std::unique_ptr< PredictionNueRebinSA > LoadFrom(TDirectory *dir)
Can load any Prediction or an actual PredictionNueRebinSA.
virtual Spectrum PredictUnoscillated() const
Definition: IPrediction.cxx:82
OStream cerr
Definition: OStream.cxx:7
static std::unique_ptr< PredictionCombinePeriods > LoadFrom(TDirectory *dir)
static std::unique_ptr< PredictionSystNue2017 > LoadFrom(TDirectory *dir)
static std::unique_ptr< PredictionNoExtrap > LoadFrom(TDirectory *dir)
static std::unique_ptr< PredictionSystNueSecondAna > LoadFrom(TDirectory *dir)
virtual Spectrum Predict(osc::IOscCalculator *calc) const =0
Representation of a spectrum in any variable, with associated POT.
Definition: Spectrum.h:37
virtual Spectrum PredictSyst(osc::IOscCalculator *calc, const SystShifts &syst) const
Definition: IPrediction.cxx:98
static std::unique_ptr< PredictionAddRock > LoadFrom(TDirectory *dir)
virtual Spectrum PredictComponentSyst(osc::IOscCalculator *calc, const SystShifts &syst, Flavors::Flavors_t flav, Current::Current_t curr, Sign::Sign_t sign) const
static std::unique_ptr< PredictionNoOsc > LoadFrom(TDirectory *dir)
static std::unique_ptr< PredictionExtendToPeripheral > LoadFrom(TDirectory *dir)
static std::unique_ptr< PredictionSterile > LoadFrom(TDirectory *dir)
osc::NoOscillations noosc
Definition: NueSystFuncs.h:44
osc::OscCalculatorDumb calc
def sign(x)
Definition: canMan.py:204
static std::unique_ptr< PredictionInterp > LoadFrom(TDirectory *dir)
static std::unique_ptr< PredictionXSecTuning > LoadFrom(TDirectory *dir)
std::unique_ptr< IPrediction > LoadFrom< IPrediction >(TDirectory *dir)
Definition: IPrediction.cxx:38
TDirectory * dir
Definition: macro.C:5
static std::unique_ptr< PredictionNumuFAHadE > LoadFrom(TDirectory *dir)
string syst
Definition: plotSysts.py:176
assert(nhit_max >=nhit_nbins)
static std::unique_ptr< PredictionTemplateShift > LoadFrom(TDirectory *dir)
static std::unique_ptr< PredictionExtrap > LoadFrom(TDirectory *dir)