PredictionNoOsc.cxx
Go to the documentation of this file.
2 
6 
7 #include "CAFAna/Core/Loaders.h"
8 
10 
11 #include "TDirectory.h"
12 #include "TObjString.h"
13 
14 
15 namespace ana
16 {
17  REGISTER_LOADFROM("PredictionNoOsc", IPrediction, PredictionNoOsc);
18 
19  //----------------------------------------------------------------------
21  const std::string& label,
22  const Binning& bins,
23  const Var& var,
24  const Cut& cut,
25  const SystShifts& shift,
26  const Var& wei)
27  : PredictionNoOsc(loader, HistAxis(label, bins, var), cut, shift, wei)
28  {
29  }
30 
31  //----------------------------------------------------------------------
33  const HistAxis& axis,
34  const Cut& cut,
35  const SystShifts& shift,
36  const Var& wei)
37  : fSpectrum( loader, axis, cut, shift, wei),
38  fSpectrumNC( loader, axis, cut && kIsNC, shift, wei),
39  fSpectrumNumu( loader, axis, cut && !kIsNC && kIsNumuCC && !kIsAntiNu, shift, wei),
40  fSpectrumNumubar(loader, axis, cut && !kIsNC && kIsNumuCC && kIsAntiNu, shift, wei),
41  fSpectrumNue( loader, axis, cut && !kIsNC && kIsBeamNue && !kIsAntiNu, shift, wei),
42  fSpectrumNuebar( loader, axis, cut && !kIsNC && kIsBeamNue && kIsAntiNu, shift, wei)
43  {
44  }
45 
46  //----------------------------------------------------------------------
48  Flavors::Flavors_t flav,
50  Sign::Sign_t sign) const
51  {
52  if(flav == Flavors::kAll &&
53  curr == Current::kBoth &&
54  sign == Sign::kBoth)
55  return Predict((osc::IOscCalc*)(nullptr)); // Faster
56 
57  if(curr & Current::kNC){
58  // We don't have NC broken down by sign or flavour
59  assert(flav & Flavors::kAll && sign & Sign::kBoth);
60  return fSpectrumNC;
61  }
62 
63  assert(curr == Current::kCC);
64 
65  using namespace Flavors;
66  using namespace Current;
67  using namespace Sign;
68 
70  ret.Clear();
71 
72  // Safe to assume by this point that it's 100% CC
73  if(flav & kNuMuToNuMu && sign & kNu) ret += fSpectrumNumu;
74  if(flav & kNuMuToNuMu && sign & kAntiNu) ret += fSpectrumNumubar;
75  if(flav & kNuEToNuE && sign & kNu) ret += fSpectrumNue;
76  if(flav & kNuEToNuE && sign & kAntiNu) ret += fSpectrumNuebar;
77 
78  return ret;
79  }
80 
81  //----------------------------------------------------------------------
82  void PredictionNoOsc::SaveTo(TDirectory* dir, const std::string& name) const
83  {
84  TDirectory* tmp = gDirectory;
85 
86  dir = dir->mkdir(name.c_str()); // switch to subdir
87  dir->cd();
88 
89  TObjString("PredictionNoOsc").Write("type");
90 
91  fSpectrum.SaveTo(dir, "spect");
92  fSpectrumNC.SaveTo(dir, "spect_nc");
93  fSpectrumNumu.SaveTo(dir, "spect_numu");
94  fSpectrumNumubar.SaveTo(dir, "spect_numubar");
95  fSpectrumNue.SaveTo(dir, "spect_nue");
96  fSpectrumNuebar.SaveTo(dir, "spect_nuebar");
97 
98  dir->Write();
99  delete dir;
100 
101  tmp->cd();
102  }
103 
104  //----------------------------------------------------------------------
105  std::unique_ptr<PredictionNoOsc> PredictionNoOsc::LoadFrom(TDirectory* dir, const std::string& name)
106  {
107  dir = dir->GetDirectory(name.c_str()); // switch to subdir
108  assert(dir);
109 
111  *ana::LoadFrom<Spectrum>(dir, "spect"),
112  *ana::LoadFrom<Spectrum>(dir, "spect_nc"),
113  *ana::LoadFrom<Spectrum>(dir, "spect_numu"),
114  *ana::LoadFrom<Spectrum>(dir, "spect_numubar"),
115  *ana::LoadFrom<Spectrum>(dir, "spect_nue"),
116  *ana::LoadFrom<Spectrum>(dir, "spect_nuebar"));
117 
118  delete dir;
119 
120  // Can't use make_unique because constructor is protected
121  return std::unique_ptr<PredictionNoOsc>(ret);
122  }
123 }
const XML_Char * name
Definition: expat.h:151
const Cut kIsNumuCC(CCFlavSel(14, 14))
Select CC .
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
Antineutrinos-only.
Definition: IPrediction.h:50
virtual void SaveTo(TDirectory *dir, const std::string &name) const override
Simple record of shifts applied to systematic parameters.
Definition: SystShifts.h:20
(&#39;beam &#39;)
Definition: IPrediction.h:15
General interface to oscillation calculators.
Definition: StanTypedefs.h:22
const Cut kIsAntiNu([](const caf::SRProxy *sr){if(sr->mc.nnu==0) return false;assert(sr->mc.nnu==1);return sr->mc.nu[0].pdg< 0;})
Is this truly an antineutrino?
Definition: TruthCuts.h:53
const Cut kIsBeamNue(CCFlavSel(12, 12))
Select CC .
static std::unique_ptr< PredictionNoOsc > LoadFrom(TDirectory *dir, const std::string &name)
void Clear()
Definition: Spectrum.cxx:372
Float_t tmp
Definition: plot.C:36
Representation of a spectrum in any variable, with associated POT.
Definition: Spectrum.h:40
const char * label
Charged-current interactions.
Definition: IPrediction.h:39
virtual Spectrum PredictComponent(osc::IOscCalc *calc, Flavors::Flavors_t flav, Current::Current_t curr, Sign::Sign_t sign) const override
Interactions of both types.
Definition: IPrediction.h:42
PredictionNoOsc(SpectrumLoaderBase &loader, const HistAxis &axis, const Cut &cut, const SystShifts &shift=kNoShift, const Var &wei=kUnweighted)
const Cut kIsNC([](const caf::SRProxy *sr){if(sr->mc.nnu==0) return false;assert(sr->mc.nnu==1);return!sr->mc.nu[0].iscc;})
Is this a Neutral Current event?
Definition: TruthCuts.h:8
void SaveTo(TDirectory *dir, const std::string &name) const
Definition: Spectrum.cxx:517
loader
Definition: demo0.py:10
(&#39; survival&#39;)
Definition: IPrediction.h:19
Base class for the various types of spectrum loader.
const Binning bins
Definition: NumuCC_CPiBin.h:8
::xsd::cxx::tree::string< char, simple_type > string
Definition: Database.h:154
const Cut cut
Definition: exporter_fd.C:30
TDirectory * dir
Definition: macro.C:5
REGISTER_LOADFROM("BENDecomp", IDecomp, BENDecomp)
Neutral-current interactions.
Definition: IPrediction.h:40
assert(nhit_max >=nhit_nbins)
Both neutrinos and antineutrinos.
Definition: IPrediction.h:52
virtual Spectrum Predict(osc::IOscCalc *) const override
All neutrinos, any flavor.
Definition: IPrediction.h:26
def sign(x)
Definition: canMan.py:197
Prediction that wraps a simple Spectrum.