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()
28 
29 namespace ana
30 {
31  //----------------------------------------------------------------------
32  // Definition to satisfy declaration in Core/LoadFromFile.h
33  template <>
34  std::unique_ptr<IPrediction> LoadFrom<IPrediction>(TDirectory* dir)
35  {
36  TObjString* ptag = (TObjString*)dir->Get("type");
37  assert(ptag);
38 
39  const TString tag = ptag->GetString();
40 
41  if(tag == "PredictionNoExtrap") return PredictionNoExtrap::LoadFrom(dir);
42  if(tag == "PredictionExtrap") return PredictionExtrap::LoadFrom(dir);
43 
44  // Backwards compatibility
45  if(tag == "PredictionInterp" ||
46  tag == "PredictionInterp2") return PredictionInterp::LoadFrom(dir);
47 
48  if(tag == "PredictionNoOsc") return PredictionNoOsc::LoadFrom(dir);
49 
50  if(tag == "PredictionCombinePeriods") return PredictionCombinePeriods::LoadFrom(dir);
51 
52  if(tag == "PredictionSterile") return PredictionSterile::LoadFrom(dir);
53 
54  if(tag == "PredictionSystNue2017") return PredictionSystNue2017::LoadFrom(dir);
55 
56  if(tag == "PredictionExtendToPeripheral") return PredictionExtendToPeripheral::LoadFrom(dir);
57 
58  if(tag == "PredictionAddRock") return PredictionAddRock::LoadFrom(dir);
59 
60  if(tag == "NDPredictionSterile") return NDPredictionSterile::LoadFrom(dir);
61  if(tag == "FDPredictionSterile") return FDPredictionSterile::LoadFrom(dir);
62 
63  if(tag == "PredictionXSecTuning") return PredictionXSecTuning::LoadFrom(dir);
64 
65  std::cerr << "Unknown Prediction type '" << tag << "'" << std::endl;
66  abort();
67  }
68 
69  //----------------------------------------------------------------------
71  {
72  // Default implementation
74  return Predict(&noosc);
75  }
76 
77 
78  //----------------------------------------------------------------------
79  // placeholder method that should be overridden by Stan-aware concrete Prediction classes
81  {
82  assert(0 && "This Prediction hasn't implemented a Stan-aware Predict()!");
83  }
84 
85  //----------------------------------------------------------------------
87  const SystShifts& syst) const
88  {
89  assert(syst.IsNominal() && "This Prediction doesn't support PredictSyst(). Did you just mean Predict()?");
90 
91  // Default implementation: no treatment of systematics
92  return Predict(calc);
93  }
94 
95  //----------------------------------------------------------------------
97  const SystShifts& syst) const
98  {
99  assert(syst.IsNominal() && "This Prediction doesn't support PredictSyst(). Did you just mean Predict()?");
100 
101  // Default implementation: no treatment of systematics
102  return Predict(calc);
103  }
104 
105  //----------------------------------------------------------------------
106  // placeholder method that should be overridden by Stan-aware concrete Prediction classes
108  Flavors::Flavors_t flav,
110  Sign::Sign_t sign) const
111  {
112  assert(0 && "This Prediction hasn't implemented a Stan-aware PredictComponent()!");
113  }
114 
115  //----------------------------------------------------------------------
117  const SystShifts& syst,
118  Flavors::Flavors_t flav,
120  Sign::Sign_t sign) const
121  {
122  assert(syst.IsNominal() && "This Prediction doesn't support PredictSyst(). Did you just mean Predict()?");
123 
124  // Default implementation: no treatment of systematics
125  return PredictComponent(calc, flav, curr, sign);
126  }
127 
128 
129  //----------------------------------------------------------------------
131  const SystShifts& syst,
132  Flavors::Flavors_t flav,
134  Sign::Sign_t sign) const
135  {
136  assert(syst.IsNominal() && "This Prediction doesn't support PredictSyst(). Did you just mean Predict()?");
137 
138  // Default implementation: no treatment of systematics
139  return PredictComponent(calc, flav, curr, sign);
140  }
141 
142  //----------------------------------------------------------------------
143  void IPrediction::SaveTo(TDirectory*) const
144  {
145  assert(0 && "Not implemented");
146  }
147 
148 }
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)
virtual Spectrum PredictUnoscillated() const
Definition: IPrediction.cxx:70
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)
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:86
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
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:34
TDirectory * dir
Definition: macro.C:5
assert(nhit_max >=nhit_nbins)
static std::unique_ptr< PredictionExtrap > LoadFrom(TDirectory *dir)
def sign(x)
Definition: canMan.py:197