PredictionExtrapSum.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 namespace ana
11 {
12  //----------------------------------------------------------------------
13 
14  PredictionExtrapSum::PredictionExtrapSum( std::vector<TFile*> fins, const std::string& path )
15  {
16  for ( auto f : fins )
17  {
18  fPreds.push_back( LoadFrom<PredictionExtrap>( f, path ).release() );
19  }
20  assert(!fPreds.empty());
21  }
22 
23  PredictionExtrapSum::PredictionExtrapSum( TFile* fin, const std::vector<std::string>& paths )
24  {
25  for ( auto p : paths )
26  {
27  fPreds.push_back( LoadFrom<PredictionExtrap>( fin, p ).release() );
28  }
29  assert(!fPreds.empty());
30  }
31 
32  //----------------------------------------------------------------------
34  {
35  for( auto p : fPreds ) delete p;
36  }
37 
38  //----------------------------------------------------------------------
40  {
41  return PredictComponent( calc,
44  Sign::kBoth);
45  }
46 
47  //----------------------------------------------------------------------
49  {
50  return PredictComponent( calc,
53  Sign::kBoth);
54  }
55 
56  //----------------------------------------------------------------------
57  template <typename T>
59  Flavors::Flavors_t flav,
61  Sign::Sign_t sign ) const
62  {
63  Spectrum ret = fPreds.front()->ComponentNCTotal(); // Get binning
64  ret.Clear();
65 
66  for( unsigned int i = 0; i < fPreds.size(); ++i ) ret += fPreds[i]->PredictComponent( calc, flav, curr, sign );
67 
68  return ret;
69  }
70 
72  Flavors::Flavors_t flav,
74  Sign::Sign_t sign ) const;
76  Flavors::Flavors_t flav,
77  Current::Current_t curr,
78  Sign::Sign_t sign ) const;
79 
80  //----------------------------------------------------------------------
82  Flavors::Flavors_t flav,
83  Current::Current_t curr,
84  Sign::Sign_t sign) const
85  {
86  return _PredictComponent(calc, flav, curr, sign);
87  }
88 
89  //----------------------------------------------------------------------
91  Flavors::Flavors_t flav,
92  Current::Current_t curr,
93  Sign::Sign_t sign) const
94  {
95  return _PredictComponent(calc, flav, curr, sign);
96  }
97 
98  //----------------------------------------------------------------------
100  {
101  OscillatableSpectrum ret = fPreds.front()->ComponentCC( from, to );
102  ret.Clear();
103 
104  for( unsigned int i = 0; i < fPreds.size(); ++i ) ret += fPreds[i]->ComponentCC( from, to );
105 
106  return ret;
107  }
108 
109  //----------------------------------------------------------------------
110  //nc
112  {
113  Spectrum ret = fPreds.front()->ComponentNCTotal(); // Get binning
114  ret.Clear();
115 
116  for( unsigned int i = 0; i < fPreds.size(); ++i ) ret += fPreds[i]->ComponentNCTotal();
117 
118  return ret;
119  }
121  {
122  Spectrum ret = fPreds.front()->ComponentNCTotal(); // Get binning
123  ret.Clear();
124 
125  for( unsigned int i = 0; i < fPreds.size(); ++i ) ret += fPreds[i]->ComponentNC();
126 
127  return ret;
128  }
130  {
131  Spectrum ret = fPreds.front()->ComponentNCTotal(); // Get binning
132  ret.Clear();
133 
134  for( unsigned int i = 0; i < fPreds.size(); ++i ) ret += fPreds[i]->ComponentNCAnti();
135 
136  return ret;
137  }
138  //end nc
139  //----------------------------------------------------------------------
140 
141  // The SaveTo and LoadFrom below are a work in progress
142  /*
143  void PredictionExtrapSum::SaveTo(TDirectory* dir) const
144  {
145  TDirectory* tmp = gDirectory;
146 
147  dir->cd();
148 
149  TObjString("PredictionExtrapSum").Write("type");
150 
151  fExtrap->SaveTo(dir->mkdir("extrap"));
152 
153  tmp->cd();
154  }
155 
156  //----------------------------------------------------------------------
157  std::unique_ptr<PredictionExtrapSum> PredictionExtrapSum::LoadFrom(TDirectory* dir)
158  {
159  assert(dir->GetDirectory("extrap"));
160  IExtrap* extrap = ana::LoadFrom<IExtrap>(dir->GetDirectory("extrap")).release();
161 
162  return std::unique_ptr<PredictionExtrapSum>(new PredictionExtrapSum(extrap));
163  }
164  */
165 
166 }
TString fin
Definition: Style.C:24
Cuts and Vars for the 2020 FD DiF Study.
Definition: vars.h:6
virtual Spectrum Predict(osc::IOscCalc *calc) const override
const char * p
Definition: xmltok.h:285
General interface to oscillation calculators.
Definition: StanTypedefs.h:23
Spectrum ComponentNCTotal() const override
void Clear()
Definition: Spectrum.cxx:362
osc::OscCalcDumb calc
virtual Spectrum PredictComponent(osc::IOscCalc *calc, Flavors::Flavors_t flav, Current::Current_t curr, Sign::Sign_t sign) const override
Representation of a spectrum in any variable, with associated POT.
Definition: Spectrum.h:40
Spectrum ComponentNCAnti() const override
Interactions of both types.
Definition: IPrediction.h:42
Spectrum ComponentNC() const override
Spectrum _PredictComponent(osc::_IOscCalc< T > *calc, Flavors::Flavors_t flav, Current::Current_t curr, Sign::Sign_t sign) const
std::vector< const PredictionExtrap * > fPreds
OscillatableSpectrum ComponentCC(int from, int to) const override
const std::string path
Definition: plot_BEN.C:43
assert(nhit_max >=nhit_nbins)
Both neutrinos and antineutrinos.
Definition: IPrediction.h:52
All neutrinos, any flavor.
Definition: IPrediction.h:26
Spectrum with true energy information, allowing it to be oscillated
def sign(x)
Definition: canMan.py:197
enum BeamMode string