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

Loads shifted spectra from files. More...

#include "/cvmfs/nova-development.opensciencegrid.org/novasoft/releases/N20-11-28/3FlavorAna/Prediction/PredictionSyst3Flavor2020.h"

Inheritance diagram for ana::PredictionSyst3Flavor2020:
ana::PredictionInterp ana::IPrediction

Public Types

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

Public Member Functions

 PredictionSyst3Flavor2020 (ENu2020ExtrapType extrap, osc::IOscCalc *osc, const std::vector< const ISyst * > &systs, std::string beam="fhc", bool isFakeData=false, bool mergePeripheral=true, const std::string fname="", bool minimizeMemory=true, bool NERSC=false)
 Nue constructor. More...
 
 PredictionSyst3Flavor2020 (ENu2020ExtrapType extrap, osc::IOscCalc *osc, const std::string beam, const int EhadFracQuant, const std::vector< const ISyst * > &systs, bool isFakeData=false, const std::string fname="", bool minimizeMemory=true, bool NERSC=false)
 Numu constructor. More...
 
virtual ~PredictionSyst3Flavor2020 ()
 
IPredictionGetNominalPrediction ()
 
const ShiftedPredsGetShiftedPrediction (const ISyst *syst)
 
void SaveTo (TDirectory *dir, const std::string &name) const override
 
Spectrum Predict (osc::IOscCalc *calc) const override
 
Spectrum Predict (osc::IOscCalcStan *calc) const override
 
Spectrum PredictSyst (osc::IOscCalc *calc, const SystShifts &shift) const override
 
Spectrum PredictSyst (osc::IOscCalcStan *calc, const SystShifts &shift) const override
 
Spectrum PredictComponent (osc::IOscCalc *calc, Flavors::Flavors_t flav, Current::Current_t curr, Sign::Sign_t sign) const override
 
Spectrum PredictComponent (osc::IOscCalcStan *calc, Flavors::Flavors_t flav, Current::Current_t curr, Sign::Sign_t sign) const override
 
Spectrum PredictComponentSyst (osc::IOscCalc *calc, const SystShifts &shift, Flavors::Flavors_t flav, Current::Current_t curr, Sign::Sign_t sign) const override
 
Spectrum PredictComponentSyst (osc::IOscCalcStan *calc, const SystShifts &shift, Flavors::Flavors_t flav, Current::Current_t curr, Sign::Sign_t sign) const override
 
void MinimizeMemory ()
 
void DebugPlot (const ISyst *syst, osc::IOscCalc *calc, Flavors::Flavors_t flav=Flavors::kAll, Current::Current_t curr=Current::kBoth, Sign::Sign_t sign=Sign::kBoth) const
 
void DebugPlots (osc::IOscCalc *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::IOscCalc *oscSeed)
 
void DebugPlotColz (const ISyst *syst, osc::IOscCalc *calc, Flavors::Flavors_t flav=Flavors::kAll, Current::Current_t curr=Current::kBoth, Sign::Sign_t sign=Sign::kBoth) const
 
void DebugPlotsColz (osc::IOscCalc *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< Eigen::ArrayXd > &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 std::string &systName) const
 Find coefficients describing the ratios from this component. More...
 
std::vector< const ISyst * > GetAllSysts () const
 
Spectrum ShiftSpectrum (const Spectrum &s, CoeffsType type, bool nubar, const SystShifts &shift) const
 
Spectrum ShiftedComponent (osc::IOscCalc *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...
 
Spectrum ShiftedComponent (osc::IOscCalcStan *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< PredictionSyst3Flavor2020LoadFrom (TDirectory *dir, const std::string &name)
 
static void LoadFromBody (TDirectory *dir, PredictionInterp *ret, std::vector< const ISyst * > veto={})
 

Protected Member Functions

 PredictionSyst3Flavor2020 ()
 
void AddNormSysts (const std::vector< const ISyst * > &systs, ENu2020ExtrapType extrap)
 Must set fBeam first. More...
 
void AddNormSyst (const ISyst *syst, const std::vector< const ISyst * > &systs, double fracNueApp, double fracOthers)
 
std::string SigmaToString (int sigma) const
 
IPredictionLoadNuePtExtrapPred (TFile *file, ENu2020ExtrapType extrap, std::string syst_name, std::string sigma_str) const
 
IPredictionLoadNumuPtExtrapPred (TFile *file, int EhadFracQuant, std::string syst_name, std::string sigma_str) const
 
bool IsFHC () const
 Interprets fBeam. More...
 
void InitFits () const
 
void InitFitsHelper (ShiftedPreds &sp, std::vector< std::vector< std::vector< Coeffs >>> &fits, Sign::Sign_t sign) const
 
template<typename T >
Spectrum _ShiftedComponent (osc::_IOscCalc< 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 T >
Spectrum _PredictComponentSyst (osc::_IOscCalc< 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
 
osc::IOscCalcfOscOrigin
 The oscillation values we assume when evaluating the coefficients. More...
 
Spectrum fBinning
 Dummy spectrum to provide binning. More...
 
ThreadLocal< std::map< Key_t, Val_t > > fNomCache
 
bool fSplitBySign
 

Detailed Description

Loads shifted spectra from files.

Definition at line 21 of file PredictionSyst3Flavor2020.h.

Member Enumeration Documentation

Enumerator
kNueApp 
kNueSurv 
kNumuSurv 
kNC 
kOther 

Taus, numu appearance.

kNCoeffTypes 

Definition at line 117 of file PredictionInterp.h.

Enumerator
kCombineSigns 
kSplitBySign 

Definition at line 26 of file PredictionInterp.h.

Constructor & Destructor Documentation

ana::PredictionSyst3Flavor2020::PredictionSyst3Flavor2020 ( ENu2020ExtrapType  extrap,
osc::IOscCalc osc,
const std::vector< const ISyst * > &  systs,
std::string  beam = "fhc",
bool  isFakeData = false,
bool  mergePeripheral = true,
const std::string  fname = "",
bool  minimizeMemory = true,
bool  NERSC = false 
)

Nue constructor.

Definition at line 27 of file PredictionSyst3Flavor2020.cxx.

References AddNormSysts(), osc::_IOscCalc< T >::Copy(), om::cout, allTimeWatchdog::endl, plot_validation_datamc::fname, ana::PredictionInterp::fOscOrigin, ana::PredictionInterp::fPredNom, ana::PredictionInterp::fPreds, ana::PredictionInterp::fSplitBySign, ana::GetDummyShifts(), cet::getenv(), ana::PredictionInterp::InitFits(), IsFHC(), ana::kAna2020NormFHC, ana::kAna2020NormHornCorr, ana::kAna2020NormRHC, ana::kAnaCalibDriftSyst, ana::kAnaCherenkovSyst, ana::kCombo, ana::kComboPtExtrap, ana::kFake, ana::kLeptonAngleSystFDXZ2020, ana::kLeptonAngleSystFDYZ2020, ana::kLeptonAngleSystNDXZ2020, ana::kLeptonAngleSystNDYZ2020, ana::kMichelTaggingSyst2020, ana::kNoExtrap, ana::kNue2020Binning, ana::kProportional, ana::kPropPtExtrap, ana::LoadFrom< IPrediction >(), LoadNuePtExtrapPred(), ana::PredictionInterp::MinimizeMemory(), ana::PredictionInterp::ShiftedPreds::preds, runNovaSAM::release, ana::PredictionInterp::ShiftedPreds::shifts, sigma(), SigmaToString(), string, and ana::PredictionInterp::ShiftedPreds::systName.

37  : fBeam(beam)
38  {
39  gROOT->SetMustClean(false);
40 
41  fOscOrigin = osc->Copy();
42 
43  fSplitBySign = IsFHC();
44 
45  const bool isPtExtrap = extrap == ENu2020ExtrapType::kComboPtExtrap || extrap == ENu2020ExtrapType::kPropPtExtrap;
46 
47  std::cout << "mergePeripheral is "
48  << (mergePeripheral ? "true" : "false") << std::endl;
49 
50  std::cout << "use FakeNDData predictions is "
51  << (isFakeData ? "true" : "false") << std::endl;
52  std::string extrapStr = "pred_";
53  if (extrap == ENu2020ExtrapType::kProportional) extrapStr += "xp_prop";
54  if (extrap == ENu2020ExtrapType::kCombo) extrapStr += "xp_combo";
55  if (extrap == ENu2020ExtrapType::kNoExtrap) extrapStr += "nxp";
56 
57  if (extrap == ENu2020ExtrapType::kFake) extrapStr += "xp_prop";
58 
59  extrapStr += "_";
60 
61  std::cout << "Loading nominals..." << std::endl;
62 
63  IPrediction *nom;
64 
65  std::string fnameSyst;
66 
67  if (fname != "") {
68  std::cout << "Loading predictions from unofficial file..." << std::endl;
69  std::cout << "\t--> " << fname << std::endl;
70  fnameSyst = fname;
71  } else {
72  // --- Set some defaults. These aren't final, so they need to be updated, but that's better than nothing.
73  std::string FileDir = "/cvmfs/nova.osgstorage.org/analysis/3flavor/Predictions/";
74  if(NERSC) {
75  FileDir = std::string(std::getenv("FCHELPERANA2020_LIB_PATH")) + "/Predictions/";
76  }
77  if ( isPtExtrap ) {
78  std::cout << "\t Loading the Pt Extrap files." << std::endl;
79  if ( IsFHC() && !isFakeData) { fnameSyst = FileDir + "pred_xp_nue_combo_Nue2020Axis_full_FHCAllSysts_PtQuants3_nueconcat_realNDData_20200427.root";
80  } else if (!IsFHC() && !isFakeData) { fnameSyst = FileDir + "pred_xp_nue_prop_Nue2020Axis_full_RHCAllSysts_PtQuants3_nueconcat_realNDData_20200427.root";
81  } else if ( IsFHC() && isFakeData) { fnameSyst = FileDir + "pred_xp_nue_combo_Nue2020Axis_full_FHCAllSysts_PtQuants3_nueconcat_fakeNDData_20200427.root";
82  } else if (!IsFHC() && isFakeData) { fnameSyst = FileDir + "pred_xp_nue_prop_Nue2020Axis_full_RHCAllSysts_PtQuants3_nueconcat_fakeNDData_20200427.root";
83  }
84  } else {
85  std::cout << "\t Loading the Non Pt Extrap files." << std::endl;
86  if ( IsFHC() && !isFakeData) { fnameSyst = FileDir + "pred_Nue2020Axis_full_FHCAllSysts_nueconcat_20200428.root";
87  } else if (!IsFHC() && !isFakeData) { fnameSyst = FileDir + "pred_Nue2020Axis_full_RHCAllSysts_nueconcat_20200428.root";
88  } else if ( IsFHC() && isFakeData) { fnameSyst = FileDir + "pred_xp_nue_combo_Nue2020Axis_full_FHCAllSysts_nueconcat_fakeNDData_20200427.root";
89  } else if (!IsFHC() && isFakeData) { fnameSyst = FileDir + "pred_xp_nue_prop_Nue2020Axis_full_RHCAllSysts_nueconcat_fakeNDData_20200427.root";
90  }
91  }
92  std::cout << "Loading the predictions from official file..." << std::endl;
93  std::cout << "\t--> " << fnameSyst << std::endl;
94  }
95 
96  TFile* fSyst = TFile::Open(fnameSyst.c_str(), "read");
97  if(fSyst->IsZombie())
98  {
99  std::cout << "Couldn't open " << fnameSyst << std::endl;
100  abort();
101  }
102 
103  std::string varname ="/nue_pred_Nue2020Axis";
104 
105  // make PredictionExtendOwning
106 
107  IPrediction* nomCore;
108  if ( isPtExtrap ) {
109  //std::cout << "In the isPtExtrap loading loop." << std::endl;
110  nomCore = LoadNuePtExtrapPred( fSyst, extrap, "Nominal", "noShift" );
111  } else {
112  //std::cout << "In the non-PtExtrap loading loop." << std::endl;
113  nomCore = ana::LoadFrom<IPrediction>(fSyst, extrapStr + "Nominal/noShift" + varname).release();
114  }
115  PredictionNoExtrap* nomNoExtrap = ana::LoadFrom<PredictionNoExtrap>(fSyst, "pred_nxp_Nominal/noShift" + varname).release();
116 
117  fPredNom = std::make_unique<PredictExtendOwning>(nomCore, nomNoExtrap, kNue2020Binning, true);
118  nom = new PredictExtendOwning(nomCore, nomNoExtrap, kNue2020Binning, true);
119 
120  for(const ISyst* syst: systs)
121  {
122  if(syst == &kAna2020NormFHC ||
123  syst == &kAna2020NormRHC ||
124  syst == &kAna2020NormHornCorr) continue;
125 
126  // michel tagging only for FHC
127  if(!IsFHC() && syst == &kMichelTaggingSyst2020) continue;
128 
129  // lepton angle syst only for PtExtrap
130  if(!isPtExtrap &&
131  (syst == &kLeptonAngleSystNDXZ2020 ||
132  syst == &kLeptonAngleSystNDYZ2020 ||
133  syst == &kLeptonAngleSystFDXZ2020 ||
134  syst == &kLeptonAngleSystFDYZ2020)) continue;
135 
136  std::string systName = syst->ShortName();
137 
138  std::cout << "Loading " << systName << "..." << std::endl;
139 
140  ShiftedPreds sp;
141  sp.systName = systName;
142 
143  for(int sigma: GetDummyShifts(syst))
144  {
145  sp.shifts.push_back(sigma);
146 
147  if (sigma == 0) {sp.preds.push_back(nom); continue;}
148 
149  // Treat Cherenkov And CalibDrift as one sided by
150  // fixing negative shifts to the nominal
151  if((syst == &kAnaCherenkovSyst || syst == &kAnaCalibDriftSyst) && (sigma == -1 || sigma == -2))
152  {
153  sp.preds.push_back(nom);
154  continue;
155  }
156 
157  const std::string sigmaStr = "/"+SigmaToString(sigma);
158 
159  IPrediction* shCore;
160  if ( isPtExtrap ) {
161  //std::cout << "In the isPtExtrap loading loop." << std::endl;
162  shCore = LoadNuePtExtrapPred( fSyst, extrap, systName, SigmaToString( sigma ) );
163  } else {
164  //std::cout << "In the non-PtExtrap loading loop." << std::endl;
165  shCore = ana::LoadFrom<IPrediction>(fSyst, extrapStr + systName + sigmaStr +varname).release();
166  }
167  PredictionNoExtrap* shNoExtrap = ana::LoadFrom<PredictionNoExtrap>(fSyst, "pred_nxp_" + systName + sigmaStr +varname).release();
168 
169  sp.preds.push_back(new PredictExtendOwning(shCore, shNoExtrap, kNue2020Binning, true));
170  } // end for sigma
171  // std::cout<<" test find "<<systName<<" "<<syst->find(systName)<<std::endl;
172  fPreds.emplace(syst, sp);
173  } // end for syst
174 
175  // Calculate all the ratios etc
176  InitFits();
177 
178  AddNormSysts(systs, extrap);
179 
180  // Clean up. Don't use if you need to make debug plots
181  if(minimizeMemory)
182  {
183  MinimizeMemory();
184  }
185 
186  delete fSyst;
187  }
const DummyAnaSyst kAna2020NormFHC("NormFHC2020","FHC. Norm.")
std::vector< SystGroupDef > systs
Definition: syst_header.h:385
bool mergePeripheral
IPrediction * LoadNuePtExtrapPred(TFile *file, ENu2020ExtrapType extrap, std::string syst_name, std::string sigma_str) const
const DummyAnaSyst kAna2020NormHornCorr("NormHornCorr","HornCorr Norm.")
std::vector< int > GetDummyShifts(const ISyst *s)
const DummyAnaSyst kAna2020NormRHC("NormRHC2020","RHC. Norm.")
bool IsFHC() const
Interprets fBeam.
const LeptonAngleSyst kLeptonAngleSystNDYZ2020("LeptonAngleSystNDYZ2020","Lepton Angle Syst ND YZ", caf::kNEARDET, kAngleShiftYZ, 0.010)
Definition: AngleSysts.h:35
const LeptonAngleSyst kLeptonAngleSystNDXZ2020("LeptonAngleSystNDXZ2020","Lepton Angle Syst ND XZ", caf::kNEARDET, kAngleShiftXZ, 0.010)
Definition: AngleSysts.h:34
std::unique_ptr< IPrediction > fPredNom
The nominal prediction.
const LeptonAngleSyst kLeptonAngleSystFDXZ2020("LeptonAngleSystFDXZ2020","Lepton Angle Syst FD XZ", caf::kFARDET, kAngleShiftXZ, 0.010)
Definition: AngleSysts.h:36
const DummyAnaSyst kAnaCherenkovSyst("Cherenkov","Cherenkov")
const Binning kNue2020Binning
std::string getenv(std::string const &name)
void AddNormSysts(const std::vector< const ISyst * > &systs, ENu2020ExtrapType extrap)
Must set fBeam first.
std::string SigmaToString(int sigma) const
std::unique_ptr< IPrediction > LoadFrom< IPrediction >(TDirectory *dir, const std::string &label)
Definition: IPrediction.cxx:18
double sigma(TH1F *hist, double percentile)
const MichelTaggingSyst2020 kMichelTaggingSyst2020
OStream cout
Definition: OStream.cxx:6
virtual _IOscCalc * Copy() const =0
std::unordered_map< const ISyst *, ShiftedPreds > fPreds
osc::IOscCalc * fOscOrigin
The oscillation values we assume when evaluating the coefficients.
const DummyAnaSyst kAnaCalibDriftSyst("CalibDrift","CalibDrift")
const LeptonAngleSyst kLeptonAngleSystFDYZ2020("LeptonAngleSystFDYZ2020","Lepton Angle Syst FD YZ", caf::kFARDET, kAngleShiftYZ, 0.010)
Definition: AngleSysts.h:37
enum BeamMode string
ana::PredictionSyst3Flavor2020::PredictionSyst3Flavor2020 ( ENu2020ExtrapType  extrap,
osc::IOscCalc osc,
const std::string  beam,
const int  EhadFracQuant,
const std::vector< const ISyst * > &  systs,
bool  isFakeData = false,
const std::string  fname = "",
bool  minimizeMemory = true,
bool  NERSC = false 
)

Numu constructor.

Definition at line 191 of file PredictionSyst3Flavor2020.cxx.

References AddNormSysts(), osc::_IOscCalc< T >::Copy(), om::cout, allTimeWatchdog::endl, fin, plot_validation_datamc::fname, ana::PredictionInterp::fOscOrigin, ana::PredictionInterp::fPredNom, ana::PredictionInterp::fPreds, ana::PredictionInterp::fSplitBySign, ana::GetDummyShifts(), cet::getenv(), ana::PredictionInterp::InitFits(), IsFHC(), ana::kAna2020NormFHC, ana::kAna2020NormHornCorr, ana::kAna2020NormRHC, ana::kAnaCalibDriftSyst, ana::kAnaCherenkovSyst, ana::kLeptonAngleSystFDXZ2020, ana::kLeptonAngleSystFDYZ2020, ana::kLeptonAngleSystNDXZ2020, ana::kLeptonAngleSystNDYZ2020, ana::kMichelTaggingSyst2020, ana::kNueAcceptSystSignalKin2020FHC, ana::kNueAcceptSystSignalKin2020RHC, ana::kNueAcceptSystSignalKinPtExtrap2020FHC, ana::kNueAcceptSystSignalKinPtExtrap2020RHC, ana::kNuMu, ana::kNuMuNoExtrap, ana::kNuMuPtExtrap, ana::LoadFrom< IPrediction >(), LoadNumuPtExtrapPred(), ana::PredictionInterp::MinimizeMemory(), ana::PredictionInterp::ShiftedPreds::preds, runNovaSAM::release, ana::PredictionInterp::ShiftedPreds::shifts, sigma(), SigmaToString(), string, ana::PredictionInterp::ShiftedPreds::systName, and art::to_string().

200  : fBeam(beam)
201  {
202  gROOT->SetMustClean(false);
203 
204  fOscOrigin = osc->Copy();
205 
206  fSplitBySign = IsFHC();
207 
208  const bool isPtExtrap = extrap == ENu2020ExtrapType::kNuMuPtExtrap;
209 
210  std::cout << "use FakeNDData predictions is "
211  << (isFakeData ? "true" : "false") << std::endl;
212 
213  std::string extrapStr = "pred_";
214  if (extrap == ENu2020ExtrapType::kNuMu) extrapStr += "xp_numu";
215  if (extrap == ENu2020ExtrapType::kNuMuNoExtrap) extrapStr += "nxp";
216  extrapStr += "_";
217 
218  std::string VarName = "numu_pred_NumuEnergy_EhadFracQuant"+std::to_string(EhadFracQuant);
219  if (EhadFracQuant == -1) VarName = "numu_pred_NumuEnergy";
220 
221  std::cout << "\nLooking at VarName " << VarName << " --> Loading nominals now..." << std::endl;
222 
223  std::string fnameSyst = fname;
224  if (fname != "") {
225  std::cout << "Loading predictions from unofficial file..." << std::endl;
226  std::cout << "\t--> " << fnameSyst << std::endl;
227  } else {
228  // --- Set some defaults. These aren't final, so they need to be updated, but that's better than nothing.
229  std::string FileDir = "/cvmfs/nova.osgstorage.org/analysis/3flavor/Predictions/";
230  if(NERSC) {
231  FileDir = std::string(std::getenv("FCHELPERANA2020_LIB_PATH")) + "/Predictions/";
232  }
233  if ( isPtExtrap ) {
234  std::cout << "\t Loading the Pt Extrap files." << std::endl;
235  if ( IsFHC() && !isFakeData ) { fnameSyst = FileDir + "pred_xp_numu_NumuEnergy_AllQuantiles_full_FHCAllSysts_PtQuants3_numuconcat_realNDData_20200427.root";
236  } else if ( !IsFHC() && !isFakeData ) { fnameSyst = FileDir + "pred_xp_numu_NumuEnergy_AllQuantiles_full_RHCAllSysts_PtQuants3_numuconcat_realNDData_20200427.root";
237  } else if ( IsFHC() && isFakeData ) { fnameSyst = FileDir + "pred_xp_numu_NumuEnergy_AllQuantiles_full_FHCAllSysts_PtQuants3_numuconcat_fakeNDData_20200427.root";
238  } else if ( !IsFHC() && isFakeData ) { fnameSyst = FileDir + "pred_xp_numu_NumuEnergy_AllQuantiles_full_RHCAllSysts_PtQuants3_numuconcat_fakeNDData_20200427.root";
239  }
240  } else {
241  std::cout << "\t Loading the Non-Pt Extrap files." << std::endl;
242  if ( IsFHC() && !isFakeData ) { fnameSyst = FileDir + "pred_NumuEnergy_AllQuantiles_full_FHCAllSysts_numuconcat_20200428.root";
243  } else if ( !IsFHC() && !isFakeData ) { fnameSyst = FileDir + "pred_NumuEnergy_AllQuantiles_full_RHCAllSysts_numuconcat_20200428.root";
244  } else if ( IsFHC() && isFakeData ) { fnameSyst = FileDir + "pred_xp_numu_NumuEnergy_AllQuantiles_full_FHCAllSysts_numuconcat_fakeNDData_20200427.root";
245  } else if ( !IsFHC() && isFakeData ) { fnameSyst = FileDir + "pred_xp_numu_NumuEnergy_AllQuantiles_full_RHCAllSysts_numuconcat_fakeNDData_20200427.root";
246  }
247  }
248  std::cout << "Loading the predictions from official file..." << std::endl;
249  std::cout << "\t--> " << fnameSyst << std::endl;
250  }
251 
252  TFile* fin = TFile::Open(fnameSyst.c_str(), "read");
253 
254  IPrediction *nom;
255  if ( isPtExtrap )
256  {
257  fPredNom = std::unique_ptr<IPrediction>( LoadNumuPtExtrapPred( fin, EhadFracQuant, "Nominal", "noShift" ) );
258  nom = LoadNumuPtExtrapPred( fin, EhadFracQuant, "Nominal", "noShift" );
259  }
260  else
261  {
262  std::string NomVar = extrapStr+"Nominal/noShift/"+VarName;
264  nom = ana::LoadFrom<IPrediction>(fin, NomVar).release();
265  }
266 
267  for(const ISyst* syst: systs){
268 
269  if(syst == &kAna2020NormFHC ||
270  syst == &kAna2020NormRHC ||
271  syst == &kAna2020NormHornCorr ||
272  // nue specific systs are not in numu files
277  syst == &kMichelTaggingSyst2020) continue;
278 
279  // lepton angle syst only for PtExtrap
280  if(!isPtExtrap &&
281  (syst == &kLeptonAngleSystNDXZ2020 ||
282  syst == &kLeptonAngleSystNDYZ2020 ||
283  syst == &kLeptonAngleSystFDXZ2020 ||
284  syst == &kLeptonAngleSystFDYZ2020)) continue;
285 
286  std::string systName = syst->ShortName();
287 
288  std::cout << "Loading " << systName << "..." << std::endl;
289 
290  ShiftedPreds sp;
291  sp.systName = systName;
292 
293  for(int sigma: GetDummyShifts(syst))
294  {
295  sp.shifts.push_back(sigma);
296 
297  if (sigma == 0) {sp.preds.push_back(nom);continue;}
298 
299  // Treat Cherenkov And CalibDrift as one sided by
300  // fixing negative shifts to the nominal
301  if((syst == &kAnaCherenkovSyst || syst == &kAnaCalibDriftSyst) &&
302  (sigma == -1 || sigma == -2))
303  {
304  sp.preds.push_back(nom);
305  continue;
306  }
307 
308  const std::string sigmaStr = "/"+SigmaToString(sigma)+"/";
309 
310  IPrediction* shCore;
311  if ( isPtExtrap ) shCore = LoadNumuPtExtrapPred( fin, EhadFracQuant, systName, SigmaToString( sigma ) );
312  else shCore = ana::LoadFrom<PredictionExtrap> (fin, extrapStr + systName + sigmaStr +VarName).release();
313  sp.preds.push_back(shCore);
314 
315  } // end for sigma
316  fPreds.emplace(syst, sp);
317  } // end for syst
318 
319  // Calculate all the ratios etc
320  InitFits();
321 
322  AddNormSysts(systs, extrap);
323 
324  if(minimizeMemory){
325  MinimizeMemory();
326  }
327 
328  delete fin;
329  }
TString fin
Definition: Style.C:24
const DummyAnaSyst kAna2020NormFHC("NormFHC2020","FHC. Norm.")
std::vector< SystGroupDef > systs
Definition: syst_header.h:385
const DummyAnaSyst kAna2020NormHornCorr("NormHornCorr","HornCorr Norm.")
std::vector< int > GetDummyShifts(const ISyst *s)
const DummyAnaSyst kAna2020NormRHC("NormRHC2020","RHC. Norm.")
const NueAcceptSystSignalKin2020FHC kNueAcceptSystSignalKin2020FHC
bool IsFHC() const
Interprets fBeam.
const LeptonAngleSyst kLeptonAngleSystNDYZ2020("LeptonAngleSystNDYZ2020","Lepton Angle Syst ND YZ", caf::kNEARDET, kAngleShiftYZ, 0.010)
Definition: AngleSysts.h:35
const LeptonAngleSyst kLeptonAngleSystNDXZ2020("LeptonAngleSystNDXZ2020","Lepton Angle Syst ND XZ", caf::kNEARDET, kAngleShiftXZ, 0.010)
Definition: AngleSysts.h:34
std::unique_ptr< IPrediction > fPredNom
The nominal prediction.
const LeptonAngleSyst kLeptonAngleSystFDXZ2020("LeptonAngleSystFDXZ2020","Lepton Angle Syst FD XZ", caf::kFARDET, kAngleShiftXZ, 0.010)
Definition: AngleSysts.h:36
const DummyAnaSyst kAnaCherenkovSyst("Cherenkov","Cherenkov")
IPrediction * LoadNumuPtExtrapPred(TFile *file, int EhadFracQuant, std::string syst_name, std::string sigma_str) const
std::string getenv(std::string const &name)
void AddNormSysts(const std::vector< const ISyst * > &systs, ENu2020ExtrapType extrap)
Must set fBeam first.
const NueAcceptSystSignalKin2020FHC kNueAcceptSystSignalKinPtExtrap2020FHC(ana::kExtrapPt,"accept_signalkin_pTextrap_FHC_2020")
std::string SigmaToString(int sigma) const
std::unique_ptr< IPrediction > LoadFrom< IPrediction >(TDirectory *dir, const std::string &label)
Definition: IPrediction.cxx:18
double sigma(TH1F *hist, double percentile)
const MichelTaggingSyst2020 kMichelTaggingSyst2020
OStream cout
Definition: OStream.cxx:6
virtual _IOscCalc * Copy() const =0
std::string to_string(ModuleType mt)
Definition: ModuleType.h:32
std::unordered_map< const ISyst *, ShiftedPreds > fPreds
osc::IOscCalc * fOscOrigin
The oscillation values we assume when evaluating the coefficients.
const DummyAnaSyst kAnaCalibDriftSyst("CalibDrift","CalibDrift")
const LeptonAngleSyst kLeptonAngleSystFDYZ2020("LeptonAngleSystFDYZ2020","Lepton Angle Syst FD YZ", caf::kFARDET, kAngleShiftYZ, 0.010)
Definition: AngleSysts.h:37
const NueAcceptSystSignalKin2020RHC kNueAcceptSystSignalKinPtExtrap2020RHC(ana::kExtrapPt,"accept_signalkin_pTextrap_RHC_2020")
enum BeamMode string
const NueAcceptSystSignalKin2020RHC kNueAcceptSystSignalKin2020RHC
ana::PredictionSyst3Flavor2020::~PredictionSyst3Flavor2020 ( )
virtual

Definition at line 332 of file PredictionSyst3Flavor2020.cxx.

References AddNormSysts().

333  {
334  }
ana::PredictionSyst3Flavor2020::PredictionSyst3Flavor2020 ( )
inlineprotected

Definition at line 70 of file PredictionSyst3Flavor2020.h.

References file, IsFHC, sigma(), string, and make_syst_table_plots::syst_name.

70 {}

Member Function Documentation

template<typename T >
Spectrum ana::PredictionInterp::_PredictComponentSyst ( osc::_IOscCalc< 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 526 of file PredictionInterp.cxx.

References ana::SystShifts::ActiveSysts(), ana::assert(), om::cerr, ana::Spectrum::Clear(), allTimeWatchdog::endl, ana::PredictionInterp::fBinning, ana::PredictionInterp::fPreds, osc::_IOscCalc< 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, and ana::PredictionInterp::ShiftedComponent().

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

531  {
532  InitFits();
533 
535  ret.Clear();
536 
537  // Check that we're able to handle all the systs we were passed
538  for(const ISyst* syst: shift.ActiveSysts()){
539  if(fPreds.find(syst) == fPreds.end()){
540  std::cerr << "This PredictionInterp is not set up to handle the requested systematic: " << syst->ShortName() << std::endl;
541  abort();
542  }
543  } // end for syst
544 
545 
546  const TMD5* hash = calc ? calc->GetParamsHash() : 0;
547 
548  if(curr & Current::kCC){
549  if(flav & Flavors::kNuEToNuE) ret += ShiftedComponent(calc, hash, shift, Flavors::kNuEToNuE, Current::kCC, sign, kNueSurv);
550  if(flav & Flavors::kNuEToNuMu) ret += ShiftedComponent(calc, hash, shift, Flavors::kNuEToNuMu, Current::kCC, sign, kOther );
551  if(flav & Flavors::kNuEToNuTau) ret += ShiftedComponent(calc, hash, shift, Flavors::kNuEToNuTau, Current::kCC, sign, kOther );
552 
553  if(flav & Flavors::kNuMuToNuE) ret += ShiftedComponent(calc, hash, shift, Flavors::kNuMuToNuE, Current::kCC, sign, kNueApp );
554  if(flav & Flavors::kNuMuToNuMu) ret += ShiftedComponent(calc, hash, shift, Flavors::kNuMuToNuMu, Current::kCC, sign, kNumuSurv);
555  if(flav & Flavors::kNuMuToNuTau) ret += ShiftedComponent(calc, hash, shift, Flavors::kNuMuToNuTau, Current::kCC, sign, kOther );
556  }
557  if(curr & Current::kNC){
558  assert(flav == Flavors::kAll); // Don't know how to calculate anything else
559 
560  ret += ShiftedComponent(calc, hash, shift, Flavors::kAll, Current::kNC, sign, kNC);
561  }
562 
563  delete hash;
564 
565  return ret;
566  }
(&#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:361
Charged-current interactions.
Definition: IPrediction.h:39
Spectrum fBinning
Dummy spectrum to provide binning.
std::vector< float > Spectrum
Definition: Constants.h:610
virtual TMD5 * GetParamsHash() const
Use to check two calculators are in the same state.
Definition: IOscCalc.h:39
(&#39; survival&#39;)
Definition: IPrediction.h:19
Taus, numu appearance.
Neutral-current interactions.
Definition: IPrediction.h:40
assert(nhit_max >=nhit_nbins)
std::unordered_map< const ISyst *, ShiftedPreds > fPreds
All neutrinos, any flavor.
Definition: IPrediction.h:26
(&#39; appearance&#39;)
Definition: IPrediction.h:16
Spectrum ShiftedComponent(osc::IOscCalc *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:197
template<typename T >
Spectrum ana::PredictionInterp::_ShiftedComponent ( osc::_IOscCalc< 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 474 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().

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

481  {
483  "PredictionInterp::ShiftedComponent() can only be called using doubles or stan::math::vars");
484 
485  if(fSplitBySign && sign == Sign::kBoth){
486  return (ShiftedComponent(calc, hash, shift, flav, curr, Sign::kAntiNu, type)+
487  ShiftedComponent(calc, hash, shift, flav, curr, Sign::kNu, type));
488  }
489 
490  // Must be the base case of the recursion to use the cache. Otherwise we
491  // can cache systematically shifted versions of our children, which is
492  // wrong. Also, some calculators won't hash themselves.
493  // Moreover, caching is not going to work with stan::math::vars
494  // since they get reset every time Stan's log_prob() is called.
495  const bool canCache = (hash != 0) && !std::is_same<T, stan::math::var>::value;
496 
497  const Key_t key = {flav, curr, sign};
498  auto it = fNomCache->find(key);
499 
500  // Should the interpolation use the nubar fits?
501  const bool nubar = (fSplitBySign && sign == Sign::kAntiNu);
502 
503  // We have the nominal for this exact combination of flav, curr, sign, calc
504  // stored. Shift it and return.
505  if(canCache && it != fNomCache->end() && it->second.hash == *hash){
506  return ShiftSpectrum(it->second.nom, type, nubar, shift);
507  }
508 
509  // We need to compute the nominal again for whatever reason
510  const Spectrum nom = fPredNom->PredictComponent(calc, flav, curr, sign);
511 
512  if(canCache){
513  // Insert into the cache if not already there, or update if there but
514  // with old oscillation parameters.
515  if(it == fNomCache->end())
516  fNomCache->emplace(key, Val_t({*hash, nom}));
517  else
518  it->second = {*hash, nom};
519  }
520 
521  return ShiftSpectrum(nom, type, nubar, shift);
522  }
set< int >::iterator it
Antineutrinos-only.
Definition: IPrediction.h:50
ThreadLocal< std::map< Key_t, Val_t > > fNomCache
std::unique_ptr< IPrediction > fPredNom
The nominal prediction.
const XML_Char int const XML_Char * value
Definition: expat.h:331
std::vector< float > Spectrum
Definition: Constants.h:610
Neutrinos-only.
Definition: IPrediction.h:49
Both neutrinos and antineutrinos.
Definition: IPrediction.h:52
Spectrum ShiftedComponent(osc::IOscCalc *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.
Spectrum ShiftSpectrum(const Spectrum &s, CoeffsType type, bool nubar, const SystShifts &shift) const
def sign(x)
Definition: canMan.py:197
void ana::PredictionSyst3Flavor2020::AddNormSyst ( const ISyst syst,
const std::vector< const ISyst * > &  systs,
double  fracNueApp,
double  fracOthers 
)
protected

Definition at line 409 of file PredictionSyst3Flavor2020.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, make_syst_table_plots::h, ana::PredictionInterp::kNCoeffTypes, plotROC::nBins, ana::PredictionInterp::ShiftedPreds::nCoeffs, ana::PredictionInterp::Predict(), ana::PredictionInterp::ShiftedPreds::preds, ana::PredictionInterp::ShiftedPreds::shifts, ana::ISyst::ShortName(), ana::PredictionInterp::ShiftedPreds::systName, and ana::Spectrum::ToTH1().

Referenced by AddNormSysts().

412  {
413  // Bail out if we're not actually requested to include this systematic
414  if(std::find(systs.begin(), systs.end(), syst) == systs.end()) return;
415 
416  TH1D* h = Predict(fOscOrigin).ToTH1(1);
417  const int nBins = h->GetNbinsX();
418  delete h;
419 
420  ShiftedPreds normsp;
421  normsp.systName = syst->ShortName();
422  normsp.shifts = {0};
423  normsp.preds = {fPredNom.get()};
424  normsp.fits.resize(kNCoeffTypes);
425  if(fSplitBySign) normsp.fitsNubar.resize(kNCoeffTypes);
426 
427  // The first fits coeff is for nue signal, the rest are for nue bkg and numu
428  normsp.fits[CoeffsType::kNueApp].resize(nBins+2);
429  if(fSplitBySign) normsp.fitsNubar[CoeffsType::kNueApp].resize(nBins+2);
430  for(int binIdx = 0; binIdx < nBins+2; ++binIdx){
431  normsp.fits[CoeffsType::kNueApp][binIdx].emplace_back(0, 0, fracNueApp, 1);
432  if(fSplitBySign) normsp.fitsNubar[CoeffsType::kNueApp][binIdx].emplace_back(0, 0, fracNueApp, 1);
433  }
434 
435  for(int coeff = 1; coeff < kNCoeffTypes; ++coeff){
436  normsp.fits[coeff].resize(nBins+2);
437  if(fSplitBySign) normsp.fitsNubar[coeff].resize(nBins+2);
438  for(int binIdx = 0; binIdx < nBins+2; ++binIdx){
439  normsp.fits[coeff][binIdx].emplace_back(0, 0, fracOthers, 1);
440  if(fSplitBySign) normsp.fitsNubar[coeff][binIdx].emplace_back(0, 0, fracOthers, 1);
441  }
442  }
443 
444  normsp.FillRemaps();
445  normsp.nCoeffs = 1;
446  fPreds.emplace(syst, normsp);
447  }
int nBins
Definition: plotROC.py:16
std::vector< SystGroupDef > systs
Definition: syst_header.h:385
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:148
std::unique_ptr< IPrediction > fPredNom
The nominal prediction.
double coeff(double W, int m, int l, bool real)
Spectrum Predict(osc::IOscCalc *calc) const override
std::unordered_map< const ISyst *, ShiftedPreds > fPreds
osc::IOscCalc * fOscOrigin
The oscillation values we assume when evaluating the coefficients.
void ana::PredictionSyst3Flavor2020::AddNormSysts ( const std::vector< const ISyst * > &  systs,
ENu2020ExtrapType  extrap 
)
protected

Must set fBeam first.

Definition at line 338 of file PredictionSyst3Flavor2020.cxx.

References AddNormSyst(), IsFHC(), ana::kAna2020NormFHC, ana::kAna2020NormHornCorr, ana::kAna2020NormRHC, ana::kNuMu, ana::kNuMuNoExtrap, and ana::kNuMuPtExtrap.

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

339  {
340  // Normalisation systematic consists of 6 pieces
341  // 4 horn-currents uncorrelated
342  // e.g. FHC norm applies shift to fhc,
343  // no shift to rhc, and vice versa
344  // POT = 0.55% (docdb-42952)
345  // Overlay (docdb-43838):
346  // numu = 0.21%/0.48% (FHC/RHC)
347  // nue = 0.41%/0.53% (FHC/RHC)
348  // overlay 'numu' applies to numu signal and nue signal
349  // overlay 'nue' applies to nue bkg
350  // FHC
351  const double kNormNumuFHC = 0.0059;
352  const double kNormNueFHC = 0.0069;
353  // RHC
354  const double kNormNumuRHC = 0.0073;
355  const double kNormNueRHC = 0.0076;
356 
357  // FD fully-uncorrelated mass uncertainty
358  // mass = 0.19% (docdb-20816)
359  // gg mismatch
360  // (Genie-Geant mismatch of the primary particle list)
361  // gg_mismatch = 0.8% (docdb-?????)
362  // both horn-current correlated
363  // Mass + gg_mismatch
364  const double kNormHornCorr = 0.0082;
365 
366  // Remember: none of these normalization systematics will affect the nue rock component
367  // final nue pred = rock prediction + fiducial prediction with systematics (this class)
368  // That final nue pred is calculated at analysis time, not here
369  // (see GetNuePrediction2020 in joint_fit_2020_loader_tools.h)
370 
371  // Include horn-correlated norm
372  AddNormSyst(&kAna2020NormHornCorr, systs, kNormHornCorr, kNormHornCorr);
373 
374  // Include syst for wrong beam type to keep the fit happy, but set it to
375  // zero magnitude
376  if(IsFHC())
377  {
378  // Are we in numu? => keep only one kNormNumu
380  {
381  AddNormSyst(&kAna2020NormFHC, systs, kNormNumuFHC, kNormNumuFHC);
382  AddNormSyst(&kAna2020NormRHC, systs, .0, .0);
383  }
384  // Are we in nue? => pass both kNormNumu and kNormNue
385  else
386  {
387  AddNormSyst(&kAna2020NormFHC, systs, kNormNumuFHC, kNormNueFHC);
388  AddNormSyst(&kAna2020NormRHC, systs, .0, .0);
389  }
390  }
391  else
392  {
393  // Are we in numu? => keep only one kNormNumu
395  {
396  AddNormSyst(&kAna2020NormFHC, systs, .0, .0);
397  AddNormSyst(&kAna2020NormRHC, systs, kNormNumuRHC, kNormNumuRHC);
398  }
399  // Are we in nue? => pass both kNormNumu and kNormNue
400  else
401  {
402  AddNormSyst(&kAna2020NormFHC, systs, .0, .0);
403  AddNormSyst(&kAna2020NormRHC, systs, kNormNumuRHC, kNormNueRHC);
404  }
405  }
406  }
const DummyAnaSyst kAna2020NormFHC("NormFHC2020","FHC. Norm.")
std::vector< SystGroupDef > systs
Definition: syst_header.h:385
const DummyAnaSyst kAna2020NormHornCorr("NormHornCorr","HornCorr Norm.")
const DummyAnaSyst kAna2020NormRHC("NormRHC2020","RHC. Norm.")
bool IsFHC() const
Interprets fBeam.
void AddNormSyst(const ISyst *syst, const std::vector< const ISyst * > &systs, double fracNueApp, double fracOthers)
OscillatableSpectrum ana::IPrediction::ComponentCC ( int  from,
int  to 
) const
virtualinherited

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

Definition at line 105 of file IPrediction.cxx.

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

Referenced by ana::PredictionCombinePeriods::ComponentCC(), ana::PredictionAddRock::ComponentCC(), and ND_DataMC().

106  {
107  std::cout << "WARNING! ComponentCC is unimplemented in IPrediction" << std::endl; abort();
108  }
OStream cout
Definition: OStream.cxx:6
Spectrum ana::IPrediction::ComponentNC ( ) const
virtualinherited

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

Definition at line 115 of file IPrediction.cxx.

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

Referenced by ana::PredictionAddRock::ComponentNC().

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

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

Definition at line 120 of file IPrediction.cxx.

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

Referenced by ana::PredictionAddRock::ComponentNCAnti().

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

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

Definition at line 110 of file IPrediction.cxx.

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

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

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

Definition at line 717 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, make_syst_table_plots::h, MECModelEnuComparisons::i, ana::PredictionInterp::InitFits(), makeTrainCVSamples::int, std::isnan(), it, nbins, ana::IPrediction::PredictComponent(), ana::PredictionInterp::PredictComponentSyst(), ratio(), ana::ISyst::ShortName(), std::sqrt(), ss, ana::Spectrum::ToTH1(), and submit_syst::x.

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

722  {
723  InitFits();
724 
725  auto it = fPreds.find(syst);
726  if(it == fPreds.end()){
727  std::cout << "PredictionInterp::DebugPlots(): "
728  << syst->ShortName() << " not found" << std::endl;
729  return;
730  }
731 
732  std::unique_ptr<TH1> nom(fPredNom->PredictComponent(calc, flav, curr, sign).ToTH1(18e20));
733  const int nbins = nom->GetNbinsX();
734 
735  TGraph* curves[nbins];
736  TGraph* points[nbins];
737 
738  for(int i = 0; i <= 80; ++i){
739  const double x = .1*i-4;
740  const SystShifts ss(it->first, x);
741  std::unique_ptr<TH1> h(PredictComponentSyst(calc, ss, flav, curr, sign).ToTH1(18e20));
742 
743  for(int bin = 0; bin < nbins; ++bin){
744  if(i == 0){
745  curves[bin] = new TGraph;
746  points[bin] = new TGraph;
747  }
748 
749  const double ratio = h->GetBinContent(bin+1)/nom->GetBinContent(bin+1);
750 
751  if(!std::isnan(ratio)) curves[bin]->SetPoint(curves[bin]->GetN(), x, ratio);
752  else curves[bin]->SetPoint(curves[bin]->GetN(), x, 1);
753  } // end for bin
754  } // end for i (x)
755 
756  // As elswhere, to allow BirksC etc that need a different nominal to plot
757  // right.
758  IPrediction* pNom = 0;
759  for(unsigned int shiftIdx = 0; shiftIdx < it->second.shifts.size(); ++shiftIdx){
760  if(it->second.shifts[shiftIdx] == 0) pNom = it->second.preds[shiftIdx];;
761  }
762  if(pNom){ // if not, probably MinimizeMemory() was called
763  std::unique_ptr<TH1> hnom(pNom->PredictComponent(calc, flav, curr, sign).ToTH1(18e20));
764 
765  for(unsigned int shiftIdx = 0; shiftIdx < it->second.shifts.size(); ++shiftIdx){
766  if(!it->second.preds[shiftIdx]) continue; // Probably MinimizeMemory()
767  std::unique_ptr<TH1> h(it->second.preds[shiftIdx]->PredictComponent(calc, flav, curr, sign).ToTH1(18e20));
768 
769  for(int bin = 0; bin < nbins; ++bin){
770  const double ratio = h->GetBinContent(bin+1)/hnom->GetBinContent(bin+1);
771  if(!std::isnan(ratio)) points[bin]->SetPoint(points[bin]->GetN(), it->second.shifts[shiftIdx], ratio);
772  else points[bin]->SetPoint(points[bin]->GetN(), it->second.shifts[shiftIdx], 1);
773  }
774  } // end for shiftIdx
775  } // end if pNom
776 
777 
778  int nx = int(sqrt(nbins));
779  int ny = int(sqrt(nbins));
780  if(nx*ny < nbins) ++nx;
781  if(nx*ny < nbins) ++ny;
782 
783  TCanvas* c = new TCanvas;
784  c->Divide(nx, ny);
785 
786  for(int bin = 0; bin < nbins; ++bin){
787  c->cd(bin+1);
788  (new TH2F("",
789  TString::Format("%s %g < %s < %g;Shift;Ratio",
790  it->second.systName.c_str(),
791  nom->GetXaxis()->GetBinLowEdge(bin+1),
792  nom->GetXaxis()->GetTitle(),
793  nom->GetXaxis()->GetBinUpEdge(bin+1)),
794  100, -4, +4, 100, .5, 1.5))->Draw();
795  curves[bin]->Draw("l same");
796  points[bin]->SetMarkerStyle(kFullDotMedium);
797  points[bin]->Draw("p same");
798  } // end for bin
799 
800  c->cd(0);
801  }
tree Draw("slc.nhit")
set< int >::iterator it
T sqrt(T number)
Definition: d0nt_math.hpp:156
TH1 * ratio(TH1 *h1, TH1 *h2)
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
Spectrum PredictComponentSyst(osc::IOscCalc *calc, const SystShifts &shift, Flavors::Flavors_t flav, Current::Current_t curr, Sign::Sign_t sign) const override
float bin[41]
Definition: plottest35.C:14
OStream cout
Definition: OStream.cxx:6
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
def sign(x)
Definition: canMan.py:197
void ana::PredictionInterp::DebugPlotColz ( const ISyst syst,
osc::IOscCalc calc,
Flavors::Flavors_t  flav = Flavors::kAll,
Current::Current_t  curr = Current::kBoth,
Sign::Sign_t  sign = Sign::kBoth 
) const
inherited

Definition at line 821 of file PredictionInterp.cxx.

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

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

826  {
827  InitFits();
828 
829  std::unique_ptr<TH1> nom(fPredNom->PredictComponent(calc, flav, curr, sign).ToTH1(18e20));
830  const int nbins = nom->GetNbinsX();
831 
832  TH2* h2 = new TH2F("", (syst->LatexName()+";;#sigma").c_str(),
833  nbins, nom->GetXaxis()->GetXmin(), nom->GetXaxis()->GetXmax(),
834  80, -4, +4);
835  h2->GetXaxis()->SetTitle(nom->GetXaxis()->GetTitle());
836 
837  for(int i = 1; i <= 80; ++i){
838  const double y = h2->GetYaxis()->GetBinCenter(i);
839  const SystShifts ss(syst, y);
840  std::unique_ptr<TH1> h(PredictComponentSyst(calc, ss, flav, curr, sign).ToTH1(18e20));
841 
842  for(int bin = 0; bin < nbins; ++bin){
843  const double ratio = h->GetBinContent(bin+1)/nom->GetBinContent(bin+1);
844 
845  if(!isnan(ratio) && !isinf(ratio))
846  h2->Fill(h2->GetXaxis()->GetBinCenter(bin), y, ratio);
847  } // end for bin
848  } // end for i (x)
849 
850  h2->Draw("colz");
851  h2->SetMinimum(0.5);
852  h2->SetMaximum(1.5);
853  }
int isinf(const stan::math::var &a)
Definition: std_isinf.hpp:16
TH1 * ratio(TH1 *h1, TH1 *h2)
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
Spectrum PredictComponentSyst(osc::IOscCalc *calc, const SystShifts &shift, Flavors::Flavors_t flav, Current::Current_t curr, Sign::Sign_t sign) const override
float bin[41]
Definition: plottest35.C:14
TH1F * h2
Definition: plot.C:45
def sign(x)
Definition: canMan.py:197
void ana::PredictionInterp::DebugPlots ( osc::IOscCalc 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 804 of file PredictionInterp.cxx.

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

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

809  {
810  for(auto& it: fPreds){
811  DebugPlot(it.first, calc, flav, curr, sign);
812 
813  if(!savePattern.empty()){
814  assert(savePattern.find("%s") != std::string::npos);
815  gPad->Print(TString::Format(savePattern.c_str(), it.second.systName.c_str()).Data());
816  }
817  } // end for it
818  }
set< int >::iterator it
assert(nhit_max >=nhit_nbins)
void DebugPlot(const ISyst *syst, osc::IOscCalc *calc, Flavors::Flavors_t flav=Flavors::kAll, Current::Current_t curr=Current::kBoth, Sign::Sign_t sign=Sign::kBoth) const
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
def sign(x)
Definition: canMan.py:197
void ana::PredictionInterp::DebugPlotsColz ( osc::IOscCalc 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 856 of file PredictionInterp.cxx.

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

861  {
862  InitFits();
863 
864  for(auto& it: fPreds){
865  new TCanvas;
866  DebugPlotColz(it.first, calc, flav, curr, sign);
867 
868  if(!savePattern.empty()){
869  assert(savePattern.find("%s") != std::string::npos);
870  gPad->Print(TString::Format(savePattern.c_str(), it.second.systName.c_str()).Data());
871  }
872  } // end for it
873  }
set< int >::iterator it
void DebugPlotColz(const ISyst *syst, osc::IOscCalc *calc, Flavors::Flavors_t flav=Flavors::kAll, Current::Current_t curr=Current::kBoth, Sign::Sign_t sign=Sign::kBoth) const
assert(nhit_max >=nhit_nbins)
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
def sign(x)
Definition: canMan.py:197
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 std::string systName 
) const
inherited

Find coefficients describing the ratios from this component.

Definition at line 197 of file PredictionInterp.cxx.

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

Referenced by ana::PredictionInterp::FitRatios(), and 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<Eigen::ArrayXd> ratios;
217  ratios.reserve(preds.size());
218  for(auto& p: preds){
219  ratios.emplace_back(Ratio(p->PredictComponent(fOscOrigin,
220  flav, curr, sign),
221  nom).GetEigen());
222 
223  // Check none of the ratio values is crazy
224  Eigen::ArrayXd& r = ratios.back();
225  for(int i = 0; i < r.size(); ++i){
226  if(r[i] > 500){
227  std::cout << "PredictionInterp: WARNING, ratio in bin "
228  << i << " for " << shifts[&p-&preds.front()]
229  << " sigma shift of " << systName
230  << " is " << r[i] << ". Ignoring." << std::endl;
231  r[i] = 1;
232  }
233  }
234  }
235 
236  return FitRatios(shifts, ratios);
237  }
const char * p
Definition: xmltok.h:285
std::vector< float > Spectrum
Definition: Constants.h:610
OStream cout
Definition: OStream.cxx:6
assert(nhit_max >=nhit_nbins)
TRandom3 r(0)
osc::IOscCalc * fOscOrigin
The oscillation values we assume when evaluating the coefficients.
std::vector< std::vector< Coeffs > > FitRatios(const std::vector< double > &shifts, const std::vector< Eigen::ArrayXd > &ratios) const
Find coefficients describing this set of shifts.
def sign(x)
Definition: canMan.py:197
std::vector< std::vector< PredictionInterp::Coeffs > > ana::PredictionInterp::FitRatios ( const std::vector< double > &  shifts,
const std::vector< Eigen::ArrayXd > &  ratios 
) const
inherited

Find coefficients describing this set of shifts.

Definition at line 97 of file PredictionInterp.cxx.

References ana::assert(), plot_validation_datamc::c, om::cout, lem_server::cs, util::cube(), e, allTimeWatchdog::endl, stan::math::fabs(), ana::PredictionInterp::FitComponent(), MECModelEnuComparisons::i, m, 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::~PredictionInterp().

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

Definition at line 240 of file PredictionInterp.cxx.

References ana::PredictionInterp::fPreds.

241  {
242  std::vector<const ISyst*> allsysts;
243  for (const auto &p : fPreds)
244  allsysts.push_back(p.first);
245 
246  return allsysts;
247  }
const char * p
Definition: xmltok.h:285
std::unordered_map< const ISyst *, ShiftedPreds > fPreds
IPrediction* ana::PredictionSyst3Flavor2020::GetNominalPrediction ( )
inline

Method to expose fPredNom

Returns
fPredNom Unique ptr to nominal prediction

Definition at line 51 of file PredictionSyst3Flavor2020.h.

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

52  {
53  //std::cout << "GETNOMPRED " << fPredNom.get() << std::endl;
54  return fPredNom.get();
55  };
std::unique_ptr< IPrediction > fPredNom
The nominal prediction.
const ShiftedPreds& ana::PredictionSyst3Flavor2020::GetShiftedPrediction ( const ISyst syst)
inline

Method to expose fPreds

Returns
shifted prediction (ShiftedPreds) from fPreds

Definition at line 60 of file PredictionSyst3Flavor2020.h.

References dir, ana::LoadFrom(), ana::SaveTo(), and string.

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

61  {
62  // for (auto& shift:fPreds[syst].preds) { std::cout << "\t Func shift: " << shift.get() << " " << std::endl; }
63  return fPreds[syst];
64  };
std::unordered_map< const ISyst *, ShiftedPreds > fPreds
void ana::PredictionInterp::InitFits ( ) const
protectedinherited

Definition at line 266 of file PredictionInterp.cxx.

References ana::Spectrum::Clear(), 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::InitFitsHelper(), it, ana::Sign::kAntiNu, ana::Sign::kBoth, ana::Sign::kNu, ana::Spectrum::Livetime(), ana::PredictionInterp::ShiftedPreds::nCoeffs, and ana::Spectrum::POT().

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

267  {
268  // No systs
269  if(fPreds.empty()){
270  if(fBinning.POT() > 0 || fBinning.Livetime() > 0) return;
271  }
272  // Already initialized
273  else if(!fPreds.empty() && !fPreds.begin()->second.fits.empty()) return;
274 
275  for(auto& it: fPreds){
276  ShiftedPreds& sp = it.second;
277 
278  if(fSplitBySign){
279  InitFitsHelper(sp, sp.fits, Sign::kNu);
280  InitFitsHelper(sp, sp.fitsNubar, Sign::kAntiNu);
281  }
282  else{
283  InitFitsHelper(sp, sp.fits, Sign::kBoth);
284  }
285  sp.nCoeffs = sp.fits[0][0].size();
286 
287  // Copy the outputs into the remapped indexing order. TODO this is very
288  // ugly. Best would be to generate things in this order natively.
289  sp.FillRemaps();
290  }
291 
292  // Predict something, anything, so that we can know what binning to use
293  fBinning = fPredNom->Predict(fOscOrigin);
294  fBinning.Clear();
295  }
set< int >::iterator it
Antineutrinos-only.
Definition: IPrediction.h:50
void Clear()
Definition: Spectrum.cxx:361
std::unique_ptr< IPrediction > fPredNom
The nominal prediction.
Spectrum fBinning
Dummy spectrum to provide binning.
double POT() const
Definition: Spectrum.h:227
Neutrinos-only.
Definition: IPrediction.h:49
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
osc::IOscCalc * fOscOrigin
The oscillation values we assume when evaluating the coefficients.
double Livetime() const
Seconds. For informational purposes only. No calculations use this.
Definition: Spectrum.h:230
void ana::PredictionInterp::InitFitsHelper ( ShiftedPreds sp,
std::vector< std::vector< std::vector< Coeffs >>> &  fits,
Sign::Sign_t  sign 
) const
protectedinherited

Definition at line 250 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, ana::PredictionInterp::ShiftedPreds::shifts, and ana::PredictionInterp::ShiftedPreds::systName.

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

253  {
254  fits.resize(kNCoeffTypes);
255 
256  fits[kNueApp] = FitComponent(sp.shifts, sp.preds, Flavors::kNuMuToNuE, Current::kCC, sign, sp.systName);
257  fits[kNueSurv] = FitComponent(sp.shifts, sp.preds, Flavors::kNuEToNuE, Current::kCC, sign, sp.systName);
258  fits[kNumuSurv] = FitComponent(sp.shifts, sp.preds, Flavors::kNuMuToNuMu, Current::kCC, sign, sp.systName);
259 
260  fits[kNC] = FitComponent(sp.shifts, sp.preds, Flavors::kAll, Current::kNC, sign, sp.systName);
261 
262  fits[kOther] = FitComponent(sp.shifts, sp.preds, Flavors::kNuEToNuMu | Flavors::kAllNuTau, Current::kCC, sign, sp.systName);
263  }
(&#39; appearance&#39;)
Definition: IPrediction.h:18
(&#39;beam &#39;)
Definition: IPrediction.h:15
Charged-current interactions.
Definition: IPrediction.h:39
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 std::string &systName) const
Find coefficients describing the ratios from this component.
(&#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
def sign(x)
Definition: canMan.py:197
bool ana::PredictionSyst3Flavor2020::IsFHC ( ) const
protected

Interprets fBeam.

Definition at line 568 of file PredictionSyst3Flavor2020.cxx.

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

Referenced by AddNormSysts(), and PredictionSyst3Flavor2020().

569  {
570  if(fBeam == "fhc" ) return true;
571  if(fBeam == "rhc") return false;
572 
573  std::cout << "PredictionSyst3Flavor2020: Bad beam string: "
574  << fBeam << std::endl;
575  abort();
576  }
OStream cout
Definition: OStream.cxx:6
std::unique_ptr< PredictionSyst3Flavor2020 > ana::PredictionSyst3Flavor2020::LoadFrom ( TDirectory *  dir,
const std::string name 
)
static

Definition at line 450 of file PredictionSyst3Flavor2020.cxx.

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

451  {
452  std::cout << "PredictionSyst3Flavor2020::LoadFrom() not implemented" << std::endl;
453  abort();
454 
455  // TODO: implement with correct Norm syst and PtExtrap loading
456  /*
457  TObjString* tag = (TObjString*)dir->Get("type");
458  assert(tag);
459 
460  assert(tag->GetString() == "PredictionSyst3Flavor2020");
461 
462  std::unique_ptr<PredictionSyst3Flavor2020> ret(new PredictionSyst3Flavor2020);
463  LoadFromBody(dir, ret.get(), {&kAna2020NormFHC, &kAna2020NormRHC});
464 
465  const TObjString* beam = (TObjString*)dir->Get("beam");
466  assert(beam);
467  ret->fBeam = beam->GetString();
468 
469  ret->fSplitBySign = ret->IsFHC();
470 
471  // Just enable all norm systs unconditionally. Way too hard to do otherwise
472  // NB fBeam was set above. That's necessary for correctness.
473  ret->AddNormSysts({&kAna2020NormFHC, &kAna2020NormRHC});
474 
475  return ret;
476  */
477  }
OStream cout
Definition: OStream.cxx:6
void ana::PredictionInterp::LoadFromBody ( TDirectory *  dir,
PredictionInterp ret,
std::vector< const ISyst * >  veto = {} 
)
staticinherited

Definition at line 663 of file PredictionInterp.cxx.

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

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

665  {
666  ret->fPredNom = ana::LoadFrom<IPrediction>(dir, "pred_nom");
667 
668  TH1* hSystNames = (TH1*)dir->Get("syst_names");
669  if(hSystNames){
670  for(int systIdx = 0; systIdx < hSystNames->GetNbinsX(); ++systIdx){
671  ShiftedPreds sp;
672  sp.systName = hSystNames->GetXaxis()->GetBinLabel(systIdx+1);
673 
674  const ISyst* syst = Registry<ISyst>::ShortNameToPtr(sp.systName);
675 
676  if(std::find(veto.begin(), veto.end(), syst) != veto.end()) continue;
677 
678  for(int shift = -3; shift <= +3; ++shift){
679  const std::string subname = TString::Format("pred_%s_%+d", sp.systName.c_str(), shift).Data();
680  TDirectory *preddir = dir->GetDirectory(subname.c_str());
681  if(!preddir) continue; // Can happen for genie systs
682  delete preddir;
683 
684  sp.shifts.push_back(shift);
685  sp.preds.emplace_back(ana::LoadFrom<IPrediction>(dir, subname).release());
686  } // end for shift
687 
688  ret->fPreds.emplace(syst, std::move(sp));
689  } // end for systIdx
690  } // end if hSystNames
691 
692  ret->fOscOrigin = ana::LoadFrom<osc::IOscCalc>(dir, "osc_origin").release();
693  }
std::unique_ptr< IPrediction > LoadFrom< IPrediction >(TDirectory *dir, const std::string &label)
Definition: IPrediction.cxx:18
TDirectory * dir
Definition: macro.C:5
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
enum BeamMode string
IPrediction * ana::PredictionSyst3Flavor2020::LoadNuePtExtrapPred ( TFile *  file,
ENu2020ExtrapType  extrap,
std::string  syst_name,
std::string  sigma_str 
) const
protected

Definition at line 515 of file PredictionSyst3Flavor2020.cxx.

References om::cout, allTimeWatchdog::endl, ana::kComboPtExtrap, ana::kPropPtExtrap, string, and PandAna.Demos.tute_pid_validation::var.

Referenced by PredictionSyst3Flavor2020().

516  {
517  std::string signal_str = "pred_xp_nue_signal";
518 
519  std::string bkgd_str = "pred_xp_nue_bkgd_";
520  if ( extrap == ENu2020ExtrapType::kComboPtExtrap ) bkgd_str += "combo";
521  else if ( extrap == ENu2020ExtrapType::kPropPtExtrap ) bkgd_str += "prop";
522  else
523  {
524  std::cout << "ENu2020ExtrapType must be kComboPtExtrap or kPropPtExtrap" << std::endl;
525  abort();
526  }
527 
528  std::string var = "nue_pred_Nue2020Axis";
529 
530  std::vector<std::string> pred_paths;
531 
532  // Path for background prediction
533  pred_paths.push_back( Form( "%s_%s/%s/%s", bkgd_str.c_str(), syst_name.c_str(), sigma_str.c_str(), var.c_str() ) );
534 
535  // Paths for signal Pt quantile predictions
536  int NPtQuants = 3;
537  for ( int ptQuant = 1; ptQuant <= NPtQuants; ++ptQuant )
538  {
539  std::string signal_path = Form( "%s_%s/%s/%s_Signal_PtQuant%d", signal_str.c_str(), syst_name.c_str(), sigma_str.c_str(), var.c_str(), ptQuant );
540  pred_paths.push_back( signal_path );
541  }
542 
543  return new PredictionExtrapSum( file, pred_paths );
544  }
OStream cout
Definition: OStream.cxx:6
TFile * file
Definition: cellShifts.C:17
enum BeamMode string
IPrediction * ana::PredictionSyst3Flavor2020::LoadNumuPtExtrapPred ( TFile *  file,
int  EhadFracQuant,
std::string  syst_name,
std::string  sigma_str 
) const
protected

Definition at line 547 of file PredictionSyst3Flavor2020.cxx.

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

Referenced by PredictionSyst3Flavor2020().

548  {
549  if ( EhadFracQuant < 1 || EhadFracQuant > 4 )
550  {
551  std::cout << "Pt extrap requires 1 <= EhadFracQuant >= 4" << std::endl;
552  abort();
553  }
554 
555  std::string base_path = Form( "pred_xp_numu_%s/%s/numu_pred_NumuEnergy_EhadFracQuant%d", syst_name.c_str(), sigma_str.c_str(), EhadFracQuant );
556 
557  int NPtQuants = 3;
558  std::vector<std::string> pred_paths;
559  for ( int ptQuant = 1; ptQuant <= NPtQuants; ++ptQuant )
560  {
561  pred_paths.push_back( base_path + Form( "_PtQuant%dof%d", ptQuant, NPtQuants ) );
562  }
563 
564  return new PredictionExtrapSum( file, pred_paths );
565  }
OStream cout
Definition: OStream.cxx:6
TFile * file
Definition: cellShifts.C:17
enum BeamMode string
void ana::PredictionInterp::MinimizeMemory ( )
inherited

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

Definition at line 696 of file PredictionInterp.cxx.

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

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

697  {
698  std::set<IPrediction*> todel;
699  for(auto& it: fPreds){
700  std::vector<IPrediction*>& preds = it.second.preds;
701  for(unsigned int i = 0; i < preds.size(); ++i){
702  if(preds[i] != fPredNom.get()){
703  todel.insert(preds[i]);
704  preds[i] = 0;
705  }
706  }
707  }
708 
709  for(IPrediction* p: todel) delete p;
710 
711  // We probably just freed up a lot of memory, but malloc by default hangs
712  // on to all of it as cache.
713  malloc_trim(0);
714  }
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::IOscCalc calc) const
overridevirtualinherited
Spectrum ana::PredictionInterp::Predict ( osc::IOscCalcStan calc) const
overridevirtualinherited

Reimplemented from ana::IPrediction.

Definition at line 311 of file PredictionInterp.cxx.

References ana::PredictionInterp::fPredNom.

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

Implements ana::IPrediction.

Definition at line 317 of file PredictionInterp.cxx.

References ana::PredictionInterp::fPredNom.

Referenced by syst_plot_test().

321  {
322  return fPredNom->PredictComponent(calc, flav, curr, sign);
323  }
std::unique_ptr< IPrediction > fPredNom
The nominal prediction.
def sign(x)
Definition: canMan.py:197
Spectrum ana::PredictionInterp::PredictComponent ( osc::IOscCalcStan calc,
Flavors::Flavors_t  flav,
Current::Current_t  curr,
Sign::Sign_t  sign 
) const
overridevirtualinherited

Reimplemented from ana::IPrediction.

Definition at line 326 of file PredictionInterp.cxx.

References ana::PredictionInterp::fPredNom.

330  {
331  return fPredNom->PredictComponent(calc, flav, curr, sign);
332  }
std::unique_ptr< IPrediction > fPredNom
The nominal prediction.
def sign(x)
Definition: canMan.py:197
Spectrum ana::PredictionInterp::PredictComponentSyst ( osc::IOscCalc 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 570 of file PredictionInterp.cxx.

References ana::PredictionInterp::_PredictComponentSyst().

Referenced by check_predinterp(), check_predinterp_numu(), ana::PredictionInterp::DebugPlot(), ana::PredictionInterp::DebugPlotColz(), and ana::PredictionInterp::PredictSyst().

575  {
576  return _PredictComponentSyst(calc, shift, flav, curr, sign);
577  }
Spectrum _PredictComponentSyst(osc::_IOscCalc< T > *calc, const SystShifts &shift, Flavors::Flavors_t flav, Current::Current_t curr, Sign::Sign_t sign) const
Templated helper for PredictComponentSyst.
def sign(x)
Definition: canMan.py:197
Spectrum ana::PredictionInterp::PredictComponentSyst ( osc::IOscCalcStan 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 580 of file PredictionInterp.cxx.

References ana::PredictionInterp::_PredictComponentSyst().

585  {
586  return _PredictComponentSyst(calc, shift, flav, curr, sign);
587  }
Spectrum _PredictComponentSyst(osc::_IOscCalc< T > *calc, const SystShifts &shift, Flavors::Flavors_t flav, Current::Current_t curr, Sign::Sign_t sign) const
Templated helper for PredictComponentSyst.
def sign(x)
Definition: canMan.py:197
Spectrum ana::PredictionInterp::PredictSyst ( osc::IOscCalc calc,
const SystShifts shift 
) const
overridevirtualinherited

Reimplemented from ana::IPrediction.

Definition at line 335 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().

337  {
338  InitFits();
339 
340  return PredictComponentSyst(calc, shift,
343  Sign::kBoth);
344  }
Interactions of both types.
Definition: IPrediction.h:42
Spectrum PredictComponentSyst(osc::IOscCalc *calc, const SystShifts &shift, Flavors::Flavors_t flav, Current::Current_t curr, Sign::Sign_t sign) const override
Both neutrinos and antineutrinos.
Definition: IPrediction.h:52
All neutrinos, any flavor.
Definition: IPrediction.h:26
Spectrum ana::PredictionInterp::PredictSyst ( osc::IOscCalcStan calc,
const SystShifts shift 
) const
overridevirtualinherited

Reimplemented from ana::IPrediction.

Definition at line 347 of file PredictionInterp.cxx.

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

349  {
350  InitFits();
351 
352  return PredictComponentSyst(calc,
353  shift,
356  Sign::kBoth);
357  }
Interactions of both types.
Definition: IPrediction.h:42
Spectrum PredictComponentSyst(osc::IOscCalc *calc, const SystShifts &shift, Flavors::Flavors_t flav, Current::Current_t curr, Sign::Sign_t sign) const override
Both neutrinos and antineutrinos.
Definition: IPrediction.h:52
All neutrinos, any flavor.
Definition: IPrediction.h:26
Spectrum ana::IPrediction::PredictUnoscillated ( ) const
virtualinherited

Reimplemented in ana::PredictionSterile.

Definition at line 33 of file IPrediction.cxx.

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

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

34  {
35  // Default implementation
37  return Predict(&noosc);
38  }
Pass neutrinos through unchanged.
Definition: IOscCalc.h:45
virtual Spectrum Predict(osc::IOscCalc *calc) const =0
osc::NoOscillations noosc
Definition: NueSystFuncs.h:44
void ana::PredictionSyst3Flavor2020::SaveTo ( TDirectory *  dir,
const std::string name 
) const
overridevirtual

Reimplemented from ana::PredictionInterp.

Definition at line 480 of file PredictionSyst3Flavor2020.cxx.

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

481  {
482  std::cout << "PredictionSyst3Flavor2020::SaveTo() not implemented" << std::endl;
483  abort();
484 
485  // TODO: implement with correct Norm syst (and PtExtrap) saving
486  /*
487  PredictionInterp::SaveTo(dir);
488 
489  TDirectory* tmp = gDirectory;
490 
491  dir->cd();
492  // Overwrite "IPrediction"
493  TObjString("PredictionSyst3Flavor2020").Write("type");
494 
495  TObjString(fBeam.c_str()).Write("beam");
496 
497  tmp->cd();
498  */
499  }
OStream cout
Definition: OStream.cxx:6
void ana::PredictionInterp::SetOscSeed ( osc::IOscCalc oscSeed)
inherited

Definition at line 298 of file PredictionInterp.cxx.

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

298  {
299  fOscOrigin = oscSeed->Copy();
300  for(auto& it: fPreds) it.second.fits.clear();
301  InitFits();
302  }
set< int >::iterator it
virtual _IOscCalc * Copy() const =0
std::unordered_map< const ISyst *, ShiftedPreds > fPreds
osc::IOscCalc * fOscOrigin
The oscillation values we assume when evaluating the coefficients.
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 388 of file PredictionInterp.cxx.

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

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

393  {
394  static_assert(std::is_same_v<T, double> ||
395  std::is_same_v<T, stan::math::var>,
396  "PredictionInterp::ShiftBins() can only be called using doubles or stan::math::vars");
397  if(nubar) assert(fSplitBySign);
398 
399 
400  if(!std::is_same_v<T, stan::math::var> && shift.HasAnyStan()){
401  std::cout << "PredictionInterp: stan shifts on non-stan spectrum, something is wrong" << std::endl;
402  abort();
403  }
404 
405  T corr[N];
406  for(unsigned int i = 0; i < N; ++i) corr[i] = 1;
407 
408  for(auto& it: fPreds){
409  const ISyst* syst = it.first;
410  const ShiftedPreds& sp = it.second;
411 
412  T x = shift.GetShift<T>(syst);
413 
414  // need to actually do the calculation for the autodiff version
415  // to make sure the gradient is computed correctly
416  if(x == 0 && (!std::is_same_v<T, stan::math::var> || !shift.HasStan(syst))) continue;
417 
418  int shiftBin = (util::GetValAs<double>(x) - sp.shifts[0])/sp.Stride();
419  shiftBin = std::max(0, shiftBin);
420  shiftBin = std::min(shiftBin, sp.nCoeffs - 1);
421 
422  const Coeffs* fits = nubar ? &sp.fitsNubarRemap[type][shiftBin].front() : &sp.fitsRemap[type][shiftBin].front();
423 
424  x -= sp.shifts[shiftBin];
425 
426  const T x_cube = util::cube(x);
427  const T x_sqr = util::sqr(x);
428 
429  for(unsigned int n = 0; n < N; ++n){
430  // Uncomment to debug crashes in this function
431  // assert(type < fits.size());
432  // assert(n < sp.fits[type].size());
433  // assert(shiftBin < int(sp.fits[type][n].size()));
434 
435  const Coeffs& f = fits[n];
436 
437  corr[n] *= f.a*x_cube + f.b*x_sqr + f.c*x + f.d;
438  } // end for n
439  } // end for syst
440 
441  for(unsigned int n = 0; n < N; ++n){
442  // std::max() doesn't work with stan::math::var
443  arr[n] *= (corr[n] > 0.) ? corr[n] : 0.;
444  }
445 
446  }
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
OStream cout
Definition: OStream.cxx:6
std::vector< std::string > fits
assert(nhit_max >=nhit_nbins)
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::IOscCalc 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 449 of file PredictionInterp.cxx.

References ana::PredictionInterp::_ShiftedComponent(), calc, febshutoff_auto::curr, samweb_client.utility::hash, and canMan::sign().

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

456  {
457  return _ShiftedComponent(calc, hash, shift, flav, curr, sign, type);
458  }
Spectrum _ShiftedComponent(osc::_IOscCalc< 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.
def sign(x)
Definition: canMan.py:197
Spectrum ana::PredictionInterp::ShiftedComponent ( osc::IOscCalcStan calc,
const TMD5 *  hash,
const SystShifts shift,
Flavors::Flavors_t  flav,
Current::Current_t  curr,
Sign::Sign_t  sign,
CoeffsType  type 
) const
inherited
Spectrum ana::PredictionInterp::ShiftSpectrum ( const Spectrum s,
CoeffsType  type,
bool  nubar,
const SystShifts shift 
) const
inherited

Definition at line 360 of file PredictionInterp.cxx.

References ana::SystShifts::ActiveSysts(), om::cout, allTimeWatchdog::endl, ana::Spectrum::GetBinnings(), ana::Spectrum::GetEigen(), ana::Spectrum::GetEigenStan(), ana::Spectrum::GetLabels(), ana::SystShifts::GetShift(), ana::SystShifts::HasAnyStan(), ana::Spectrum::HasStan(), ana::SystShifts::IsNominal(), ana::Spectrum::Livetime(), ana::Spectrum::POT(), and ana::PredictionInterp::ShiftBins().

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

364  {
365  if(s.HasStan() && (!shift.IsNominal() && !shift.HasAnyStan())){
366  std::cout << "PredictionInterp used with Stan oscillations but non-Stan syst shifts. Is that what you expected?" << std::endl;
367  std::cout << " Systs set: " << std::endl;
368  for (const auto & syst : shift.ActiveSysts())
369  std::cout << " " << syst->ShortName() << " = " << shift.GetShift(syst) << std::endl;
370  }
371 
372  if(s.HasStan() || shift.HasAnyStan()){
373  // Need the second case for the NC component
374  Eigen::ArrayXstan vec = s.HasStan() ? s.GetEigenStan(s.POT()) : Eigen::ArrayXstan(s.GetEigen(s.POT()));
375 
376  ShiftBins(vec.size(), vec.data(), type, nubar, shift);
377  return Spectrum(std::move(vec), HistAxis(s.GetLabels(), s.GetBinnings()), s.POT(), s.Livetime());
378  }
379  else{
380  Eigen::ArrayXd vec = s.GetEigen(s.POT());
381  ShiftBins(vec.size(), vec.data(), type, nubar, shift);
382  return Spectrum(std::move(vec), HistAxis(s.GetLabels(), s.GetBinnings()), s.POT(), s.Livetime());
383  }
384  }
void ShiftBins(unsigned int N, T *arr, CoeffsType type, bool nubar, const SystShifts &shift) const
Helper for ShiftSpectrum.
_HistAxis< Var > HistAxis
Definition: HistAxis.h:103
const XML_Char * s
Definition: expat.h:262
Eigen::VectorXd vec
std::vector< float > Spectrum
Definition: Constants.h:610
OStream cout
Definition: OStream.cxx:6
Eigen::Array< stan::math::var, Eigen::Dynamic, 1 > ArrayXstan
Definition: StanUtils.h:7
std::string ana::PredictionSyst3Flavor2020::SigmaToString ( int  sigma) const
protected

Definition at line 502 of file PredictionSyst3Flavor2020.cxx.

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

Referenced by PredictionSyst3Flavor2020().

503  {
504  if(sigma == -2) return "minusTwo";
505  if(sigma == -1) return "minusOne";
506  if(sigma == 0) return "";
507  if(sigma == +1) return "plusOne";
508  if(sigma == +2) return "plusTwo";
509 
510  std::cout << "PredictionSyst3Flavor2020: unknown sigma " << sigma << std::endl;
511  abort();
512  }
double sigma(TH1F *hist, double percentile)
OStream cout
Definition: OStream.cxx:6
bool ana::PredictionInterp::SplitBySign ( ) const
inlineinherited

Definition at line 116 of file PredictionInterp.h.

References ana::PredictionInterp::fSplitBySign.

116 {return fSplitBySign;}

Member Data Documentation

std::string ana::PredictionSyst3Flavor2020::fBeam
protected

Definition at line 88 of file PredictionSyst3Flavor2020.h.

Referenced by IsFHC().

Spectrum ana::PredictionInterp::fBinning
mutableprotectedinherited

Dummy spectrum to provide binning.

Definition at line 205 of file PredictionInterp.h.

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

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

Definition at line 223 of file PredictionInterp.h.

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

osc::IOscCalc* 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
std::unordered_map<const ISyst*, ShiftedPreds> ana::PredictionInterp::fSumPreds
mutableprotectedinherited

Definition at line 200 of file PredictionInterp.h.


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