Public Member Functions | Protected Attributes | List of all members
ana::LabelsAndBins Class Reference

#include "/cvmfs/nova.opensciencegrid.org/externals/cafanacore/v01.11/src/CAFAna/Core/LabelsAndBins.h"

Inheritance diagram for ana::LabelsAndBins:
ana::_HistAxis< ana::_Var< SRType > > ana::_HistAxis< MultiVar > ana::_HistAxis< NuTruthVar > ana::_HistAxis< Var > ana::_HistAxis< T >

Public Member Functions

 LabelsAndBins (const std::vector< std::string > &labels, const std::vector< Binning > &bins)
 
 LabelsAndBins (const std::string &label, const Binning &bins)
 
 LabelsAndBins (const std::string &labelX, const Binning &binsX, const std::string &labelY, const Binning &binsY)
 
 LabelsAndBins (const std::string &label, int nx, double x0, double x1)
 Shortcut for simple binnings. More...
 
 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. More...
 
 LabelsAndBins (const LabelsAndBins &ax)=default
 
 LabelsAndBins (const std::vector< LabelsAndBins > &axes)
 
 LabelsAndBins (const LabelsAndBins &xax, const LabelsAndBins &yax)
 
 LabelsAndBins (const LabelsAndBins &xax, const LabelsAndBins &yax, const LabelsAndBins &zax)
 
unsigned int NDimensions () const
 
const std::vector< std::string > & GetLabels () const
 
const std::vector< Binning > & GetBinnings () const
 
const BinningGetBins1D () const
 Appropriate binning and labelling for that 1D Var. More...
 
const std::stringGetLabel1D () const
 

Protected Attributes

std::vector< std::stringfLabels
 
std::vector< BinningfBins
 
std::optional< BinningfBins1D
 
std::optional< std::stringfLabel1D
 

Detailed Description

Definition at line 9 of file LabelsAndBins.h.

Constructor & Destructor Documentation

ana::LabelsAndBins::LabelsAndBins ( const std::vector< std::string > &  labels,
const std::vector< Binning > &  bins 
)

Definition at line 8 of file LabelsAndBins.cxx.

References ana::assert(), fBins, and fLabels.

Referenced by LabelsAndBins().

11  {
12  assert(fLabels.size() == fBins.size());
13  }
std::vector< Binning > fBins
Definition: LabelsAndBins.h:77
const Binning bins
Definition: NumuCC_CPiBin.h:8
assert(nhit_max >=nhit_nbins)
std::vector< std::string > fLabels
Definition: LabelsAndBins.h:76
ana::LabelsAndBins::LabelsAndBins ( const std::string label,
const Binning bins 
)
inline

Definition at line 17 of file LabelsAndBins.h.

19  : LabelsAndBins(std::vector<std::string>(1, label),
20  std::vector<Binning>(1, bins))
21  {
22  }
LabelsAndBins(const std::vector< std::string > &labels, const std::vector< Binning > &bins)
const char * label
const Binning bins
Definition: NumuCC_CPiBin.h:8
ana::LabelsAndBins::LabelsAndBins ( const std::string labelX,
const Binning binsX,
const std::string labelY,
const Binning binsY 
)
inline

Definition at line 24 of file LabelsAndBins.h.

28  : LabelsAndBins({labelX, labelY}, {binsX, binsY})
29  {
30  }
LabelsAndBins(const std::vector< std::string > &labels, const std::vector< Binning > &bins)
ana::LabelsAndBins::LabelsAndBins ( const std::string label,
int  nx,
double  x0,
double  x1 
)
inline

Shortcut for simple binnings.

Definition at line 33 of file LabelsAndBins.h.

36  {
37  }
Float_t x1[n_points_granero]
Definition: compare.C:5
LabelsAndBins(const std::vector< std::string > &labels, const std::vector< Binning > &bins)
const char * label
static Binning Simple(int n, double lo, double hi, const std::vector< std::string > &labels={})
Definition: Binning.cxx:107
ana::LabelsAndBins::LabelsAndBins ( const std::string labelX,
int  nx,
double  x0,
double  x1,
const std::string labelY,
int  ny,
double  y0,
double  y1 
)
inline

Shortcut for simple binnings.

Definition at line 40 of file LabelsAndBins.h.

References visualisationForPaperMasterPlot::ax, file_size_ana::axes, and LabelsAndBins().

44  : LabelsAndBins(labelX, Binning::Simple(nx, x0, x1),
45  labelY, Binning::Simple(ny, y0, y1))
46  {
47  }
Float_t y1[n_points_granero]
Definition: compare.C:5
Float_t x1[n_points_granero]
Definition: compare.C:5
LabelsAndBins(const std::vector< std::string > &labels, const std::vector< Binning > &bins)
static Binning Simple(int n, double lo, double hi, const std::vector< std::string > &labels={})
Definition: Binning.cxx:107
ana::LabelsAndBins::LabelsAndBins ( const LabelsAndBins ax)
default
ana::LabelsAndBins::LabelsAndBins ( const std::vector< LabelsAndBins > &  axes)

Definition at line 16 of file LabelsAndBins.cxx.

References a, ana::assert(), fBins, and fLabels.

17  {
18  for(const auto& a: axes){
19  fLabels.insert(fLabels.end(), a.fLabels.begin(), a.fLabels.end());
20  fBins.insert(fBins.end(), a.fBins.begin(), a.fBins.end());
21  }
22 
23  assert(fLabels.size() == fBins.size());
24  }
std::vector< Binning > fBins
Definition: LabelsAndBins.h:77
const double a
assert(nhit_max >=nhit_nbins)
std::vector< std::string > fLabels
Definition: LabelsAndBins.h:76
ana::LabelsAndBins::LabelsAndBins ( const LabelsAndBins xax,
const LabelsAndBins yax 
)
inline

Definition at line 53 of file LabelsAndBins.h.

55  : LabelsAndBins(std::vector<LabelsAndBins>{xax, yax})
56  {
57  }
LabelsAndBins(const std::vector< std::string > &labels, const std::vector< Binning > &bins)
ana::LabelsAndBins::LabelsAndBins ( const LabelsAndBins xax,
const LabelsAndBins yax,
const LabelsAndBins zax 
)
inline

Definition at line 59 of file LabelsAndBins.h.

62  : LabelsAndBins(std::vector<LabelsAndBins>{xax, yax, zax})
63  {
64  }
LabelsAndBins(const std::vector< std::string > &labels, const std::vector< Binning > &bins)

Member Function Documentation

const std::vector<Binning>& ana::LabelsAndBins::GetBinnings ( ) const
inline
const Binning & ana::LabelsAndBins::GetBins1D ( ) const

Appropriate binning and labelling for that 1D Var.

Definition at line 27 of file LabelsAndBins.cxx.

References ana::assert(), b, fBins, fBins1D, getGoodRuns4SAM::n, and ana::Binning::Simple().

Referenced by ana::ReweightableSpectrum::Fill(), ana::Spectrum::Fill(), GetBinnings(), ana::ReweightableSpectrum::LoadFrom(), ana::Spectrum::Mean(), ana::Spectrum::SaveTo(), ana::Spectrum::Spectrum(), ana::Spectrum::ToTH1(), and ana::ReweightableSpectrum::ToTH2().

28  {
29  if(fBins.size() == 1) return fBins[0];
30 
31  if(fBins1D) return *fBins1D;
32 
33  assert(!fBins.empty());
34 
35  int n = 1;
36  for(const Binning& b: fBins) n *= b.NBins();
37  fBins1D = Binning::Simple(n, 0, n);
38 
39  return *fBins1D;
40  }
std::optional< Binning > fBins1D
Definition: LabelsAndBins.h:79
std::vector< Binning > fBins
Definition: LabelsAndBins.h:77
const hit & b
Definition: hits.cxx:21
assert(nhit_max >=nhit_nbins)
static Binning Simple(int n, double lo, double hi, const std::vector< std::string > &labels={})
Definition: Binning.cxx:107
const std::string & ana::LabelsAndBins::GetLabel1D ( ) const

Definition at line 43 of file LabelsAndBins.cxx.

References fLabel1D, fLabels, submit_hadd::l, and string.

Referenced by GetBinnings(), ana::Spectrum::ToTH1(), and ana::ReweightableSpectrum::ToTH2().

44  {
45  if(fLabels.size() == 1) return fLabels[0];
46 
47  if(fLabel1D) return *fLabel1D;
48 
49  fLabel1D = "";
50  for(const std::string& l: fLabels) *fLabel1D += l + " and ";
51  fLabel1D->resize(fLabel1D->size()-5); // drop extra "and"
52 
53  return *fLabel1D;
54  }
std::optional< std::string > fLabel1D
Definition: LabelsAndBins.h:80
std::vector< std::string > fLabels
Definition: LabelsAndBins.h:76
enum BeamMode string
const std::vector<std::string>& ana::LabelsAndBins::GetLabels ( ) const
inline
unsigned int ana::LabelsAndBins::NDimensions ( ) const
inline

Member Data Documentation

std::vector<Binning> ana::LabelsAndBins::fBins
protected
std::optional<Binning> ana::LabelsAndBins::fBins1D
mutableprotected

Definition at line 79 of file LabelsAndBins.h.

Referenced by GetBins1D().

std::optional<std::string> ana::LabelsAndBins::fLabel1D
mutableprotected

Definition at line 80 of file LabelsAndBins.h.

Referenced by GetLabel1D().

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

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