PredictionExtendToPeripheral.h
Go to the documentation of this file.
1 #pragma once
2 
5 
6 namespace ana
7 {
8  class PredictionNoExtrap;
9 
10  /// Combines two extrapolations, one with extrapolated predictions of the
11  /// core bins (and nominal peripheral) and one with all nominal predictions,
12  /// to apply the correct weights to the peripheral sample (copying the high
13  /// PID bin).
15  {
16  public:
17  /// Takes ownership of \a predCore and \a predNoExtrap
18 
20  PredictionNoExtrap* predNoExtrap,
21  bool mergePeripheral = true,
22  int nbins = 3);
23 
24  // alwasys specify bins matching your input binning for a correct total NBin value:
25  // ana2018 official one is: const Binning kNue2018Binning = Binning::Simple(27,0,27);
26  // nbins for flexible energy/reco vars binning instead of 9 hardcoded. default set to 3 to adapt ana2018 3bin.
27 
29  PredictionNoExtrap* predNoExtrap,
30  const ana::Binning& bins,
31  bool mergePeripheral = true,
32  int nbins = 3);
33 
35 
36  // un-hide inherited method stubs so we don't get warnings from the compiler
38 
39  virtual Spectrum Predict(osc::IOscCalc* calc) const override;
40  virtual Spectrum Predict(osc::IOscCalcStan* calc) const override;
41 
43  Flavors::Flavors_t flav,
45  Sign::Sign_t sign) const override;
47  Flavors::Flavors_t flav,
48  Current::Current_t curr,
49  Sign::Sign_t sign) const override;
50 
51  OscillatableSpectrum ComponentCC(int from, int to) const override;
52  //nc
53  Spectrum ComponentNCTotal() const override;
54  Spectrum ComponentNC() const override;
55  Spectrum ComponentNCAnti() const override;
56  //end nc
57 
58  void Reduce();
59 
60  virtual void SaveTo(TDirectory* dir, const std::string& name) const override;
61  static std::unique_ptr<PredictionExtendToPeripheral> LoadFrom(TDirectory* dir, const std::string& name);
62 
64 
66  {
67  return fPredCore;
68  };
69 
70  protected:
72 
73  template <typename T>
75  Flavors::Flavors_t flav,
76  Current::Current_t curr,
77  Sign::Sign_t sign) const;
78 
79  Spectrum ReduceHelperNC(const Spectrum& s) const;
80 
81  Spectrum MergePeripheral(const Spectrum& s) const;
83  Spectrum ExtendRecoWeight(const Spectrum& Core, const Spectrum& NoExtrap) const;
86  OscillatableSpectrum NoExtrap) const;
87 
92  int fNPIDBin;
93 
94  // TODO: there has to be a better way to calculate all the boundaries/merge peripheral...
95  const int fNBinsI = fBins.NBins();
96  const int fEnergyBins = fNBinsI/fNPIDBin;
97  const int fPeriNum = int(fEnergyBins/2);
98  const int fNBinsO = fNBinsI-fPeriNum;
99  //give me a reason that we have flexible energy bins for different pid or lets keep this form
100  const int fNCore = (fNPIDBin-1)*fEnergyBins;
101  const int fPeriBin = fNCore+int((fEnergyBins-fPeriNum)/2)+1;
102 
103  // the rule is, with FD cut we consistently have first '2' bins empty from energy cut,
104  // and (fEnergyBins-1) empty after merging Peri
105  // TODO: ... I... hardcoded the whole reduce assuming 9 energy bin everywhere...
106  // i currently dont have a better idea how to manage this part other than passing empty bin info to Reduce...T_T
107  // But I dont want to implement it for now, maybe later when I start to mess up fitter/surface XD
108  const int fReduceBin = fNBinsI - 2* fNPIDBin - fEnergyBins +1;
109  const Binning ReduceBinning = Binning::Simple(fReduceBin, 0, fReduceBin);
110 
117 
124  //nc
128  //end nc
129 
130  bool fIsMerged;
131  };
132 
133  /// PredictionExtendToPeripheral doesn't own its constituent predictions,
134  /// but some of its descendants will need it to.
136  {
137  public:
139  PredictionNoExtrap* pne,
140  bool merge = true)
141  : PredictionExtendToPeripheral(pe, pne, merge)
142  {
143  }
144 
146  PredictionNoExtrap* pne,
147  const ana::Binning& b,
148  bool merge = true)
149  : PredictionExtendToPeripheral(pe, pne, b, merge)
150  {
151  }
152 
154 
155  };
156 
157 }
const XML_Char * name
Definition: expat.h:151
Spectrum _PredictComponent(osc::_IOscCalc< T > *calc, Flavors::Flavors_t flav, Current::Current_t curr, Sign::Sign_t sign) const
Spectrum ReduceHelperNC(const Spectrum &s) const
Represent the binning of a Spectrum&#39;s x-axis.
Definition: Binning.h:16
Cuts and Vars for the 2020 FD DiF Study.
Definition: vars.h:6
bool mergePeripheral
Spectrum MergePeripheral(const Spectrum &s) const
General interface to oscillation calculators.
Definition: StanTypedefs.h:22
osc::OscCalcDumb calc
Representation of a spectrum in any variable, with associated POT.
Definition: Spectrum.h:40
const XML_Char * s
Definition: expat.h:262
const int nbins
Definition: cellShifts.C:15
OscillatableSpectrum ReduceHelper(const OscillatableSpectrum &s) const
virtual Spectrum PredictSyst(osc::IOscCalc *calc, const SystShifts &syst) const
Definition: IPrediction.cxx:49
PredictExtendOwning(IPrediction *pe, PredictionNoExtrap *pne, const ana::Binning &b, bool merge=true)
OscillatableSpectrum MergePeripheralOsc(const OscillatableSpectrum &s) const
const Binning bins
Definition: NumuCC_CPiBin.h:8
OscillatableSpectrum ComponentCC(int from, int to) const override
virtual Spectrum Predict(osc::IOscCalc *calc) const override
void NoExtrap(std::string InputString, bool RunProd4Cuts=true, bool RunAllCuts=false, bool Debug=false)
Definition: NoExtrap.C:36
TDirectory * dir
Definition: macro.C:5
int NBins() const
Definition: Binning.h:29
const hit & b
Definition: hits.cxx:21
Standard interface to all prediction techniques.
Definition: IPrediction.h:57
virtual Spectrum PredictComponent(osc::IOscCalc *calc, Flavors::Flavors_t flav, Current::Current_t curr, Sign::Sign_t sign) const override
OscillatableSpectrum ExtendRecoWeightOscillatable(const OscillatableSpectrum &Core, OscillatableSpectrum NoExtrap) const
Prediction that just uses FD MC, with no extrapolation.
Spectrum with true energy information, allowing it to be oscillated
static std::unique_ptr< PredictionExtendToPeripheral > LoadFrom(TDirectory *dir, const std::string &name)
Spectrum ExtendRecoWeight(const Spectrum &Core, const Spectrum &NoExtrap) const
PredictExtendOwning(IPrediction *pe, PredictionNoExtrap *pne, bool merge=true)
virtual void SaveTo(TDirectory *dir, const std::string &name) const override
static Binning Simple(int n, double lo, double hi, const std::vector< std::string > &labels={})
Definition: Binning.cxx:107
def sign(x)
Definition: canMan.py:197
enum BeamMode string