All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
HistAxis.cxx
Go to the documentation of this file.
2 
3 #include <iostream>
4 
5 namespace ana
6 {
7  //----------------------------------------------------------------------
8  template<class T> _HistAxis<T>::
9  _HistAxis(const std::string& label,
10  const Binning& bins,
11  const T& var)
12  : fLabels(1, label),
13  fBins(1, bins),
14  fVars(1, var)
15  {
16  }
17 
18  //----------------------------------------------------------------------
19  template<class T> _HistAxis<T>::
20  _HistAxis(const std::vector<std::string>& labels,
21  const std::vector<Binning>& bins,
22  const std::vector<T>& vars)
23  : fLabels(labels), fBins(bins), fVars(vars)
24  {
25  assert(fLabels.size() == fBins.size());
26  assert(fBins.size() == fVars.size());
27  }
28 
29  //----------------------------------------------------------------------
30  template<class T> _HistAxis<T>::
31  _HistAxis(const std::string& labelX,
32  const Binning& binsX,
33  const T& varX,
34  const std::string& labelY,
35  const Binning& binsY,
36  const T& varY)
37  : fLabels({labelX, labelY}),
38  fBins({binsX, binsY}),
39  fVars({varX, varY})
40  {
41  }
42 
43  //----------------------------------------------------------------------
44  template<class T> _HistAxis<T>::
45  _HistAxis(const std::string& label,
46  int nx, double x0, double x1,
47  const T& var)
48  : _HistAxis(label, Binning::Simple(nx, x0, x1), var)
49  {
50  }
51 
52  //----------------------------------------------------------------------
53  template<class T> _HistAxis<T>::
54  _HistAxis(const std::string& labelX,
55  int nx, double x0, double x1,
56  const T& varX,
57  const std::string& labelY,
58  int ny, double y0, double y1,
59  const T& varY)
60  : _HistAxis(labelX, Binning::Simple(nx, x0, x1), varX,
61  labelY, Binning::Simple(ny, y0, y1), varY)
62  {
63  }
64 
65  //----------------------------------------------------------------------
66  template<class T> T _HistAxis<T>::GetMultiDVar() const
67  {
68  switch(fVars.size()){
69  case 1:
70  return fVars[0];
71  case 2:
72  return Var2D(fVars[0], fBins[0],
73  fVars[1], fBins[1]);
74  case 3:
75  return Var3D(fVars[0], fBins[0],
76  fVars[1], fBins[1],
77  fVars[2], fBins[2]);
78  default:
79  std::cout << "Error: HistAxis::GetMultiDVar() doesn't support "
80  << fVars.size() << "-dimensional axes" << std::endl;
81  abort();
82  }
83  }
84 
85  // explicitly instantiate the template for the types we know we have
86  template class _HistAxis<Var>;
87  template class _HistAxis<SpillVar>;
88 }
std::vector< Binning > fBins
Definition: HistAxis.h:58
* labels
Represent the binning of a Spectrum&#39;s x-axis.
Definition: Binning.h:18
_Var< T > Var2D(const _Var< T > &a, const Binning &binsa, const _Var< T > &b, const Binning &binsb)
Variable formed from two input variables.
Definition: Var.cxx:109
std::vector< T > fVars
Definition: HistAxis.h:59
process_name opflashCryoW ana
_Var< T > Var3D(const _Var< T > &a, const Binning &binsa, const _Var< T > &b, const Binning &binsb, const _Var< T > &c, const Binning &binsc)
This is just like a Var2D, but useful for 3D Spectra.
Definition: Var.cxx:133
_HistAxis(const std::string &label, const Binning &bins, const T &var)
Definition: HistAxis.cxx:9
fBins({binsX, binsY})
T GetMultiDVar() const
Definition: HistAxis.cxx:66
Collect information describing the x-axis of an analysis histogram.
Definition: HistAxis.h:14
fVars({varX, varY})
Definition: HistAxis.cxx:39
BEGIN_PROLOG could also be cout
std::vector< std::string > fLabels
Definition: HistAxis.h:57