HistAxis.h
Go to the documentation of this file.
1 #pragma once
2 
4 
6 
7 #include "CAFAna/Core/MultiVar.h"
8 #include "CAFAna/Core/Var.h"
9 
10 #include <string>
11 
12 namespace ana
13 {
14  /// \brief Collect information describing the x-axis of an analysis histogram
15  ///
16  /// That is, what it should be labelled, what the binning should be, and what
17  /// variable will be being filled into it.
18  template<class T> class _HistAxis: public LabelsAndBins
19  {
20  public:
21  // The one constructor to rule them all
22  _HistAxis(const std::vector<std::string>& labels,
23  const std::vector<Binning>& bins,
24  const std::vector<T>& vars = {});
25 
26  // Forwards
28  const Binning& bins,
29  const T& var)
30  : _HistAxis(std::vector<std::string>(1, label),
31  std::vector<Binning>(1, bins),
32  std::vector<T>(1, var))
33  {
34  }
35 
37  const Binning& bins)
38  : _HistAxis(std::vector<std::string>(1, label),
39  std::vector<Binning>(1, bins))
40  {
41  }
42 
43  _HistAxis(const std::string& labelX,
44  const Binning& binsX,
45  const T& varX,
46  const std::string& labelY,
47  const Binning& binsY,
48  const T& varY)
49  : _HistAxis({labelX, labelY}, {binsX, binsY}, {varX, varY})
50  {
51  }
52 
53  /// Shortcut for simple binnings
55  int nx, double x0, double x1,
56  const T& var)
57  : _HistAxis(label, Binning::Simple(nx, x0, x1), var)
58  {
59  }
60 
61  /// Shortcut for simple binnings
62  _HistAxis(const std::string& labelX,
63  int nx, double x0, double x1,
64  const T& varX,
65  const std::string& labelY,
66  int ny, double y0, double y1,
67  const T& varY)
68  : _HistAxis(labelX, Binning::Simple(nx, x0, x1), varX,
69  labelY, Binning::Simple(ny, y0, y1), varY)
70  {
71  }
72 
73  _HistAxis(const _HistAxis<T>& ax) = default;
74 
75  _HistAxis(const std::vector<_HistAxis<T>>& axes);
76 
77  _HistAxis(const _HistAxis<T>& xax,
78  const _HistAxis<T>& yax)
79  : _HistAxis(std::vector<_HistAxis<T>>{xax, yax})
80  {
81  }
82 
83  _HistAxis(const _HistAxis<T>& xax,
84  const _HistAxis<T>& yax,
85  const _HistAxis<T>& zax)
86  : _HistAxis(std::vector<_HistAxis<T>>{xax, yax, zax})
87  {
88  }
89 
90  bool HasVars() const {return !fVars.empty();}
91 
92  const std::vector<T>& GetVars() const {return fVars;}
93 
94  /// A variable "flattening" all the dimensions into one 1D value. Use
95  /// sparingly.
96  T GetVar1D() const;
97 
98  protected:
99  std::vector<T> fVars;
100  };
101 
102  // Typedefs
107 }
bool HasVars() const
Definition: HistAxis.h:90
_HistAxis(const std::string &labelX, const Binning &binsX, const T &varX, const std::string &labelY, const Binning &binsY, const T &varY)
Definition: HistAxis.h:43
_HistAxis< Var > HistAxis
Definition: HistAxis.h:103
Represent the binning of a Spectrum&#39;s x-axis.
Definition: Binning.h:16
Cuts and Vars for the 2020 FD DiF Study.
Definition: vars.h:6
_HistAxis< SpillVar > SpillHistAxis
Definition: HistAxis.h:105
const std::vector< T > & GetVars() const
Definition: HistAxis.h:92
Float_t y1[n_points_granero]
Definition: compare.C:5
Float_t x1[n_points_granero]
Definition: compare.C:5
std::vector< T > fVars
Definition: HistAxis.h:99
_HistAxis< MultiVar > MultiVarHistAxis
Definition: HistAxis.h:104
const char * label
_HistAxis(const std::string &label, const Binning &bins)
Definition: HistAxis.h:36
_HistAxis(const std::string &label, const Binning &bins, const T &var)
Definition: HistAxis.h:27
const std::map< std::pair< std::string, std::string >, Variable > vars
_HistAxis(const std::string &labelX, int nx, double x0, double x1, const T &varX, const std::string &labelY, int ny, double y0, double y1, const T &varY)
Shortcut for simple binnings.
Definition: HistAxis.h:62
_HistAxis(const std::vector< std::string > &labels, const std::vector< Binning > &bins, const std::vector< T > &vars={})
Definition: HistAxis.cxx:19
const Binning bins
Definition: NumuCC_CPiBin.h:8
_HistAxis(const _HistAxis< T > &xax, const _HistAxis< T > &yax)
Definition: HistAxis.h:77
Collect information describing the x-axis of an analysis histogram.
Definition: HistAxis.h:18
double T
Definition: Xdiff_gwt.C:5
_HistAxis< NuTruthVar > NuTruthHistAxis
Definition: HistAxis.h:106
_HistAxis(const _HistAxis< T > &xax, const _HistAxis< T > &yax, const _HistAxis< T > &zax)
Definition: HistAxis.h:83
_HistAxis(const std::string &label, int nx, double x0, double x1, const T &var)
Shortcut for simple binnings.
Definition: HistAxis.h:54
T GetVar1D() const
Definition: HistAxis.cxx:43
enum BeamMode string