All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
EnsembleSpectrum.h
Go to the documentation of this file.
1 #pragma once
2 
4 
5 #include <cassert>
6 
7 class TGraphAsymmErrors;
8 
9 namespace ana
10 {
11  class EnsembleRatio;
12 
13  // TODO Multiverse class encapsulating a vector of shifts/weights and an ID
14  // number?
15 
17  {
18  public:
20  const HistAxis& axis,
21  const SpillCut& spillcut,
22  const Cut& cut,
23  const std::vector<SystShifts>& univ_shifts,
24  const Var& cv_wei = kUnweighted);
25 
27  const HistAxis& axis,
28  const SpillCut& spillcut,
29  const Cut& cut,
30  const std::vector<Var>& univ_weis,
31  const Var& cv_wei = kUnweighted);
32 
33  Spectrum Nominal() const {return fNom;}
34  unsigned int NUniverses() const {return fUnivs.size();}
35  Spectrum Universe(unsigned int i) const
36  {
37  assert(i < fUnivs.size());
38  return fUnivs[i];
39  }
40 
41  double POT() const {return fNom.POT();}
42 
43  double Livetime() const {return fNom.Livetime();}
44 
45  /// Result can be painted prettily with \ref DrawErrorBand
46  TGraphAsymmErrors* ErrorBand(double exposure,
47  EExposureType expotype = kPOT,
48  EBinType bintype = kBinContent) const;
49 
50  void Scale(double c);
51 
54 
57 
59  EnsembleSpectrum operator*(const EnsembleRatio& rhs) const;
60 
62  EnsembleSpectrum operator/(const EnsembleRatio& rhs) const;
63 
64  void SaveTo(TDirectory* dir) const;
65  static std::unique_ptr<EnsembleSpectrum> LoadFrom(TDirectory* dir);
66 
67  unsigned int NDimensions() const{return fNom.NDimensions();}
68  std::vector<std::string> GetLabels() const {return fNom.GetLabels();}
69  std::vector<Binning> GetBinnings() const {return fNom.GetBinnings();}
70 
71  protected:
72  EnsembleSpectrum(const Spectrum& nom) : fNom(nom) {}
73 
75  std::vector<Spectrum> fUnivs;
76  };
77 
78  // Commutative
79  inline EnsembleSpectrum operator*(const EnsembleRatio& lhs, const EnsembleSpectrum& rhs){return rhs*lhs;}
80  inline EnsembleSpectrum operator/(const EnsembleRatio& lhs, const EnsembleSpectrum& rhs){return rhs/lhs;}
81 
82  void DrawErrorBand(TH1* nom,
83  TGraphAsymmErrors* band,
84  int bandCol = -1,
85  double alpha = 1);
86 }
std::vector< Binning > GetBinnings() const
Spectrum Nominal() const
EnsembleSpectrum operator-(const EnsembleSpectrum &rhs) const
EnsembleSpectrum operator+(const EnsembleSpectrum &rhs) const
EnsembleSpectrum(SpectrumLoaderBase &loader, const HistAxis &axis, const SpillCut &spillcut, const Cut &cut, const std::vector< SystShifts > &univ_shifts, const Var &cv_wei=kUnweighted)
tuple loader
Definition: demo.py:7
static std::unique_ptr< EnsembleSpectrum > LoadFrom(TDirectory *dir)
EnsembleSpectrum & operator+=(const EnsembleSpectrum &rhs)
process_name opflashCryoW ana
std::vector< std::string > GetLabels() const
Representation of a spectrum in any variable, with associated POT.
Definition: Spectrum.h:30
EnsembleSpectrum & operator*=(const EnsembleRatio &rhs)
EnsembleSpectrum(const Spectrum &nom)
void SaveTo(TDirectory *dir) const
EnsembleSpectrum & operator/=(const EnsembleRatio &rhs)
EExposureType
For use as an argument to Spectrum::ToTH1.
double Livetime() const
EnsembleSpectrum operator*(const EnsembleRatio &lhs, const EnsembleSpectrum &rhs)
unsigned int NDimensions() const
EnsembleSpectrum operator/(const EnsembleRatio &rhs) const
unsigned int NDimensions() const
Definition: Spectrum.h:323
double POT() const
Definition: Spectrum.h:289
EnsembleRatio operator/(const EnsembleSpectrum &lhs, const EnsembleSpectrum &rhs)
Definition: EnsembleRatio.h:39
tuple dir
Definition: dropbox.py:28
Base class for the various types of spectrum loader.
std::vector< Spectrum > fUnivs
TGraphAsymmErrors * ErrorBand(double exposure, EExposureType expotype=kPOT, EBinType bintype=kBinContent) const
Result can be painted prettily with DrawErrorBand.
EnsembleSpectrum & operator-=(const EnsembleSpectrum &rhs)
const Var kUnweighted([](const caf::SRSliceProxy *){return 1;})
The simplest possible Var, always 1. Used as a default weight.
std::vector< std::string > GetLabels() const
Definition: Spectrum.h:324
EnsembleSpectrum operator*(const EnsembleRatio &rhs) const
double Livetime() const
Seconds. For informational purposes only. No calculations use this.
Definition: Spectrum.h:292
Spectrum Universe(unsigned int i) const
void DrawErrorBand(TH1 *nom, TGraphAsymmErrors *band, int bandCol, double alpha)
std::vector< Binning > GetBinnings() const
Definition: Spectrum.h:325
unsigned int NUniverses() const