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

Helper for PredictionInterpTemplates. More...

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

Inheritance diagram for ana::PredictionTemplateShift:
ana::IPrediction

Public Member Functions

 PredictionTemplateShift (IPrediction *pred, const NueSystFromHist *syst, double sigma)
 
Spectrum PredictComponent (osc::IOscCalculator *calc, Flavors::Flavors_t flav, Current::Current_t curr, Sign::Sign_t sign) const override
 
Spectrum Predict (osc::IOscCalculator *calc) const override
 
void SaveTo (TDirectory *dir) const override
 
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
 
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< PredictionTemplateShiftLoadFrom (TDirectory *dir)
 

Protected Member Functions

Spectrum Weight (const Spectrum &s, OscChannel chan) const
 

Protected Attributes

IPredictionfPred
 
const NueSystFromHistfSyst
 
double fSigma
 

Detailed Description

Helper for PredictionInterpTemplates.

Definition at line 10 of file PredictionInterpTemplates.h.

Constructor & Destructor Documentation

ana::PredictionTemplateShift::PredictionTemplateShift ( IPrediction pred,
const NueSystFromHist syst,
double  sigma 
)
inline

Member Function Documentation

virtual OscillatableSpectrum ana::IPrediction::ComponentCC ( int  from,
int  to 
) const
inlinevirtualinherited
virtual Spectrum ana::IPrediction::ComponentNC ( ) const
inlinevirtualinherited

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

Definition at line 111 of file IPrediction.h.

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

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

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

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

Definition at line 113 of file IPrediction.h.

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

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

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

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

Definition at line 109 of file IPrediction.h.

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

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

110  {std::cout << "WARNING! ComponentNCTotal is unimplemented in IPrediction" << std::endl; abort();}
OStream cout
Definition: OStream.cxx:6
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  }
std::unique_ptr< PredictionTemplateShift > ana::PredictionTemplateShift::LoadFrom ( TDirectory *  dir)
static

Definition at line 104 of file PredictionInterpTemplates.cxx.

References om::cout, allTimeWatchdog::endl, ana::getAllNueSecondAnaTemplateSysts(), ana::kSystCVN, ana::kSystLEM, ana::kSystLID, ana::LoadFrom< IPrediction >(), BlessedPlots::pid, plot_validation_datamc::pred, ana::PredictionInterpTemplates::PredictionInterpTemplates(), PredictionTemplateShift(), runNovaSAM::release, plotSysts::syst, and getGoodRuns4SAM::tag.

Referenced by ana::LoadFrom< IPrediction >(), and Predict().

105  {
106  TObjString* tag = (TObjString*)dir->Get("type");
107  assert(tag);
108  assert(tag->GetString() == "PredictionTemplateShift");
109 
110  IPrediction* pred = ana::LoadFrom<IPrediction>(dir->GetDirectory("pred")).release();
111 
112  TObjString* tosSyst = (TObjString*)dir->Get("syst");
113  assert(tosSyst);
114  const std::string ssyst = tosSyst->GetString().Data();
115 
116  // Ugh, this is pretty dreadful. TODO think about how to serialize
117  // systematics better. ROOT6 to the rescue?
118  const NueSystFromHist* syst = 0;
120  for(const NueSystFromHist* s: getAllNueSecondAnaTemplateSysts(pid)){
121  if(s->ShortName() == ssyst){
122  if(syst != 0 && syst != s){
123  std::cout << "Error: multiple systs found matching '"
124  << ssyst << "'" << std::endl;
125  abort();
126  }
127  syst = s;
128  }
129  }
130  }
131  if(!syst){
132  std::cout << "Error: no syst found matching '" << ssyst << "'" << std::endl;
133  abort();
134  }
135 
136  TVectorD* vSigma = (TVectorD*)dir->Get("sigma");
137  assert(vSigma);
138  assert(vSigma->GetNrows() == 1);
139 
140  return std::unique_ptr<PredictionTemplateShift>(new PredictionTemplateShift(pred, syst, (*vSigma)[0]));
141  }
const XML_Char * s
Definition: expat.h:262
NuESystPID
Definition: NueSysts.h:12
OStream cout
Definition: OStream.cxx:6
PredictionTemplateShift(IPrediction *pred, const NueSystFromHist *syst, double sigma)
::xsd::cxx::tree::string< char, simple_type > string
Definition: Database.h:154
std::unique_ptr< IPrediction > LoadFrom< IPrediction >(TDirectory *dir)
Definition: IPrediction.cxx:38
TDirectory * dir
Definition: macro.C:5
std::vector< const NueSystFromHist * > getAllNueSecondAnaTemplateSysts(NuESystPID pid)
string syst
Definition: plotSysts.py:176
Spectrum ana::PredictionTemplateShift::Predict ( osc::IOscCalculator calc) const
inlineoverridevirtual

Implements ana::IPrediction.

Definition at line 28 of file PredictionInterpTemplates.h.

References febshutoff_auto::chan, dir, ana::Flavors::kAll, ana::Current::kBoth, ana::Sign::kBoth, LoadFrom(), PredictComponent(), SaveTo(), and Weight().

29  {
31  }
Spectrum PredictComponent(osc::IOscCalculator *calc, Flavors::Flavors_t flav, Current::Current_t curr, Sign::Sign_t sign) const override
Interactions of both types.
Definition: IPrediction.h:42
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::PredictionTemplateShift::PredictComponent ( osc::IOscCalculator calc,
Flavors::Flavors_t  flav,
Current::Current_t  curr,
Sign::Sign_t  sign 
) const
overridevirtual

Implements ana::IPrediction.

Definition at line 45 of file PredictionInterpTemplates.cxx.

References ana::Spectrum::Clear(), fPred, ana::Flavors::kAll, ana::Sign::kBoth, ana::Current::kCC, ana::Current::kNC, ana::kNCToNC, ana::Flavors::kNuEToNuE, ana::kNuEToNuECC, ana::Flavors::kNuEToNuMu, ana::kNuEToNuMuCC, ana::Flavors::kNuEToNuTau, ana::kNuEToNuTauCC, ana::Flavors::kNuMuToNuE, ana::kNuMuToNuECC, ana::Flavors::kNuMuToNuMu, ana::kNuMuToNuMuCC, ana::Flavors::kNuMuToNuTau, ana::kNuMuToNuTauCC, ana::IPrediction::PredictComponent(), runNovaSAM::ret, and Weight().

Referenced by Predict(), and PredictionTemplateShift().

49  {
50  // Just predict something to get the right binning
52  ret.Clear();
53 
54  if(curr & Current::kCC){
55  if(flav & Flavors::kNuEToNuE)
56  ret += Weight(fPred->PredictComponent(calc, Flavors::kNuEToNuE, Current::kCC, sign), kNuEToNuECC);
57 
58  if(flav & Flavors::kNuMuToNuMu)
59  ret += Weight(fPred->PredictComponent(calc, Flavors::kNuMuToNuMu, Current::kCC, sign), kNuMuToNuMuCC);
60 
61  if(flav & Flavors::kNuEToNuMu)
62  ret += Weight(fPred->PredictComponent(calc, Flavors::kNuEToNuMu, Current::kCC, sign), kNuEToNuMuCC);
63 
64  if(flav & Flavors::kNuEToNuTau)
65  ret += Weight(fPred->PredictComponent(calc, Flavors::kNuEToNuTau, Current::kCC, sign), kNuEToNuTauCC);
66 
67  if(flav & Flavors::kNuMuToNuE)
68  ret += Weight(fPred->PredictComponent(calc, Flavors::kNuMuToNuE, Current::kCC, sign), kNuMuToNuECC);
69 
70  if(flav & Flavors::kNuMuToNuTau)
71  ret += Weight(fPred->PredictComponent(calc, Flavors::kNuMuToNuTau, Current::kCC, sign), kNuMuToNuTauCC);
72  }
73  if(curr & Current::kNC){
74  assert(flav == Flavors::kAll); // Don't know how to calculate anything else
75  assert(sign == Sign::kBoth); // Why would you want to split NCs out by sign?
76 
77  ret += Weight(fPred->PredictComponent(calc, Flavors::kAll, Current::kNC, Sign::kBoth), kNCToNC);
78  }
79 
80  return ret;
81  }
(&#39; appearance&#39;)
Definition: IPrediction.h:18
virtual Spectrum PredictComponent(osc::IOscCalculator *calc, Flavors::Flavors_t flav, Current::Current_t curr, Sign::Sign_t sign) const =0
(&#39;beam &#39;)
Definition: IPrediction.h:15
Spectrum Weight(const Spectrum &s, OscChannel chan) const
void Clear()
Definition: Spectrum.cxx:878
Charged-current interactions.
Definition: IPrediction.h:39
def sign(x)
Definition: canMan.py:204
(&#39; survival&#39;)
Definition: IPrediction.h:19
Neutral-current interactions.
Definition: IPrediction.h:40
Both neutrinos and antineutrinos.
Definition: IPrediction.h:52
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::PredictionTemplateShift::SaveTo ( TDirectory *  dir) const
overridevirtual

Reimplemented from ana::IPrediction.

Definition at line 84 of file PredictionInterpTemplates.cxx.

References fPred, fSigma, fSyst, ana::IPrediction::SaveTo(), ana::ISyst::ShortName(), and tmp.

Referenced by Predict().

85  {
86  TDirectory* tmp = gDirectory;
87 
88  dir->cd();
89  TObjString("PredictionTemplateShift").Write("type");
90 
91  fPred->SaveTo(dir->mkdir("pred"));
92 
93  TObjString sSyst = fSyst->ShortName().c_str();
94  sSyst.Write("syst");
95 
96  TVectorD vSigma(1);
97  vSigma[0] = fSigma;
98  vSigma.Write("sigma");
99 
100  tmp->cd();
101  }
virtual const std::string & ShortName() const final
The name printed out to the screen.
Definition: ISyst.h:27
virtual void SaveTo(TDirectory *dir) const
Float_t tmp
Definition: plot.C:36
TDirectory * dir
Definition: macro.C:5
Spectrum ana::PredictionTemplateShift::Weight ( const Spectrum s,
OscChannel  chan 
) const
protected

Definition at line 15 of file PredictionInterpTemplates.cxx.

References ana::AlmostEqual(), fSigma, fSyst, ana::Spectrum::GetBinnings(), ana::Spectrum::GetLabels(), h1, h2, MECModelEnuComparisons::i, ana::kNueSAEnergyBinning, ana::kPOT, ana::Spectrum::Livetime(), ana::NueSystFromHist::PIDBinning(), ana::Spectrum::POT(), ana::Spectrum::ToTH1(), ana::ToTH2(), w, and ana::NueSystFromHist::WeightFor().

Referenced by Predict(), and PredictComponent().

17  {
18  TH1D* h1 = s.ToTH1(s.POT(), kPOT);
19  TH2* h2 = ToTH2(s, s.POT(), kPOT,
21 
22  assert(h1->GetNbinsX() == 30);
23  assert(h2->GetNbinsX() == 3);
24  assert(h2->GetNbinsY() == 10);
25 
26  for(int i = 0; i < h1->GetNbinsX(); ++i){
27  const int ipid = i / 10;
28  const int iE = i % 10;
29 
30  // Double-check indexing
31  assert(AlmostEqual(h1->GetBinContent(i+1), h2->GetBinContent(ipid+1, iE+1)));
32 
33  const double w = fSyst->WeightFor(chan, fSigma,
34  h2->GetXaxis()->GetBinCenter(ipid+1),
35  h2->GetYaxis()->GetBinCenter(iE+1));
36 
37  h1->SetBinContent(i+1, w*h1->GetBinContent(i+1));
38  }
39 
40  delete h2;
41  return Spectrum(h1, s.GetLabels(), s.GetBinnings(), s.POT(), s.Livetime());
42  }
const Binning kNueSAEnergyBinning
The energy part of the SA 2D binning.
Definition: Binning.h:100
const XML_Char * s
Definition: expat.h:262
double WeightFor(OscChannel chan, double sigma, double pid, double nueenergy) const
Binning PIDBinning() const
bool AlmostEqual(double a, double b)
Definition: Utilities.cxx:732
TH2 * ToTH2(const Spectrum &s, double exposure, ana::EExposureType expotype, const Binning &binsx, const Binning &binsy, ana::EBinType bintype)
Definition: Utilities.cxx:374
TH1F * h2
Definition: plot.C:45
TH1F * h1
Float_t w
Definition: plot.C:20

Member Data Documentation

IPrediction* ana::PredictionTemplateShift::fPred
protected

Definition at line 40 of file PredictionInterpTemplates.h.

Referenced by PredictComponent(), and SaveTo().

double ana::PredictionTemplateShift::fSigma
protected

Definition at line 42 of file PredictionInterpTemplates.h.

Referenced by SaveTo(), and Weight().

const NueSystFromHist* ana::PredictionTemplateShift::fSyst
protected

Definition at line 41 of file PredictionInterpTemplates.h.

Referenced by SaveTo(), and Weight().


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