NDOscCurve.cxx
Go to the documentation of this file.
2 
3 #include "CAFAna/Core/Binning.h"
4 
6 
7 #include <cassert>
8 #include <map>
9 
10 #include "TH1.h"
11 #include "TMath.h"
12 
13 namespace ana
14 {
15  //----------------------------------------------------------------------
16  /// Helper for constructors
17  Eigen::ArrayXd ToEigenSterile(osc::IOscCalc* calc, int from, int to)
18  {
20 
21  double lold = sterile->GetL();
22  sterile->SetL(1.0);
23 
24  const unsigned int N = kTrueLOverTrueEBins.NBins();
25 
26  // Have to allow for underflow and overflow
27  Eigen::ArrayXd ret(N+2);
28  ret[0] = 0; // underflow
29  ret[N+1] = (from == to || to == 0) ? 1 : 0; // overflow
30 
31  for(unsigned int i = 1; i <= N; ++i){
32  const double x0 = kTrueLOverTrueEBins.Edges()[i-1];
33  const double x1 = kTrueLOverTrueEBins.Edges()[i];
34 
35  const double LOverE = (x0+x1)/2;
36  if(LOverE > 0){
37  //Adding Oscillation Averaging Function from docDB-15433
38  double delta = x1-x0;
39  double Dmsq = sterile->GetDm(4);
40  double f = 2*1.27*Dmsq;
41  double dLoE = 0.;
42  if(f != 0) dLoE = TMath::ACos(TMath::Sin(0.5*f*delta)/(0.5*f*delta) )/f;
43  double LoE_plus = LOverE + dLoE;
44  double LoE_minus = LOverE - dLoE;
45  double AvProb = 0.5*(sterile->P(from,to,1.0/LoE_minus)+sterile->P(from,to,1.0/LoE_plus));
46  ret[i] = AvProb;
47  }
48  else{
49  ret[i] = (from == to) ? 1 : 0;
50  }
51  }
52 
53  sterile->SetL(lold);
54 
55  return ret;
56  }
57 
58  //----------------------------------------------------------------------
60  : Ratio(Hist::Adopt(ToEigenSterile(calc, from, to)),
61  std::vector<Binning>(1, kTrueEnergyBins),
62  std::vector<std::string>(1, "True Energy (GeV)")),
63  fFrom(from), fTo(to)
64  {
65  }
66 
67  //----------------------------------------------------------------------
69  {
70  }
71 
72  //----------------------------------------------------------------------
73  TH1D* NDOscCurve::ToTH1(bool title) const
74  {
75  // Could have a file temporarily open
76  DontAddDirectory guard;
77 
78  TH1D* ret = Ratio::ToTH1();
79  ret->GetYaxis()->SetTitle("Probability");
80 
81  if(title){
82  // Don't do this work unless it's explicitly requested
83  std::map<int, std::string> nus;
84  nus[12] = nus[-12] = "e";
85  nus[14] = nus[-14] = "#mu";
86  nus[16] = nus[-16] = "#tau";
87  nus[0] = "active";
88  const std::string nu = (fFrom > 0) ? "#nu" : "#bar#nu";
89 
90  ret->SetTitle((nu+"_{"+nus[fFrom]+"}#rightarrow"+nu+"_{"+nus[fTo]+"}").c_str());
91  }
92 
93  return ret;
94  }
95 }
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
TH1D * ToTH1(Color_t col=kBlack, Style_t style=kSolid) const
Definition: Ratio.cxx:67
double delta
Definition: runWimpSim.h:98
const Binning kTrueLOverTrueEBins
Default true-energy bin edges.
Definition: Binning.cxx:62
const IOscCalcSterile * DowncastToSterile(const IOscCalc *calc, bool quiet)
Float_t x1[n_points_granero]
Definition: compare.C:5
General interface to oscillation calculators.
Definition: Hist.h:21
osc::OscCalcDumb calc
NDOscCurve(osc::IOscCalc *calc, int from, int to)
Definition: NDOscCurve.cxx:59
double GetL() const override
TH1D * ToTH1(bool title=false) const
Definition: NDOscCurve.cxx:73
virtual ~NDOscCurve()
Definition: NDOscCurve.cxx:68
virtual double GetDm(int i) const =0
const Binning kTrueEnergyBins
Default true-energy bin edges.
Definition: Binning.h:13
base class for sterile oscillation calculators In the context of a sterile oscillation calculator...
Represent the ratio between two spectra.
Definition: Ratio.h:8
const std::vector< double > & Edges() const
Definition: Binning.h:34
virtual T P(int flavBefore, int flavAfter, double E)=0
E in GeV; flavors as PDG codes (so, neg==>antinu)
int NBins() const
Definition: Binning.h:29
Eigen::ArrayXd ToEigenSterile(osc::IOscCalc *calc, int from, int to)
Helper for constructors.
Definition: NDOscCurve.cxx:17
Prevent histograms being added to the current directory.
Definition: UtilsExt.h:46
virtual void SetL(double L) override
enum BeamMode string