LabelsAndBins.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "CAFAna/Core/Binning.h"
4 
5 #include <string>
6 
7 namespace ana
8 {
10  {
11  public:
12  // The one constructor to rule them all
13  LabelsAndBins(const std::vector<std::string>& labels,
14  const std::vector<Binning>& bins);
15 
16  // Forwards
18  const Binning& bins)
19  : LabelsAndBins(std::vector<std::string>(1, label),
20  std::vector<Binning>(1, bins))
21  {
22  }
23 
24  LabelsAndBins(const std::string& labelX,
25  const Binning& binsX,
26  const std::string& labelY,
27  const Binning& binsY)
28  : LabelsAndBins({labelX, labelY}, {binsX, binsY})
29  {
30  }
31 
32  /// Shortcut for simple binnings
34  int nx, double x0, double x1)
35  : LabelsAndBins(label, Binning::Simple(nx, x0, x1))
36  {
37  }
38 
39  /// Shortcut for simple binnings
40  LabelsAndBins(const std::string& labelX,
41  int nx, double x0, double x1,
42  const std::string& labelY,
43  int ny, double y0, double y1)
44  : LabelsAndBins(labelX, Binning::Simple(nx, x0, x1),
45  labelY, Binning::Simple(ny, y0, y1))
46  {
47  }
48 
49  LabelsAndBins(const LabelsAndBins& ax) = default;
50 
51  LabelsAndBins(const std::vector<LabelsAndBins>& axes);
52 
54  const LabelsAndBins& yax)
55  : LabelsAndBins(std::vector<LabelsAndBins>{xax, yax})
56  {
57  }
58 
60  const LabelsAndBins& yax,
61  const LabelsAndBins& zax)
62  : LabelsAndBins(std::vector<LabelsAndBins>{xax, yax, zax})
63  {
64  }
65 
66  unsigned int NDimensions() const{return fLabels.size();}
67 
68  const std::vector<std::string>& GetLabels() const {return fLabels;}
69  const std::vector<Binning>& GetBinnings() const {return fBins;}
70 
71  /// Appropriate binning and labelling for that 1D Var
72  const Binning& GetBins1D() const;
73  const std::string& GetLabel1D() const;
74 
75  protected:
76  std::vector<std::string> fLabels;
77  std::vector<Binning> fBins;
78 
79  mutable std::optional<Binning> fBins1D;
80  mutable std::optional<std::string> fLabel1D;
81  };
82 }
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
Float_t y1[n_points_granero]
Definition: compare.C:5
std::optional< Binning > fBins1D
Definition: LabelsAndBins.h:79
Float_t x1[n_points_granero]
Definition: compare.C:5
LabelsAndBins(const std::vector< std::string > &labels, const std::vector< Binning > &bins)
std::vector< Binning > fBins
Definition: LabelsAndBins.h:77
std::optional< std::string > fLabel1D
Definition: LabelsAndBins.h:80
const char * label
LabelsAndBins(const std::string &labelX, int nx, double x0, double x1, const std::string &labelY, int ny, double y0, double y1)
Shortcut for simple binnings.
Definition: LabelsAndBins.h:40
LabelsAndBins(const std::string &label, const Binning &bins)
Definition: LabelsAndBins.h:17
const std::string & GetLabel1D() const
const Binning & GetBins1D() const
Appropriate binning and labelling for that 1D Var.
const std::vector< Binning > & GetBinnings() const
Definition: LabelsAndBins.h:69
const Binning bins
Definition: NumuCC_CPiBin.h:8
unsigned int NDimensions() const
Definition: LabelsAndBins.h:66
LabelsAndBins(const LabelsAndBins &xax, const LabelsAndBins &yax)
Definition: LabelsAndBins.h:53
LabelsAndBins(const std::string &labelX, const Binning &binsX, const std::string &labelY, const Binning &binsY)
Definition: LabelsAndBins.h:24
LabelsAndBins(const LabelsAndBins &xax, const LabelsAndBins &yax, const LabelsAndBins &zax)
Definition: LabelsAndBins.h:59
LabelsAndBins(const std::string &label, int nx, double x0, double x1)
Shortcut for simple binnings.
Definition: LabelsAndBins.h:33
std::vector< std::string > fLabels
Definition: LabelsAndBins.h:76
const std::vector< std::string > & GetLabels() const
Definition: LabelsAndBins.h:68
enum BeamMode string