PredictionSterile.cxx
Go to the documentation of this file.
2 
3 #include <iostream>
4 #include <typeinfo>
5 #include <utility>
6 
8 
11 
12 #include "TDirectory.h"
13 #include "TObjString.h"
14 
15 namespace ana
16 {
17  //----------------------------------------------------------------------
18  PredictionSterile::PredictionSterile(std::unique_ptr<ModularExtrapSterile> &&extrap)
19  : PredictionExtrap(std::move(extrap))
20  // This base class constructor initializes everything
21  {
22  }
23 
24  //---------------------------------------------------------------------------
26  : PredictionExtrap(std::move(load))
27  {
28  }
29 
30  //----------------------------------------------------------------------
32  {
33  // Use an osc::OscCalcSterile to avoid warnings/errors from PredictComponent
34  // Just set to a 3 flavor calculator, with all oscillation parameters to 0
36  noosc.SetNFlavors(3);
37  noosc.SetL(0);
38  noosc.SetRho(0);
39  noosc.SetAngle(1, 2, 0);
40  noosc.SetAngle(1, 3, 0);
41  noosc.SetAngle(2, 3, 0);
42  noosc.SetDelta(1, 3, 0);
43  noosc.SetDm(2, 0);
44  noosc.SetDm(3, 0);
45  return Predict(&noosc);
46  }
47 
48  //----------------------------------------------------------------------
50  Flavors::Flavors_t flav,
52  Sign::Sign_t sign) const
53  {
54  Spectrum ret = fExtrap->NCTotalComponent(); // Get binning
55  ret.Clear();
56 
57  if(curr & Current::kCC){
58  // Nothing new here
59  ret += PredictionExtrap::PredictComponent(calc, flav, Current::kCC, sign);
60  }
61  if(curr & Current::kNC){
62  osc::OscCalcSterile* calc_sterile = osc::DowncastToSterile(calc);
63 
64  if(calc_sterile) {
65  // The PredictionSterile constructors all require a ModularExtrap Sterile,
66  // so this should be safe unless someone else makes a change that breaks this
67  ModularExtrapSterile* extrap = static_cast<ModularExtrapSterile*>(fExtrap.get());
68 
69  // Oscillate NCs as <start flavor> to any active flavor,
70  // then multiply by the proportion of NCs that originate as <start flavor>
71  if(flav & Flavors::kNuEToNuE && sign & Sign::kNu)
72  ret += extrap->OscNCComponent().Oscillated(calc_sterile, +12, 0)
73  *extrap->NCNueProportion();
74  if(flav & Flavors::kNuEToNuE && sign & Sign::kAntiNu)
75  ret += extrap->OscNCComponent().Oscillated(calc_sterile, -12, 0)
76  *extrap->NCAntiNueProportion();
77 
78  if(flav & Flavors::kNuMuToNuMu && sign & Sign::kNu)
79  ret += extrap->OscNCComponent().Oscillated(calc_sterile, +14, 0)
80  *extrap->NCNumuProportion();
81  if(flav & Flavors::kNuMuToNuMu && sign & Sign::kAntiNu)
82  ret += extrap->OscNCComponent().Oscillated(calc_sterile, -14, 0)
83  *extrap->NCAntiNumuProportion();
84  }
85  else {
86  std::cerr << "Input calculator was not of type OscCalcSterile." << std::endl
87  << "Reverting to 3 Flavor oscillation with no NC oscillations." << std::endl;
88 
89  ret += PredictionExtrap::PredictComponent(calc, flav, Current::kNC, sign);
90  }
91  }
92 
93  return ret;
94  }
95 
96  //----------------------------------------------------------------------
97  void PredictionSterile::SaveTo(TDirectory* dir, const std::string& name) const
98  {
99  TDirectory* tmp = gDirectory;
100 
101  PredictionExtrap::SaveTo(dir, name);
102 
103  dir = (TDirectory*)dir->GetDirectory(name.c_str()); // switch to subdir
104  dir->cd();
105 
106  TObjString("PredictionSterile").Write("type", TObject::kOverwrite);
107 
108  delete dir;
109 
110  tmp->cd();
111  }
112 
113  //----------------------------------------------------------------------
114  std::unique_ptr<PredictionSterile> PredictionSterile::LoadFrom(TDirectory* dir, const std::string& name)
115  {
116  TObjString* ptag = (TObjString*)dir->Get((name+"/type").c_str());
117  assert(ptag);
118 
119  const TString tag = ptag->GetString();
120  assert(tag.CompareTo("PredictionSterile") == 0);
121  delete ptag;
122 
123  std::unique_ptr<PredictionSterile> ret(
124  new PredictionSterile( std::move( *(PredictionExtrap::LoadFrom(dir, name).release()) ) )
125  );
126 
127  return ret;
128  }
129 }
Spectrum PredictComponent(osc::IOscCalc *calc, Flavors::Flavors_t flav, Current::Current_t curr, Sign::Sign_t sign) const override
const XML_Char * name
Definition: expat.h:151
Cuts and Vars for the 2020 FD DiF Study.
Definition: vars.h:6
void SetNFlavors(int nflavors)
Antineutrinos-only.
Definition: IPrediction.h:50
Ratio NCAntiNumuProportion() const
(&#39;beam &#39;)
Definition: IPrediction.h:15
General interface to oscillation calculators.
Definition: StanTypedefs.h:22
void load(std::string lib)
Definition: load_libs.C:3
void SetDelta(int i, int j, double delta)
static std::unique_ptr< PredictionSterile > LoadFrom(TDirectory *dir, const std::string &name)
Adapt the PMNS_Sterile calculator to standard interface.
OStream cerr
Definition: OStream.cxx:7
Ratio NCNueProportion() const
Return the proportion of NCs that originate as a given neutrino flavor/sign.
virtual void SaveTo(TDirectory *dir, const std::string &name) const override
void Clear()
Definition: Spectrum.cxx:372
OscillatableSpectrum OscNCComponent() const
Return the oscillatable NC component.
Float_t tmp
Definition: plot.C:36
osc::OscCalcDumb calc
Ratio NCNumuProportion() const
Representation of a spectrum in any variable, with associated POT.
Definition: Spectrum.h:40
Charged-current interactions.
Definition: IPrediction.h:39
Ratio NCAntiNueProportion() const
Spectrum Predict(osc::IOscCalc *calc) const override
static std::unique_ptr< PredictionExtrap > LoadFrom(TDirectory *dir, const std::string &name)
osc::NoOscillations noosc
Definition: NueSystFuncs.h:44
Neutrinos-only.
Definition: IPrediction.h:49
const OscCalcSterile * DowncastToSterile(const IOscCalc *calc)
(&#39; survival&#39;)
Definition: IPrediction.h:19
void SetAngle(int i, int j, double th)
::xsd::cxx::tree::string< char, simple_type > string
Definition: Database.h:154
virtual void SaveTo(TDirectory *dir, const std::string &name) const override
Spectrum Oscillated(osc::IOscCalc *calc, int from, int to) const
void SetDm(int i, double dm)
std::unique_ptr< IExtrap > fExtrap
virtual void SetL(double L) override
TDirectory * dir
Definition: macro.C:5
virtual void SetRho(double rho) override
virtual Spectrum PredictUnoscillated() const override
Neutral-current interactions.
Definition: IPrediction.h:40
assert(nhit_max >=nhit_nbins)
Take the output of an extrapolation and oscillate it as required.
virtual Spectrum PredictComponent(osc::IOscCalc *calc, Flavors::Flavors_t flav, Current::Current_t curr, Sign::Sign_t sign) const override
def sign(x)
Definition: canMan.py:197