ATLAS Offline Software
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
SingleHistogramDefinition Class Reference

Almost-a-struct for holding the single histogram definition. More...

#include <SingleHistogramDefinition.h>

Collaboration diagram for SingleHistogramDefinition:

Public Types

typedef const std::string & Titles_t
 
typedef const unsigned int NBins_t
 
typedef const float Var_t
 

Public Member Functions

 SingleHistogramDefinition ()
 
 SingleHistogramDefinition (Titles_t name, Titles_t histoType, Titles_t title, NBins_t nbinsX, Var_t xLo, Var_t xHi, Titles_t xName, Titles_t yName, Titles_t theFolder="")
 C'tor for 1D histograms (no Y bins or limits) More...
 
 SingleHistogramDefinition (Titles_t name, Titles_t histoType, Titles_t title, NBins_t nbinsX, NBins_t nbinsY, Var_t xLo, Var_t xHi, Var_t yLo, Var_t yHi, Titles_t xName, Titles_t yName, Titles_t theFolder="")
 C'tor for 2D histograms (Y bins and limits) More...
 
 SingleHistogramDefinition (Titles_t name, Titles_t histoType, Titles_t title, NBins_t nbinsX, NBins_t nbinsY, NBins_t nbinsZ, Var_t xLo, Var_t xHi, Var_t yLo, Var_t yHi, Var_t zLo, Var_t zHi, Titles_t xName, Titles_t yName, Titles_t zName, Titles_t theFolder="")
 C'tor for 3D histograms (Y,Z bins and limits) More...
 
bool empty () const
 Is the histogram definition empty? More...
 
std::string str () const
 String representation of the histogram definition. More...
 
bool validType () const
 Does the histogram definition have a valid type (TH1, TH2 etc)? More...
 
bool isValid () const
 Is the histogram definition valid. More...
 
std::string stringIndex () const
 add the folder path to produce the full histogram name e.g. myFolder/myHisto More...
 
std::string titleDigest () const
 produce single-line representation of the titles (titles separated by the ';' delimiter) More...
 

Static Public Member Functions

static std::string stringIndex (const std::string &thisname, const std::string &thisfolder)
 concatenate a sanitised folderName with the histogram name More...
 

Public Attributes

std::string name
 
std::string histoType
 
std::string title
 
unsigned int nBinsX
 
unsigned int nBinsY
 
unsigned int nBinsZ
 
IHistogramDefinitionSvc::axesLimits_t xAxis
 
IHistogramDefinitionSvc::axesLimits_t yAxis
 
IHistogramDefinitionSvc::axesLimits_t zAxis
 
std::string xTitle
 
std::string yTitle
 
std::string zTitle
 
std::string allTitles
 
std::string folder
 
bool m_empty
 

Detailed Description

Almost-a-struct for holding the single histogram definition.

Definition at line 17 of file SingleHistogramDefinition.h.

Member Typedef Documentation

◆ NBins_t

Definition at line 20 of file SingleHistogramDefinition.h.

◆ Titles_t

Definition at line 19 of file SingleHistogramDefinition.h.

◆ Var_t

Definition at line 21 of file SingleHistogramDefinition.h.

Constructor & Destructor Documentation

◆ SingleHistogramDefinition() [1/4]

SingleHistogramDefinition::SingleHistogramDefinition ( )

Definition at line 14 of file SingleHistogramDefinition.cxx.

14  :
15  name{},
16  histoType{},
17  title{},
18  nBinsX{},
19  nBinsY{},
20  nBinsZ{},
21  xAxis(std::make_pair(std::numeric_limits<float>::quiet_NaN(), std::numeric_limits<float>::quiet_NaN())),
22  yAxis(std::make_pair(std::numeric_limits<float>::quiet_NaN(), std::numeric_limits<float>::quiet_NaN())),
23  zAxis(std::make_pair(std::numeric_limits<float>::quiet_NaN(), std::numeric_limits<float>::quiet_NaN())),
24  xTitle{},
25  yTitle{},
26  zTitle{},
27  allTitles{},
28  folder{},
29  m_empty(true) {
30 }

◆ SingleHistogramDefinition() [2/4]

SingleHistogramDefinition::SingleHistogramDefinition ( Titles_t  name,
Titles_t  histoType,
Titles_t  title,
NBins_t  nbinsX,
Var_t  xLo,
Var_t  xHi,
Titles_t  xName,
Titles_t  yName,
Titles_t  theFolder = "" 
)

C'tor for 1D histograms (no Y bins or limits)

Definition at line 32 of file SingleHistogramDefinition.cxx.

36  :
37  name(thename), histoType(thehistoType), title(thetitle),
38  nBinsX(nbinsX), nBinsY(0), nBinsZ(0),
39  xAxis(xLo, xHi),
40  yAxis(std::numeric_limits<float>::quiet_NaN(), std::numeric_limits<float>::quiet_NaN()),
41  zAxis(std::numeric_limits<float>::quiet_NaN(), std::numeric_limits<float>::quiet_NaN()),
42  xTitle(xName), yTitle(yName), zTitle(""),
43  folder(thefolder), m_empty(false) {
44 
46 }

◆ SingleHistogramDefinition() [3/4]

SingleHistogramDefinition::SingleHistogramDefinition ( Titles_t  name,
Titles_t  histoType,
Titles_t  title,
NBins_t  nbinsX,
NBins_t  nbinsY,
Var_t  xLo,
Var_t  xHi,
Var_t  yLo,
Var_t  yHi,
Titles_t  xName,
Titles_t  yName,
Titles_t  theFolder = "" 
)

C'tor for 2D histograms (Y bins and limits)

Definition at line 48 of file SingleHistogramDefinition.cxx.

51  :
52  name(thename), histoType(thehistoType), title(thetitle),
53  nBinsX(nbinsX), nBinsY(nbinsY), nBinsZ(0),
54  xAxis(xLo, xHi),
55  yAxis(yLo, yHi),
56  zAxis(std::numeric_limits<float>::quiet_NaN(), std::numeric_limits<float>::quiet_NaN()),
57  xTitle(xName), yTitle(yName), zTitle(""),
58  folder(thefolder), m_empty(false) {
59  // should do sanity checks here
60 
62 }

◆ SingleHistogramDefinition() [4/4]

SingleHistogramDefinition::SingleHistogramDefinition ( Titles_t  name,
Titles_t  histoType,
Titles_t  title,
NBins_t  nbinsX,
NBins_t  nbinsY,
NBins_t  nbinsZ,
Var_t  xLo,
Var_t  xHi,
Var_t  yLo,
Var_t  yHi,
Var_t  zLo,
Var_t  zHi,
Titles_t  xName,
Titles_t  yName,
Titles_t  zName,
Titles_t  theFolder = "" 
)

C'tor for 3D histograms (Y,Z bins and limits)

Definition at line 64 of file SingleHistogramDefinition.cxx.

67  :
68  name(thename), histoType(thehistoType), title(thetitle),
69  nBinsX(nbinsX), nBinsY(nbinsY), nBinsZ(nbinsZ),
70  xAxis(xLo, xHi),
71  yAxis(yLo, yHi),
72  zAxis(zLo, zHi),
73  xTitle(xName), yTitle(yName), zTitle(zName),
74  folder(thefolder), m_empty(false) {
75  // should do sanity checks here
76 
78 }

Member Function Documentation

◆ empty()

bool SingleHistogramDefinition::empty ( ) const

Is the histogram definition empty?

Definition at line 81 of file SingleHistogramDefinition.cxx.

81  {
82  return m_empty;
83 }

◆ isValid()

bool SingleHistogramDefinition::isValid ( ) const

Is the histogram definition valid.

Definition at line 104 of file SingleHistogramDefinition.cxx.

104  {
105  if (name.empty() or histoType.empty()) {
106  return false;
107  }
108  bool sane(true);
109  // note: if yaxis is left undefined, the limits should be NaN, but (NaN != NaN) is always true
110  const bool sensibleLimits = (xAxis.first != xAxis.second)and(yAxis.first != yAxis.second)and(zAxis.first != zAxis.second);
111  const bool sensibleXBins = (nBinsX != 0);
112  const bool sensibleYBins = (nBinsY != 0);
113  const bool sensibleZBins = (nBinsZ != 0);
114  const bool sensibleTitles = not (title.empty() or xTitle.empty());
115  sane = (sensibleLimits and sensibleXBins and sensibleTitles);
116  if (histoType.substr(0, 3) == "TH2") {
117  sane = (sane and sensibleYBins);
118  }
119  if (histoType.substr(0, 3) == "TH3") {
120  sane = (sane and sensibleYBins and sensibleZBins);
121  }
122  return sane;
123 }

◆ str()

std::string SingleHistogramDefinition::str ( ) const

String representation of the histogram definition.

Definition at line 86 of file SingleHistogramDefinition.cxx.

86  {
87  const std::string s(" ");
88 
90  s + std::to_string(xAxis.first) + s + std::to_string(xAxis.second) + s +
91  std::to_string(yAxis.first) + s + std::to_string(yAxis.second) + s +
92  std::to_string(zAxis.first) + s + std::to_string(zAxis.second) + s +
93  xTitle + s + yTitle + s + zTitle;
94 }

◆ stringIndex() [1/2]

std::string SingleHistogramDefinition::stringIndex ( ) const

add the folder path to produce the full histogram name e.g. myFolder/myHisto

Definition at line 126 of file SingleHistogramDefinition.cxx.

126  {
127  return stringIndex(name, folder);
128 }

◆ stringIndex() [2/2]

std::string SingleHistogramDefinition::stringIndex ( const std::string &  thisname,
const std::string &  thisfolder 
)
static

concatenate a sanitised folderName with the histogram name

Definition at line 138 of file SingleHistogramDefinition.cxx.

138  {
139  if (thisfolder.empty()) {
140  return thisname;
141  }
142  const std::string delimiter("/");
143  std::string result(thisfolder);
144  if ((thisfolder.substr(0, 1)) == delimiter) {
145  result = thisfolder.substr(1, thisfolder.size() - 2);// reduce "/myfolder" to "myfolder"
146  }
147  size_t lastChar(result.size() - 1);
148  if ((result.substr(lastChar, 1) != delimiter)) {
149  result = result + delimiter; // add a slash: "myfolder" => "myfolder/"
150  }
151  return result + thisname;
152 }

◆ titleDigest()

std::string SingleHistogramDefinition::titleDigest ( ) const

produce single-line representation of the titles (titles separated by the ';' delimiter)

Definition at line 131 of file SingleHistogramDefinition.cxx.

131  {
132  const std::string s(";");
133 
134  return title + s + xTitle + s + yTitle + s + zTitle;
135 }

◆ validType()

bool SingleHistogramDefinition::validType ( ) const

Does the histogram definition have a valid type (TH1, TH2 etc)?

Definition at line 97 of file SingleHistogramDefinition.cxx.

97  {
98  const std::string signature((histoType.substr(0, 3)));
99 
100  return((signature == "TH1")or(signature == "TH2")or(signature == "TH3")or(signature == "TPr") or(signature == "TEf"));
101 }

Member Data Documentation

◆ allTitles

std::string SingleHistogramDefinition::allTitles

Definition at line 56 of file SingleHistogramDefinition.h.

◆ folder

std::string SingleHistogramDefinition::folder

Definition at line 57 of file SingleHistogramDefinition.h.

◆ histoType

std::string SingleHistogramDefinition::histoType

Definition at line 45 of file SingleHistogramDefinition.h.

◆ m_empty

bool SingleHistogramDefinition::m_empty

Definition at line 73 of file SingleHistogramDefinition.h.

◆ name

std::string SingleHistogramDefinition::name

Definition at line 44 of file SingleHistogramDefinition.h.

◆ nBinsX

unsigned int SingleHistogramDefinition::nBinsX

Definition at line 47 of file SingleHistogramDefinition.h.

◆ nBinsY

unsigned int SingleHistogramDefinition::nBinsY

Definition at line 48 of file SingleHistogramDefinition.h.

◆ nBinsZ

unsigned int SingleHistogramDefinition::nBinsZ

Definition at line 49 of file SingleHistogramDefinition.h.

◆ title

std::string SingleHistogramDefinition::title

Definition at line 46 of file SingleHistogramDefinition.h.

◆ xAxis

IHistogramDefinitionSvc::axesLimits_t SingleHistogramDefinition::xAxis

Definition at line 50 of file SingleHistogramDefinition.h.

◆ xTitle

std::string SingleHistogramDefinition::xTitle

Definition at line 53 of file SingleHistogramDefinition.h.

◆ yAxis

IHistogramDefinitionSvc::axesLimits_t SingleHistogramDefinition::yAxis

Definition at line 51 of file SingleHistogramDefinition.h.

◆ yTitle

std::string SingleHistogramDefinition::yTitle

Definition at line 54 of file SingleHistogramDefinition.h.

◆ zAxis

IHistogramDefinitionSvc::axesLimits_t SingleHistogramDefinition::zAxis

Definition at line 52 of file SingleHistogramDefinition.h.

◆ zTitle

std::string SingleHistogramDefinition::zTitle

Definition at line 55 of file SingleHistogramDefinition.h.


The documentation for this class was generated from the following files:
SingleHistogramDefinition::stringIndex
std::string stringIndex() const
add the folder path to produce the full histogram name e.g. myFolder/myHisto
Definition: SingleHistogramDefinition.cxx:126
SingleHistogramDefinition::nBinsX
unsigned int nBinsX
Definition: SingleHistogramDefinition.h:47
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
get_generator_info.result
result
Definition: get_generator_info.py:21
SingleHistogramDefinition::nBinsZ
unsigned int nBinsZ
Definition: SingleHistogramDefinition.h:49
SingleHistogramDefinition::yTitle
std::string yTitle
Definition: SingleHistogramDefinition.h:54
SingleHistogramDefinition::histoType
std::string histoType
Definition: SingleHistogramDefinition.h:45
SingleHistogramDefinition::folder
std::string folder
Definition: SingleHistogramDefinition.h:57
SingleHistogramDefinition::xAxis
IHistogramDefinitionSvc::axesLimits_t xAxis
Definition: SingleHistogramDefinition.h:50
python.AthDsoLogger.delimiter
delimiter
Definition: AthDsoLogger.py:71
SingleHistogramDefinition::title
std::string title
Definition: SingleHistogramDefinition.h:46
SingleHistogramDefinition::xTitle
std::string xTitle
Definition: SingleHistogramDefinition.h:53
rootconvert.yLo
yLo
Definition: rootconvert.py:33
rootconvert.xLo
xLo
Definition: rootconvert.py:32
ActsTrk::to_string
std::string to_string(const DetectorType &type)
Definition: GeometryDefs.h:34
SingleHistogramDefinition::m_empty
bool m_empty
Definition: SingleHistogramDefinition.h:73
SingleHistogramDefinition::titleDigest
std::string titleDigest() const
produce single-line representation of the titles (titles separated by the ';' delimiter)
Definition: SingleHistogramDefinition.cxx:131
rootconvert.yHi
yHi
Definition: rootconvert.py:33
SingleHistogramDefinition::zTitle
std::string zTitle
Definition: SingleHistogramDefinition.h:55
rootconvert.xHi
xHi
Definition: rootconvert.py:32
SingleHistogramDefinition::name
std::string name
Definition: SingleHistogramDefinition.h:44
SingleHistogramDefinition::yAxis
IHistogramDefinitionSvc::axesLimits_t yAxis
Definition: SingleHistogramDefinition.h:51
SingleHistogramDefinition::allTitles
std::string allTitles
Definition: SingleHistogramDefinition.h:56
SingleHistogramDefinition::zAxis
IHistogramDefinitionSvc::axesLimits_t zAxis
Definition: SingleHistogramDefinition.h:52
SingleHistogramDefinition::nBinsY
unsigned int nBinsY
Definition: SingleHistogramDefinition.h:48