Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
ana::PredictionSystJoint2018 Class Reference

Loads shifted spectra from files. More...

#include "/cvmfs/nova-development.opensciencegrid.org/novasoft/releases/N20-02-16/CAFAna/Prediction/PredictionSystJoint2018.h"

Inheritance diagram for ana::PredictionSystJoint2018:
ana::PredictionInterp ana::IPrediction

Public Types

enum  EMode_t { kCombineSigns, kSplitBySign }
 
enum  CoeffsType {
  kNueApp, kNueSurv, kNumuSurv, kNC,
  kOther, kNCoeffTypes
}
 

Public Member Functions

 PredictionSystJoint2018 (ENu2018ExtrapType extrap, osc::IOscCalculator *osc, const std::vector< const ISyst * > &systs, std::string beam="fhc", bool isFakeData=false, bool mergePeripheral=true, const std::string fname="", bool minimizeMemory=true, const std::vector< const ISyst * > &sumsysts={})
 Nue constructor. More...
 
 PredictionSystJoint2018 (ENu2018ExtrapType extrap, osc::IOscCalculator *osc, const std::string beam, int WhichQuant, const std::vector< const ISyst * > &systs, const std::string fname, bool minimizeMemory=true)
 Numu constructor. More...
 
virtual ~PredictionSystJoint2018 ()
 
IPredictionGetNominalPrediction ()
 
const ShiftedPreds GetShiftedPrediction (const ISyst *syst)
 
void SaveTo (TDirectory *dir) const override
 
Spectrum Predict (osc::IOscCalculator *calc) const override
 
SpectrumStan Predict (osc::IOscCalculatorStan *calc) const override
 
Spectrum PredictSyst (osc::IOscCalculator *calc, const SystShifts &shift) const override
 
SpectrumStan PredictSyst (osc::IOscCalculatorStan *calc, const SystShifts &shift) const override
 
Spectrum PredictComponent (osc::IOscCalculator *calc, Flavors::Flavors_t flav, Current::Current_t curr, Sign::Sign_t sign) const override
 
SpectrumStan PredictComponent (osc::IOscCalculatorStan *calc, Flavors::Flavors_t flav, Current::Current_t curr, Sign::Sign_t sign) const override
 
Spectrum PredictComponentSyst (osc::IOscCalculator *calc, const SystShifts &shift, Flavors::Flavors_t flav, Current::Current_t curr, Sign::Sign_t sign) const override
 
SpectrumStan PredictComponentSyst (osc::IOscCalculatorStan *calc, const SystShifts &shift, Flavors::Flavors_t flav, Current::Current_t curr, Sign::Sign_t sign) const override
 
void Derivative (osc::IOscCalculator *calc, const SystShifts &shift, double pot, std::unordered_map< const ISyst *, std::vector< double >> &dp) const override
 
void MinimizeMemory ()
 
void DebugPlot (const ISyst *syst, osc::IOscCalculator *calc, Flavors::Flavors_t flav=Flavors::kAll, Current::Current_t curr=Current::kBoth, Sign::Sign_t sign=Sign::kBoth) const
 
void DebugPlots (osc::IOscCalculator *calc, const std::string &savePattern="", Flavors::Flavors_t flav=Flavors::kAll, Current::Current_t curr=Current::kBoth, Sign::Sign_t sign=Sign::kBoth) const
 
void SetOscSeed (osc::IOscCalculator *oscSeed)
 
void DebugPlotColz (const ISyst *syst, osc::IOscCalculator *calc, Flavors::Flavors_t flav=Flavors::kAll, Current::Current_t curr=Current::kBoth, Sign::Sign_t sign=Sign::kBoth) const
 
void DebugPlotsColz (osc::IOscCalculator *calc, const std::string &savePattern="", Flavors::Flavors_t flav=Flavors::kAll, Current::Current_t curr=Current::kBoth, Sign::Sign_t sign=Sign::kBoth) const
 
bool SplitBySign () const
 
std::vector< std::vector< Coeffs > > FitRatios (const std::vector< double > &shifts, const std::vector< std::unique_ptr< TH1 >> &ratios) const
 Find coefficients describing this set of shifts. More...
 
std::vector< std::vector< Coeffs > > FitComponent (const std::vector< double > &shifts, const std::vector< IPrediction * > &preds, Flavors::Flavors_t flav, Current::Current_t curr, Sign::Sign_t sign) const
 Find coefficients describing the ratios from this component. More...
 
Spectrum ShiftSpectrum (const Spectrum &s, CoeffsType type, bool nubar, const SystShifts &shift) const
 
SpectrumStan ShiftSpectrum (const SpectrumStan &s, CoeffsType type, bool nubar, const SystShifts &shift) const
 
Spectrum ShiftedComponent (osc::IOscCalculator *calc, const TMD5 *hash, const SystShifts &shift, Flavors::Flavors_t flav, Current::Current_t curr, Sign::Sign_t sign, CoeffsType type) const
 Helper for PredictComponentSyst. More...
 
SpectrumStan ShiftedComponent (osc::_IOscCalculator< stan::math::var > *calc, const TMD5 *hash, const SystShifts &shift, Flavors::Flavors_t flav, Current::Current_t curr, Sign::Sign_t sign, CoeffsType type) const
 
virtual Spectrum PredictUnoscillated () const
 
virtual OscillatableSpectrum ComponentCC (int from, int to) const
 
virtual Spectrum ComponentNCTotal () const
 
virtual Spectrum ComponentNC () const
 
virtual Spectrum ComponentNCAnti () const
 

Static Public Member Functions

static std::unique_ptr< PredictionSystJoint2018LoadFrom (TDirectory *dir)
 
static void LoadFromBody (TDirectory *dir, PredictionInterp *ret, std::vector< const ISyst * > veto={})
 

Protected Member Functions

 PredictionSystJoint2018 ()
 
void AddNormSysts (const std::vector< const ISyst * > &systs)
 Must set fBeam first. More...
 
void AddNormSyst (const ISyst *syst, const std::vector< const ISyst * > &systs, double frac)
 
std::string SigmaToString (int sigma) const
 
bool IsFHC () const
 Interprets fBeam. More...
 
std::vector< std::vector< Coeffs > > FitSumComponent (const std::vector< ShiftedPreds > &spf, Flavors::Flavors_t flav, Current::Current_t curr, Sign::Sign_t sign) const
 
void InitFits () const
 
void InitFitsHelper (ShiftedPreds &sp, std::vector< std::vector< std::vector< Coeffs >>> &fits, Sign::Sign_t sign) const
 
void InitFitsSumHelper (std::vector< ShiftedPreds > &sps, std::vector< std::vector< std::vector< Coeffs >>> &fits, Sign::Sign_t sign) const
 
void ComponentDerivative (osc::IOscCalculator *calc, Flavors::Flavors_t flav, Current::Current_t curr, Sign::Sign_t sign, CoeffsType type, const SystShifts &shift, double pot, std::unordered_map< const ISyst *, std::vector< double >> &dp) const
 Helper for Derivative. More...
 
template<typename U , typename T >
_ShiftedComponent (osc::_IOscCalculator< T > *calc, const TMD5 *hash, const SystShifts &shift, Flavors::Flavors_t flav, Current::Current_t curr, Sign::Sign_t sign, CoeffsType type) const
 Templated helper for ShiftedComponent. More...
 
template<typename U , typename T >
_PredictComponentSyst (osc::_IOscCalculator< T > *calc, const SystShifts &shift, Flavors::Flavors_t flav, Current::Current_t curr, Sign::Sign_t sign) const
 Templated helper for PredictComponentSyst. More...
 
template<typename T >
void ShiftBins (unsigned int N, T *arr, CoeffsType type, bool nubar, const SystShifts &shift) const
 Helper for ShiftSpectrum. More...
 

Protected Attributes

std::string fBeam
 
std::unique_ptr< IPredictionfPredNom
 The nominal prediction. More...
 
std::unordered_map< const ISyst *, ShiftedPredsfPreds
 
std::unordered_map< const ISyst *, ShiftedPredsfSumPreds
 
ShiftedPreds fSummedsp
 
osc::IOscCalculatorfOscOrigin
 The oscillation values we assume when evaluating the coefficients. More...
 
Spectrum fBinning
 Dummy spectrum to provide binning. More...
 
std::map< Key_t, Val_tfNomCache
 
bool fSplitBySign
 

Detailed Description

Loads shifted spectra from files.

Definition at line 17 of file PredictionSystJoint2018.h.

Member Enumeration Documentation

Enumerator
kNueApp 
kNueSurv 
kNumuSurv 
kNC 
kOther 

Taus, numu appearance.

kNCoeffTypes 

Definition at line 127 of file PredictionInterp.h.

Enumerator
kCombineSigns 
kSplitBySign 

Definition at line 31 of file PredictionInterp.h.

Constructor & Destructor Documentation

ana::PredictionSystJoint2018::PredictionSystJoint2018 ( ENu2018ExtrapType  extrap,
osc::IOscCalculator osc,
const std::vector< const ISyst * > &  systs,
std::string  beam = "fhc",
bool  isFakeData = false,
bool  mergePeripheral = true,
const std::string  fname = "",
bool  minimizeMemory = true,
const std::vector< const ISyst * > &  sumsysts = {} 
)

Nue constructor.

Definition at line 48 of file PredictionSystJoint2018.cxx.

References AddNormSysts(), ana::HistCache::ClearCache(), osc::_IOscCalculator< T >::Copy(), om::cout, allTimeWatchdog::endl, plot_validation_datamc::fname, ana::PredictionInterp::fOscOrigin, ana::PredictionInterp::fPredNom, ana::PredictionInterp::fPreds, ana::PredictionInterp::fSplitBySign, ana::PredictionInterp::fSummedsp, ana::PredictionInterp::fSumPreds, ana::GetDummyShifts(), ana::PredictionInterp::InitFits(), IsFHC(), ana::kAna2018NormFHC, ana::kAna2018NormRHC, ana::kAnaCherenkovSyst, ana::kAnaLightlevelSyst, ana::kCombo, ana::kFake, ana::kNoExtrap, ana::kNue2018Binning, ana::kProportional, ana::PredictionInterp::MinimizeMemory(), ana::PredictionInterp::ShiftedPreds::preds, runNovaSAM::release, ana::PredictionInterp::ShiftedPreds::shifts, SigmaToString(), plotSysts::syst, and ana::PredictionInterp::ShiftedPreds::systName.

57  : fBeam(beam)
58  {
59  gROOT->SetMustClean(false);
60 
61  fOscOrigin = osc->Copy();
62 
63  fSplitBySign = IsFHC();
64 
65  std::cout << "mergePeripheral is "
66  << (mergePeripheral ? "true" : "false") << std::endl;
67 
68  std::cout << "use FakeNDData predictions is "
69  << (isFakeData ? "true" : "false") << std::endl;
70  std::string extrapStr = "pred_";
71  if (extrap == kProportional) extrapStr += "xp_prop";
72  if (extrap == kCombo) extrapStr += "xp_combo";
73  if (extrap == kNoExtrap) extrapStr += "nxp";
74 
75  if (extrap == kFake) extrapStr += "xp_prop";
76 
77  extrapStr += "_";
78 
79  std::cout << "Loading nominals..." << std::endl;
80 
81  IPrediction *nom;
82 
83  std::string fnameSyst;
84 
85  if (fname != ""){
86  std::cout << "Loading predictions from unofficial file..." << std::endl;
87  std::cout << "\t--> " << fname << std::endl;
88  fnameSyst = fname;
89  }
90 
91  else if (IsFHC() && !isFakeData)
92  fnameSyst = "/nova/ana/nu_e_ana/Ana2018/Predictions/provisional_singles/NueProd4SystematicsOnRealNDData_2018-05-22/pred_allxp_Nue2018Axis_full_FHCAllSyst_nueconcat_realNDData_2018-05-22.root";
93  else if (!IsFHC() && !isFakeData)
94  fnameSyst = "/nova/ana/nu_e_ana/Ana2018/Predictions/provisional_singles/NueProd4SystematicsOnRealNDData_2018-05-22/pred_allxp_Nue2018Axis_full_RHCAllSyst_nueconcat_realNDData_2018-05-22.root";
95  else if (IsFHC() && isFakeData)
96  fnameSyst = "/nova/ana/nu_e_ana/Ana2018/Predictions/provisional_singles/NueProd4SystematicsOnFakeNDData_2018-05-23/pred_allxp_Nue2018Axis_full_FHCAllSysts_nueconcat_fakeNDData_05_22_2018_pass1_merged.root";
97  else if (!IsFHC() && isFakeData)
98  fnameSyst = "/nova/ana/nu_e_ana/Ana2018/Predictions/provisional_singles/NueProd4SystematicsOnFakeNDData_2018-05-23/pred_allxp_Nue2018Axis_full_RHCAllSysts_nueconcat_fakeNDData_05_22_2018_pass1_merged.root";
99 
100  TFile fSyst(fnameSyst.c_str());
101  if(fSyst.IsZombie()){
102  std::cout << "Couldn't open " << fnameSyst << std::endl;
103  abort();
104  }
105 
106  std::string varname ="/nue_pred_Nue2018Axis";
107 
108  // make PredictionExtendOwning
109 
110  IPrediction* nomCore = LoadFromFile<IPrediction>(&fSyst, extrapStr + "Nominal/noShift" + varname).release();
111  PredictionNoExtrap* nomNoExtrap = LoadFromFile<PredictionNoExtrap>(&fSyst, "pred_nxp_Nominal/noShift" + varname).release();
112 
113  fPredNom = std::make_unique<PredictExtendOwning>(nomCore, nomNoExtrap, kNue2018Binning, true);
114  nom = new PredictExtendOwning(nomCore, nomNoExtrap, kNue2018Binning, true);
115 
116 
117  // We have exactly 1 syst for the 2018 that is non-standard is some way
118  // The light level syst uses an alternative nominal. Grab that now.
119 
120  IPrediction* nomLightLevel;
121 
122  IPrediction* nomLLCore = LoadFromFile<IPrediction>(
123  &fSyst, extrapStr + "Lightlevel/noShift"+varname).release();
124  PredictionNoExtrap* nomLLNoExtrap = LoadFromFile<PredictionNoExtrap>(
125  &fSyst, "pred_nxp_Lightlevel/noShift"+varname).release();
126 
127  nomLightLevel = new PredictExtendOwning(
128  nomLLCore, nomLLNoExtrap, true);
129 
130  for(const ISyst* syst: systs){
131 
132  if(syst == &kAna2018NormFHC ||
133  syst == &kAna2018NormRHC) continue;
134 
135  std::string systName = syst->ShortName();
136 
137  std::cout << "Loading " << systName << "..." << std::endl;
138 
139  ShiftedPreds sp;
140  sp.systName = systName;
141 
142  for(int sigma: GetDummyShifts(syst))
143  {
144  sp.shifts.push_back(sigma);
145 
146  if (sigma == 0)
147  {
148  if(syst == &kAnaLightlevelSyst ||
150  {
151  std::cout << "\tLooking at systName " << systName << ", so pushing back nomLightLevel " << std::endl;
152  sp.preds.push_back(nomLightLevel);
153  }
154  else
155  sp.preds.push_back(nom);
156  continue;
157  }
158 
159  const std::string sigmaStr = "/"+SigmaToString(sigma);
160 
161  IPrediction* shCore = LoadFromFile<IPrediction>(&fSyst, extrapStr + systName + sigmaStr +varname).release();
162  PredictionNoExtrap* shNoExtrap = LoadFromFile<PredictionNoExtrap>(&fSyst, "pred_nxp_" + systName + sigmaStr +varname).release();
163 
164  sp.preds.push_back(new PredictExtendOwning(shCore, shNoExtrap, kNue2018Binning, true));
165 
166  } // end for sigma
167  // std::cout<<" test find "<<systName<<" "<<syst->find(systName)<<std::endl;
168  fPreds.emplace(syst, sp);
169  } // end for syst
170 
171  bool switcher = true;
172 
173  for(const ISyst* syst: sumsysts){
174 
175  std::string systName = syst->ShortName();
176  ShiftedPreds sp;
177  sp.systName = systName;
178 
179  for(int sigma: GetDummyShifts(syst)){
180  sp.shifts.push_back(sigma);
181 
182  if( sigma == 0 ) {sp.preds.push_back(nom);continue;}
183 
184  const std::string sigmaStr = "/"+SigmaToString(sigma);
185 
186  IPrediction* shCore = LoadFromFile<IPrediction>(&fSyst, extrapStr + systName + sigmaStr +varname).release();
187  PredictionNoExtrap* shNoExtrap = LoadFromFile<PredictionNoExtrap>(&fSyst, "pred_nxp_" + systName + sigmaStr +varname).release();
188 
189  sp.preds.push_back(new PredictExtendOwning(shCore, shNoExtrap, kNue2018Binning, true));
190  int trigger(5);
191  //initialize template to the first one
192  if(switcher){
193  std::cout<<"Warning: PredictInterp is summing systs in quadrature... Are you sure this is what you want???"<<std::endl;
194  std::cout<<"Please press y/n: "<<std::endl;
195  usleep(1000000);
196  std::cout<<"Aborting in "<<trigger--<<"seconds!!!!"<<std::endl;
197  if(sigma == 0){fSummedsp.preds.push_back(nom);continue;}
198  fSummedsp.preds.push_back(new PredictExtendOwning(shCore, shNoExtrap, kNue2018Binning, true));
199  }
200  } // end for sigma
201  switcher = false;
202  fSumPreds.emplace(syst, sp);
203  }// end for syst
204 
205 
206  // Calculate all the ratios etc
207  InitFits();
208 
209  AddNormSysts(systs);
210 
211  // Clean up. Don't use if you need to make debug plots
212  if(minimizeMemory){
213  MinimizeMemory();
215  }
216  }
void AddNormSysts(const std::vector< const ISyst * > &systs)
Must set fBeam first.
std::vector< SystGroupDef > systs
Definition: syst_header.h:384
virtual _IOscCalculator * Copy() const =0
std::vector< int > GetDummyShifts(const ISyst *s)
std::unique_ptr< IPrediction > fPredNom
The nominal prediction.
const DummyAnaSyst kAnaLightlevelSyst("Lightlevel","Lightlevel")
const DummyAnaSyst kAnaCherenkovSyst("Cherenkov","Cherenkov")
bool mergePeripheral
std::vector< IPrediction * > preds
osc::IOscCalculator * fOscOrigin
The oscillation values we assume when evaluating the coefficients.
const Binning kNue2018Binning
Definition: NueCuts2018.h:173
std::unordered_map< const ISyst *, ShiftedPreds > fSumPreds
OStream cout
Definition: OStream.cxx:6
::xsd::cxx::tree::string< char, simple_type > string
Definition: Database.h:154
bool IsFHC() const
Interprets fBeam.
const DummyAnaSyst kAna2018NormRHC("NormRHC2018","RHC. Norm.")
string syst
Definition: plotSysts.py:176
std::string SigmaToString(int sigma) const
std::unordered_map< const ISyst *, ShiftedPreds > fPreds
static void ClearCache()
Definition: HistCache.cxx:310
const DummyAnaSyst kAna2018NormFHC("NormFHC2018","FHC. Norm.")
ana::PredictionSystJoint2018::PredictionSystJoint2018 ( ENu2018ExtrapType  extrap,
osc::IOscCalculator osc,
const std::string  beam,
int  WhichQuant,
const std::vector< const ISyst * > &  systs,
const std::string  fname,
bool  minimizeMemory = true 
)

Numu constructor.

Definition at line 220 of file PredictionSystJoint2018.cxx.

References AddNormSysts(), ana::HistCache::ClearCache(), osc::_IOscCalculator< T >::Copy(), om::cout, allTimeWatchdog::endl, fin, ana::PredictionInterp::fOscOrigin, ana::PredictionInterp::fPredNom, ana::PredictionInterp::fPreds, ana::PredictionInterp::fSplitBySign, ana::GetDummyShifts(), ana::PredictionInterp::InitFits(), IsFHC(), ana::kAna2018NormFHC, ana::kAna2018NormRHC, ana::kNuMu, ana::kNuMuNoExtrap, ana::PredictionInterp::MinimizeMemory(), ana::PredictionInterp::ShiftedPreds::preds, runNovaSAM::release, ana::PredictionInterp::ShiftedPreds::shifts, SigmaToString(), plotSysts::syst, ana::PredictionInterp::ShiftedPreds::systName, and art::to_string().

227  : fBeam(beam)
228  {
229  gROOT->SetMustClean(false);
230 
231  fOscOrigin = osc->Copy();
232 
233  fSplitBySign = IsFHC();
234 
235  std::string extrapStr = "pred_";
236  if (extrap == kNuMu) extrapStr += "xp_numu";
237  if (extrap == kNuMuNoExtrap) extrapStr += "nxp";
238  extrapStr += "_";
239 
240  std::string VarName = "numu_pred_Energy_Quant"+std::to_string(WhichQuant);
241  if (WhichQuant == -1) VarName = "numu_pred_NumuEnergy";
242 
243  std::cout << "\nLooking at VarName " << VarName << " --> Loading nominals now..." << std::endl;
244 
245  TFile fin(fname.c_str());
246 
247  IPrediction *nom;
248  std::string NomVar = extrapStr+"Nominal/noShift/"+VarName;
249  fPredNom = LoadFromFile<IPrediction>(&fin, NomVar);
250  nom = LoadFromFile<IPrediction>(&fin, NomVar).release();
251  // --- The light level syst uses an alternative nominal. Grab that now.
252  std::string LNomVar = extrapStr+"Lightlevel/noShift/"+VarName;
253  IPrediction* nomLightLevel = LoadFromFile<IPrediction>(&fin, LNomVar).release();
254 
255  for(const ISyst* syst: systs){
256 
257  if(syst == &kAna2018NormFHC ||
258  syst == &kAna2018NormRHC ||
259  syst->ShortName() == "RPAShapeRES2018Test" // || // As we aren't using it in Ana18, and so not in the Pred. files.
260  // -- When using Ana18 Predictions, need to comment out the following XSec Systs.
261  //syst->ShortName() == "RPAShapeenh2019" ||
262  //syst->ShortName() == "RPAShapesupp2019" ||
263  //syst->ShortName() == "RPAShapeRES2019" ||
264  //syst->ShortName() == "MECShape2018RPAFixNu" ||
265  //syst->ShortName() == "MECShape2018RPAFixAntiNu"
266  ) continue;
267 
268  std::string systName = syst->ShortName();
269 
270  std::cout << "Loading " << systName << "..." << std::endl;
271 
272  ShiftedPreds sp;
273  sp.systName = systName;
274 
275  for(int sigma: GetDummyShifts(syst)){
276  sp.shifts.push_back(sigma);
277 
278  if (sigma == 0){
279  if (systName == "Lightlevel" || systName == "Cherenkov") {
280  std::cout << "\tLooking at systName " << systName << ", so pushing back nomLightLevel " << std::endl;
281  sp.preds.push_back(nomLightLevel);
282  } else {
283  sp.preds.push_back(nom);
284  }
285  continue;
286  }
287 
288  const std::string sigmaStr = "/"+SigmaToString(sigma)+"/";
289 
290  auto shCore = LoadFromFile<PredictionExtrap> (&fin, extrapStr + systName + sigmaStr +VarName).release();
291  sp.preds.push_back(shCore);
292 
293  } // end for sigma
294  fPreds.emplace(syst, sp);
295  } // end for syst
296 
297  // Calculate all the ratios etc
298  InitFits();
299  //LoadedCallback();
300  AddNormSysts(systs);
301 
302  if(minimizeMemory){
303  MinimizeMemory();
305  }
306  }
TString fin
Definition: Style.C:24
void AddNormSysts(const std::vector< const ISyst * > &systs)
Must set fBeam first.
std::vector< SystGroupDef > systs
Definition: syst_header.h:384
virtual _IOscCalculator * Copy() const =0
std::vector< int > GetDummyShifts(const ISyst *s)
std::unique_ptr< IPrediction > fPredNom
The nominal prediction.
osc::IOscCalculator * fOscOrigin
The oscillation values we assume when evaluating the coefficients.
OStream cout
Definition: OStream.cxx:6
::xsd::cxx::tree::string< char, simple_type > string
Definition: Database.h:154
bool IsFHC() const
Interprets fBeam.
const DummyAnaSyst kAna2018NormRHC("NormRHC2018","RHC. Norm.")
string syst
Definition: plotSysts.py:176
std::string SigmaToString(int sigma) const
std::string to_string(ModuleType mt)
Definition: ModuleType.h:32
std::unordered_map< const ISyst *, ShiftedPreds > fPreds
static void ClearCache()
Definition: HistCache.cxx:310
const DummyAnaSyst kAna2018NormFHC("NormFHC2018","FHC. Norm.")
ana::PredictionSystJoint2018::~PredictionSystJoint2018 ( )
virtual

Definition at line 309 of file PredictionSystJoint2018.cxx.

References AddNormSysts().

310  {
311  }
ana::PredictionSystJoint2018::PredictionSystJoint2018 ( )
inlineprotected

Member Function Documentation

template<typename U , typename T >
U ana::PredictionInterp::_PredictComponentSyst ( osc::_IOscCalculator< T > *  calc,
const SystShifts shift,
Flavors::Flavors_t  flav,
Current::Current_t  curr,
Sign::Sign_t  sign 
) const
protectedinherited

Templated helper for PredictComponentSyst.

Definition at line 615 of file PredictionInterp.cxx.

References ana::SystShifts::ActiveSysts(), om::cerr, ana::Spectrum::Clear(), allTimeWatchdog::endl, ana::PredictionInterp::fBinning, ana::PredictionInterp::fPreds, osc::_IOscCalculator< T >::GetParamsHash(), samweb_client.utility::hash, ana::PredictionInterp::InitFits(), ana::Flavors::kAll, ana::Current::kCC, ana::Current::kNC, ana::PredictionInterp::kNC, ana::PredictionInterp::kNueApp, ana::PredictionInterp::kNueSurv, ana::Flavors::kNuEToNuE, ana::Flavors::kNuEToNuMu, ana::Flavors::kNuEToNuTau, ana::PredictionInterp::kNumuSurv, ana::Flavors::kNuMuToNuE, ana::Flavors::kNuMuToNuMu, ana::Flavors::kNuMuToNuTau, ana::PredictionInterp::kOther, runNovaSAM::ret, ana::PredictionInterp::ShiftedComponent(), and plotSysts::syst.

620  {
621  InitFits();
622 
623  U ret = fBinning;
624  ret.Clear();
625 
626  // Check that we're able to handle all the systs we were passed
627  for(const ISyst* syst: shift.ActiveSysts()){
628  if(fPreds.find(syst) == fPreds.end()){
629  std::cerr << "This PredictionInterp is not set up to handle the requested systematic: " << syst->ShortName() << std::endl;
630  abort();
631  }
632  } // end for syst
633 
634 
635  const TMD5* hash = calc ? calc->GetParamsHash() : 0;
636 
637  if(curr & Current::kCC){
638  if(flav & Flavors::kNuEToNuE) ret += ShiftedComponent(calc, hash, shift, Flavors::kNuEToNuE, Current::kCC, sign, kNueSurv);
639  if(flav & Flavors::kNuEToNuMu) ret += ShiftedComponent(calc, hash, shift, Flavors::kNuEToNuMu, Current::kCC, sign, kOther );
640  if(flav & Flavors::kNuEToNuTau) ret += ShiftedComponent(calc, hash, shift, Flavors::kNuEToNuTau, Current::kCC, sign, kOther );
641 
642  if(flav & Flavors::kNuMuToNuE) ret += ShiftedComponent(calc, hash, shift, Flavors::kNuMuToNuE, Current::kCC, sign, kNueApp );
643  if(flav & Flavors::kNuMuToNuMu) ret += ShiftedComponent(calc, hash, shift, Flavors::kNuMuToNuMu, Current::kCC, sign, kNumuSurv);
644  if(flav & Flavors::kNuMuToNuTau) ret += ShiftedComponent(calc, hash, shift, Flavors::kNuMuToNuTau, Current::kCC, sign, kOther );
645  }
646  if(curr & Current::kNC){
647  assert(flav == Flavors::kAll); // Don't know how to calculate anything else
648 
649  ret += ShiftedComponent(calc, hash, shift, Flavors::kAll, Current::kNC, sign, kNC);
650  }
651 
652  delete hash;
653 
654  return ret;
655  }
(&#39; appearance&#39;)
Definition: IPrediction.h:18
(&#39;beam &#39;)
Definition: IPrediction.h:15
OStream cerr
Definition: OStream.cxx:7
void Clear()
Definition: Spectrum.cxx:878
Charged-current interactions.
Definition: IPrediction.h:39
virtual TMD5 * GetParamsHash() const
Use to check two calculators are in the same state.
Spectrum fBinning
Dummy spectrum to provide binning.
Spectrum ShiftedComponent(osc::IOscCalculator *calc, const TMD5 *hash, const SystShifts &shift, Flavors::Flavors_t flav, Current::Current_t curr, Sign::Sign_t sign, CoeffsType type) const
Helper for PredictComponentSyst.
def sign(x)
Definition: canMan.py:204
(&#39; survival&#39;)
Definition: IPrediction.h:19
Taus, numu appearance.
string syst
Definition: plotSysts.py:176
Neutral-current interactions.
Definition: IPrediction.h:40
std::unordered_map< const ISyst *, ShiftedPreds > fPreds
All neutrinos, any flavor.
Definition: IPrediction.h:26
(&#39; appearance&#39;)
Definition: IPrediction.h:16
template<typename U , typename T >
U ana::PredictionInterp::_ShiftedComponent ( osc::_IOscCalculator< T > *  calc,
const TMD5 *  hash,
const SystShifts shift,
Flavors::Flavors_t  flav,
Current::Current_t  curr,
Sign::Sign_t  sign,
CoeffsType  type 
) const
protectedinherited

Templated helper for ShiftedComponent.

Definition at line 563 of file PredictionInterp.cxx.

References febshutoff_auto::curr, ana::PredictionInterp::fNomCache, ana::PredictionInterp::fPredNom, ana::PredictionInterp::fSplitBySign, samweb_client.utility::hash, it, ana::Sign::kAntiNu, ana::Sign::kBoth, findDuplicateFiles::key, ana::Sign::kNu, ana::PredictionInterp::ShiftedComponent(), and ana::PredictionInterp::ShiftSpectrum().

570  {
572  "PredictionInterp::ShiftedComponent() can only be called using doubles or stan::math::vars");
573 
574  if(fSplitBySign && sign == Sign::kBoth){
575  return (ShiftedComponent(calc, hash, shift, flav, curr, Sign::kAntiNu, type)+
576  ShiftedComponent(calc, hash, shift, flav, curr, Sign::kNu, type));
577  }
578 
579  // Must be the base case of the recursion to use the cache. Otherwise we
580  // can cache systematically shifted versions of our children, which is
581  // wrong. Also, some calculators won't hash themselves.
582  // Moreover, caching is not going to work with stan::math::vars
583  // since they get reset every time Stan's log_prob() is called.
584  const bool canCache = (hash != 0) && !std::is_same<T, stan::math::var>::value;
585 
586  const Key_t key = {flav, curr, sign};
587  auto it = fNomCache.find(key);
588 
589  // Should the interpolation use the nubar fits?
590  const bool nubar = (fSplitBySign && sign == Sign::kAntiNu);
591 
592  // We have the nominal for this exact combination of flav, curr, sign, calc
593  // stored. Shift it and return.
594  if(canCache && it != fNomCache.end() && it->second.hash == *hash){
595  return ShiftSpectrum(it->second.nom, type, nubar, shift);
596  }
597 
598  // We need to compute the nominal again for whatever reason
599  const auto nom = fPredNom->PredictComponent(calc, flav, curr, sign);
600 
601  if(canCache){
602  // Insert into the cache if not already there, or update if there but
603  // with old oscillation parameters.
604  if(it == fNomCache.end())
605  fNomCache.emplace(key, Val_t({*hash, nom}));
606  else
607  it->second = {*hash, nom};
608  }
609 
610  return ShiftSpectrum(nom, type, nubar, shift);
611  }
set< int >::iterator it
Antineutrinos-only.
Definition: IPrediction.h:50
::xsd::cxx::tree::type type
Definition: Database.h:110
std::unique_ptr< IPrediction > fPredNom
The nominal prediction.
std::map< Key_t, Val_t > fNomCache
const XML_Char int const XML_Char * value
Definition: expat.h:331
Spectrum ShiftedComponent(osc::IOscCalculator *calc, const TMD5 *hash, const SystShifts &shift, Flavors::Flavors_t flav, Current::Current_t curr, Sign::Sign_t sign, CoeffsType type) const
Helper for PredictComponentSyst.
Neutrinos-only.
Definition: IPrediction.h:49
def sign(x)
Definition: canMan.py:204
Both neutrinos and antineutrinos.
Definition: IPrediction.h:52
Spectrum ShiftSpectrum(const Spectrum &s, CoeffsType type, bool nubar, const SystShifts &shift) const
void ana::PredictionSystJoint2018::AddNormSyst ( const ISyst syst,
const std::vector< const ISyst * > &  systs,
double  frac 
)
protected

Definition at line 338 of file PredictionSystJoint2018.cxx.

References coeff(), ana::PredictionInterp::ShiftedPreds::FillRemaps(), ana::PredictionInterp::ShiftedPreds::fits, ana::PredictionInterp::ShiftedPreds::fitsNubar, ana::PredictionInterp::fOscOrigin, ana::PredictionInterp::fPredNom, ana::PredictionInterp::fPreds, ana::PredictionInterp::fSplitBySign, demo3::h, ana::PredictionInterp::kNCoeffTypes, plotROC::nBins, ana::PredictionInterp::ShiftedPreds::nCoeffs, ana::PredictionInterp::Predict(), ana::PredictionInterp::ShiftedPreds::preds, ana::PredictionInterp::ShiftedPreds::shifts, ana::ISyst::ShortName(), plotSysts::syst, ana::PredictionInterp::ShiftedPreds::systName, and ana::Spectrum::ToTH1().

Referenced by AddNormSysts(), and PredictionSystJoint2018().

341  {
342  // Bail out if we're not actually requested to include this systematic
343  if(std::find(systs.begin(), systs.end(), syst) == systs.end()) return;
344 
345  TH1* h = Predict(fOscOrigin).ToTH1(1);
346  const int nBins = h->GetNbinsX();
347  delete h;
348 
349  ShiftedPreds normsp;
350  normsp.systName = syst->ShortName();
351  normsp.shifts = {0};
352  normsp.preds = {fPredNom.get()};
353  normsp.fits.resize(kNCoeffTypes);
354  if(fSplitBySign) normsp.fitsNubar.resize(kNCoeffTypes);
355 
356  for(int coeff = 0; coeff < kNCoeffTypes; ++coeff){
357  normsp.fits[coeff].resize(nBins+2);
358  if(fSplitBySign) normsp.fitsNubar[coeff].resize(nBins+2);
359  for(int binIdx = 0; binIdx < nBins+2; ++binIdx){
360  normsp.fits[coeff][binIdx].emplace_back(0, 0, frac, 1);
361  if(fSplitBySign) normsp.fitsNubar[coeff][binIdx].emplace_back(0, 0, frac, 1);
362  }
363  }
364 
365  normsp.FillRemaps();
366 
367  normsp.nCoeffs = 1;
368 
369  fPreds.emplace(syst, normsp);
370  }
int nBins
Definition: plotROC.py:16
std::vector< SystGroupDef > systs
Definition: syst_header.h:384
TH1D * ToTH1(double exposure, Color_t col=kBlack, Style_t style=kSolid, EExposureType expotype=kPOT, EBinType bintype=kBinContent) const
Histogram made from this Spectrum, scaled to some exposure.
Definition: Spectrum.cxx:553
std::unique_ptr< IPrediction > fPredNom
The nominal prediction.
osc::IOscCalculator * fOscOrigin
The oscillation values we assume when evaluating the coefficients.
double frac(double x)
Fractional part.
double coeff(double W, int m, int l, bool real)
Spectrum Predict(osc::IOscCalculator *calc) const override
string syst
Definition: plotSysts.py:176
std::unordered_map< const ISyst *, ShiftedPreds > fPreds
h
Definition: demo3.py:41
void ana::PredictionSystJoint2018::AddNormSysts ( const std::vector< const ISyst * > &  systs)
protected

Must set fBeam first.

Definition at line 315 of file PredictionSystJoint2018.cxx.

References AddNormSyst(), IsFHC(), ana::kAna2018NormFHC, and ana::kAna2018NormRHC.

Referenced by PredictionSystJoint2018(), and ~PredictionSystJoint2018().

316  {
317  // DocDb-27230-v7 and DocDb-27821 >v1
318  // leave horn currents uncorrelated
319  // e.g. FHC norm applies shift to fhc,
320  // no shift to rhc, and vice versa
321  const double kNormFHC = 0.0144;
322  const double kNormRHC = 0.0064;
323 
324  // Include syst for wrong beam type to keep the fit happy, but set it to
325  // zero magnitude
326  if(IsFHC()){
327  AddNormSyst(&kAna2018NormFHC, systs, kNormFHC);
329  }
330  else{
332  AddNormSyst(&kAna2018NormRHC, systs, kNormRHC);
333  }
334  }
std::vector< SystGroupDef > systs
Definition: syst_header.h:384
bool IsFHC() const
Interprets fBeam.
const DummyAnaSyst kAna2018NormRHC("NormRHC2018","RHC. Norm.")
void AddNormSyst(const ISyst *syst, const std::vector< const ISyst * > &systs, double frac)
const DummyAnaSyst kAna2018NormFHC("NormFHC2018","FHC. Norm.")
virtual OscillatableSpectrum ana::IPrediction::ComponentCC ( int  from,
int  to 
) const
inlinevirtualinherited
void ana::PredictionInterp::ComponentDerivative ( osc::IOscCalculator calc,
Flavors::Flavors_t  flav,
Current::Current_t  curr,
Sign::Sign_t  sign,
CoeffsType  type,
const SystShifts shift,
double  pot,
std::unordered_map< const ISyst *, std::vector< double >> &  dp 
) const
protectedinherited

Helper for Derivative.

Definition at line 679 of file PredictionInterp.cxx.

References ana::PredictionInterp::Coeffs::a, ana::PredictionInterp::Coeffs::b, ana::PredictionInterp::Coeffs::c, calib::corr(), util::cube(), ana::PredictionInterp::Coeffs::d, ana::HistCache::Delete(), release_diff::diff, MakeMiniprodValidationCuts::f, fits, ana::PredictionInterp::fPreds, ana::PredictionInterp::fSplitBySign, ana::SystShifts::GetShift(), demo3::h, it, ana::Sign::kAntiNu, ana::Sign::kBoth, ana::Sign::kNu, std::max(), std::min(), getGoodRuns4SAM::n, ana::PredictionInterp::PredictComponentSyst(), util::sqr(), plotSysts::syst, ana::Spectrum::ToTH1(), and submit_syst::x.

Referenced by ana::PredictionInterp::Derivative().

687  {
688  if(fSplitBySign && sign == Sign::kBoth){
689  ComponentDerivative(calc, flav, curr, Sign::kNu, type, shift, pot, dp);
690  ComponentDerivative(calc, flav, curr, Sign::kAntiNu, type, shift, pot, dp);
691  return;
692  }
693 
694  // this method is only ever going to be used by the "Frequentist" version of the class.
695  // don't bother templating.
696  const Spectrum base = PredictComponentSyst(calc, shift, flav, curr, sign);
697  TH1D* h = base.ToTH1(pot);
698  double* arr = h->GetArray();
699  const unsigned int N = h->GetNbinsX()+2;
700 
701 
702  // Should the interpolation use the nubar fits?
703  const bool nubar = (fSplitBySign && sign == Sign::kAntiNu);
704 
705  for(auto& it: dp){
706  const ISyst* syst = it.first;
707  std::vector<double>& diff = it.second;
708  if(diff.empty()) diff.resize(N);
709  assert(diff.size() == N);
710  assert(fPreds.find(syst) != fPreds.end());
711  const ShiftedPreds& sp = fPreds[syst];
712 
713  // not instrumenting this method for stan::math::vars
714  // since we're using autodiff anyway
715  double x = util::GetValAs<double>(shift.GetShift(syst));
716 
717  int shiftBin = (x - sp.shifts[0])/sp.Stride();
718  shiftBin = std::max(0, shiftBin);
719  shiftBin = std::min(shiftBin, sp.nCoeffs-1);
720 
721  const Coeffs* fits = nubar ? &sp.fitsNubarRemap[type][shiftBin].front() : &sp.fitsRemap[type][shiftBin].front();
722 
723  x -= sp.shifts[shiftBin];
724 
725  const double x_cube = util::cube(x);
726  const double x_sqr = util::sqr(x);
727 
728  for(unsigned int n = 0; n < N; ++n){
729  // Uncomment to debug crashes in this function
730  // assert(type < fits.size());
731  // assert(n < sp.fits[type].size());
732  // assert(shiftBin < int(sp.fits[type][n].size()));
733  const Coeffs& f = fits[n];
734 
735  const double corr = f.a*x_cube + f.b*x_sqr + f.c*x + f.d;
736  if(corr > 0) diff[n] += (3*f.a*x_sqr + 2*f.b*x + f.c)/corr*arr[n];
737  } // end for n
738  } // end for syst
739 
741  }
T max(const caf::Proxy< T > &a, T b)
set< int >::iterator it
Antineutrinos-only.
Definition: IPrediction.h:50
double corr(TGraph *g, double thresh)
T cube(T x)
More efficient cube function than pow(x,3)
Definition: MathUtil.h:26
void ComponentDerivative(osc::IOscCalculator *calc, Flavors::Flavors_t flav, Current::Current_t curr, Sign::Sign_t sign, CoeffsType type, const SystShifts &shift, double pot, std::unordered_map< const ISyst *, std::vector< double >> &dp) const
Helper for Derivative.
const XML_Char int const XML_Char int const XML_Char * base
Definition: expat.h:331
T sqr(T x)
More efficient square function than pow(x,2)
Definition: MathUtil.h:23
::xsd::cxx::tree::type type
Definition: Database.h:110
static void Delete(TH1D *&h)
Definition: HistCache.cxx:215
#define pot
Neutrinos-only.
Definition: IPrediction.h:49
def sign(x)
Definition: canMan.py:204
string syst
Definition: plotSysts.py:176
std::vector< std::string > fits
Both neutrinos and antineutrinos.
Definition: IPrediction.h:52
std::unordered_map< const ISyst *, ShiftedPreds > fPreds
T min(const caf::Proxy< T > &a, T b)
Spectrum PredictComponentSyst(osc::IOscCalculator *calc, const SystShifts &shift, Flavors::Flavors_t flav, Current::Current_t curr, Sign::Sign_t sign) const override
h
Definition: demo3.py:41
virtual Spectrum ana::IPrediction::ComponentNC ( ) const
inlinevirtualinherited

Reimplemented in ana::PredictionExtendToPeripheral, ana::PredictionAddRock, ana::PredictionCombinePeriods, and ana::PredictionExtrap.

Definition at line 111 of file IPrediction.h.

References om::cout, and allTimeWatchdog::endl.

Referenced by ana::PredictionAddRock::ComponentNC(), and ana::PredictionExtendToPeripheral::PredictionExtendToPeripheral().

112  {std::cout << "WARNING! ComponentNC is unimplemented in IPrediction" << std::endl; abort();}
OStream cout
Definition: OStream.cxx:6
virtual Spectrum ana::IPrediction::ComponentNCAnti ( ) const
inlinevirtualinherited

Reimplemented in ana::PredictionExtendToPeripheral, ana::PredictionAddRock, ana::PredictionCombinePeriods, and ana::PredictionExtrap.

Definition at line 113 of file IPrediction.h.

References om::cout, dir, allTimeWatchdog::endl, and ana::SaveTo().

Referenced by ana::PredictionAddRock::ComponentNCAnti(), and ana::PredictionExtendToPeripheral::PredictionExtendToPeripheral().

114  {std::cout << "WARNING! ComponentNCAnti is unimplemented in IPrediction" << std::endl; abort();}
OStream cout
Definition: OStream.cxx:6
virtual Spectrum ana::IPrediction::ComponentNCTotal ( ) const
inlinevirtualinherited

Reimplemented in ana::PredictionExtendToPeripheral, ana::PredictionAddRock, ana::PredictionCombinePeriods, and ana::PredictionExtrap.

Definition at line 109 of file IPrediction.h.

References om::cout, and allTimeWatchdog::endl.

Referenced by ana::PredictionAddRock::ComponentNCTotal(), and ana::PredictionExtendToPeripheral::PredictionExtendToPeripheral().

110  {std::cout << "WARNING! ComponentNCTotal is unimplemented in IPrediction" << std::endl; abort();}
OStream cout
Definition: OStream.cxx:6
void ana::PredictionInterp::DebugPlot ( const ISyst syst,
osc::IOscCalculator calc,
Flavors::Flavors_t  flav = Flavors::kAll,
Current::Current_t  curr = Current::kBoth,
Sign::Sign_t  sign = Sign::kBoth 
) const
inherited

Definition at line 920 of file PredictionInterp.cxx.

References bin, plot_validation_datamc::c, om::cout, Draw(), allTimeWatchdog::endl, genie::utils::style::Format(), ana::PredictionInterp::fPredNom, ana::PredictionInterp::fPreds, demo3::h, MECModelEnuComparisons::i, ana::PredictionInterp::InitFits(), makeTrainCVSamples::int, std::isnan(), it, nbins, ana::IPrediction::PredictComponent(), ana::PredictionInterp::PredictComponentSyst(), plotSysts::ratio, ana::ISyst::ShortName(), std::sqrt(), ss, and submit_syst::x.

Referenced by ana::PredictionInterp::DebugPlots().

925  {
926  InitFits();
927 
928  auto it = fPreds.find(syst);
929  if(it == fPreds.end()){
930  std::cout << "PredictionInterp::DebugPlots(): "
931  << syst->ShortName() << " not found" << std::endl;
932  return;
933  }
934 
935 
936  // force-convert to _Spectrum<double> for ease here since in DebugPlots()
937  // we're not concerned with preserving autodiff or speed.
938  // (more instances further below.)
939  std::unique_ptr<TH1> nom(Spectrum(fPredNom->PredictComponent(calc, flav, curr, sign)).ToTH1(18e20));
940  const int nbins = nom->GetNbinsX();
941 
942  TGraph* curves[nbins];
943  TGraph* points[nbins];
944 
945  for(int i = 0; i <= 80; ++i){
946  const double x = .1*i-4;
947  const SystShifts ss(it->first, x);
948  std::unique_ptr<TH1> h(Spectrum(PredictComponentSyst(calc, ss, flav, curr, sign)).ToTH1(18e20));
949 
950  for(int bin = 0; bin < nbins; ++bin){
951  if(i == 0){
952  curves[bin] = new TGraph;
953  points[bin] = new TGraph;
954  }
955 
956  const double ratio = h->GetBinContent(bin+1)/nom->GetBinContent(bin+1);
957 
958  if(!std::isnan(ratio)) curves[bin]->SetPoint(curves[bin]->GetN(), x, ratio);
959  else curves[bin]->SetPoint(curves[bin]->GetN(), x, 1);
960  } // end for bin
961  } // end for i (x)
962 
963  // As elswhere, to allow BirksC etc that need a different nominal to plot
964  // right.
965  IPrediction* pNom = 0;
966  for(unsigned int shiftIdx = 0; shiftIdx < it->second.shifts.size(); ++shiftIdx){
967  if(it->second.shifts[shiftIdx] == 0) pNom = it->second.preds[shiftIdx];
968  }
969  if(pNom){ // if not, probably MinimizeMemory() was called
970  std::unique_ptr<TH1> hnom(Spectrum(pNom->PredictComponent(calc, flav, curr, sign)).ToTH1(18e20));
971 
972  for(unsigned int shiftIdx = 0; shiftIdx < it->second.shifts.size(); ++shiftIdx){
973  if(!it->second.preds[shiftIdx]) continue; // Probably MinimizeMemory()
974  std::unique_ptr<TH1> h;
975  h = std::move(std::unique_ptr<TH1>(Spectrum(it->second.preds[shiftIdx]->PredictComponent(calc, flav, curr, sign)).ToTH1(18e20)));
976 
977  for(int bin = 0; bin < nbins; ++bin){
978  const double ratio = h->GetBinContent(bin+1)/hnom->GetBinContent(bin+1);
979  if(!std::isnan(ratio)) points[bin]->SetPoint(points[bin]->GetN(), it->second.shifts[shiftIdx], ratio);
980  else points[bin]->SetPoint(points[bin]->GetN(), it->second.shifts[shiftIdx], 1);
981  }
982  } // end for shiftIdx
983  } // end if pNom
984 
985 
986  int nx = int(sqrt(nbins));
987  int ny = int(sqrt(nbins));
988  if(nx*ny < nbins) ++nx;
989  if(nx*ny < nbins) ++ny;
990 
991  TCanvas* c = new TCanvas;
992  c->Divide(nx, ny);
993 
994  for(int bin = 0; bin < nbins; ++bin){
995  c->cd(bin+1);
996  (new TH2F("",
997  TString::Format("%s %g < %s < %g;Shift;Ratio",
998  it->second.systName.c_str(),
999  nom->GetXaxis()->GetBinLowEdge(bin+1),
1000  nom->GetXaxis()->GetTitle(),
1001  nom->GetXaxis()->GetBinUpEdge(bin+1)),
1002  100, -4, +4, 100, .5, 1.5))->Draw();
1003  curves[bin]->Draw("l same");
1004  points[bin]->SetMarkerStyle(kFullDotMedium);
1005  points[bin]->Draw("p same");
1006  } // end for bin
1007 
1008  c->cd(0);
1009  }
set< int >::iterator it
T sqrt(T number)
Definition: d0nt_math.hpp:156
Float_t ss
Definition: plot.C:24
int isnan(const stan::math::var &a)
Definition: std_isnan.hpp:18
std::unique_ptr< IPrediction > fPredNom
The nominal prediction.
const int nbins
Definition: cellShifts.C:15
float bin[41]
Definition: plottest35.C:14
def sign(x)
Definition: canMan.py:204
OStream cout
Definition: OStream.cxx:6
string syst
Definition: plotSysts.py:176
recTree Draw("energy.numu.trkccE>>precosmics","fdcuts&&preshutdown")
void Format(TGraph *gr, int lcol, int lsty, int lwid, int mcol, int msty, double msiz)
Definition: Style.cxx:154
std::unordered_map< const ISyst *, ShiftedPreds > fPreds
Spectrum PredictComponentSyst(osc::IOscCalculator *calc, const SystShifts &shift, Flavors::Flavors_t flav, Current::Current_t curr, Sign::Sign_t sign) const override
h
Definition: demo3.py:41
void ana::PredictionInterp::DebugPlotColz ( const ISyst syst,
osc::IOscCalculator calc,
Flavors::Flavors_t  flav = Flavors::kAll,
Current::Current_t  curr = Current::kBoth,
Sign::Sign_t  sign = Sign::kBoth 
) const
inherited

Definition at line 1029 of file PredictionInterp.cxx.

References bin, ana::PredictionInterp::fPredNom, demo3::h, h2, MECModelEnuComparisons::i, ana::PredictionInterp::InitFits(), std::isinf(), std::isnan(), ana::ISyst::LatexName(), nbins, ana::PredictionInterp::PredictComponentSyst(), plotSysts::ratio, ss, and submit_syst::y.

Referenced by ana::PredictionInterp::DebugPlotsColz().

1034  {
1035  InitFits();
1036 
1037  std::unique_ptr<TH1> nom(fPredNom->PredictComponent(calc, flav, curr, sign).ToTH1(18e20));
1038  const int nbins = nom->GetNbinsX();
1039 
1040  TH2* h2 = new TH2F("", (syst->LatexName()+";;#sigma").c_str(),
1041  nbins, nom->GetXaxis()->GetXmin(), nom->GetXaxis()->GetXmax(),
1042  80, -4, +4);
1043  h2->GetXaxis()->SetTitle(nom->GetXaxis()->GetTitle());
1044 
1045  for(int i = 1; i <= 80; ++i){
1046  const double y = h2->GetYaxis()->GetBinCenter(i);
1047  const SystShifts ss(syst, y);
1048  std::unique_ptr<TH1> h(PredictComponentSyst(calc, ss, flav, curr, sign).ToTH1(18e20));
1049 
1050  for(int bin = 0; bin < nbins; ++bin){
1051  const double ratio = h->GetBinContent(bin+1)/nom->GetBinContent(bin+1);
1052 
1053  if(!isnan(ratio) && !isinf(ratio))
1054  h2->Fill(h2->GetXaxis()->GetBinCenter(bin), y, ratio);
1055  } // end for bin
1056  } // end for i (x)
1057 
1058  h2->Draw("colz");
1059  h2->SetMinimum(0.5);
1060  h2->SetMaximum(1.5);
1061  }
int isinf(const stan::math::var &a)
Definition: std_isinf.hpp:16
Float_t ss
Definition: plot.C:24
int isnan(const stan::math::var &a)
Definition: std_isnan.hpp:18
std::unique_ptr< IPrediction > fPredNom
The nominal prediction.
const int nbins
Definition: cellShifts.C:15
float bin[41]
Definition: plottest35.C:14
def sign(x)
Definition: canMan.py:204
TH1F * h2
Definition: plot.C:45
string syst
Definition: plotSysts.py:176
Spectrum PredictComponentSyst(osc::IOscCalculator *calc, const SystShifts &shift, Flavors::Flavors_t flav, Current::Current_t curr, Sign::Sign_t sign) const override
h
Definition: demo3.py:41
void ana::PredictionInterp::DebugPlots ( osc::IOscCalculator calc,
const std::string &  savePattern = "",
Flavors::Flavors_t  flav = Flavors::kAll,
Current::Current_t  curr = Current::kBoth,
Sign::Sign_t  sign = Sign::kBoth 
) const
inherited

Definition at line 1012 of file PredictionInterp.cxx.

References ana::PredictionInterp::DebugPlot(), genie::utils::style::Format(), ana::PredictionInterp::fPreds, and it.

Referenced by check_predinterp(), check_predinterp_numu(), and test_prediction_interp().

1017  {
1018  for(auto& it: fPreds){
1019  DebugPlot(it.first, calc, flav, curr, sign);
1020 
1021  if(!savePattern.empty()){
1022  assert(savePattern.find("%s") != std::string::npos);
1023  gPad->Print(TString::Format(savePattern.c_str(), it.second.systName.c_str()).Data());
1024  }
1025  } // end for it
1026  }
void DebugPlot(const ISyst *syst, osc::IOscCalculator *calc, Flavors::Flavors_t flav=Flavors::kAll, Current::Current_t curr=Current::kBoth, Sign::Sign_t sign=Sign::kBoth) const
set< int >::iterator it
def sign(x)
Definition: canMan.py:204
void Format(TGraph *gr, int lcol, int lsty, int lwid, int mcol, int msty, double msiz)
Definition: Style.cxx:154
std::unordered_map< const ISyst *, ShiftedPreds > fPreds
void ana::PredictionInterp::DebugPlotsColz ( osc::IOscCalculator calc,
const std::string &  savePattern = "",
Flavors::Flavors_t  flav = Flavors::kAll,
Current::Current_t  curr = Current::kBoth,
Sign::Sign_t  sign = Sign::kBoth 
) const
inherited

Definition at line 1064 of file PredictionInterp.cxx.

References ana::PredictionInterp::DebugPlotColz(), genie::utils::style::Format(), ana::PredictionInterp::fPreds, ana::PredictionInterp::InitFits(), and it.

1069  {
1070  InitFits();
1071 
1072  for(auto it: fPreds){
1073  new TCanvas;
1074  DebugPlotColz(it.first, calc, flav, curr, sign);
1075 
1076  if(!savePattern.empty()){
1077  assert(savePattern.find("%s") != std::string::npos);
1078  gPad->Print(TString::Format(savePattern.c_str(), it.second.systName.c_str()).Data());
1079  }
1080  } // end for it
1081  }
set< int >::iterator it
void DebugPlotColz(const ISyst *syst, osc::IOscCalculator *calc, Flavors::Flavors_t flav=Flavors::kAll, Current::Current_t curr=Current::kBoth, Sign::Sign_t sign=Sign::kBoth) const
def sign(x)
Definition: canMan.py:204
void Format(TGraph *gr, int lcol, int lsty, int lwid, int mcol, int msty, double msiz)
Definition: Style.cxx:154
std::unordered_map< const ISyst *, ShiftedPreds > fPreds
void ana::PredictionInterp::Derivative ( osc::IOscCalculator calc,
const SystShifts shift,
double  pot,
std::unordered_map< const ISyst *, std::vector< double >> &  dp 
) const
overridevirtualinherited

Reimplemented from ana::IPrediction.

Definition at line 744 of file PredictionInterp.cxx.

References om::cerr, ana::PredictionInterp::ComponentDerivative(), allTimeWatchdog::endl, ana::PredictionInterp::fPreds, ana::PredictionInterp::InitFits(), it, ana::Flavors::kAll, ana::Sign::kBoth, ana::Current::kCC, ana::Current::kNC, ana::PredictionInterp::kNC, ana::PredictionInterp::kNueApp, ana::PredictionInterp::kNueSurv, ana::Flavors::kNuEToNuE, ana::Flavors::kNuEToNuMu, ana::Flavors::kNuEToNuTau, ana::PredictionInterp::kNumuSurv, ana::Flavors::kNuMuToNuE, ana::Flavors::kNuMuToNuMu, ana::Flavors::kNuMuToNuTau, and ana::PredictionInterp::kOther.

748  {
749  InitFits();
750 
751  // Check that we're able to handle all the systs we were passed
752  for(auto& it: dp){
753  if(fPreds.find(it.first) == fPreds.end()){
754  std::cerr << "This PredictionInterp is not set up to handle the requested systematic: " << it.first->ShortName() << std::endl;
755  abort();
756  }
757  it.second.clear();
758  } // end for syst
759 
763 
767 
769 
770  // Simpler (much slower) implementation in terms of finite differences for
771  // test purposes
772  /*
773  const Spectrum p0 = PredictSyst(calc, shift);
774  TH1D* h0 = p0.ToTH1(pot);
775 
776  const double dx = 1e-9;
777  for(auto& it: dp){
778  const ISyst* s = it.first;
779  std::vector<double>& v = it.second;
780  SystShifts s2 = shift;
781  s2.SetShift(s, s2.GetShift(s)+dx);
782 
783  const Spectrum p1 = PredictSyst(calc, s2);
784 
785  TH1D* h1 = p1.ToTH1(pot);
786 
787  v.resize(h1->GetNbinsX()+2);
788  for(int i = 0; i < h1->GetNbinsX()+2; ++i){
789  v[i] = (h1->GetBinContent(i) - h0->GetBinContent(i))/dx;
790  }
791 
792  HistCache::Delete(h1);
793  }
794 
795  HistCache::Delete(h0);
796  */
797  }
set< int >::iterator it
(&#39; appearance&#39;)
Definition: IPrediction.h:18
(&#39;beam &#39;)
Definition: IPrediction.h:15
OStream cerr
Definition: OStream.cxx:7
void ComponentDerivative(osc::IOscCalculator *calc, Flavors::Flavors_t flav, Current::Current_t curr, Sign::Sign_t sign, CoeffsType type, const SystShifts &shift, double pot, std::unordered_map< const ISyst *, std::vector< double >> &dp) const
Helper for Derivative.
Charged-current interactions.
Definition: IPrediction.h:39
#define pot
(&#39; survival&#39;)
Definition: IPrediction.h:19
Taus, numu appearance.
Neutral-current interactions.
Definition: IPrediction.h:40
Both neutrinos and antineutrinos.
Definition: IPrediction.h:52
std::unordered_map< const ISyst *, ShiftedPreds > fPreds
All neutrinos, any flavor.
Definition: IPrediction.h:26
(&#39; appearance&#39;)
Definition: IPrediction.h:16
std::vector< std::vector< PredictionInterp::Coeffs > > ana::PredictionInterp::FitComponent ( const std::vector< double > &  shifts,
const std::vector< IPrediction * > &  preds,
Flavors::Flavors_t  flav,
Current::Current_t  curr,
Sign::Sign_t  sign 
) const
inherited

Find coefficients describing the ratios from this component.

Definition at line 198 of file PredictionInterp.cxx.

References om::cout, allTimeWatchdog::endl, ana::PredictionInterp::FitRatios(), ana::PredictionInterp::fOscOrigin, MECModelEnuComparisons::i, ana::IPrediction::PredictComponent(), r(), plotSysts::ratios, and submit_syst::y.

Referenced by ana::PredictionInterp::InitFitsHelper().

203  {
204  IPrediction* pNom = 0;
205  for(unsigned int i = 0; i < shifts.size(); ++i){
206  if(shifts[i] == 0) pNom = preds[i];
207  }
208  assert(pNom);
209 
210  // Do it this way rather than via fPredNom so that systematics evaluated
211  // relative to some alternate nominal (eg Birks C where the appropriate
212  // nominal is no-rock) can work.
213  const Spectrum nom = pNom->PredictComponent(fOscOrigin,
214  flav, curr, sign);
215 
216  std::vector<std::unique_ptr<TH1>> ratios;
217  for(auto& p: preds){
218  ratios.emplace_back(Ratio(p->PredictComponent(fOscOrigin,
219  flav, curr, sign),
220  nom).ToTH1());
221 
222  // Check none of the ratio values is utterly crazy
223  std::unique_ptr<TH1>& r = ratios.back();
224  for(int i = 0; i < r->GetNbinsX()+2; ++i){
225  const double y = r->GetBinContent(i);
226  if(y > 500){
227  std::cout << "PredictionInterp: WARNING, ratio in bin "
228  << i << " is " << y << ". Ignoring." << std::endl;
229  r->SetBinContent(i, 1);
230  }
231  }
232  }
233 
234  return FitRatios(shifts, ratios);
235  }
const char * p
Definition: xmltok.h:285
std::vector< std::vector< Coeffs > > FitRatios(const std::vector< double > &shifts, const std::vector< std::unique_ptr< TH1 >> &ratios) const
Find coefficients describing this set of shifts.
osc::IOscCalculator * fOscOrigin
The oscillation values we assume when evaluating the coefficients.
def sign(x)
Definition: canMan.py:204
OStream cout
Definition: OStream.cxx:6
TRandom3 r(0)
std::vector< std::vector< PredictionInterp::Coeffs > > ana::PredictionInterp::FitRatios ( const std::vector< double > &  shifts,
const std::vector< std::unique_ptr< TH1 >> &  ratios 
) const
inherited

Find coefficients describing this set of shifts.

Definition at line 106 of file PredictionInterp.cxx.

References plot_validation_datamc::c, lem_server::cs, util::cube(), e, stan::math::fabs(), MECModelEnuComparisons::i, m, plotSysts::ratios, res, runNovaSAM::ret, util::sqr(), update_sam_good_runs_metadata::stride, registry_explorer::v, y1, and submit_syst::y2.

Referenced by ana::PredictionInterp::FitComponent(), and ana::PredictionInterp::FitSumComponent().

108  {
109  assert(shifts.size() == ratios.size());
110  std::vector<std::vector<Coeffs>> ret;
111 
112  const int binMax = ratios[0]->GetNbinsX();
113 
114  for(int binIdx = 0; binIdx < binMax+2; ++binIdx){
115  ret.push_back({});
116  // This is cubic interpolation. For each adjacent set of four points we
117  // determine coefficients for a cubic which will be the curve between the
118  // center two. We constrain the function to match the two center points
119  // and to have the right mean gradient at them. This causes this patch to
120  // match smoothly with the next one along. The resulting function is
121  // continuous and first and second differentiable. At the ends of the
122  // range we fit a quadratic instead with only one constraint on the
123  // slope. The coordinate conventions are that point y1 sits at x=0 and y2
124  // at x=1. The matrices are simply the inverses of writing out the
125  // constraints expressed above.
126 
127  // Special-case for linear interpolation
128  if(ratios.size() == 2){
129  const double y0 = ratios[0]->GetBinContent(binIdx);
130  const double y1 = ratios[1]->GetBinContent(binIdx);
131 
132  ret.back().emplace_back(0, 0, y1-y0, y0);
133  continue;
134  }
135 
136  {
137  const double y1 = ratios[0]->GetBinContent(binIdx);
138  const double y2 = ratios[1]->GetBinContent(binIdx);
139  const double y3 = ratios[2]->GetBinContent(binIdx);
140  const double v[3] = {y1, y2, (y3-y1)/2};
141  const double m[9] = { 1, -1, 1,
142  -2, 2, -1,
143  1, 0, 0};
144  const TVectorD res = TMatrixD(3, 3, m) * TVectorD(3, v);
145  ret.back().emplace_back(0, res(0), res(1), res(2));
146  }
147 
148  // We're assuming here that the shifts are separated by exactly 1 sigma.
149  for(unsigned int shiftIdx = 1; shiftIdx < ratios.size()-2; ++shiftIdx){
150  const double y0 = ratios[shiftIdx-1]->GetBinContent(binIdx);
151  const double y1 = ratios[shiftIdx ]->GetBinContent(binIdx);
152  const double y2 = ratios[shiftIdx+1]->GetBinContent(binIdx);
153  const double y3 = ratios[shiftIdx+2]->GetBinContent(binIdx);
154 
155  const double v[4] = {y1, y2, (y2-y0)/2, (y3-y1)/2};
156  const double m[16] = { 2, -2, 1, 1,
157  -3, 3, -2, -1,
158  0, 0, 1, 0,
159  1, 0, 0, 0};
160  const TVectorD res = TMatrixD(4, 4, m) * TVectorD(4, v);
161  ret.back().emplace_back(res(0), res(1), res(2), res(3));
162  } // end for shiftIdx
163 
164  {
165  const int N = ratios.size()-3;
166  const double y0 = ratios[N ]->GetBinContent(binIdx);
167  const double y1 = ratios[N+1]->GetBinContent(binIdx);
168  const double y2 = ratios[N+2]->GetBinContent(binIdx);
169  const double v[3] = {y1, y2, (y2-y0)/2};
170  const double m[9] = {-1, 1, -1,
171  0, 0, 1,
172  1, 0, 0};
173  const TVectorD res = TMatrixD(3, 3, m) * TVectorD(3, v);
174  ret.back().emplace_back(0, res(0), res(1), res(2));
175  }
176  } // end for binIdx
177 
178  double stride = -1;
179  for(unsigned int i = 0; i < shifts.size()-1; ++i){
180  const double newStride = shifts[i+1]-shifts[i];
181  assert((stride < 0 || fabs(stride-newStride) < 1e-3) &&
182  "Variably-spaced syst templates are unsupported");
183  stride = newStride;
184  }
185 
186  // If the stride is actually not 1, need to rescale all the coefficients
187  for(std::vector<Coeffs>& cs: ret)
188  for(Coeffs& c: cs){
189  c = Coeffs(c.a/util::cube(stride),
190  c.b/util::sqr(stride),
191  c.c/stride,
192  c.d);}
193  return ret;
194  }
fvar< T > fabs(const fvar< T > &x)
Definition: fabs.hpp:15
Float_t y1[n_points_granero]
Definition: compare.C:5
T cube(T x)
More efficient cube function than pow(x,3)
Definition: MathUtil.h:26
T sqr(T x)
More efficient square function than pow(x,2)
Definition: MathUtil.h:23
TVectorT< double > TVectorD
Definition: Utilities.h:18
TMatrixT< double > TMatrixD
Definition: Utilities.h:16
Float_t e
Definition: plot.C:35
std::vector< std::vector< PredictionInterp::Coeffs > > ana::PredictionInterp::FitSumComponent ( const std::vector< ShiftedPreds > &  spf,
Flavors::Flavors_t  flav,
Current::Current_t  curr,
Sign::Sign_t  sign 
) const
protectedinherited

Definition at line 239 of file PredictionInterp.cxx.

References bin, ana::HistCache::Copy(), ana::HistCache::Delete(), ana::PredictionInterp::FitRatios(), ana::PredictionInterp::fOscOrigin, ana::Spectrum::GetBinnings(), chisquared::hpred, MECModelEnuComparisons::i, ana::HistCache::New(), pot, ana::Spectrum::POT(), ana::IPrediction::PredictComponent(), std::sqrt(), and ana::Spectrum::ToTH1().

Referenced by ana::PredictionInterp::InitFitsSumHelper().

243  {
244  IPrediction* pNom = 0;
245  //take 1st one as template
246  std::vector<double> shifts = sps[0].shifts;
247  std::vector<IPrediction*> preds = sps[0].preds;
248 
249  //for now, genie only take +-2
250  assert(shifts[2] == 0 && "PredictionSumInterp only implemented for +-2 shifts");
251 
252  for(unsigned int i = 0; i < shifts.size(); ++i){
253  if(shifts[i] == 0) pNom = preds[i];
254  }
255  assert(pNom);
256 
257  const Spectrum nom = pNom->PredictComponent(fOscOrigin,
258  flav, curr, sign);
259 
260  std::vector<std::unique_ptr<TH1>> sumratios;
261 
262  double pot = nom.POT();
263  const Binning binning = nom.GetBinnings()[0];
264  DontAddDirectory guard;
265  TH1D* hnom = nom.ToTH1(pot);
266  TH1D* hsummed = HistCache::Copy(hnom);
267 
268  double* quads = hsummed->GetArray();
269  int nbin = hnom->GetNbinsX();
270  double* from = hnom->GetArray();
271 
272  for(unsigned int i = 0; i < shifts.size(); i++){
273  for(auto& sp: sps){
274 
275  IPrediction* p = sp.preds[i];
276  // force-convert to _Spectrum<double> since we don't need autodiff here
277  TH1D* hpred = Spectrum(p->PredictComponent(fOscOrigin, flav, curr, sign)).ToTH1(pot);
278 
279  double* to = hpred->GetArray();
280  for(int bin = 0; bin < nbin+2; ++bin){
281  to[bin] -= from[bin];
282  to[bin] *= to[bin];
283  quads[bin] += to[bin];
284  }//end all bins
285  HistCache::Delete(hpred);
286  }//end all systpreds
287 
288  //sqrt of sum of diff
289  for(int bin = 0; bin < nbin+2; ++bin){
290  quads[bin] = sqrt(quads[bin]);
291  if(shifts[i]<0) quads[bin] *= -1.0;
292  quads[bin] += from[bin];
293  quads[bin] /= from[bin];
294  }
295 
296  std::unique_ptr<TH1> hret(HistCache::New("", binning));
297 
298  for( int i = 0; i< nbin+2; ++i){ hret->SetBinContent( i, quads[i]);}
299 
300  sumratios.emplace_back(std::move(hret));
301  } //end shifts
302  HistCache::Delete(hsummed);
303  HistCache::Delete(hnom);
304  return FitRatios(shifts, sumratios);
305  }
static TH1D * Copy(const TH1D *h)
Definition: HistCache.cxx:175
const char * p
Definition: xmltok.h:285
T sqrt(T number)
Definition: d0nt_math.hpp:156
std::vector< std::vector< Coeffs > > FitRatios(const std::vector< double > &shifts, const std::vector< std::unique_ptr< TH1 >> &ratios) const
Find coefficients describing this set of shifts.
static void Delete(TH1D *&h)
Definition: HistCache.cxx:215
#define pot
osc::IOscCalculator * fOscOrigin
The oscillation values we assume when evaluating the coefficients.
float bin[41]
Definition: plottest35.C:14
def sign(x)
Definition: canMan.py:204
static TH1D * New(const std::string &title, const Binning &bins)
Definition: HistCache.cxx:24
IPrediction* ana::PredictionSystJoint2018::GetNominalPrediction ( )
inline

Method to expose fPredNom

Returns
fPredNom Unique ptr to nominal prediction

Definition at line 45 of file PredictionSystJoint2018.h.

References ana::PredictionInterp::fPredNom.

Referenced by ana::CompareNDDataMCFromVector(), and ana::ComparePredictionsFromVector().

46  {
47  //std::cout << "GETNOMPRED " << fPredNom.get() << std::endl;
48  return fPredNom.get();
49  };
std::unique_ptr< IPrediction > fPredNom
The nominal prediction.
const ShiftedPreds ana::PredictionSystJoint2018::GetShiftedPrediction ( const ISyst syst)
inline

Method to expose fPreds

Returns
shifted prediction (ShiftedPreds) from fPreds

Definition at line 54 of file PredictionSystJoint2018.h.

References dir, ana::PredictionInterp::fPreds, LoadFrom(), SaveTo(), and plotSysts::syst.

Referenced by ana::CompareNDDataMCFromVector(), and ana::ComparePredictionsFromVector().

55  {
56  //for (auto shift:fPreds[syst].preds) { std::cout << "\t Func shift: " << shift << " " << std::endl; }
57  return fPreds[syst];
58  };
string syst
Definition: plotSysts.py:176
std::unordered_map< const ISyst *, ShiftedPreds > fPreds
void ana::PredictionInterp::InitFits ( ) const
protectedinherited

Definition at line 338 of file PredictionInterp.cxx.

References ana::Spectrum::Clear(), om::cout, allTimeWatchdog::endl, ana::PredictionInterp::fBinning, ana::PredictionInterp::ShiftedPreds::FillRemaps(), ana::PredictionInterp::ShiftedPreds::fits, ana::PredictionInterp::ShiftedPreds::fitsNubar, ana::PredictionInterp::fOscOrigin, ana::PredictionInterp::fPredNom, ana::PredictionInterp::fPreds, ana::PredictionInterp::fSplitBySign, ana::PredictionInterp::fSummedsp, ana::PredictionInterp::fSumPreds, ana::PredictionInterp::InitFitsHelper(), ana::PredictionInterp::InitFitsSumHelper(), it, ana::Sign::kAntiNu, ana::Sign::kBoth, ana::Sign::kNu, ana::kSummedSyst, ana::Spectrum::Livetime(), ana::PredictionInterp::ShiftedPreds::nCoeffs, ana::Spectrum::POT(), ana::PredictionInterp::ShiftedPreds::shifts, and ana::PredictionInterp::ShiftedPreds::systName.

Referenced by ana::PredictionInterp::_PredictComponentSyst(), ana::PredictionInterp::DebugPlot(), ana::PredictionInterp::DebugPlotColz(), ana::PredictionInterp::DebugPlotsColz(), ana::PredictionInterp::Derivative(), PredictionSystJoint2018(), ana::PredictionSystJointDemo::PredictionSystJointDemo(), ana::PredictionSystNue2017::PredictionSystNue2017(), ana::PredictionSystNueSecondAna::PredictionSystNueSecondAna(), ana::PredictionSystNumu2017::PredictionSystNumu2017(), ana::PredictionInterp::PredictSyst(), ana::PredictionInterp::SaveTo(), and ana::PredictionInterp::SetOscSeed().

339  {
340 
341  // No systs
342  if(fPreds.empty() && fSumPreds.empty()){
343  if(fBinning.POT() > 0 || fBinning.Livetime() > 0) return;
344  }
345  // Already initialized, Summed merged to fPreds
346  else if(!fPreds.empty() && !fPreds.begin()->second.fits.empty()) return;
347 
348  for(auto& it: fPreds){
349  ShiftedPreds& sp = it.second;
350 
351  if(fSplitBySign){
352  InitFitsHelper(sp, sp.fits, Sign::kNu);
353  InitFitsHelper(sp, sp.fitsNubar, Sign::kAntiNu);
354  }
355  else{
356  InitFitsHelper(sp, sp.fits, Sign::kBoth);
357  }
358  sp.nCoeffs = sp.fits[0][0].size();
359 
360  // Copy the outputs into the remapped indexing order. TODO this is very
361  // ugly. Best would be to generate things in this order natively.
362  sp.FillRemaps();
363  }
364 
365  if(!fSumPreds.empty()){
366  std::cout<<"PredictionInterp: Summing "<<fSumPreds.size()<<
367  " systematics..."<<std::endl;
368  std::vector<ShiftedPreds> sp;
369  for(auto& it: fSumPreds) sp.push_back( it.second);
370 
371  fSummedsp.systName = "Summed Syst";
372  fSummedsp.shifts = {-2, -1, 0, 1, 2};
373 
374  if(fSplitBySign){
377  }
378  else{
380  }
381  fSummedsp.nCoeffs = fSummedsp.fits[0][0].size();
382 
383  fPreds.emplace(&kSummedSyst, fSummedsp);
384  }
385 
386  // Predict something, anything, so that we can know what binning to use
387  fBinning = fPredNom->Predict(fOscOrigin);
388  fBinning.Clear();
389  }
set< int >::iterator it
Antineutrinos-only.
Definition: IPrediction.h:50
std::string systName
What systematic we&#39;re interpolating.
std::vector< std::vector< std::vector< Coeffs > > > fitsNubar
Will be filled if signs are separated, otherwise not.
void Clear()
Definition: Spectrum.cxx:878
std::unique_ptr< IPrediction > fPredNom
The nominal prediction.
std::vector< double > shifts
Shift values sampled.
osc::IOscCalculator * fOscOrigin
The oscillation values we assume when evaluating the coefficients.
const DummyAnaSyst kSummedSyst("SummedSyst","Summed Syst.")
Spectrum fBinning
Dummy spectrum to provide binning.
std::unordered_map< const ISyst *, ShiftedPreds > fSumPreds
double POT() const
Definition: Spectrum.h:263
Neutrinos-only.
Definition: IPrediction.h:49
OStream cout
Definition: OStream.cxx:6
void InitFitsSumHelper(std::vector< ShiftedPreds > &sps, std::vector< std::vector< std::vector< Coeffs >>> &fits, Sign::Sign_t sign) const
Both neutrinos and antineutrinos.
Definition: IPrediction.h:52
void InitFitsHelper(ShiftedPreds &sp, std::vector< std::vector< std::vector< Coeffs >>> &fits, Sign::Sign_t sign) const
std::unordered_map< const ISyst *, ShiftedPreds > fPreds
double Livetime() const
Seconds. For informational purposes only. No calculations use this.
Definition: Spectrum.h:266
std::vector< std::vector< std::vector< Coeffs > > > fits
Indices: [type][histogram bin][shift bin].
void ana::PredictionInterp::InitFitsHelper ( ShiftedPreds sp,
std::vector< std::vector< std::vector< Coeffs >>> &  fits,
Sign::Sign_t  sign 
) const
protectedinherited

Definition at line 308 of file PredictionInterp.cxx.

References ana::PredictionInterp::FitComponent(), fits, ana::Flavors::kAll, ana::Flavors::kAllNuTau, ana::Current::kCC, ana::Current::kNC, ana::PredictionInterp::kNC, ana::PredictionInterp::kNCoeffTypes, ana::PredictionInterp::kNueApp, ana::PredictionInterp::kNueSurv, ana::Flavors::kNuEToNuE, ana::Flavors::kNuEToNuMu, ana::PredictionInterp::kNumuSurv, ana::Flavors::kNuMuToNuE, ana::Flavors::kNuMuToNuMu, ana::PredictionInterp::kOther, ana::PredictionInterp::ShiftedPreds::preds, and ana::PredictionInterp::ShiftedPreds::shifts.

Referenced by ana::PredictionInterp::InitFits().

311  {
312  fits.resize(kNCoeffTypes);
313 
314  fits[kNueApp] = FitComponent(sp.shifts, sp.preds, Flavors::kNuMuToNuE, Current::kCC, sign);
315  fits[kNueSurv] = FitComponent(sp.shifts, sp.preds, Flavors::kNuEToNuE, Current::kCC, sign);
317 
318  fits[kNC] = FitComponent(sp.shifts, sp.preds, Flavors::kAll, Current::kNC, sign);
319 
321  }
(&#39; appearance&#39;)
Definition: IPrediction.h:18
(&#39;beam &#39;)
Definition: IPrediction.h:15
Charged-current interactions.
Definition: IPrediction.h:39
def sign(x)
Definition: canMan.py:204
(&#39; survival&#39;)
Definition: IPrediction.h:19
Taus, numu appearance.
std::vector< std::vector< Coeffs > > FitComponent(const std::vector< double > &shifts, const std::vector< IPrediction * > &preds, Flavors::Flavors_t flav, Current::Current_t curr, Sign::Sign_t sign) const
Find coefficients describing the ratios from this component.
std::vector< std::string > fits
Neutral-current interactions.
Definition: IPrediction.h:40
All neutrinos, any flavor.
Definition: IPrediction.h:26
(&#39; appearance&#39;)
Definition: IPrediction.h:16
void ana::PredictionInterp::InitFitsSumHelper ( std::vector< ShiftedPreds > &  sps,
std::vector< std::vector< std::vector< Coeffs >>> &  fits,
Sign::Sign_t  sign 
) const
protectedinherited

Definition at line 324 of file PredictionInterp.cxx.

References fits, ana::PredictionInterp::FitSumComponent(), ana::Flavors::kAll, ana::Flavors::kAllNuTau, ana::Current::kCC, ana::Current::kNC, ana::PredictionInterp::kNC, ana::PredictionInterp::kNCoeffTypes, ana::PredictionInterp::kNueApp, ana::PredictionInterp::kNueSurv, ana::Flavors::kNuEToNuE, ana::Flavors::kNuEToNuMu, ana::PredictionInterp::kNumuSurv, ana::Flavors::kNuMuToNuE, ana::Flavors::kNuMuToNuMu, and ana::PredictionInterp::kOther.

Referenced by ana::PredictionInterp::InitFits().

327  {
328  fits.resize(kNCoeffTypes);
332 
334 
336  }
(&#39; appearance&#39;)
Definition: IPrediction.h:18
(&#39;beam &#39;)
Definition: IPrediction.h:15
std::vector< std::vector< Coeffs > > FitSumComponent(const std::vector< ShiftedPreds > &spf, Flavors::Flavors_t flav, Current::Current_t curr, Sign::Sign_t sign) const
Charged-current interactions.
Definition: IPrediction.h:39
def sign(x)
Definition: canMan.py:204
(&#39; survival&#39;)
Definition: IPrediction.h:19
Taus, numu appearance.
std::vector< std::string > fits
Neutral-current interactions.
Definition: IPrediction.h:40
All neutrinos, any flavor.
Definition: IPrediction.h:26
(&#39; appearance&#39;)
Definition: IPrediction.h:16
bool ana::PredictionSystJoint2018::IsFHC ( ) const
protected

Interprets fBeam.

Definition at line 426 of file PredictionSystJoint2018.cxx.

References om::cout, allTimeWatchdog::endl, and fBeam.

Referenced by AddNormSysts(), and PredictionSystJoint2018().

427  {
428  if(fBeam == "fhc" ) return true;
429  if(fBeam == "rhc") return false;
430 
431  std::cout << "PredictionSystJoint2018: Bad beam string: "
432  << fBeam << std::endl;
433  abort();
434  }
OStream cout
Definition: OStream.cxx:6
std::unique_ptr< PredictionSystJoint2018 > ana::PredictionSystJoint2018::LoadFrom ( TDirectory *  dir)
static

Definition at line 373 of file PredictionSystJoint2018.cxx.

References POTSpillRate::beam, ana::kAna2018NormFHC, ana::kAna2018NormRHC, ana::PredictionInterp::LoadFromBody(), runNovaSAM::ret, and getGoodRuns4SAM::tag.

Referenced by GetShiftedPrediction().

374  {
375  TObjString* tag = (TObjString*)dir->Get("type");
376  assert(tag);
377 
378  assert(tag->GetString() == "PredictionSystJoint2018");
379 
380  std::unique_ptr<PredictionSystJoint2018> ret(new PredictionSystJoint2018);
382 
383  const TObjString* beam = (TObjString*)dir->Get("beam");
384  assert(beam);
385  ret->fBeam = beam->GetString();
386 
387  ret->fSplitBySign = ret->IsFHC();
388 
389  // Just enable all norm systs unconditionally. Way too hard to do otherwise
390  // NB fBeam was set above. That's necessary for correctness.
391  ret->AddNormSysts({&kAna2018NormFHC, &kAna2018NormRHC});
392 
393  return ret;
394  }
const DummyAnaSyst kAna2018NormRHC("NormRHC2018","RHC. Norm.")
TDirectory * dir
Definition: macro.C:5
static void LoadFromBody(TDirectory *dir, PredictionInterp *ret, std::vector< const ISyst * > veto={})
const DummyAnaSyst kAna2018NormFHC("NormFHC2018","FHC. Norm.")
void ana::PredictionInterp::LoadFromBody ( TDirectory *  dir,
PredictionInterp ret,
std::vector< const ISyst * >  veto = {} 
)
staticinherited

Definition at line 864 of file PredictionInterp.cxx.

References genie::utils::style::Format(), ana::PredictionInterp::fOscOrigin, ana::PredictionInterp::fPredNom, ana::PredictionInterp::fPreds, ana::LoadFrom< IPrediction >(), plot_validation_datamc::pred, ana::PredictionInterp::ShiftedPreds::preds, runNovaSAM::release, plotSysts::shift, ana::PredictionInterp::ShiftedPreds::shifts, ana::Registry< T >::ShortNameToPtr(), plotSysts::syst, and ana::PredictionInterp::ShiftedPreds::systName.

Referenced by LoadFrom(), ana::PredictionSystJointDemo::LoadFrom(), ana::PredictionInterp::LoadFrom(), ana::PredictionSystNueSecondAna::LoadFrom(), ana::PredictionSystNue2017::LoadFrom(), and ana::PredictionSystNumu2017::LoadFrom().

866  {
867  ret->fPredNom = ana::LoadFrom<IPrediction>(dir->GetDirectory("pred_nom"));
868 
869  TH1* hSystNames = (TH1*)dir->Get("syst_names");
870  if(hSystNames){
871  for(int systIdx = 0; systIdx < hSystNames->GetNbinsX(); ++systIdx){
872  ShiftedPreds sp;
873  sp.systName = hSystNames->GetXaxis()->GetBinLabel(systIdx+1);
874 
875  auto syst = Registry<ISyst>::ShortNameToPtr(sp.systName);
876 
877  if(std::find(veto.begin(), veto.end(), syst) != veto.end()) continue;
878 
879  for(int shift = -3; shift <= +3; ++shift){
880  TDirectory* preddir = dir->GetDirectory(TString::Format("pred_%s_%+d", sp.systName.c_str(), shift).Data());
881  if(!preddir) continue; // Can happen for genie systs
882 
883  IPrediction* pred = ana::LoadFrom<IPrediction>(preddir).release();
884 
885  sp.shifts.push_back(shift);
886  sp.preds.push_back(pred);
887  } // end for shift
888 
889  ret->fPreds.emplace(syst, sp);
890  } // end for systIdx
891  } // end if hSystNames
892 
893  ret->fOscOrigin = ana::LoadFrom<osc::IOscCalculator>(dir->GetDirectory("osc_origin")).release();
894  }
std::unique_ptr< IPrediction > LoadFrom< IPrediction >(TDirectory *dir)
Definition: IPrediction.cxx:38
TDirectory * dir
Definition: macro.C:5
string syst
Definition: plotSysts.py:176
void Format(TGraph *gr, int lcol, int lsty, int lwid, int mcol, int msty, double msiz)
Definition: Style.cxx:154
static const T * ShortNameToPtr(const std::string &s, bool allowFail=false)
Definition: Registry.cxx:60
void ana::PredictionInterp::MinimizeMemory ( )
inherited

After calling this DebugPlots won't work fully and SaveTo won't work at all.

Definition at line 897 of file PredictionInterp.cxx.

References ana::PredictionInterp::fPredNom, ana::PredictionInterp::fPreds, MECModelEnuComparisons::i, and it.

Referenced by PredictionSystJoint2018(), and ana::PredictionSystJointDemo::PredictionSystJointDemo().

898  {
899  std::set<IPrediction*> todel;
900  for(auto& it: fPreds){
901  std::vector<IPrediction*>& preds = it.second.preds;
902  for(unsigned int i = 0; i < preds.size(); ++i){
903  if(preds[i] != fPredNom.get()){
904  todel.insert(preds[i]);
905  preds[i] = 0;
906  }
907  }
908  }
909 
910  for(IPrediction* p: todel) delete p;
911 
912  // We probably just freed up a lot of memory, but malloc by default hangs
913  // on to all of it as cache.
914  #ifndef DARWINBUILD
915  malloc_trim(0);
916  #endif
917  }
set< int >::iterator it
const char * p
Definition: xmltok.h:285
std::unique_ptr< IPrediction > fPredNom
The nominal prediction.
std::unordered_map< const ISyst *, ShiftedPreds > fPreds
Spectrum ana::PredictionInterp::Predict ( osc::IOscCalculator calc) const
overridevirtualinherited
SpectrumStan ana::PredictionInterp::Predict ( osc::IOscCalculatorStan calc) const
overridevirtualinherited

Reimplemented from ana::IPrediction.

Definition at line 405 of file PredictionInterp.cxx.

References ana::PredictionInterp::fPredNom.

406  {
407  return fPredNom->Predict(calc);
408  }
std::unique_ptr< IPrediction > fPredNom
The nominal prediction.
Spectrum ana::PredictionInterp::PredictComponent ( osc::IOscCalculator calc,
Flavors::Flavors_t  flav,
Current::Current_t  curr,
Sign::Sign_t  sign 
) const
overridevirtualinherited

Implements ana::IPrediction.

Definition at line 411 of file PredictionInterp.cxx.

References ana::PredictionInterp::fPredNom.

Referenced by compare_pid_cut_sens(), fa_fd_data_mc_systs(), syst_plot_test(), systematics_table(), and systematics_table_from_pred_interp().

415  {
416  return fPredNom->PredictComponent(calc, flav, curr, sign);
417  }
std::unique_ptr< IPrediction > fPredNom
The nominal prediction.
def sign(x)
Definition: canMan.py:204
SpectrumStan ana::PredictionInterp::PredictComponent ( osc::IOscCalculatorStan calc,
Flavors::Flavors_t  flav,
Current::Current_t  curr,
Sign::Sign_t  sign 
) const
overridevirtualinherited

Reimplemented from ana::IPrediction.

Definition at line 420 of file PredictionInterp.cxx.

References ana::PredictionInterp::fPredNom.

424  {
425  return fPredNom->PredictComponent(calc, flav, curr, sign);
426  }
std::unique_ptr< IPrediction > fPredNom
The nominal prediction.
def sign(x)
Definition: canMan.py:204
Spectrum ana::PredictionInterp::PredictComponentSyst ( osc::IOscCalculator calc,
const SystShifts shift,
Flavors::Flavors_t  flav,
Current::Current_t  curr,
Sign::Sign_t  sign 
) const
overridevirtualinherited
SpectrumStan ana::PredictionInterp::PredictComponentSyst ( osc::IOscCalculatorStan calc,
const SystShifts shift,
Flavors::Flavors_t  flav,
Current::Current_t  curr,
Sign::Sign_t  sign 
) const
overridevirtualinherited

Reimplemented from ana::IPrediction.

Definition at line 669 of file PredictionInterp.cxx.

References calc, febshutoff_auto::curr, plotSysts::shift, and canMan::sign().

674  {
675  return _PredictComponentSyst<SpectrumStan>(calc, shift, flav, curr, sign);
676  }
osc::OscCalculatorDumb calc
def sign(x)
Definition: canMan.py:204
Spectrum ana::PredictionInterp::PredictSyst ( osc::IOscCalculator calc,
const SystShifts shift 
) const
overridevirtualinherited

Reimplemented from ana::IPrediction.

Definition at line 429 of file PredictionInterp.cxx.

References ana::PredictionInterp::InitFits(), ana::Flavors::kAll, ana::Current::kBoth, ana::Sign::kBoth, and ana::PredictionInterp::PredictComponentSyst().

Referenced by check_predinterp(), check_predinterp_numu(), demo::DrawUpDownRatioCanvas(), mec_tuning(), mec_tuning_fitter_2020(), starPlot(), test_stanfit_systpulls(), and TestPred().

431  {
432  InitFits();
433 
434  return PredictComponentSyst(calc,
435  shift,
438  Sign::kBoth);
439  }
Interactions of both types.
Definition: IPrediction.h:42
Both neutrinos and antineutrinos.
Definition: IPrediction.h:52
All neutrinos, any flavor.
Definition: IPrediction.h:26
Spectrum PredictComponentSyst(osc::IOscCalculator *calc, const SystShifts &shift, Flavors::Flavors_t flav, Current::Current_t curr, Sign::Sign_t sign) const override
SpectrumStan ana::PredictionInterp::PredictSyst ( osc::IOscCalculatorStan calc,
const SystShifts shift 
) const
overridevirtualinherited

Reimplemented from ana::IPrediction.

Definition at line 442 of file PredictionInterp.cxx.

References ana::PredictionInterp::InitFits(), ana::Flavors::kAll, ana::Current::kBoth, ana::Sign::kBoth, and ana::PredictionInterp::PredictComponentSyst().

444  {
445  InitFits();
446 
447  return PredictComponentSyst(calc,
448  shift,
451  Sign::kBoth);
452  }
Interactions of both types.
Definition: IPrediction.h:42
Both neutrinos and antineutrinos.
Definition: IPrediction.h:52
All neutrinos, any flavor.
Definition: IPrediction.h:26
Spectrum PredictComponentSyst(osc::IOscCalculator *calc, const SystShifts &shift, Flavors::Flavors_t flav, Current::Current_t curr, Sign::Sign_t sign) const override
Spectrum ana::IPrediction::PredictUnoscillated ( ) const
virtualinherited

Reimplemented in ana::PredictionSterile.

Definition at line 82 of file IPrediction.cxx.

References noosc, and ana::IPrediction::Predict().

Referenced by cc(), demo5(), demo::DrawUpDownRatioCanvas(), Efficiency(), efficiency(), efficiencySA(), fa_fd_data_mc_systs(), GetSpectra(), numu_demo_split_plot(), plot_nd_data_mc(), template_basic(), and test_ana().

83  {
84  // Default implementation
86  return Predict(&noosc);
87  }
Pass neutrinos through unchanged.
virtual Spectrum Predict(osc::IOscCalculator *calc) const =0
osc::NoOscillations noosc
Definition: NueSystFuncs.h:44
void ana::PredictionSystJoint2018::SaveTo ( TDirectory *  dir) const
overridevirtual

Reimplemented from ana::PredictionInterp.

Definition at line 397 of file PredictionSystJoint2018.cxx.

References fBeam, ana::PredictionInterp::SaveTo(), tmp, and Write().

Referenced by GetShiftedPrediction().

398  {
400 
401  TDirectory* tmp = gDirectory;
402 
403  dir->cd();
404  // Overwrite "IPrediction"
405  TObjString("PredictionSystJoint2018").Write("type");
406 
407  TObjString(fBeam.c_str()).Write("beam");
408 
409  tmp->cd();
410  }
Float_t tmp
Definition: plot.C:36
virtual void SaveTo(TDirectory *dir) const override
TDirectory * dir
Definition: macro.C:5
gm Write()
void ana::PredictionInterp::SetOscSeed ( osc::IOscCalculator oscSeed)
inherited

Definition at line 392 of file PredictionInterp.cxx.

References osc::_IOscCalculator< T >::Copy(), ana::PredictionInterp::fOscOrigin, ana::PredictionInterp::fPreds, ana::PredictionInterp::InitFits(), and it.

392  {
393  fOscOrigin = oscSeed->Copy();
394  for(auto& it: fPreds) it.second.fits.clear();
395  InitFits();
396  }
set< int >::iterator it
virtual _IOscCalculator * Copy() const =0
osc::IOscCalculator * fOscOrigin
The oscillation values we assume when evaluating the coefficients.
std::unordered_map< const ISyst *, ShiftedPreds > fPreds
template<typename T >
void ana::PredictionInterp::ShiftBins ( unsigned int  N,
T arr,
CoeffsType  type,
bool  nubar,
const SystShifts shift 
) const
protectedinherited

Helper for ShiftSpectrum.

Definition at line 484 of file PredictionInterp.cxx.

References ana::PredictionInterp::Coeffs::a, ana::PredictionInterp::Coeffs::b, ana::PredictionInterp::Coeffs::c, calib::corr(), util::cube(), ana::PredictionInterp::Coeffs::d, MakeMiniprodValidationCuts::f, fits, ana::PredictionInterp::ShiftedPreds::fitsNubarRemap, ana::PredictionInterp::ShiftedPreds::fitsRemap, ana::PredictionInterp::fPreds, ana::PredictionInterp::fSplitBySign, ana::SystShifts::GetShift(), MECModelEnuComparisons::i, it, std::max(), std::min(), getGoodRuns4SAM::n, ana::PredictionInterp::ShiftedPreds::nCoeffs, ana::PredictionInterp::ShiftedPreds::shifts, util::sqr(), ana::PredictionInterp::ShiftedPreds::Stride(), plotSysts::syst, T, and submit_syst::x.

Referenced by ana::PredictionInterp::ShiftSpectrum().

489  {
491  "PredictionInterp::ShiftBins() can only be called using doubles or stan::math::vars");
492  if(nubar) assert(fSplitBySign);
493 
494  T corr[N];
495  for(unsigned int i = 0; i < N; ++i) corr[i] = 1;
496 
497  for(auto& it: fPreds){
498  const ISyst* syst = it.first;
499  const ShiftedPreds& sp = it.second;
500 
501  T x = shift.GetShift<T>(syst);
502 
503  // need to actually do the calculation for the autodiff version
504  // to make sure the gradient is computed correctly
505  if(x == 0 && !std::is_same<T, stan::math::var>::value) continue;
506 
507  int shiftBin = (util::GetValAs<double>(x) - sp.shifts[0])/sp.Stride();
508  shiftBin = std::max(0, shiftBin);
509  shiftBin = std::min(shiftBin, sp.nCoeffs-1);
510 
511  const Coeffs* fits = nubar ? &sp.fitsNubarRemap[type][shiftBin].front() : &sp.fitsRemap[type][shiftBin].front();
512 
513  x -= sp.shifts[shiftBin];
514 
515  const T x_cube = util::cube(x);
516  const T x_sqr = util::sqr(x);
517 
518  for(unsigned int n = 0; n < N; ++n){
519  // Uncomment to debug crashes in this function
520  // assert(type < fits.size());
521  // assert(n < sp.fits[type].size());
522  // assert(shiftBin < int(sp.fits[type][n].size()));
523 
524  const Coeffs& f = fits[n];
525 
526  corr[n] *= f.a*x_cube + f.b*x_sqr + f.c*x + f.d;
527  } // end for n
528  } // end for syst
529 
530  for(unsigned int n = 0; n < N; ++n){
531  // std::max() doesn't work with stan::math::var
532  arr[n] *= (corr[n] > 0.) ? corr[n] : 0.;
533  }
534 
535  }
T max(const caf::Proxy< T > &a, T b)
set< int >::iterator it
double corr(TGraph *g, double thresh)
T cube(T x)
More efficient cube function than pow(x,3)
Definition: MathUtil.h:26
T sqr(T x)
More efficient square function than pow(x,2)
Definition: MathUtil.h:23
::xsd::cxx::tree::type type
Definition: Database.h:110
const XML_Char int const XML_Char * value
Definition: expat.h:331
string syst
Definition: plotSysts.py:176
std::vector< std::string > fits
double T
Definition: Xdiff_gwt.C:5
std::unordered_map< const ISyst *, ShiftedPreds > fPreds
T min(const caf::Proxy< T > &a, T b)
Spectrum ana::PredictionInterp::ShiftedComponent ( osc::IOscCalculator calc,
const TMD5 *  hash,
const SystShifts shift,
Flavors::Flavors_t  flav,
Current::Current_t  curr,
Sign::Sign_t  sign,
CoeffsType  type 
) const
inherited

Helper for PredictComponentSyst.

Definition at line 538 of file PredictionInterp.cxx.

References calc, febshutoff_auto::curr, samweb_client.utility::hash, plotSysts::shift, and canMan::sign().

Referenced by ana::PredictionInterp::_PredictComponentSyst(), and ana::PredictionInterp::_ShiftedComponent().

545  {
546  return _ShiftedComponent<Spectrum>(calc, hash, shift, flav, curr, sign, type);
547  }
osc::OscCalculatorDumb calc
::xsd::cxx::tree::type type
Definition: Database.h:110
def sign(x)
Definition: canMan.py:204
SpectrumStan ana::PredictionInterp::ShiftedComponent ( osc::_IOscCalculator< stan::math::var > *  calc,
const TMD5 *  hash,
const SystShifts shift,
Flavors::Flavors_t  flav,
Current::Current_t  curr,
Sign::Sign_t  sign,
CoeffsType  type 
) const
inherited

Definition at line 550 of file PredictionInterp.cxx.

References calc, febshutoff_auto::curr, samweb_client.utility::hash, plotSysts::shift, and canMan::sign().

557  {
558  return _ShiftedComponent<SpectrumStan>(calc, hash, shift, flav, curr, sign, type);
559  }
osc::OscCalculatorDumb calc
::xsd::cxx::tree::type type
Definition: Database.h:110
def sign(x)
Definition: canMan.py:204
Spectrum ana::PredictionInterp::ShiftSpectrum ( const Spectrum s,
CoeffsType  type,
bool  nubar,
const SystShifts shift 
) const
inherited

Definition at line 455 of file PredictionInterp.cxx.

References ana::Spectrum::GetBinnings(), ana::Spectrum::GetLabels(), demo3::h, ana::Spectrum::Livetime(), ana::Spectrum::POT(), plotSysts::shift, ana::PredictionInterp::ShiftBins(), and ana::Spectrum::ToTH1().

Referenced by ana::PredictionInterp::_ShiftedComponent().

459  {
460  // TODO histogram operations could be too slow
461  TH1D *h = s.ToTH1(s.POT());
462 
463  ShiftBins(h->GetNbinsX()+2, h->GetArray(), type, nubar, shift);
464 
465  return Spectrum(std::unique_ptr<TH1D>(h), s.GetLabels(), s.GetBinnings(), s.POT(), s.Livetime());
466  }
void ShiftBins(unsigned int N, T *arr, CoeffsType type, bool nubar, const SystShifts &shift) const
Helper for ShiftSpectrum.
::xsd::cxx::tree::type type
Definition: Database.h:110
const XML_Char * s
Definition: expat.h:262
h
Definition: demo3.py:41
SpectrumStan ana::PredictionInterp::ShiftSpectrum ( const SpectrumStan s,
CoeffsType  type,
bool  nubar,
const SystShifts shift 
) const
inherited

Definition at line 469 of file PredictionInterp.cxx.

References ana::SpectrumStan::GetBinnings(), ana::SpectrumStan::GetLabels(), ana::SpectrumStan::Livetime(), ana::SpectrumStan::POT(), plotSysts::shift, ana::PredictionInterp::ShiftBins(), and ana::SpectrumStan::ToBins().

473  {
474 
475  auto binContents = s.ToBins(s.POT());
476 
477  ShiftBins(binContents.size(), &binContents.front(), type, nubar, shift);
478 
479  return SpectrumStan(std::move(binContents), s.GetLabels(), s.GetBinnings(), s.POT(), s.Livetime());
480  }
void ShiftBins(unsigned int N, T *arr, CoeffsType type, bool nubar, const SystShifts &shift) const
Helper for ShiftSpectrum.
::xsd::cxx::tree::type type
Definition: Database.h:110
const XML_Char * s
Definition: expat.h:262
std::string ana::PredictionSystJoint2018::SigmaToString ( int  sigma) const
protected

Definition at line 413 of file PredictionSystJoint2018.cxx.

References om::cout, and allTimeWatchdog::endl.

Referenced by PredictionSystJoint2018().

414  {
415  if(sigma == -2) return "minusTwo";
416  if(sigma == -1) return "minusOne";
417  if(sigma == 0) return "";
418  if(sigma == +1) return "plusOne";
419  if(sigma == +2) return "plusTwo";
420 
421  std::cout << "PredictionSystJoint2018: unknown sigma " << sigma << std::endl;
422  abort();
423  }
OStream cout
Definition: OStream.cxx:6
bool ana::PredictionInterp::SplitBySign ( ) const
inlineinherited

Definition at line 126 of file PredictionInterp.h.

126 {return fSplitBySign;}

Member Data Documentation

std::string ana::PredictionSystJoint2018::fBeam
protected

Definition at line 78 of file PredictionSystJoint2018.h.

Referenced by IsFHC(), and SaveTo().

Spectrum ana::PredictionInterp::fBinning
mutableprotectedinherited

Dummy spectrum to provide binning.

Definition at line 223 of file PredictionInterp.h.

Referenced by ana::PredictionInterp::_PredictComponentSyst(), and ana::PredictionInterp::InitFits().

std::map<Key_t, Val_t> ana::PredictionInterp::fNomCache
mutableprotectedinherited

Definition at line 241 of file PredictionInterp.h.

Referenced by ana::PredictionInterp::_ShiftedComponent().

osc::IOscCalculator* ana::PredictionInterp::fOscOrigin
protectedinherited
std::unique_ptr<IPrediction> ana::PredictionInterp::fPredNom
protectedinherited
std::unordered_map<const ISyst*, ShiftedPreds> ana::PredictionInterp::fPreds
mutableprotectedinherited
bool ana::PredictionInterp::fSplitBySign
protectedinherited
ShiftedPreds ana::PredictionInterp::fSummedsp
mutableprotectedinherited
std::unordered_map<const ISyst*, ShiftedPreds> ana::PredictionInterp::fSumPreds
mutableprotectedinherited

The documentation for this class was generated from the following files: