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

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

Inheritance diagram for ana::PredictionExtendToPeripheral:
ana::IPrediction ana::PredictExtendOwning ana::PredictExtendOwning

Public Member Functions

 PredictionExtendToPeripheral (IPrediction *predCore, PredictionNoExtrap *predNoExtrap, bool mergePeripheral=true, int nbins=3)
 Takes ownership of predCore and predNoExtrap. More...
 
 PredictionExtendToPeripheral (IPrediction *predCore, PredictionNoExtrap *predNoExtrap, const ana::Binning &bins, bool mergePeripheral=true, int nbins=3)
 
virtual ~PredictionExtendToPeripheral ()
 
virtual Spectrum Predict (osc::IOscCalculator *calc) const override
 
virtual Spectrum PredictComponent (osc::IOscCalculator *calc, Flavors::Flavors_t flav, Current::Current_t curr, Sign::Sign_t sign) const override
 
OscillatableSpectrum ComponentCC (int from, int to) const override
 
Spectrum ComponentNCTotal () const override
 
Spectrum ComponentNC () const override
 
Spectrum ComponentNCAnti () const override
 
void Reduce ()
 
void Scale (double from, double to, double scale)
 
virtual void SaveTo (TDirectory *dir) const override
 
 PredictionExtendToPeripheral ()=delete
 
IPredictionGetCore ()
 
virtual Spectrum PredictUnoscillated () const
 
virtual SpectrumStan Predict (osc::IOscCalculatorStan *calc) const
 
virtual Spectrum PredictSyst (osc::IOscCalculator *calc, const SystShifts &syst) const
 
virtual SpectrumStan PredictSyst (osc::IOscCalculatorStan *calc, const SystShifts &syst) const
 
virtual SpectrumStan PredictComponent (osc::IOscCalculatorStan *calc, Flavors::Flavors_t flav, Current::Current_t curr, Sign::Sign_t sign) const
 
virtual Spectrum PredictComponentSyst (osc::IOscCalculator *calc, const SystShifts &syst, Flavors::Flavors_t flav, Current::Current_t curr, Sign::Sign_t sign) const
 
virtual SpectrumStan PredictComponentSyst (osc::IOscCalculatorStan *calc, const SystShifts &syst, Flavors::Flavors_t flav, Current::Current_t curr, Sign::Sign_t sign) const
 
virtual void Derivative (osc::IOscCalculator *calc, const SystShifts &shift, double pot, std::unordered_map< const ISyst *, std::vector< double >> &dchi) const
 

Static Public Member Functions

static std::unique_ptr< PredictionExtendToPeripheralLoadFrom (TDirectory *dir)
 

Protected Member Functions

OscillatableSpectrum ReduceHelper (const OscillatableSpectrum &s) const
 
Spectrum ReduceHelperNC (const Spectrum &s) const
 
SpectrumMergePeripheral (const Spectrum &s) const
 
OscillatableSpectrumMergePeripheralOsc (const OscillatableSpectrum &s) const
 
SpectrumExtendRecoWeight (const Spectrum &Core, const Spectrum &NoExtrap) const
 
OscillatableSpectrumExtendRecoWeightOscillatable (const OscillatableSpectrum &Core, OscillatableSpectrum NoExtrap) const
 

Protected Attributes

IPredictionfPredCore
 
PredictionNoExtrapfPredNoExtrap
 
Binning fBins
 
bool fMergePeripheral
 
int fNPIDBin
 
const int fNBinsI = fBins.NBins()
 
const int fEnergyBins = fNBinsI/fNPIDBin
 
const int fPeriNum = int(fEnergyBins/2)
 
const int fNBinsO = fNBinsI-fPeriNum
 
const int fNCore = (fNPIDBin-1)*fEnergyBins
 
const int fPeriBin = fNCore+int((fEnergyBins-fPeriNum)/2)+1
 
const int fReduceBin = fNBinsI - 2* fNPIDBin - fEnergyBins +1
 
const Binning ReduceBinning = Binning::Simple(fReduceBin, 0, fReduceBin)
 
OscillatableSpectrumfNuEToNuE
 
OscillatableSpectrumfAntiNuEToAntiNuE
 
OscillatableSpectrumfNuEToNuMu
 
OscillatableSpectrumfAntiNuEToAntiNuMu
 
OscillatableSpectrumfNuEToNuTau
 
OscillatableSpectrumfAntiNuEToAntiNuTau
 
OscillatableSpectrumfNuMuToNuE
 
OscillatableSpectrumfAntiNuMuToAntiNuE
 
OscillatableSpectrumfNuMuToNuMu
 
OscillatableSpectrumfAntiNuMuToAntiNuMu
 
OscillatableSpectrumfNuMuToNuTau
 
OscillatableSpectrumfAntiNuMuToAntiNuTau
 
SpectrumfNCTot
 
SpectrumfNC
 
SpectrumfNCAnti
 
bool fIsMerged
 

Detailed Description

Combines two extrapolations, one with extrapolated predictions of the core bins (and nominal peripheral) and one with all nominal predictions, to apply the correct weights to the peripheral sample (copying the high PID bin).

Definition at line 14 of file PredictionExtendToPeripheral.h.

Constructor & Destructor Documentation

ana::PredictionExtendToPeripheral::PredictionExtendToPeripheral ( IPrediction predCore,
PredictionNoExtrap predNoExtrap,
bool  mergePeripheral = true,
int  nbins = 3 
)

Takes ownership of predCore and predNoExtrap.

Definition at line 18 of file PredictionExtendToPeripheral.cxx.

19  : PredictionExtendToPeripheral(predCore, predNoExtrap, Binning::Simple(27,0,27), mergePeripheral, nbins)
20  {
21  }
const int nbins
Definition: cellShifts.C:15
bool mergePeripheral
static Binning Simple(int n, double lo, double hi, const std::vector< std::string > &labels={})
Definition: Binning.cxx:38
ana::PredictionExtendToPeripheral::PredictionExtendToPeripheral ( IPrediction predCore,
PredictionNoExtrap predNoExtrap,
const ana::Binning bins,
bool  mergePeripheral = true,
int  nbins = 3 
)

Definition at line 24 of file PredictionExtendToPeripheral.cxx.

References ana::PredictionExtrap::ComponentCC(), ana::IPrediction::ComponentCC(), ana::PredictionExtrap::ComponentNC(), ana::IPrediction::ComponentNC(), ana::PredictionExtrap::ComponentNCAnti(), ana::IPrediction::ComponentNCAnti(), ana::PredictionExtrap::ComponentNCTotal(), ana::IPrediction::ComponentNCTotal(), om::cout, allTimeWatchdog::endl, ExtendRecoWeight(), ExtendRecoWeightOscillatable(), fAntiNuEToAntiNuE, fAntiNuEToAntiNuMu, fAntiNuEToAntiNuTau, fAntiNuMuToAntiNuE, fAntiNuMuToAntiNuMu, fAntiNuMuToAntiNuTau, fIsMerged, fMergePeripheral, fNC, fNCAnti, fNCTot, fNuEToNuE, fNuEToNuMu, fNuEToNuTau, fNuMuToNuE, fNuMuToNuMu, fNuMuToNuTau, fPredCore, and fPredNoExtrap.

25  : fPredCore(predCore),
26  fPredNoExtrap(predNoExtrap),
27  fBins(bins),
30  {
31 
32  if(!fMergePeripheral) std::cout << "WARNING: Not merging peripheral. Check inputs." << std::endl;
33 
36 
39 
42 
45 
48 
51 
55 
56  fIsMerged = false;
57  }
OscillatableSpectrum ComponentCC(int from, int to) const override
virtual Spectrum ComponentNC() const
Definition: IPrediction.h:111
Spectrum ComponentNC() const override
Spectrum * ExtendRecoWeight(const Spectrum &Core, const Spectrum &NoExtrap) const
Spectrum ComponentNCTotal() const override
OscillatableSpectrum * ExtendRecoWeightOscillatable(const OscillatableSpectrum &Core, OscillatableSpectrum NoExtrap) const
const int nbins
Definition: cellShifts.C:15
bool mergePeripheral
virtual Spectrum ComponentNCAnti() const
Definition: IPrediction.h:113
OStream cout
Definition: OStream.cxx:6
virtual Spectrum ComponentNCTotal() const
Definition: IPrediction.h:109
virtual OscillatableSpectrum ComponentCC(int from, int to) const
Definition: IPrediction.h:103
Spectrum ComponentNCAnti() const override
ana::PredictionExtendToPeripheral::~PredictionExtendToPeripheral ( )
virtual

Definition at line 60 of file PredictionExtendToPeripheral.cxx.

References fAntiNuEToAntiNuE, fAntiNuEToAntiNuMu, fAntiNuEToAntiNuTau, fAntiNuMuToAntiNuE, fAntiNuMuToAntiNuMu, fAntiNuMuToAntiNuTau, fNC, fNCAnti, fNCTot, fNuEToNuE, fNuEToNuMu, fNuEToNuTau, fNuMuToNuE, fNuMuToNuMu, and fNuMuToNuTau.

61  {
62  delete fNCTot;
63  delete fNC;
64  delete fNCAnti;
65  // We don't necessarily own the predictions, leave them alone
66 
67  delete fNuEToNuE;
68  delete fAntiNuEToAntiNuE;
69  delete fNuEToNuMu;
70  delete fAntiNuEToAntiNuMu;
71  delete fNuEToNuTau;
72  delete fAntiNuEToAntiNuTau;
73 
74  delete fNuMuToNuE;
75  delete fAntiNuMuToAntiNuE;
76  delete fNuMuToNuMu;
77  delete fAntiNuMuToAntiNuMu;
78  delete fNuMuToNuTau;
79  delete fAntiNuMuToAntiNuTau;
80  }
ana::PredictionExtendToPeripheral::PredictionExtendToPeripheral ( )
delete

Referenced by LoadFrom().

Member Function Documentation

OscillatableSpectrum ana::PredictionExtendToPeripheral::ComponentCC ( int  from,
int  to 
) const
overridevirtual

Reimplemented from ana::IPrediction.

Definition at line 389 of file PredictionExtendToPeripheral.cxx.

References fAntiNuEToAntiNuE, fAntiNuEToAntiNuMu, fAntiNuEToAntiNuTau, fAntiNuMuToAntiNuE, fAntiNuMuToAntiNuMu, fAntiNuMuToAntiNuTau, fNuEToNuE, fNuEToNuMu, fNuEToNuTau, fNuMuToNuE, fNuMuToNuMu, and fNuMuToNuTau.

390  {
391  // beam nues and numu survival come from extending the effect on the high
392  // CVN bin into the peripheral sample
393  if (from == +12 && to == +12) return *fNuEToNuE;
394  if (from == +12 && to == +14) return *fNuEToNuMu;
395  if (from == +12 && to == +16) return *fNuEToNuTau;
396 
397  if (from == +14 && to == +12) return *fNuMuToNuE;
398  if (from == +14 && to == +14) return *fNuMuToNuMu;
399  if (from == +14 && to == +16) return *fNuMuToNuTau;
400 
401  if (from == -12 && to == -12) return *fAntiNuEToAntiNuE;
402  if (from == -12 && to == -14) return *fAntiNuEToAntiNuMu;
403  if (from == -12 && to == -16) return *fAntiNuEToAntiNuTau;
404 
405  if (from == -14 && to == -12) return *fAntiNuMuToAntiNuE;
406  if (from == -14 && to == -14) return *fAntiNuMuToAntiNuMu;
407  if (from == -14 && to == -16) return *fAntiNuMuToAntiNuTau;
408 
409  assert(0 && "Not reached");
410  }
Spectrum ana::PredictionExtendToPeripheral::ComponentNC ( ) const
overridevirtual

Reimplemented from ana::IPrediction.

Definition at line 418 of file PredictionExtendToPeripheral.cxx.

References fNC.

Referenced by PredictComponent().

419  {
420  return *fNC;
421  }
Spectrum ana::PredictionExtendToPeripheral::ComponentNCAnti ( ) const
overridevirtual

Reimplemented from ana::IPrediction.

Definition at line 422 of file PredictionExtendToPeripheral.cxx.

References fNCAnti.

Referenced by PredictComponent().

423  {
424  return *fNCAnti;
425  }
Spectrum ana::PredictionExtendToPeripheral::ComponentNCTotal ( ) const
overridevirtual

Reimplemented from ana::IPrediction.

Definition at line 414 of file PredictionExtendToPeripheral.cxx.

References fNCTot.

415  {
416  return *fNCTot;
417  }
virtual void ana::IPrediction::Derivative ( osc::IOscCalculator calc,
const SystShifts shift,
double  pot,
std::unordered_map< const ISyst *, std::vector< double >> &  dchi 
) const
inlinevirtualinherited

Reimplemented in ana::PredictionInterp, and ana::PredictionAddRock.

Definition at line 92 of file IPrediction.h.

Referenced by ana::PredictionAddRock::Derivative(), and ana::SingleSampleExperiment::Derivative().

96  {
97  // Implementing this function is optional. If you don't implement it,
98  // this default implementation will be used, which signals to callers
99  // that your Prediction doesn't implement this feature.
100  dchi.clear();
101  }
Spectrum * ana::PredictionExtendToPeripheral::ExtendRecoWeight ( const Spectrum Core,
const Spectrum NoExtrap 
) const
protected

Definition at line 271 of file PredictionExtendToPeripheral.cxx.

References bin, fEnergyBins, fMergePeripheral, fNBinsI, fNCore, MergePeripheral(), and ana::Ratio::ToTH1().

Referenced by GetCore(), and PredictionExtendToPeripheral().

273  {
274  // NoExtrap has the nominal FD prediction in it, while Core has the
275  // our decomposed prediction. We want to copy over the decomp weights,
276  // which will just be the Core / NoExtrap bin content. That covers
277  // extrapolation in energy bins.
278  TH1 *hrat = Ratio(Core,NoExtrap).ToTH1();
279 
280  const int FirstPeripheralBin = fNCore+1;
281  const int LastPeripheralBin = fNBinsI;
282  const int EBinsPerSelBin = fEnergyBins;
283 
284  for (int bin = FirstPeripheralBin; bin<= LastPeripheralBin; bin++){
285  // Copy decomp ratio from high CVN bin to peripheral bin
286  hrat->SetBinContent(bin,hrat->GetBinContent(bin-EBinsPerSelBin));
287  }
288  Ratio rat(hrat,"Ana Bin");
289 
290  Spectrum extrap = NoExtrap*rat;
291 
292  // Done if we don't want to collapse energy spectrum in peripheral sample
293  if (!fMergePeripheral)
294  return new Spectrum(extrap);
295 
296  // Now, we have to merge all energy bins in the peripheral sample
297  // This is only applicable to the Nue2017 result, so assume 28 bins
298  return MergePeripheral(extrap);
299  }
Spectrum * MergePeripheral(const Spectrum &s) const
float bin[41]
Definition: plottest35.C:14
void NoExtrap(std::string InputString, bool RunProd4Cuts=true, bool RunAllCuts=false, bool Debug=false)
Definition: NoExtrap.C:35
OscillatableSpectrum * ana::PredictionExtendToPeripheral::ExtendRecoWeightOscillatable ( const OscillatableSpectrum Core,
OscillatableSpectrum  NoExtrap 
) const
protected

Definition at line 303 of file PredictionExtendToPeripheral.cxx.

References bin, fEnergyBins, fMergePeripheral, fNBinsO, fNCore, MergePeripheralOsc(), ana::ReweightableSpectrum::ReweightToRecoSpectrum(), ana::Ratio::ToTH1(), and ana::OscillatableSpectrum::Unoscillated().

Referenced by GetCore(), and PredictionExtendToPeripheral().

305  {
306  // NoExtrap has the nominal FD prediction in it, while Core has the
307  // our decomposed prediction. We want to copy over the decomp weights,
308  // which will just be the Core / NoExtrap bin content
309 
310  // Calling Unoscillated() will project down to the predicted reco spectra
311 
312  Spectrum recoCore = Core.Unoscillated();
313 
314  Spectrum recoNoExtrap = NoExtrap.Unoscillated();
315  TH1 *hrat = Ratio(recoCore,recoNoExtrap).ToTH1();
316 
317  const int FirstPeripheralBin = fNCore+1;
318  const int LastPeripheralBin = fNBinsO;
319 
320  const int EBinsPerSelBin = fEnergyBins;
321  for (int bin = FirstPeripheralBin; bin<= LastPeripheralBin; bin++){
322  // Copy decomp ratio from high CVN bin to peripheral bin
323  hrat->SetBinContent(bin,hrat->GetBinContent(bin-EBinsPerSelBin));
324  }
325  Ratio rat(hrat,"Ana Bin");
326  NoExtrap.ReweightToRecoSpectrum(rat*recoNoExtrap);
327 
328  // We're done if we don't want to merge peripheral sample energy dist
329  if (!fMergePeripheral)
330  return new OscillatableSpectrum(NoExtrap);
331 
333  }
OscillatableSpectrum * MergePeripheralOsc(const OscillatableSpectrum &s) const
float bin[41]
Definition: plottest35.C:14
void NoExtrap(std::string InputString, bool RunProd4Cuts=true, bool RunAllCuts=false, bool Debug=false)
Definition: NoExtrap.C:35
IPrediction* ana::PredictionExtendToPeripheral::GetCore ( )
inline
std::unique_ptr< PredictionExtendToPeripheral > ana::PredictionExtendToPeripheral::LoadFrom ( TDirectory *  dir)
static

Definition at line 449 of file PredictionExtendToPeripheral.cxx.

References ana::bins, ana::Binning::LoadFrom(), ana::LoadFrom< IPrediction >(), PredictionExtendToPeripheral(), runNovaSAM::release, and cvnie::subdir.

Referenced by ana::LoadFrom< IPrediction >().

450  {
451  assert(dir->GetDirectory("predCore"));
452  assert(dir->GetDirectory("predNoExtrap"));
453  assert(dir->GetDirectory("bins"));
454 
455  auto predCore = ana::LoadFrom<IPrediction>(dir->GetDirectory("predCore")).release();
456  PredictionNoExtrap* predNoExtrap = ana::LoadFrom<PredictionNoExtrap>(dir->GetDirectory("predNoExtrap")).release();
457 
458  TDirectory* subdir = dir->GetDirectory("bins");
459  Binning bins= *Binning::LoadFrom(subdir);
460 
461  bool mergeperipheral = true; // default
462 
463  TVectorD* vMergePeripheral = (TVectorD*)dir->Get("mergePeripheral");
464  // An attempt to be backwards compatable to already generated files
465  if (vMergePeripheral){
466  assert(vMergePeripheral->GetNrows() == 1);
467  mergeperipheral = bool((*vMergePeripheral)[0]);
468  }
469 
470  return std::unique_ptr<PredictionExtendToPeripheral>(new PredictionExtendToPeripheral(predCore, predNoExtrap, bins, mergeperipheral));
471  }
subdir
Definition: cvnie.py:7
const Binning bins
Definition: NumuCC_CPiBin.h:8
std::unique_ptr< IPrediction > LoadFrom< IPrediction >(TDirectory *dir)
Definition: IPrediction.cxx:38
TDirectory * dir
Definition: macro.C:5
static std::unique_ptr< Binning > LoadFrom(TDirectory *dir)
Definition: Binning.cxx:221
Spectrum * ana::PredictionExtendToPeripheral::MergePeripheral ( const Spectrum s) const
protected

Definition at line 219 of file PredictionExtendToPeripheral.cxx.

References bin, ana::HistCache::Delete(), fNBinsI, fNBinsO, fNCore, fPeriBin, ana::Spectrum::GetLabels(), demo3::h, MECModelEnuComparisons::i, ana::Spectrum::Livetime(), ana::HistCache::New(), ana::Spectrum::POT(), ana::Binning::Simple(), and ana::Spectrum::ToTH1().

Referenced by ExtendRecoWeight(), and GetCore().

220  {
221  Binning bin = Binning::Simple(fNBinsO, 0, fNBinsO);
222  std::unique_ptr<TH1D> hret(HistCache::New("", bin));
223 
224  TH1D* h = s.ToTH1(s.POT());
225  for (int i = 1; i <= fNCore; i++){
226  hret->SetBinContent(i,h->GetBinContent(i)); // Copy Core;
227  }
228 
229  hret->SetBinContent(fPeriBin, h->Integral(fNBinsI-8, fNBinsI)); // Merge peripheral
231 
232  return new Spectrum(std::move(hret),
233  s.GetLabels(),
234  {bin},
235  s.POT(),
236  s.Livetime());
237  }
const XML_Char * s
Definition: expat.h:262
static void Delete(TH1D *&h)
Definition: HistCache.cxx:215
float bin[41]
Definition: plottest35.C:14
static TH1D * New(const std::string &title, const Binning &bins)
Definition: HistCache.cxx:24
static Binning Simple(int n, double lo, double hi, const std::vector< std::string > &labels={})
Definition: Binning.cxx:38
h
Definition: demo3.py:41
OscillatableSpectrum * ana::PredictionExtendToPeripheral::MergePeripheralOsc ( const OscillatableSpectrum s) const
protected

Definition at line 240 of file PredictionExtendToPeripheral.cxx.

References ana::bins, ana::HistCache::Delete(), fNBinsI, fNBinsO, fNCore, fPeriBin, ana::ReweightableSpectrum::GetLabels(), ana::OscillatableSpectrum::Livetime(), ana::HistCache::NewTH2D(), ana::OscillatableSpectrum::POT(), ana::Binning::Simple(), and ana::ReweightableSpectrum::ToTH2().

Referenced by ExtendRecoWeightOscillatable(), and GetCore().

241  {
242  const Binning bins = Binning::Simple(fNBinsO, 0, fNBinsO);
243  std::unique_ptr<TH2D> hret(HistCache::NewTH2D("", bins));
244  TH2D *hextrap = s.ToTH2(s.POT());
245 
246  for (int binX = 1; binX <= fNCore; binX++){
247  for (int binY = 1; binY < hret->GetNbinsY() +1; binY++){
248  hret->SetBinContent(binX,binY,hextrap->GetBinContent(binX,binY));
249  }
250  }
251  // Now, project all the bins in columns 28+ down to the 28th
252  for (int binX = fNCore+1; binX <= fNBinsI; binX++){
253  for (int binY = 1; binY < hret->GetNbinsY() +1; binY++){
254 
255  hret->SetBinContent(fPeriBin, binY, hret->GetBinContent(fPeriBin,binY)+
256  hextrap->GetBinContent(binX,binY));
257  }
258  }
259  HistCache::Delete(hextrap);
260 
261  return new OscillatableSpectrum(// std::move(hret), // no constructor transferring ownership exists, sadly
262  hret.get(),
263  s.GetLabels(),
264  {bins},
265  s.POT(),
266  s.Livetime());
267  }
static TH2D * NewTH2D(const std::string &title, const Binning &bins)
Definition: HistCache.cxx:80
const XML_Char * s
Definition: expat.h:262
static void Delete(TH1D *&h)
Definition: HistCache.cxx:215
const Binning bins
Definition: NumuCC_CPiBin.h:8
static Binning Simple(int n, double lo, double hi, const std::vector< std::string > &labels={})
Definition: Binning.cxx:38
Spectrum ana::PredictionExtendToPeripheral::Predict ( osc::IOscCalculator calc) const
overridevirtual

Implements ana::IPrediction.

Definition at line 210 of file PredictionExtendToPeripheral.cxx.

References ana::Flavors::kAll, ana::Current::kBoth, ana::Sign::kBoth, and PredictComponent().

Referenced by test_nue2017Prediction().

211  {
212  return PredictComponent(calc,
215  Sign::kBoth);
216  }
Interactions of both types.
Definition: IPrediction.h:42
virtual Spectrum PredictComponent(osc::IOscCalculator *calc, 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
SpectrumStan ana::IPrediction::Predict ( osc::IOscCalculatorStan calc) const
virtualinherited

Reimplemented in ana::PredictionInterp, and ana::PredictionExtrap.

Definition at line 92 of file IPrediction.cxx.

93  {
94  assert(0 && "This Prediction hasn't implemented a Stan-aware Predict()!");
95  }
Spectrum ana::PredictionExtendToPeripheral::PredictComponent ( osc::IOscCalculator calc,
Flavors::Flavors_t  flav,
Current::Current_t  curr,
Sign::Sign_t  sign 
) const
overridevirtual

Implements ana::IPrediction.

Definition at line 338 of file PredictionExtendToPeripheral.cxx.

References ana::Spectrum::Clear(), ComponentNC(), ComponentNCAnti(), fAntiNuEToAntiNuE, fAntiNuEToAntiNuMu, fAntiNuEToAntiNuTau, fAntiNuMuToAntiNuE, fAntiNuMuToAntiNuMu, fAntiNuMuToAntiNuTau, fNCTot, fNuEToNuE, fNuEToNuMu, fNuEToNuTau, fNuMuToNuE, fNuMuToNuMu, fNuMuToNuTau, ana::Flavors::kAll, ana::Sign::kAntiNu, ana::Current::kCC, ana::Current::kNC, ana::Sign::kNu, ana::Flavors::kNuEToNuE, ana::Flavors::kNuEToNuMu, ana::Flavors::kNuEToNuTau, ana::Flavors::kNuMuToNuE, ana::Flavors::kNuMuToNuMu, ana::Flavors::kNuMuToNuTau, ana::OscillatableSpectrum::Oscillated(), and runNovaSAM::ret.

Referenced by Predict(), and test_nue2017Prediction().

342  {
343  Spectrum ret = *fNCTot;
344 
345  ret.Clear();
346 
347  if(curr & Current::kCC){
348 
349  if(flav & Flavors::kNuEToNuE && sign & Sign::kNu)
350  ret += fNuEToNuE->Oscillated(calc, +12, +12);
351  if(flav & Flavors::kNuEToNuE && sign & Sign::kAntiNu)
352  ret += fAntiNuEToAntiNuE->Oscillated(calc, -12, -12);
353  if(flav & Flavors::kNuEToNuMu && sign & Sign::kNu)
354  ret += fNuEToNuMu->Oscillated(calc, +12, +14);
355  if(flav & Flavors::kNuEToNuMu && sign & Sign::kAntiNu)
356  ret += fAntiNuEToAntiNuMu->Oscillated(calc, -12, -14);
357  if(flav & Flavors::kNuEToNuTau && sign & Sign::kNu)
358  ret += fNuEToNuTau->Oscillated(calc, +12, +16);
359  if(flav & Flavors::kNuEToNuTau && sign & Sign::kAntiNu)
360  ret += fAntiNuEToAntiNuTau->Oscillated(calc, -12, -16);
361 
362  if(flav & Flavors::kNuMuToNuE && sign & Sign::kNu)
363  ret += fNuMuToNuE->Oscillated(calc, +14, +12);
364  if(flav & Flavors::kNuMuToNuE && sign & Sign::kAntiNu)
365  ret += fAntiNuMuToAntiNuE->Oscillated(calc, -14, -12);
366  if(flav & Flavors::kNuMuToNuMu && sign & Sign::kNu)
367  ret += fNuMuToNuMu->Oscillated(calc, +14, +14);
368  if(flav & Flavors::kNuMuToNuMu && sign & Sign::kAntiNu)
369  ret += fAntiNuMuToAntiNuMu->Oscillated(calc, -14, -14);
370  if(flav & Flavors::kNuMuToNuTau && sign & Sign::kNu)
371  ret += fNuMuToNuTau->Oscillated(calc, +14, +16);
372  if(flav & Flavors::kNuMuToNuTau && sign & Sign::kAntiNu)
373  ret += fAntiNuMuToAntiNuTau->Oscillated(calc, -14, -16);
374 
375  }
376 
377  if(curr & Current::kNC){
378  assert(flav == Flavors::kAll); // Don't know how to calculate anything else
379 
380  if(sign & Sign::kNu) ret += this->ComponentNC();
381  if(sign & Sign::kAntiNu) ret += this->ComponentNCAnti();
382 
383  }
384 
385  return ret;
386  }
Spectrum Oscillated(osc::IOscCalculator *calc, int from, int to) const
Antineutrinos-only.
Definition: IPrediction.h:50
(&#39; appearance&#39;)
Definition: IPrediction.h:18
(&#39;beam &#39;)
Definition: IPrediction.h:15
void Clear()
Definition: Spectrum.cxx:878
Charged-current interactions.
Definition: IPrediction.h:39
Neutrinos-only.
Definition: IPrediction.h:49
def sign(x)
Definition: canMan.py:204
(&#39; survival&#39;)
Definition: IPrediction.h:19
Neutral-current interactions.
Definition: IPrediction.h:40
All neutrinos, any flavor.
Definition: IPrediction.h:26
(&#39; appearance&#39;)
Definition: IPrediction.h:16
SpectrumStan ana::IPrediction::PredictComponent ( osc::IOscCalculatorStan calc,
Flavors::Flavors_t  flav,
Current::Current_t  curr,
Sign::Sign_t  sign 
) const
virtualinherited

Reimplemented in ana::PredictionInterp, and ana::PredictionExtrap.

Definition at line 119 of file IPrediction.cxx.

123  {
124  assert(0 && "This Prediction hasn't implemented a Stan-aware PredictComponent()!");
125  }
Spectrum ana::IPrediction::PredictComponentSyst ( osc::IOscCalculator calc,
const SystShifts syst,
Flavors::Flavors_t  flav,
Current::Current_t  curr,
Sign::Sign_t  sign 
) const
virtualinherited

Reimplemented in ana::PredictionInterp, ana::PredictionNumuFAHadE, ana::PredictionCombinePeriods, and ana::PredictionAddRock.

Definition at line 128 of file IPrediction.cxx.

References ana::SystShifts::IsNominal(), and ana::IPrediction::PredictComponent().

Referenced by PlotSysts(), ana::PredictionAddRock::PredictComponentSyst(), ana::PredictionCombinePeriods::PredictComponentSyst(), ana::PredictionNumuFAHadE::PredictComponentSyst(), systematics_extrap_comp_from_pred_interp(), systematics_summary_from_pred_interp(), and systematics_table_from_pred_interp().

133  {
134  assert(syst.IsNominal() && "This Prediction doesn't support PredictSyst(). Did you just mean Predict()?");
135 
136  // Default implementation: no treatment of systematics
137  return PredictComponent(calc, flav, curr, sign);
138  }
virtual Spectrum PredictComponent(osc::IOscCalculator *calc, Flavors::Flavors_t flav, Current::Current_t curr, Sign::Sign_t sign) const =0
def sign(x)
Definition: canMan.py:204
string syst
Definition: plotSysts.py:176
SpectrumStan ana::IPrediction::PredictComponentSyst ( osc::IOscCalculatorStan calc,
const SystShifts syst,
Flavors::Flavors_t  flav,
Current::Current_t  curr,
Sign::Sign_t  sign 
) const
virtualinherited

Reimplemented in ana::PredictionInterp.

Definition at line 142 of file IPrediction.cxx.

References ana::SystShifts::IsNominal(), and ana::IPrediction::PredictComponent().

147  {
148  assert(syst.IsNominal() && "This Prediction doesn't support PredictSyst(). Did you just mean Predict()?");
149 
150  // Default implementation: no treatment of systematics
151  return PredictComponent(calc, flav, curr, sign);
152  }
virtual Spectrum PredictComponent(osc::IOscCalculator *calc, Flavors::Flavors_t flav, Current::Current_t curr, Sign::Sign_t sign) const =0
def sign(x)
Definition: canMan.py:204
string syst
Definition: plotSysts.py:176
Spectrum ana::IPrediction::PredictSyst ( osc::IOscCalculator calc,
const SystShifts syst 
) const
virtualinherited
SpectrumStan ana::IPrediction::PredictSyst ( osc::IOscCalculatorStan calc,
const SystShifts syst 
) const
virtualinherited

Reimplemented in ana::PredictionInterp.

Definition at line 108 of file IPrediction.cxx.

References ana::SystShifts::IsNominal(), and ana::IPrediction::Predict().

110  {
111  assert(syst.IsNominal() && "This Prediction doesn't support PredictSyst(). Did you just mean Predict()?");
112 
113  // Default implementation: no treatment of systematics
114  return Predict(calc);
115  }
virtual Spectrum Predict(osc::IOscCalculator *calc) const =0
string syst
Definition: plotSysts.py:176
Spectrum ana::IPrediction::PredictUnoscillated ( ) const
virtualinherited

Reimplemented in ana::PredictionSterile.

Definition at line 82 of file IPrediction.cxx.

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

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

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

Definition at line 161 of file PredictionExtendToPeripheral.cxx.

References fAntiNuEToAntiNuE, fAntiNuEToAntiNuMu, fAntiNuEToAntiNuTau, fAntiNuMuToAntiNuE, fAntiNuMuToAntiNuMu, fAntiNuMuToAntiNuTau, fIsMerged, fNC, fNCAnti, fNCTot, fNuEToNuE, fNuEToNuMu, fNuEToNuTau, fNuMuToNuE, fNuMuToNuMu, fNuMuToNuTau, ReduceHelper(), and ReduceHelperNC().

162  {
163  assert(!fIsMerged && "Can't call Reduce() twice");
164 
177 
179 
180  fIsMerged = true; // dont collapse the whole universe...
181  }
Spectrum ReduceHelperNC(const Spectrum &s) const
OscillatableSpectrum ReduceHelper(const OscillatableSpectrum &s) const
OscillatableSpectrum ana::PredictionExtendToPeripheral::ReduceHelper ( const OscillatableSpectrum s) const
protected

Definition at line 84 of file PredictionExtendToPeripheral.cxx.

References ana::bins, ana::HistCache::Delete(), fNBinsO, fNCore, fNPIDBin, ana::ReweightableSpectrum::GetBinnings(), ana::ReweightableSpectrum::GetLabels(), MECModelEnuComparisons::i, calib::j, PandAna.Demos.pi0_spectra::labels, livetime, ana::OscillatableSpectrum::Livetime(), ana::HistCache::NewTH2D(), pot, ana::OscillatableSpectrum::POT(), ReduceBinning, SetBinContent(), ana::ReweightableSpectrum::ToTH2(), and submit_syst::x.

Referenced by GetCore(), and Reduce().

85  {
86  std::vector<std::string> labels = s.GetLabels();
87  std::vector<Binning> bins = s.GetBinnings();
88  double pot = s.POT();
89  double livetime = s.Livetime();
90 
91  std::vector<int> Bins;
92 
93  for(int i = 1; i < fNBinsO+1; i++){ Bins.push_back(i); }
94  int iter = fNPIDBin;
95 
96  Bins.erase(Bins.end()-2, Bins.end()); // bye peripheral
97  Bins.erase(Bins.begin()+(fNCore),Bins.begin()+(fNCore+2));
98 
99  while(iter-1){ // peripheral is done
100  for(int j: {9, 2, 1}){
101  Bins.erase(Bins.begin() +((iter-2)* 9+j-1));
102  }
103  --iter;
104  }
105 
106  TH2D* hin = s.ToTH2(s.POT());
107  assert( hin -> GetNbinsX() == fNBinsO && "Merge Peripheral Before Reduce!");
108  TH2D* hout = HistCache::NewTH2D(hin -> GetTitle(), ReduceBinning);
109 
110  int i = 0;
111  for(int x: Bins){
112  ++i;
113  for(int j = 0; j < hin -> GetNbinsY()+2; ++j){
114  hout -> SetBinContent(i, j, hin -> GetBinContent(x, j));
115  }
116  }
117  HistCache::Delete(hin);
118  return OscillatableSpectrum(hout, labels, bins, pot, livetime);
119 
120  }
static TH2D * NewTH2D(const std::string &title, const Binning &bins)
Definition: HistCache.cxx:80
const XML_Char * s
Definition: expat.h:262
static void Delete(TH1D *&h)
Definition: HistCache.cxx:215
#define pot
const double j
Definition: BetheBloch.cxx:29
cout<< "--"<< endl;for(Int_t iP=1;iP<=hyz->GetNbinsX();iP++){for(Int_t iC=1;iC<=hyz->GetNbinsY();iC++){if(hyv->GetBinContent(iP, iC)>-999){goal_hyv-> SetBinContent(iP, iC,-(dy[iP-1][iC-1]))
const Binning bins
Definition: NumuCC_CPiBin.h:8
Spectrum ana::PredictionExtendToPeripheral::ReduceHelperNC ( const Spectrum s) const
protected

Definition at line 124 of file PredictionExtendToPeripheral.cxx.

References ana::bins, ana::HistCache::Delete(), fNBinsO, fNCore, fNPIDBin, fReduceBin, ana::Spectrum::GetBinnings(), ana::Spectrum::GetLabels(), MECModelEnuComparisons::i, calib::j, PandAna.Demos.pi0_spectra::labels, ana::Spectrum::Livetime(), ana::HistCache::New(), pot, ana::Spectrum::POT(), ReduceBinning, SetBinContent(), ana::Spectrum::ToTH1(), and submit_syst::x.

Referenced by GetCore(), and Reduce().

125  {
126  std::vector<std::string> labels = s.GetLabels();
127  std::vector<Binning> bins = s.GetBinnings();
128  double pot = s.POT();
129 
130  std::vector<int> Bins;
131 
132  for(int i = 1; i < fNBinsO+1; i++){ Bins.push_back(i); }
133  int iter = fNPIDBin;
134 
135  Bins.erase(Bins.end()-2, Bins.end()); // bye peripheral
136  Bins.erase(Bins.begin()+(fNCore),Bins.begin()+fNCore+2);
137 
138  while(iter-1){ // peripheral is done
139  for(int j: {9, 2, 1}){
140  Bins.erase(Bins.begin() + ((iter-2)* 9+j-1));
141  }
142  --iter;
143  }
144 
145  TH1D* hin = s.ToTH1(pot);
146  assert( hin -> GetNbinsX() == fNBinsO && "Merge Peripheral Before Reduce!");
147  TH1D* hout = HistCache::New(hin -> GetTitle(), ReduceBinning);
148 
149  double* fromArr = hin -> GetArray();
150  for(int x = 0; x < fReduceBin+2; ++x){
151  hout -> SetBinContent(x, fromArr[Bins[x-1]]);
152  }
153 
154  HistCache::Delete(hin);
155  std::vector<Binning> tmp_bin = {ReduceBinning};
156  return Spectrum(std::unique_ptr<TH1D>(hout), s.GetLabels(), tmp_bin, s.POT(), s.Livetime());
157  }
const XML_Char * s
Definition: expat.h:262
static void Delete(TH1D *&h)
Definition: HistCache.cxx:215
#define pot
const double j
Definition: BetheBloch.cxx:29
cout<< "--"<< endl;for(Int_t iP=1;iP<=hyz->GetNbinsX();iP++){for(Int_t iC=1;iC<=hyz->GetNbinsY();iC++){if(hyv->GetBinContent(iP, iC)>-999){goal_hyv-> SetBinContent(iP, iC,-(dy[iP-1][iC-1]))
const Binning bins
Definition: NumuCC_CPiBin.h:8
static TH1D * New(const std::string &title, const Binning &bins)
Definition: HistCache.cxx:24
void ana::PredictionExtendToPeripheral::SaveTo ( TDirectory *  dir) const
overridevirtual

Reimplemented from ana::IPrediction.

Definition at line 428 of file PredictionExtendToPeripheral.cxx.

References fBins, fMergePeripheral, fPredCore, fPredNoExtrap, ana::Binning::SaveTo(), ana::PredictionNoExtrap::SaveTo(), ana::IPrediction::SaveTo(), and tmp.

Referenced by make_nueFDprediction_kinematics_FHC(), make_nueFDprediction_kinematics_FHC_REW(), make_nueFDprediction_kinematics_RHC(), and make_nueFDprediction_kinematics_RHC_REW().

429  {
430  TDirectory* tmp = gDirectory;
431 
432  dir->cd();
433 
434  TObjString("PredictionExtendToPeripheral").Write("type");
435 
436  fPredCore->SaveTo(dir->mkdir("predCore"));
437  fPredNoExtrap->SaveTo(dir->mkdir("predNoExtrap"));
438 
439  fBins.SaveTo(dir->mkdir("bins"));
440 
441  TVectorD vMergePeripheral(1);
442  vMergePeripheral[0] = fMergePeripheral;
443  vMergePeripheral.Write("mergePeripheral");
444 
445  tmp->cd();
446  }
virtual void SaveTo(TDirectory *dir) const
Float_t tmp
Definition: plot.C:36
void SaveTo(TDirectory *dir) const
Definition: Binning.cxx:189
virtual void SaveTo(TDirectory *dir) const override
TDirectory * dir
Definition: macro.C:5
void ana::PredictionExtendToPeripheral::Scale ( double  from,
double  to,
double  scale 
)

Definition at line 184 of file PredictionExtendToPeripheral.cxx.

References om::cout, allTimeWatchdog::endl, fAntiNuEToAntiNuE, fAntiNuEToAntiNuMu, fAntiNuEToAntiNuTau, fAntiNuMuToAntiNuE, fAntiNuMuToAntiNuMu, fAntiNuMuToAntiNuTau, fNC, fNCAnti, fNCTot, fNuEToNuE, fNuEToNuMu, fNuEToNuTau, fNuMuToNuE, fNuMuToNuMu, fNuMuToNuTau, ana::OscillatableSpectrum::Scale(), and ana::Spectrum::Scale().

185  {
186  if (from == +12 && to == +12) fNuEToNuE->Scale(scale);
187  else if (from == +12 && to == +14) fNuEToNuMu->Scale(scale);
188  else if (from == +12 && to == +16) fNuEToNuTau->Scale(scale);
189 
190  else if (from == +14 && to == +12) fNuMuToNuE->Scale(scale);
191  else if (from == +14 && to == +14) fNuMuToNuMu->Scale(scale);
192  else if (from == +14 && to == +16) fNuMuToNuTau->Scale(scale);
193 
194  else if (from == -12 && to == -12) fAntiNuEToAntiNuE->Scale(scale);
195  else if (from == -12 && to == -14) fAntiNuEToAntiNuMu->Scale(scale);
196  else if (from == -12 && to == -16) fAntiNuEToAntiNuTau->Scale(scale);
197 
198  else if (from == -14 && to == -12) fAntiNuMuToAntiNuE->Scale(scale);
199  else if (from == -14 && to == -14) fAntiNuMuToAntiNuMu->Scale(scale);
200  else if (from == -14 && to == -16) fAntiNuMuToAntiNuTau->Scale(scale);
201  else if (from == 0 && to == 0){
202  fNCTot->Scale(scale);
203  fNC->Scale(scale);
204  fNCAnti->Scale(scale);
205  }
206  else { std::cout<<"PredictionExtendToPeripheral: this is a joke, right... 0.0"<<std::endl; abort();}
207  }
void Scale(double c)
Multiply this spectrum by a constant c.
Definition: Spectrum.cxx:734
Double_t scale
Definition: plot.C:25
OStream cout
Definition: OStream.cxx:6
void Scale(double scale) const

Member Data Documentation

OscillatableSpectrum* ana::PredictionExtendToPeripheral::fAntiNuEToAntiNuE
protected
OscillatableSpectrum* ana::PredictionExtendToPeripheral::fAntiNuEToAntiNuMu
protected
OscillatableSpectrum* ana::PredictionExtendToPeripheral::fAntiNuEToAntiNuTau
protected
OscillatableSpectrum* ana::PredictionExtendToPeripheral::fAntiNuMuToAntiNuE
protected
OscillatableSpectrum* ana::PredictionExtendToPeripheral::fAntiNuMuToAntiNuMu
protected
OscillatableSpectrum* ana::PredictionExtendToPeripheral::fAntiNuMuToAntiNuTau
protected
Binning ana::PredictionExtendToPeripheral::fBins
protected

Definition at line 84 of file PredictionExtendToPeripheral.h.

Referenced by SaveTo().

const int ana::PredictionExtendToPeripheral::fEnergyBins = fNBinsI/fNPIDBin
protected
bool ana::PredictionExtendToPeripheral::fIsMerged
protected

Definition at line 124 of file PredictionExtendToPeripheral.h.

Referenced by PredictionExtendToPeripheral(), and Reduce().

bool ana::PredictionExtendToPeripheral::fMergePeripheral
protected
const int ana::PredictionExtendToPeripheral::fNBinsI = fBins.NBins()
protected
const int ana::PredictionExtendToPeripheral::fNBinsO = fNBinsI-fPeriNum
protected
Spectrum* ana::PredictionExtendToPeripheral::fNC
protected
Spectrum* ana::PredictionExtendToPeripheral::fNCAnti
protected
const int ana::PredictionExtendToPeripheral::fNCore = (fNPIDBin-1)*fEnergyBins
protected
Spectrum* ana::PredictionExtendToPeripheral::fNCTot
protected
int ana::PredictionExtendToPeripheral::fNPIDBin
protected

Definition at line 86 of file PredictionExtendToPeripheral.h.

Referenced by ReduceHelper(), and ReduceHelperNC().

OscillatableSpectrum* ana::PredictionExtendToPeripheral::fNuEToNuE
protected
OscillatableSpectrum* ana::PredictionExtendToPeripheral::fNuEToNuMu
protected
OscillatableSpectrum* ana::PredictionExtendToPeripheral::fNuEToNuTau
protected
OscillatableSpectrum* ana::PredictionExtendToPeripheral::fNuMuToNuE
protected
OscillatableSpectrum* ana::PredictionExtendToPeripheral::fNuMuToNuMu
protected
OscillatableSpectrum* ana::PredictionExtendToPeripheral::fNuMuToNuTau
protected
const int ana::PredictionExtendToPeripheral::fPeriBin = fNCore+int((fEnergyBins-fPeriNum)/2)+1
protected

Definition at line 95 of file PredictionExtendToPeripheral.h.

Referenced by MergePeripheral(), and MergePeripheralOsc().

const int ana::PredictionExtendToPeripheral::fPeriNum = int(fEnergyBins/2)
protected

Definition at line 91 of file PredictionExtendToPeripheral.h.

IPrediction* ana::PredictionExtendToPeripheral::fPredCore
protected
PredictionNoExtrap* ana::PredictionExtendToPeripheral::fPredNoExtrap
protected
const int ana::PredictionExtendToPeripheral::fReduceBin = fNBinsI - 2* fNPIDBin - fEnergyBins +1
protected

Definition at line 102 of file PredictionExtendToPeripheral.h.

Referenced by ReduceHelperNC().

const Binning ana::PredictionExtendToPeripheral::ReduceBinning = Binning::Simple(fReduceBin, 0, fReduceBin)
protected

Definition at line 103 of file PredictionExtendToPeripheral.h.

Referenced by ReduceHelper(), and ReduceHelperNC().


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