All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Protected Attributes | List of all members
ana::OscCurve Class Reference

Transition probability for any one channel as a function of energy. More...

#include <OscCurve.h>

Public Member Functions

 OscCurve (osc::IOscCalc *calc, int from, int to, bool LoverE)
 
 OscCurve (TH1 *h)
 
virtual ~OscCurve ()
 
 OscCurve (const OscCurve &rhs)
 
OscCurveoperator= (const OscCurve &rhs)
 
TH1D * ToTH1 (bool title=false) const
 

Protected Attributes

int fFrom
 
int fTo
 
TH1D * fHist
 

Detailed Description

Transition probability for any one channel as a function of energy.

Definition at line 18 of file OscCurve.h.

Constructor & Destructor Documentation

ana::OscCurve::OscCurve ( osc::IOscCalc calc,
int  from,
int  to,
bool  LoverE 
)

Definition at line 28 of file OscCurve.cxx.

29  : fFrom(from), fTo(to)
30  {
31  DontAddDirectory guard;
32 
33  fHist = LoverE ? HistCache::New("True L / E (km / GeV);Probability", kTrueLOverEBins) : HistCache::New(";True Energy (GeV);Probability", kTrueEnergyBins);
34 
35  // We have extra knowledge that calculators of this type have special
36  // modes allowing calculation in L/E and an intrinsic energy smearing.
37  OscCalcSterileApprox* approx = DowncastToSterileApprox(calc, true);
38 
39  if(approx){
40  for(int i = 0; i < fHist->GetNbinsX()+2; ++i){
41  if(LoverE){
42  const double LElo = fHist->GetXaxis()->GetBinLowEdge(i);
43  const double LEhi = fHist->GetXaxis()->GetBinUpEdge(i);
44  fHist->SetBinContent(i, approx->P_LoverE(from, to, LElo, LEhi));
45  }
46  else{
47  const double E = fHist->GetBinCenter(i);
48  const double Elo = fHist->GetXaxis()->GetBinLowEdge(i);
49  const double Ehi = fHist->GetXaxis()->GetBinUpEdge(i);
50  // Use 2% resolution (intended to be << the resolution of any actual
51  // event) or the bin width, whichever is larger
52  fHist->SetBinContent(i, approx->P_range(from, to,
53  std::min(Elo, 0.98*E),
54  std::max(Ehi, 1.02*E)));
55  }
56  fHist->SetBinError(i, 0);
57  }
58  }
59  else{
60  if(LoverE && !IsNoOscillations(calc)){
61  std::cout << "Trying to use a calculator which is not OscCalcSterileApprox with an L/E axis. Will have to code up additional hacks for this to work" << std::endl;
62  abort();
63  }
64 
65  for(int i = 0; i < fHist->GetNbinsX()+2; ++i){
66  const double E = fHist->GetBinCenter(i);
67  fHist->SetBinContent(i, E > 0 ? calc->P(from, to, E) : 0);
68  fHist->SetBinError(i, 0);
69  }
70  }
71  }
TH1D * fHist
Definition: OscCurve.h:31
const OscCalcSterileApprox * DowncastToSterileApprox(const osc::IOscCalc *calc, bool allowFail)
process_name E
const Binning kTrueLOverEBins
Definition: Binning.h:74
const Binning kTrueEnergyBins
Default true-energy bin edges.
Definition: Binning.h:71
static TH1D * New(const std::string &title, const Binning &bins)
Definition: HistCache.cxx:21
BEGIN_PROLOG could also be cout
ana::OscCurve::OscCurve ( TH1 *  h)

Definition at line 74 of file OscCurve.cxx.

75  {
76  DontAddDirectory guard;
77 
78  const TString className = h->ClassName();
79 
80  if(className == "TH1D"){
81  // Shortcut if types match
82  fHist = HistCache::Copy((TH1D*)h);
83  }
84  else{
85  fHist = HistCache::New("", h->GetXaxis());
86  fHist->Add(h);
87  }
88 
89  fHist->SetTitle(";True Energy (GeV);Probability");
90  }
TH1D * fHist
Definition: OscCurve.h:31
static TH1D * Copy(const TH1D *h)
Definition: HistCache.cxx:76
while getopts h
static TH1D * New(const std::string &title, const Binning &bins)
Definition: HistCache.cxx:21
ana::OscCurve::~OscCurve ( )
virtual

Definition at line 93 of file OscCurve.cxx.

94  {
95  if(fHist && fHist->GetDirectory()){
96  static bool once = true;
97  if(once){
98  once = false;
99  std::cerr << "OscCurve's fHist is associated with a directory. How did that happen?" << std::endl;
100  }
101  }
102 
104  }
TH1D * fHist
Definition: OscCurve.h:31
BEGIN_PROLOG could also be cerr
static void Delete(TH1D *&h)
Definition: HistCache.cxx:92
ana::OscCurve::OscCurve ( const OscCurve rhs)

Definition at line 107 of file OscCurve.cxx.

108  {
109  DontAddDirectory guard;
110 
111  assert(rhs.fHist);
112  fHist = HistCache::Copy(rhs.fHist);
113  }
TH1D * fHist
Definition: OscCurve.h:31
static TH1D * Copy(const TH1D *h)
Definition: HistCache.cxx:76

Member Function Documentation

OscCurve & ana::OscCurve::operator= ( const OscCurve rhs)

Definition at line 116 of file OscCurve.cxx.

117  {
118  if(&rhs == this) return *this;
119 
120  DontAddDirectory guard;
121 
123  assert(rhs.fHist);
124  fHist = HistCache::Copy(rhs.fHist);
125  return *this;
126  }
TH1D * fHist
Definition: OscCurve.h:31
static TH1D * Copy(const TH1D *h)
Definition: HistCache.cxx:76
static void Delete(TH1D *&h)
Definition: HistCache.cxx:92
TH1D * ana::OscCurve::ToTH1 ( bool  title = false) const

Definition at line 129 of file OscCurve.cxx.

130  {
131  // Could have a file temporarily open
132  DontAddDirectory guard;
133 
134  TH1D* ret = HistCache::Copy(fHist);
135 
136  if(title){
137  // Don't do this work unless it's explicitly requested
138  std::map<int, std::string> nus;
139  nus[12] = nus[-12] = "e";
140  nus[14] = nus[-14] = "#mu";
141  nus[16] = nus[-16] = "#tau";
142  nus[0] = "active";
143  const std::string nu = (fFrom > 0) ? "#nu" : "#bar#nu";
144 
145  ret->SetTitle((nu+"_{"+nus[fFrom]+"}#rightarrow"+nu+"_{"+nus[fTo]+"}").c_str());
146  }
147 
148  return ret;
149  }
TH1D * fHist
Definition: OscCurve.h:31
static TH1D * Copy(const TH1D *h)
Definition: HistCache.cxx:76
BEGIN_PROLOG SN nu

Member Data Documentation

int ana::OscCurve::fFrom
protected

Definition at line 30 of file OscCurve.h.

TH1D* ana::OscCurve::fHist
protected

Definition at line 31 of file OscCurve.h.

int ana::OscCurve::fTo
protected

Definition at line 30 of file OscCurve.h.


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