PredictionAddRock.cxx
Go to the documentation of this file.
3 
7 
8 #include "TDirectory.h"
9 #include "TObjString.h"
10 
11 #include "TH1.h"
12 #include "TVectorD.h"
14 
15 namespace ana
16 {
17  REGISTER_LOADFROM("PredictionAddRock", IPrediction, PredictionAddRock);
18 
19  //----------------------------------------------------------------------
20 
22  PredictionNoExtrap *predRock)
23  : fPredFid(predFid),
24  fPredRock(predRock)
25  {
26  }
27 
28  //----------------------------------------------------------------------
30  {
31  delete fPredFid;
32  delete fPredRock;
33  }
34 
35  //----------------------------------------------------------------------
37  {
38  return PredictComponent(calc,
41  Sign::kBoth);
42  }
43 
44  //----------------------------------------------------------------------
46  {
47  return PredictComponent(calc,
50  Sign::kBoth);
51  }
52 
53  //----------------------------------------------------------------------
55  const SystShifts& syst) const
56  {
57  return PredictComponentSyst(calc, syst,
60  Sign::kBoth);
61  }
62 
63  //----------------------------------------------------------------------
65  const SystShifts& syst) const
66  {
67  return PredictComponentSyst(calc, syst,
70  Sign::kBoth);
71  }
72 
73 
74  //----------------------------------------------------------------------
76  Flavors::Flavors_t flav,
78  Sign::Sign_t sign) const
79  {
80  return PredictComponentSyst(calc,kNoShift,flav,curr,sign);
81  }
82 
83  //----------------------------------------------------------------------
85  Flavors::Flavors_t flav,
87  Sign::Sign_t sign) const
88  {
89  return PredictComponentSyst(calc,kNoShift,flav,curr,sign);
90  }
91 
92  //----------------------------------------------------------------------
94  const SystShifts& syst,
95  Flavors::Flavors_t flav,
97  Sign::Sign_t sign) const
98  {
99  return _PredictComponentSyst(calc, syst, flav, curr, sign);
100  }
101 
102  //----------------------------------------------------------------------
104  const SystShifts& syst,
105  Flavors::Flavors_t flav,
107  Sign::Sign_t sign) const
108  {
109  return _PredictComponentSyst(calc, syst, flav, curr, sign);
110  }
111 
112 
113  //----------------------------------------------------------------------
114  template <typename T>
116  const SystShifts& syst,
117  Flavors::Flavors_t flav,
119  Sign::Sign_t sign) const
120  {
121  // Clone the systs
122  SystShifts systClone = syst;
123 
124  // First Check for RockScaleSyst
125  auto systScale = 1 + systClone.GetShift<T>(&kRockScaleSyst);
126  if(systScale < 0) systScale = 0;
127 
128  // the fiducial prediction definitely won't support the rock scale syst
129  systClone.RemoveShift(&kRockScaleSyst);
130 
131  // Strategy: assume PredictComponentSyst is properly implemented for the
132  // fiducial prediction, so start with that. Treat the rock as a series of
133  // delta's to that distribution, all predicted without syst shifts.
134  Spectrum ret = fPredFid->PredictComponentSyst(calc,systClone,
135  flav,curr,sign);
136 
137  if (systScale > 0)
138  {
139  Spectrum rock = RockComponent(calc, flav, curr, sign);
140  rock.Scale(systScale);
141  ret += rock;
142  }
143 
144  return ret;
145  }
146 
148  const SystShifts& syst,
149  Flavors::Flavors_t flav,
151  Sign::Sign_t sign) const;
153  const SystShifts& syst,
154  Flavors::Flavors_t flav,
155  Current::Current_t curr,
156  Sign::Sign_t sign) const;
157 
158  //----------------------------------------------------------------------
159  template <typename T>
161  Flavors::Flavors_t flav,
162  Current::Current_t curr,
163  Sign::Sign_t sign) const
164  {
166 
167  if(curr & Current::kNC){
168  assert(flav == Flavors::kAll); // Don't know how to calculate anything else
169 
170  // Predict the NC part
171  ret = fPredRock->PredictComponent(calc, flav, Current::kNC, sign);
172  }
173  else{
174  // Otherwise, still need to calculate something to get a suitably-binned
175  // Spectrum, but shouldn't keep in the total.
176  ret = fPredRock->PredictComponent(calc, Flavors::kAll, Current::kNC, Sign::kBoth);
177  ret.Clear();
178  }
179 
180 
181  if(curr & Current::kCC){
182  if (flav & Flavors::kNuEToNuE){
183  ret += fPredRock->PredictComponent(calc,
184  Flavors::kNuEToNuE,
185  Current::kCC, sign);
186  }
187  if (flav & Flavors::kNuEToNuMu){
188  ret += fPredRock->PredictComponent(calc,
189  Flavors::kNuEToNuMu,
190  Current::kCC, sign);
191  }
192  // If you're astute, you'll realize we don't do anything for tauswap.
193  // We never had tauswap rock files made, so it doesn't make sense to sum
194  // them in.
195 
196  if (flav & Flavors::kNuMuToNuE){
197  ret += fPredRock->PredictComponent(calc,
198  Flavors::kNuMuToNuE,
199  Current::kCC, sign);
200  }
201  if (flav & Flavors::kNuMuToNuMu){
202  ret += fPredRock->PredictComponent(calc,
203  Flavors::kNuMuToNuMu,
204  Current::kCC, sign);
205  }
206  }
207 
208  return ret;
209  }
210 
212  Flavors::Flavors_t flav,
213  Current::Current_t curr,
214  Sign::Sign_t sign) const;
216  Flavors::Flavors_t flav,
217  Current::Current_t curr,
218  Sign::Sign_t sign) const;
219 
220  //----------------------------------------------------------------------
222  {
223  return fPredFid->ComponentCC(from, to) + fPredRock->ComponentCC(from, to);
224  }
225 
226  //----------------------------------------------------------------------
227  //nc
229  {
231  }
232 
234  {
235  return fPredFid->ComponentNC() + fPredRock->ComponentNC();
236  }
237 
239  {
241  }
242  //end nc
243  //----------------------------------------------------------------------
244  void PredictionAddRock::SaveTo(TDirectory* dir, const std::string& name) const
245  {
246  TDirectory* tmp = gDirectory;
247 
248  dir = dir->mkdir(name.c_str()); // switch to subdir
249  dir->cd();
250 
251  TObjString("PredictionAddRock").Write("type");
252 
253  fPredFid->SaveTo(dir, "predFid");
254  fPredRock->SaveTo(dir, "predRock");
255 
256  dir->Write();
257  delete dir;
258 
259  tmp->cd();
260  }
261 
262  //----------------------------------------------------------------------
263  std::unique_ptr<PredictionAddRock> PredictionAddRock::LoadFrom(TDirectory* dir, const std::string& name)
264  {
265  dir = dir->GetDirectory(name.c_str()); // switch to subdir
266  assert(dir);
267 
268  auto predFid = ana::LoadFrom<IPrediction>(dir, "predFid").release();
269  auto predRock = ana::LoadFrom<PredictionNoExtrap>(dir, "predRock").release();
270 
271  delete dir;
272 
273  return std::unique_ptr<PredictionAddRock>(new PredictionAddRock(predFid,predRock));
274  }
275 }
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
virtual Spectrum ComponentNCAnti() const
Cuts and Vars for the 2020 FD DiF Study.
Definition: vars.h:6
Spectrum ComponentNCTotal() const override
Spectrum _PredictComponentSyst(osc::_IOscCalc< T > *calc, const SystShifts &syst, Flavors::Flavors_t flav, Current::Current_t curr, Sign::Sign_t sign) const
Spectrum ComponentNCTotal() const override
(&#39; appearance&#39;)
Definition: IPrediction.h:18
virtual Spectrum PredictSyst(osc::IOscCalc *calc, const SystShifts &syst) const override
Simple record of shifts applied to systematic parameters.
Definition: SystShifts.h:20
(&#39;beam &#39;)
Definition: IPrediction.h:15
Spectrum RockComponent(osc::_IOscCalc< T > *calc, Flavors::Flavors_t flav, Current::Current_t curr, Sign::Sign_t sign) const
virtual Spectrum PredictComponentSyst(osc::IOscCalc *calc, const SystShifts &syst, Flavors::Flavors_t flav, Current::Current_t curr, Sign::Sign_t sign) const
virtual Spectrum PredictComponentSyst(osc::IOscCalc *calc, const SystShifts &syst, Flavors::Flavors_t flav, Current::Current_t curr, Sign::Sign_t sign) const override
virtual void SaveTo(TDirectory *dir, const std::string &name) const override
void Clear()
Definition: Spectrum.cxx:433
static std::unique_ptr< PredictionAddRock > LoadFrom(TDirectory *dir, const std::string &name)
Float_t tmp
Definition: plot.C:36
virtual void SaveTo(TDirectory *dir, const std::string &name) const
osc::OscCalcDumb calc
void Scale(double c)
Multiply this spectrum by a constant c.
Definition: Spectrum.cxx:321
Representation of a spectrum in any variable, with associated POT.
Definition: Spectrum.h:33
virtual Spectrum ComponentNC() const
Spectrum ComponentNCAnti() const override
Charged-current interactions.
Definition: IPrediction.h:39
Interactions of both types.
Definition: IPrediction.h:42
static Spectrum Uninitialized()
Definition: Spectrum.h:157
OscillatableSpectrum ComponentCC(int from, int to) const override
T GetShift(const ISyst *syst) const
virtual OscillatableSpectrum ComponentCC(int from, int to) const
std::unique_ptr< IPrediction > LoadFrom< IPrediction >(TDirectory *dir, const std::string &label)
Definition: IPrediction.cxx:28
virtual void SaveTo(TDirectory *dir, const std::string &name) const override
const SystShifts kNoShift
Definition: SystShifts.h:115
(&#39; survival&#39;)
Definition: IPrediction.h:19
::xsd::cxx::tree::string< char, simple_type > string
Definition: Database.h:154
virtual Spectrum PredictComponent(osc::IOscCalc *calc, Flavors::Flavors_t flav, Current::Current_t curr, Sign::Sign_t sign) const override
PredictionNoExtrap * fPredRock
TDirectory * dir
Definition: macro.C:5
virtual Spectrum ComponentNCTotal() const
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
Standard interface to all prediction techniques.
Definition: IPrediction.h:57
double T
Definition: Xdiff_gwt.C:5
Prediction that just uses FD MC, with no extrapolation.
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
void RemoveShift(const ISyst *syst)
Definition: SystShifts.cxx:71
virtual Spectrum Predict(osc::IOscCalc *calc) const override
void rock(std::string suffix="full")
Definition: rock.C:28
Spectrum ComponentNC() const override
def sign(x)
Definition: canMan.py:197
const DummyRockScaleSyst kRockScaleSyst