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

Representation of a spectrum in any variable, with associated POT. More...

#include <Spectrum.h>

Inheritance diagram for ana::Spectrum:
ana::FluxTimesNuclei

Public Types

enum  ESparse { kDense, kSparse }
 

Public Member Functions

 Spectrum (const std::string &label, const Binning &bins, SpectrumLoaderBase &loader, const Var &var, const SpillCut &spillcut, const Cut &cut, const SystShifts &shift=kNoShift, const Var &wei=kUnweighted)
 
 Spectrum (const std::string &label, const Binning &bins, SpectrumLoaderBase &loader, const Var &var, const Cut &cut, const SystShifts &shift=kNoShift, const Var &wei=kUnweighted)
 
 Spectrum (const std::string &label, const Binning &bins, SpectrumLoaderBase &loader, const SpillVar &var, const SpillCut &cut, const SpillVar &wei=kSpillUnweighted)
 
 Spectrum (const std::string &label, const Binning &bins, SpectrumLoaderBase &loader, const MultiVar &var, const SpillCut &spillcut, const Cut &cut, const SystShifts &shift=kNoShift, const Var &wei=kUnweighted)
 The only MultiVar variant available. More...
 
 Spectrum (const std::string &label, const Binning &bins, SpectrumLoaderBase &loader, const SpillMultiVar &var, const SpillCut &cut, const SpillVar &wei=kSpillUnweighted)
 
 Spectrum (SpectrumLoaderBase &loader, const HistAxis &axis, const SpillCut &spillcut, const Cut &cut, const SystShifts &shift=kNoShift, const Var &wei=kUnweighted)
 
 Spectrum (SpectrumLoaderBase &loader, const HistAxis &axis, const Cut &cut, const SystShifts &shift=kNoShift, const Var &wei=kUnweighted)
 
 Spectrum (const std::string &label, const Binning &bins, ESparse sparse=kDense)
 
 Spectrum (const std::string &label, double pot, double livetime, const Binning &bins)
 
 Spectrum (TH1 *h, const std::vector< std::string > &labels, const std::vector< Binning > &bins, double pot, double livetime)
 Copies h. More...
 
 Spectrum (std::unique_ptr< TH1D > h, const std::vector< std::string > &labels, const std::vector< Binning > &bins, double pot, double livetime)
 Takes possession of h. More...
 
 Spectrum (const std::string &label, SpectrumLoaderBase &loader, const Binning &binsx, const Var &varx, const Binning &binsy, const Var &vary, const SpillCut &spillcut, const Cut &cut, const SystShifts &shift=kNoShift, const Var &wei=kUnweighted)
 2D Spectrum of two Vars More...
 
 Spectrum (const std::string &label, SpectrumLoaderBase &loader, const Binning &binsx, const SpillVar &varx, const Binning &binsy, const SpillVar &vary, const SpillCut &spillcut, const SpillVar &wei=kSpillUnweighted)
 2D Spectrum of two SpillVars More...
 
 Spectrum (const std::string &label, SpectrumLoaderBase &loader, const Binning &binsx, const MultiVar &varx, const Binning &binsy, const MultiVar &vary, const SpillCut &spillcut, const Cut &cut, const SystShifts &shift=kNoShift, const Var &wei=kUnweighted)
 2D Spectrum of two MultiVars More...
 
 Spectrum (const std::string &label, SpectrumLoaderBase &loader, const Binning &binsx, const SpillMultiVar &varx, const Binning &binsy, const SpillMultiVar &vary, const SpillCut &spillcut, const SpillVar &wei=kSpillUnweighted)
 2D Spectrum of two SpillMultiVars More...
 
 Spectrum (SpectrumLoaderBase &loader, const HistAxis &xAxis, const HistAxis &yAxis, const SpillCut &spillcut, const Cut &cut, const SystShifts &shift=kNoShift, const Var &wei=kUnweighted)
 2D Spectrum taking 2 HistAxis More...
 
 Spectrum (const std::string &xLabel, const std::string &yLabel, SpectrumLoaderBase &loader, const Binning &binsx, const Var &varx, const Binning &binsy, const Var &vary, const SpillCut &spillcut, const Cut &cut, const SystShifts &shift=kNoShift, const Var &wei=kUnweighted)
 
 Spectrum (const std::string &xLabel, const std::string &yLabel, SpectrumLoaderBase &loader, const Binning &binsx, const SpillVar &varx, const Binning &binsy, const SpillVar &vary, const SpillCut &spillcut, const SpillVar &wei=kSpillUnweighted)
 
 Spectrum (const std::string &xLabel, const std::string &yLabel, SpectrumLoaderBase &loader, const Binning &binsx, const MultiVar &varx, const Binning &binsy, const MultiVar &vary, const SpillCut &spillcut, const Cut &cut, const SystShifts &shift=kNoShift, const Var &wei=kUnweighted)
 
 Spectrum (const std::string &xLabel, const std::string &yLabel, SpectrumLoaderBase &loader, const Binning &binsx, const SpillMultiVar &varx, const Binning &binsy, const SpillMultiVar &vary, const SpillCut &spillcut, const SpillVar &wei=kSpillUnweighted)
 
 Spectrum (const std::string &label, SpectrumLoaderBase &loader, const Binning &binsx, const Var &varx, const Binning &binsy, const Var &vary, const Binning &binsz, const Var &varz, const SpillCut &spillcut, const Cut &cut, const SystShifts &shift=kNoShift, const Var &wei=kUnweighted, ESparse sparse=kDense)
 3D Spectrum of three Vars More...
 
 Spectrum (const std::string &xLabel, const std::string &yLabel, const std::string &zLabel, SpectrumLoaderBase &loader, const Binning &binsx, const Var &varx, const Binning &binsy, const Var &vary, const Binning &binsz, const Var &varz, const SpillCut &spillcut, const Cut &cut, const SystShifts &shift=kNoShift, const Var &wei=kUnweighted, ESparse sparse=kDense)
 
 Spectrum (SpectrumLoaderBase &loader, const HistAxis &xAxis, const HistAxis &yAxis, const HistAxis &zAxis, const SpillCut &spillcut, const Cut &cut, const SystShifts &shift=kNoShift, const Var &wei=kUnweighted, ESparse sparse=kDense)
 3D Spectrum taking 3 HistAxis More...
 
virtual ~Spectrum ()
 
 Spectrum (const Spectrum &rhs)
 
 Spectrum (Spectrum &&rhs)
 
Spectrumoperator= (const Spectrum &rhs)
 
Spectrumoperator= (Spectrum &&rhs)
 
void Fill (double x, double w=1)
 
TH1D * ToTH1 (double exposure, Color_t col=kBlack, Style_t style=kSolid, EExposureType expotype=kPOT, EBinType bintype=kBinContent) const
 Histogram made from this Spectrum, scaled to some exposure. More...
 
TH1D * ToTH1 (double exposure, EExposureType expotype, EBinType bintype=kBinContent) const
 Histogram made from this Spectrum, scaled to some exposure. More...
 
TH2 * ToTH2 (double exposure, EExposureType expotype=kPOT, EBinType bintype=kBinContent) const
 Spectrum must be 2D to obtain TH2. More...
 
TH2 * ToTH2NormX (double exposure, EExposureType expotype=kPOT) const
 Spectrum must be 2D to obtain TH2. Normalized to X axis. More...
 
TH3 * ToTH3 (double exposure, EExposureType expotype=kPOT, EBinType bintype=kBinContent) const
 Spectrum must be 3D to obtain TH3. More...
 
TH1 * ToTHX (double exposure, bool force1D=false, EExposureType expotype=kPOT) const
 Function decides what is the appropriate projection based on fBins, and does that. More...
 
double Integral (double exposure, double *err=0, EExposureType expotype=kPOT) const
 Return total number of events scaled to pot. More...
 
double Mean () const
 Return mean of 1D histogram. More...
 
Spectrum MockData (double pot, bool makethrow=true, int seed=0) const
 Mock data is FakeData with Poisson fluctuations applied. More...
 
Spectrum FakeData (double pot) const
 Fake data is a MC spectrum scaled to the POT expected in the data. More...
 
double POT () const
 
double Livetime () const
 Seconds. For informational purposes only. No calculations use this. More...
 
void OverridePOT (double newpot)
 DO NOT USE UNLESS YOU ARE 110% CERTAIN THERE ISN'T A BETTER WAY! More...
 
void OverrideLivetime (double newlive)
 DO NOT USE UNLESS YOU ARE 110% CERTAIN THERE ISN'T A BETTER WAY! More...
 
void Clear ()
 
void Scale (double c)
 Multiply this spectrum by a constant c. More...
 
Spectrumoperator+= (const Spectrum &rhs)
 
Spectrum operator+ (const Spectrum &rhs) const
 
Spectrumoperator-= (const Spectrum &rhs)
 
Spectrum operator- (const Spectrum &rhs) const
 
Spectrumoperator*= (const Ratio &rhs)
 
Spectrum operator* (const Ratio &rhs) const
 
Spectrumoperator/= (const Ratio &rhs)
 
Spectrum operator/ (const Ratio &rhs) const
 
void SaveTo (TDirectory *dir) const
 
unsigned int NDimensions () const
 
std::vector< std::string > GetLabels () const
 
std::vector< BinningGetBinnings () const
 

Static Public Member Functions

static std::unique_ptr< SpectrumLoadFrom (TDirectory *dir)
 

Protected Member Functions

 Spectrum (const std::vector< std::string > &labels, const std::vector< Binning > &bins, ESparse sparse=kDense)
 
void ConstructHistogram (ESparse sparse=kDense)
 
void RemoveLoader (SpectrumLoaderBase *)
 
void AddLoader (SpectrumLoaderBase *)
 
SpectrumPlusEqualsHelper (const Spectrum &rhs, int sign)
 Helper for operator+= and operator-=. More...
 

Protected Attributes

TH1D * fHist
 
THnSparseD * fHistSparse
 
double fPOT
 
double fLivetime
 
std::set< SpectrumLoaderBase * > fLoaderCount
 This count is maintained by SpectrumLoader, as a sanity check. More...
 
std::vector< std::string > fLabels
 
std::vector< BinningfBins
 

Friends

class SpectrumLoaderBase
 
class SpectrumLoader
 
class NullLoader
 

Detailed Description

Representation of a spectrum in any variable, with associated POT.

Definition at line 30 of file Spectrum.h.

Member Enumeration Documentation

Enumerator
kDense 
kSparse 

Definition at line 37 of file Spectrum.h.

Constructor & Destructor Documentation

ana::Spectrum::Spectrum ( const std::string &  label,
const Binning bins,
SpectrumLoaderBase loader,
const Var var,
const SpillCut spillcut,
const Cut cut,
const SystShifts shift = kNoShift,
const Var wei = kUnweighted 
)

Definition at line 43 of file Spectrum.cxx.

50  : Spectrum(label, bins)
51  {
52  loader.AddSpectrum(*this, var, spillcut, cut, shift, wei);
53  }
tuple loader
Definition: demo.py:7
shift
Definition: fcl_checks.sh:26
Spectrum(const std::string &label, const Binning &bins, SpectrumLoaderBase &loader, const Var &var, const SpillCut &spillcut, const Cut &cut, const SystShifts &shift=kNoShift, const Var &wei=kUnweighted)
Definition: Spectrum.cxx:43
ana::Spectrum::Spectrum ( const std::string &  label,
const Binning bins,
SpectrumLoaderBase loader,
const Var var,
const Cut cut,
const SystShifts shift = kNoShift,
const Var wei = kUnweighted 
)
inline

Definition at line 47 of file Spectrum.h.

53  : Spectrum(label, bins, loader, var, kNoSpillCut, cut, shift, wei)
54  {
55  }
tuple loader
Definition: demo.py:7
shift
Definition: fcl_checks.sh:26
const SpillCut kNoSpillCut([](const caf::SRSpillProxy *){return true;})
The simplest possible cut: pass everything, used as a default.
Spectrum(const std::string &label, const Binning &bins, SpectrumLoaderBase &loader, const Var &var, const SpillCut &spillcut, const Cut &cut, const SystShifts &shift=kNoShift, const Var &wei=kUnweighted)
Definition: Spectrum.cxx:43
ana::Spectrum::Spectrum ( const std::string &  label,
const Binning bins,
SpectrumLoaderBase loader,
const SpillVar var,
const SpillCut cut,
const SpillVar wei = kSpillUnweighted 
)

Definition at line 56 of file Spectrum.cxx.

61  : Spectrum(label, bins)
62  {
63  loader.AddSpectrum(*this, var, cut, wei);
64  }
tuple loader
Definition: demo.py:7
Spectrum(const std::string &label, const Binning &bins, SpectrumLoaderBase &loader, const Var &var, const SpillCut &spillcut, const Cut &cut, const SystShifts &shift=kNoShift, const Var &wei=kUnweighted)
Definition: Spectrum.cxx:43
ana::Spectrum::Spectrum ( const std::string &  label,
const Binning bins,
SpectrumLoaderBase loader,
const MultiVar var,
const SpillCut spillcut,
const Cut cut,
const SystShifts shift = kNoShift,
const Var wei = kUnweighted 
)

The only MultiVar variant available.

Definition at line 67 of file Spectrum.cxx.

74  : Spectrum(label, bins)
75  {
76  loader.AddSpectrum(*this, var, spillcut, cut, shift, wei);
77  }
tuple loader
Definition: demo.py:7
shift
Definition: fcl_checks.sh:26
Spectrum(const std::string &label, const Binning &bins, SpectrumLoaderBase &loader, const Var &var, const SpillCut &spillcut, const Cut &cut, const SystShifts &shift=kNoShift, const Var &wei=kUnweighted)
Definition: Spectrum.cxx:43
ana::Spectrum::Spectrum ( const std::string &  label,
const Binning bins,
SpectrumLoaderBase loader,
const SpillMultiVar var,
const SpillCut cut,
const SpillVar wei = kSpillUnweighted 
)

Definition at line 80 of file Spectrum.cxx.

85  : Spectrum(label, bins)
86  {
87  loader.AddSpectrum(*this, var, cut, wei);
88  }
tuple loader
Definition: demo.py:7
Spectrum(const std::string &label, const Binning &bins, SpectrumLoaderBase &loader, const Var &var, const SpillCut &spillcut, const Cut &cut, const SystShifts &shift=kNoShift, const Var &wei=kUnweighted)
Definition: Spectrum.cxx:43
ana::Spectrum::Spectrum ( SpectrumLoaderBase loader,
const HistAxis axis,
const SpillCut spillcut,
const Cut cut,
const SystShifts shift = kNoShift,
const Var wei = kUnweighted 
)

Definition at line 91 of file Spectrum.cxx.

97  : Spectrum(axis.GetLabels(), axis.GetBinnings())
98  {
99  loader.AddSpectrum(*this, axis.GetMultiDVar(), spillcut, cut, shift, wei);
100  }
tuple loader
Definition: demo.py:7
shift
Definition: fcl_checks.sh:26
Spectrum(const std::string &label, const Binning &bins, SpectrumLoaderBase &loader, const Var &var, const SpillCut &spillcut, const Cut &cut, const SystShifts &shift=kNoShift, const Var &wei=kUnweighted)
Definition: Spectrum.cxx:43
ana::Spectrum::Spectrum ( SpectrumLoaderBase loader,
const HistAxis axis,
const Cut cut,
const SystShifts shift = kNoShift,
const Var wei = kUnweighted 
)
inline

Definition at line 86 of file Spectrum.h.

91  : Spectrum(loader, axis, kNoSpillCut, cut, shift, wei)
92  {
93  }
tuple loader
Definition: demo.py:7
shift
Definition: fcl_checks.sh:26
const SpillCut kNoSpillCut([](const caf::SRSpillProxy *){return true;})
The simplest possible cut: pass everything, used as a default.
Spectrum(const std::string &label, const Binning &bins, SpectrumLoaderBase &loader, const Var &var, const SpillCut &spillcut, const Cut &cut, const SystShifts &shift=kNoShift, const Var &wei=kUnweighted)
Definition: Spectrum.cxx:43
ana::Spectrum::Spectrum ( const std::string &  label,
const Binning bins,
ESparse  sparse = kDense 
)

Definition at line 33 of file Spectrum.cxx.

36  : fHist(0), fHistSparse(0), fPOT(0), fLivetime(0),
37  fLabels(1, label), fBins(1, bins)
38  {
39  ConstructHistogram(sparse);
40  }
void ConstructHistogram(ESparse sparse=kDense)
double fPOT
Definition: Spectrum.h:342
std::vector< std::string > fLabels
Definition: Spectrum.h:348
double fLivetime
Definition: Spectrum.h:343
TH1D * fHist
Definition: Spectrum.h:340
THnSparseD * fHistSparse
Definition: Spectrum.h:341
std::vector< Binning > fBins
Definition: Spectrum.h:349
ana::Spectrum::Spectrum ( const std::string &  label,
double  pot,
double  livetime,
const Binning bins 
)

Definition at line 103 of file Spectrum.cxx.

105  : Spectrum(label, bins)
106  {
107  fPOT = pot;
108  fLivetime = livetime;
109  }
double fPOT
Definition: Spectrum.h:342
double fLivetime
Definition: Spectrum.h:343
Spectrum(const std::string &label, const Binning &bins, SpectrumLoaderBase &loader, const Var &var, const SpillCut &spillcut, const Cut &cut, const SystShifts &shift=kNoShift, const Var &wei=kUnweighted)
Definition: Spectrum.cxx:43
ana::Spectrum::Spectrum ( TH1 *  h,
const std::vector< std::string > &  labels,
const std::vector< Binning > &  bins,
double  pot,
double  livetime 
)

Copies h.

Definition at line 112 of file Spectrum.cxx.

116  : fHist(0), fHistSparse(0), fPOT(pot), fLivetime(livetime), fLabels(labels), fBins(bins)
117  {
118  if(!h){
119  fHist = 0;
120  return;
121  }
122 
123  DontAddDirectory guard;
124 
125  const TString className = h->ClassName();
126 
127  if(className == "TH1D"){
128  // Shortcut if types match
129  fHist = HistCache::Copy((TH1D*)h);
130  }
131  else{
132  fHist = HistCache::New("", h->GetXaxis());
133  fHist->Add(h);
134  }
135  }
static TH1D * Copy(const TH1D *h)
Definition: HistCache.cxx:76
double fPOT
Definition: Spectrum.h:342
while getopts h
std::vector< std::string > fLabels
Definition: Spectrum.h:348
double fLivetime
Definition: Spectrum.h:343
TH1D * fHist
Definition: Spectrum.h:340
THnSparseD * fHistSparse
Definition: Spectrum.h:341
std::vector< Binning > fBins
Definition: Spectrum.h:349
static TH1D * New(const std::string &title, const Binning &bins)
Definition: HistCache.cxx:21
ana::Spectrum::Spectrum ( std::unique_ptr< TH1D >  h,
const std::vector< std::string > &  labels,
const std::vector< Binning > &  bins,
double  pot,
double  livetime 
)

Takes possession of h.

Definition at line 138 of file Spectrum.cxx.

142  : fHist(h.release()), fHistSparse(0), fPOT(pot), fLivetime(livetime), fLabels(labels), fBins(bins)
143  {
144  }
double fPOT
Definition: Spectrum.h:342
std::vector< std::string > fLabels
Definition: Spectrum.h:348
double fLivetime
Definition: Spectrum.h:343
TH1D * fHist
Definition: Spectrum.h:340
THnSparseD * fHistSparse
Definition: Spectrum.h:341
std::vector< Binning > fBins
Definition: Spectrum.h:349
ana::Spectrum::Spectrum ( const std::string &  label,
SpectrumLoaderBase loader,
const Binning binsx,
const Var varx,
const Binning binsy,
const Var vary,
const SpillCut spillcut,
const Cut cut,
const SystShifts shift = kNoShift,
const Var wei = kUnweighted 
)

2D Spectrum of two Vars

Definition at line 147 of file Spectrum.cxx.

154  : Spectrum(label, "", loader, binsx, varx, binsy, vary, spillcut, cut, shift, wei)
155  {
156  // TODO do we want this variant when there's one with a labelY just below?
157  }
tuple loader
Definition: demo.py:7
shift
Definition: fcl_checks.sh:26
Spectrum(const std::string &label, const Binning &bins, SpectrumLoaderBase &loader, const Var &var, const SpillCut &spillcut, const Cut &cut, const SystShifts &shift=kNoShift, const Var &wei=kUnweighted)
Definition: Spectrum.cxx:43
ana::Spectrum::Spectrum ( const std::string &  label,
SpectrumLoaderBase loader,
const Binning binsx,
const SpillVar varx,
const Binning binsy,
const SpillVar vary,
const SpillCut spillcut,
const SpillVar wei = kSpillUnweighted 
)

2D Spectrum of two SpillVars

Definition at line 160 of file Spectrum.cxx.

165  : Spectrum(label, "", loader, binsx, varx, binsy, vary, spillcut, wei)
166  {
167  // TODO do we want this variant when there's one with a labelY just below?
168  }
tuple loader
Definition: demo.py:7
Spectrum(const std::string &label, const Binning &bins, SpectrumLoaderBase &loader, const Var &var, const SpillCut &spillcut, const Cut &cut, const SystShifts &shift=kNoShift, const Var &wei=kUnweighted)
Definition: Spectrum.cxx:43
ana::Spectrum::Spectrum ( const std::string &  label,
SpectrumLoaderBase loader,
const Binning binsx,
const MultiVar varx,
const Binning binsy,
const MultiVar vary,
const SpillCut spillcut,
const Cut cut,
const SystShifts shift = kNoShift,
const Var wei = kUnweighted 
)

2D Spectrum of two MultiVars

Definition at line 171 of file Spectrum.cxx.

178  : Spectrum(label, "", loader, binsx, varx, binsy, vary, spillcut, cut, shift, wei)
179  {
180  // TODO do we want this variant when there's one with a labelY just below?
181  }
tuple loader
Definition: demo.py:7
shift
Definition: fcl_checks.sh:26
Spectrum(const std::string &label, const Binning &bins, SpectrumLoaderBase &loader, const Var &var, const SpillCut &spillcut, const Cut &cut, const SystShifts &shift=kNoShift, const Var &wei=kUnweighted)
Definition: Spectrum.cxx:43
ana::Spectrum::Spectrum ( const std::string &  label,
SpectrumLoaderBase loader,
const Binning binsx,
const SpillMultiVar varx,
const Binning binsy,
const SpillMultiVar vary,
const SpillCut spillcut,
const SpillVar wei = kSpillUnweighted 
)

2D Spectrum of two SpillMultiVars

Definition at line 184 of file Spectrum.cxx.

189  : Spectrum(label, "", loader, binsx, varx, binsy, vary, spillcut, wei)
190  {
191  // TODO do we want this variant when there's one with a labelY just below?
192  }
tuple loader
Definition: demo.py:7
Spectrum(const std::string &label, const Binning &bins, SpectrumLoaderBase &loader, const Var &var, const SpillCut &spillcut, const Cut &cut, const SystShifts &shift=kNoShift, const Var &wei=kUnweighted)
Definition: Spectrum.cxx:43
ana::Spectrum::Spectrum ( SpectrumLoaderBase loader,
const HistAxis xAxis,
const HistAxis yAxis,
const SpillCut spillcut,
const Cut cut,
const SystShifts shift = kNoShift,
const Var wei = kUnweighted 
)

2D Spectrum taking 2 HistAxis

Definition at line 195 of file Spectrum.cxx.

202  : Spectrum(xAxis.GetLabels()[0], loader,
203  xAxis.GetBinnings()[0], xAxis.GetVars()[0],
204  yAxis.GetBinnings()[0], yAxis.GetVars()[0],
205  spillcut, cut, shift, wei)
206  {
207  // TODO - do we want to keep this variant around?
208  assert(xAxis.NDimensions() == 1);
209  assert(yAxis.NDimensions() == 1);
210  }
tuple loader
Definition: demo.py:7
shift
Definition: fcl_checks.sh:26
Spectrum(const std::string &label, const Binning &bins, SpectrumLoaderBase &loader, const Var &var, const SpillCut &spillcut, const Cut &cut, const SystShifts &shift=kNoShift, const Var &wei=kUnweighted)
Definition: Spectrum.cxx:43
ana::Spectrum::Spectrum ( const std::string &  xLabel,
const std::string &  yLabel,
SpectrumLoaderBase loader,
const Binning binsx,
const Var varx,
const Binning binsy,
const Var vary,
const SpillCut spillcut,
const Cut cut,
const SystShifts shift = kNoShift,
const Var wei = kUnweighted 
)

Definition at line 213 of file Spectrum.cxx.

222  : Spectrum({xLabel, yLabel}, {binsx, binsy})
Spectrum(const std::string &label, const Binning &bins, SpectrumLoaderBase &loader, const Var &var, const SpillCut &spillcut, const Cut &cut, const SystShifts &shift=kNoShift, const Var &wei=kUnweighted)
Definition: Spectrum.cxx:43
ana::Spectrum::Spectrum ( const std::string &  xLabel,
const std::string &  yLabel,
SpectrumLoaderBase loader,
const Binning binsx,
const SpillVar varx,
const Binning binsy,
const SpillVar vary,
const SpillCut spillcut,
const SpillVar wei = kSpillUnweighted 
)
ana::Spectrum::Spectrum ( const std::string &  xLabel,
const std::string &  yLabel,
SpectrumLoaderBase loader,
const Binning binsx,
const MultiVar varx,
const Binning binsy,
const MultiVar vary,
const SpillCut spillcut,
const Cut cut,
const SystShifts shift = kNoShift,
const Var wei = kUnweighted 
)
ana::Spectrum::Spectrum ( const std::string &  xLabel,
const std::string &  yLabel,
SpectrumLoaderBase loader,
const Binning binsx,
const SpillMultiVar varx,
const Binning binsy,
const SpillMultiVar vary,
const SpillCut spillcut,
const SpillVar wei = kSpillUnweighted 
)
ana::Spectrum::Spectrum ( const std::string &  label,
SpectrumLoaderBase loader,
const Binning binsx,
const Var varx,
const Binning binsy,
const Var vary,
const Binning binsz,
const Var varz,
const SpillCut spillcut,
const Cut cut,
const SystShifts shift = kNoShift,
const Var wei = kUnweighted,
ESparse  sparse = kDense 
)

3D Spectrum of three Vars

ana::Spectrum::Spectrum ( const std::string &  xLabel,
const std::string &  yLabel,
const std::string &  zLabel,
SpectrumLoaderBase loader,
const Binning binsx,
const Var varx,
const Binning binsy,
const Var vary,
const Binning binsz,
const Var varz,
const SpillCut spillcut,
const Cut cut,
const SystShifts shift = kNoShift,
const Var wei = kUnweighted,
ESparse  sparse = kDense 
)
ana::Spectrum::Spectrum ( SpectrumLoaderBase loader,
const HistAxis xAxis,
const HistAxis yAxis,
const HistAxis zAxis,
const SpillCut spillcut,
const Cut cut,
const SystShifts shift = kNoShift,
const Var wei = kUnweighted,
ESparse  sparse = kDense 
)

3D Spectrum taking 3 HistAxis

virtual ana::Spectrum::~Spectrum ( )
virtual
ana::Spectrum::Spectrum ( const Spectrum rhs)
ana::Spectrum::Spectrum ( Spectrum &&  rhs)
ana::Spectrum::Spectrum ( const std::vector< std::string > &  labels,
const std::vector< Binning > &  bins,
ESparse  sparse = kDense 
)
protected

Definition at line 22 of file Spectrum.cxx.

25  : fHist(0), fHistSparse(0), fPOT(0), fLivetime(0),
26  fLabels(labels), fBins(bins)
27  {
28  ConstructHistogram(sparse);
29  }
void ConstructHistogram(ESparse sparse=kDense)
double fPOT
Definition: Spectrum.h:342
std::vector< std::string > fLabels
Definition: Spectrum.h:348
double fLivetime
Definition: Spectrum.h:343
TH1D * fHist
Definition: Spectrum.h:340
THnSparseD * fHistSparse
Definition: Spectrum.h:341
std::vector< Binning > fBins
Definition: Spectrum.h:349

Member Function Documentation

void ana::Spectrum::AddLoader ( SpectrumLoaderBase )
protected
void ana::Spectrum::Clear ( )
void ana::Spectrum::ConstructHistogram ( ESparse  sparse = kDense)
protected
Spectrum ana::Spectrum::FakeData ( double  pot) const

Fake data is a MC spectrum scaled to the POT expected in the data.

Use for sensitivity plots and testing fit convergence

void ana::Spectrum::Fill ( double  x,
double  w = 1 
)
std::vector<Binning> ana::Spectrum::GetBinnings ( ) const
inline

Definition at line 325 of file Spectrum.h.

325 {return fBins;}
std::vector< Binning > fBins
Definition: Spectrum.h:349
std::vector<std::string> ana::Spectrum::GetLabels ( ) const
inline

Definition at line 324 of file Spectrum.h.

324 {return fLabels;}
std::vector< std::string > fLabels
Definition: Spectrum.h:348
double ana::Spectrum::Integral ( double  exposure,
double *  err = 0,
EExposureType  expotype = kPOT 
) const

Return total number of events scaled to pot.

Parameters
exposurePOT/livetime to scale to
errThe statistical error on this total (optional)
expotypeWhat the first parameter represents
double ana::Spectrum::Livetime ( ) const
inline

Seconds. For informational purposes only. No calculations use this.

Definition at line 292 of file Spectrum.h.

292 {return fLivetime;}
double fLivetime
Definition: Spectrum.h:343
static std::unique_ptr<Spectrum> ana::Spectrum::LoadFrom ( TDirectory *  dir)
static
double ana::Spectrum::Mean ( ) const

Return mean of 1D histogram.

Spectrum ana::Spectrum::MockData ( double  pot,
bool  makethrow = true,
int  seed = 0 
) const

Mock data is FakeData with Poisson fluctuations applied.

Use for low-budget MDCs, or just getting a sense of the expected scale of statistical variation

unsigned int ana::Spectrum::NDimensions ( ) const
inline

Definition at line 323 of file Spectrum.h.

323 {return fLabels.size();}
std::vector< std::string > fLabels
Definition: Spectrum.h:348
Spectrum ana::Spectrum::operator* ( const Ratio rhs) const
Spectrum& ana::Spectrum::operator*= ( const Ratio rhs)
Spectrum ana::Spectrum::operator+ ( const Spectrum rhs) const
Spectrum& ana::Spectrum::operator+= ( const Spectrum rhs)
Spectrum ana::Spectrum::operator- ( const Spectrum rhs) const
Spectrum& ana::Spectrum::operator-= ( const Spectrum rhs)
Spectrum ana::Spectrum::operator/ ( const Ratio rhs) const
Spectrum& ana::Spectrum::operator/= ( const Ratio rhs)
Spectrum& ana::Spectrum::operator= ( const Spectrum rhs)
Spectrum& ana::Spectrum::operator= ( Spectrum &&  rhs)
void ana::Spectrum::OverrideLivetime ( double  newlive)
inline

DO NOT USE UNLESS YOU ARE 110% CERTAIN THERE ISN'T A BETTER WAY!

Definition at line 298 of file Spectrum.h.

298 {fLivetime = newlive;}
double fLivetime
Definition: Spectrum.h:343
void ana::Spectrum::OverridePOT ( double  newpot)
inline

DO NOT USE UNLESS YOU ARE 110% CERTAIN THERE ISN'T A BETTER WAY!

Definition at line 295 of file Spectrum.h.

295 {fPOT = newpot;}
double fPOT
Definition: Spectrum.h:342
Spectrum& ana::Spectrum::PlusEqualsHelper ( const Spectrum rhs,
int  sign 
)
protected

Helper for operator+= and operator-=.

double ana::Spectrum::POT ( ) const
inline

Definition at line 289 of file Spectrum.h.

289 {return fPOT;}
double fPOT
Definition: Spectrum.h:342
void ana::Spectrum::RemoveLoader ( SpectrumLoaderBase )
protected
void ana::Spectrum::SaveTo ( TDirectory *  dir) const
void ana::Spectrum::Scale ( double  c)

Multiply this spectrum by a constant c.

TH1D* ana::Spectrum::ToTH1 ( double  exposure,
Color_t  col = kBlack,
Style_t  style = kSolid,
EExposureType  expotype = kPOT,
EBinType  bintype = kBinContent 
) const

Histogram made from this Spectrum, scaled to some exposure.

Parameters
exposurePOT or livetime (seconds)
colHistogram color (default black)
styleHistogram line style (default solid)
expotypeHow to interpret exposure (kPOT (default) or kLivetime)
TH1D* ana::Spectrum::ToTH1 ( double  exposure,
EExposureType  expotype,
EBinType  bintype = kBinContent 
) const
inline

Histogram made from this Spectrum, scaled to some exposure.

Parameters
exposurePOT or livetime (seconds)
expotypeHow to interpret exposure (kPOT (default) or kLivetime)

Definition at line 248 of file Spectrum.h.

251  {
252  return ToTH1(exposure, kBlack, kSolid, expotype, bintype);
253  }
TH1D * ToTH1(double exposure, Color_t col=kBlack, Style_t style=kSolid, EExposureType expotype=kPOT, EBinType bintype=kBinContent) const
Histogram made from this Spectrum, scaled to some exposure.
TH2* ana::Spectrum::ToTH2 ( double  exposure,
EExposureType  expotype = kPOT,
EBinType  bintype = kBinContent 
) const

Spectrum must be 2D to obtain TH2.

TH2* ana::Spectrum::ToTH2NormX ( double  exposure,
EExposureType  expotype = kPOT 
) const

Spectrum must be 2D to obtain TH2. Normalized to X axis.

TH3* ana::Spectrum::ToTH3 ( double  exposure,
EExposureType  expotype = kPOT,
EBinType  bintype = kBinContent 
) const

Spectrum must be 3D to obtain TH3.

TH1* ana::Spectrum::ToTHX ( double  exposure,
bool  force1D = false,
EExposureType  expotype = kPOT 
) const

Function decides what is the appropriate projection based on fBins, and does that.

Friends And Related Function Documentation

friend class NullLoader
friend

Definition at line 35 of file Spectrum.h.

friend class SpectrumLoader
friend

Definition at line 34 of file Spectrum.h.

friend class SpectrumLoaderBase
friend

Definition at line 33 of file Spectrum.h.

Member Data Documentation

std::vector<Binning> ana::Spectrum::fBins
protected

Definition at line 349 of file Spectrum.h.

TH1D* ana::Spectrum::fHist
protected

Definition at line 340 of file Spectrum.h.

THnSparseD* ana::Spectrum::fHistSparse
protected

Definition at line 341 of file Spectrum.h.

std::vector<std::string> ana::Spectrum::fLabels
protected

Definition at line 348 of file Spectrum.h.

double ana::Spectrum::fLivetime
protected

Definition at line 343 of file Spectrum.h.

std::set<SpectrumLoaderBase*> ana::Spectrum::fLoaderCount
protected

This count is maintained by SpectrumLoader, as a sanity check.

Definition at line 346 of file Spectrum.h.

double ana::Spectrum::fPOT
protected

Definition at line 342 of file Spectrum.h.


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