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

#include <EnsembleRatio.h>

Public Member Functions

 EnsembleRatio (const EnsembleSpectrum &nom, const EnsembleSpectrum &denom)
 
Ratio Nominal () const
 
unsigned int NUniverses () const
 
Ratio Universe (unsigned int i) const
 
TGraphAsymmErrors * ErrorBand () const
 
EnsembleRatiooperator*= (const EnsembleRatio &rhs)
 
EnsembleRatio operator* (const EnsembleRatio &rhs) const
 
EnsembleRatiooperator/= (const EnsembleRatio &rhs)
 
EnsembleRatio operator/ (const EnsembleRatio &rhs) const
 

Protected Attributes

Ratio fNom
 
std::vector< RatiofUnivs
 

Detailed Description

Definition at line 13 of file EnsembleRatio.h.

Constructor & Destructor Documentation

ana::EnsembleRatio::EnsembleRatio ( const EnsembleSpectrum nom,
const EnsembleSpectrum denom 
)

Definition at line 11 of file EnsembleRatio.cxx.

13  : fNom(num.Nominal(), denom.Nominal())
14  {
15  assert(num.NUniverses() == denom.NUniverses());
16  fUnivs.reserve(num.NUniverses());
17  for(unsigned int i = 0; i < num.NUniverses(); ++i)
18  fUnivs.emplace_back(num.Universe(i), denom.Universe(i));
19  }
std::vector< Ratio > fUnivs
Definition: EnsembleRatio.h:36

Member Function Documentation

TGraphAsymmErrors * ana::EnsembleRatio::ErrorBand ( ) const

Definition at line 22 of file EnsembleRatio.cxx.

23  {
24  std::unique_ptr<TH1D> hnom(fNom.ToTH1());
25 
26  std::vector<std::unique_ptr<TH1D>> hunivs;
27  hunivs.reserve(fUnivs.size());
28  for(const Ratio& u: fUnivs) hunivs.emplace_back(u.ToTH1());
29 
30  TGraphAsymmErrors* g = new TGraphAsymmErrors;
31 
32  for(int binIdx = 0; binIdx < hnom->GetNbinsX()+2; ++binIdx){
33  const double xnom = hnom->GetXaxis()->GetBinCenter(binIdx);
34  const double ynom = hnom->GetBinContent(binIdx);
35  g->SetPoint(binIdx, xnom, ynom);
36 
37  const double dx = hnom->GetXaxis()->GetBinWidth(binIdx);
38 
39  std::vector<double> ys;
40  ys.reserve(hunivs.size());
41  for(const std::unique_ptr<TH1D>& hu: hunivs){
42  ys.push_back(hu->GetBinContent(binIdx));
43  }
44 
45  // 1 sigma
46  const double y0 = FindQuantile(.5-0.6827/2, ys);
47  const double y1 = FindQuantile(.5+0.6827/2, ys);
48 
49  // It's theoretically possible for the central value to be outside the
50  // error bands - clamp to zero in that case
51  g->SetPointError(binIdx, dx/2, dx/2,
52  std::max(ynom-y0, 0.),
53  std::max(y1-ynom, 0.));
54  } // end for binIdx
55 
56  return g;
57  }
TH1D * ToTH1(Color_t col=kBlack, Style_t style=kSolid) const
Definition: Ratio.cxx:116
double FindQuantile(double frac, std::vector< double > &xs)
BEGIN_PROLOG g
std::vector< Ratio > fUnivs
Definition: EnsembleRatio.h:36
Ratio ana::EnsembleRatio::Nominal ( ) const
inline

Definition at line 18 of file EnsembleRatio.h.

18 {return fNom;}
unsigned int ana::EnsembleRatio::NUniverses ( ) const
inline

Definition at line 19 of file EnsembleRatio.h.

19 {return fUnivs.size();}
std::vector< Ratio > fUnivs
Definition: EnsembleRatio.h:36
EnsembleRatio ana::EnsembleRatio::operator* ( const EnsembleRatio rhs) const

Definition at line 70 of file EnsembleRatio.cxx.

71  {
72  EnsembleRatio ret = *this;
73  ret *= rhs;
74  return ret;
75  }
EnsembleRatio(const EnsembleSpectrum &nom, const EnsembleSpectrum &denom)
EnsembleRatio & ana::EnsembleRatio::operator*= ( const EnsembleRatio rhs)

Definition at line 60 of file EnsembleRatio.cxx.

61  {
62  assert(rhs.NUniverses() == fUnivs.size());
63  fNom *= rhs.fNom;
64  for(unsigned int i = 0; i < fUnivs.size(); ++i)
65  fUnivs[i] *= rhs.fUnivs[i];
66  return *this;
67  }
std::vector< Ratio > fUnivs
Definition: EnsembleRatio.h:36
EnsembleRatio ana::EnsembleRatio::operator/ ( const EnsembleRatio rhs) const

Definition at line 88 of file EnsembleRatio.cxx.

89  {
90  EnsembleRatio ret = *this;
91  ret /= rhs;
92  return ret;
93  }
EnsembleRatio(const EnsembleSpectrum &nom, const EnsembleSpectrum &denom)
EnsembleRatio & ana::EnsembleRatio::operator/= ( const EnsembleRatio rhs)

Definition at line 78 of file EnsembleRatio.cxx.

79  {
80  assert(rhs.NUniverses() == fUnivs.size());
81  fNom /= rhs.fNom;
82  for(unsigned int i = 0; i < fUnivs.size(); ++i)
83  fUnivs[i] /= rhs.fUnivs[i];
84  return *this;
85  }
std::vector< Ratio > fUnivs
Definition: EnsembleRatio.h:36
Ratio ana::EnsembleRatio::Universe ( unsigned int  i) const
inline

Definition at line 20 of file EnsembleRatio.h.

21  {
22  assert(i < fUnivs.size());
23  return fUnivs[i];
24  }
std::vector< Ratio > fUnivs
Definition: EnsembleRatio.h:36

Member Data Documentation

Ratio ana::EnsembleRatio::fNom
protected

Definition at line 35 of file EnsembleRatio.h.

std::vector<Ratio> ana::EnsembleRatio::fUnivs
protected

Definition at line 36 of file EnsembleRatio.h.


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