ATLAS Offline Software
Public Member Functions | Private Member Functions | Private Attributes | List of all members
HistogramDefinitionSvc Class Reference

#include <HistogramDefinitionSvc.h>

Inheritance diagram for HistogramDefinitionSvc:
Collaboration diagram for HistogramDefinitionSvc:

Public Member Functions

 HistogramDefinitionSvc (const std::string &name, ISvcLocator *svc)
 
virtual ~HistogramDefinitionSvc ()
 
virtual StatusCode initialize ()
 
virtual StatusCode finalize ()
 
SingleHistogramDefinition definition (const std::string &name, const std::string &dirName="") const final
 
std::string histoType (const std::string &name, const std::string &dirName="") const final
 
std::string title (const std::string &name, const std::string &dirName="") const final
 
unsigned int nBinsX (const std::string &name, const std::string &dirName="") const final
 
unsigned int nBinsY (const std::string &name, const std::string &dirName="") const final
 
unsigned int nBinsZ (const std::string &name, const std::string &dirName="") const final
 
IHistogramDefinitionSvc::axesLimits_t xLimits (const std::string &name, const std::string &dirName="") const final
 
IHistogramDefinitionSvc::axesLimits_t yLimits (const std::string &name, const std::string &dirName="") const final
 
IHistogramDefinitionSvc::axesLimits_t zLimits (const std::string &name, const std::string &dirName="") const final
 
std::string xTitle (const std::string &name, const std::string &dirName="") const final
 
std::string yTitle (const std::string &name, const std::string &dirName="") const final
 
std::string zTitle (const std::string &name, const std::string &dirName="") const final
 

Private Member Functions

bool sourceExists ()
 
bool formatOk ()
 

Private Attributes

StringProperty m_source {this, "DefinitionSource"}
 
StringProperty m_formatString {this, "DefinitionFormat", "text/plain"}
 
IHistogramDefinitionSvc::Formats m_format
 
std::map< std::string, SingleHistogramDefinitionm_histoDefMap
 
std::unique_ptr< IReadHistoDefm_reader
 

Detailed Description

Definition at line 26 of file HistogramDefinitionSvc.h.

Constructor & Destructor Documentation

◆ HistogramDefinitionSvc()

HistogramDefinitionSvc::HistogramDefinitionSvc ( const std::string &  name,
ISvcLocator *  svc 
)

Definition at line 25 of file HistogramDefinitionSvc.cxx.

25  :
26  base_class(name, pSvcLocator), m_format{UNKNOWN}, m_reader{} {}

◆ ~HistogramDefinitionSvc()

HistogramDefinitionSvc::~HistogramDefinitionSvc ( )
virtualdefault

Member Function Documentation

◆ definition()

SingleHistogramDefinition HistogramDefinitionSvc::definition ( const std::string &  name,
const std::string &  dirName = "" 
) const
final

Definition at line 83 of file HistogramDefinitionSvc.cxx.

83  {
85  const auto pthisHistoPair(m_histoDefMap.find(SingleHistogramDefinition::stringIndex(name, dirName)));
86 
87  if (pthisHistoPair != m_histoDefMap.end()) {
88  result = pthisHistoPair->second;
89  }
90  return result;
91 }

◆ finalize()

StatusCode HistogramDefinitionSvc::finalize ( )
virtual

Definition at line 77 of file HistogramDefinitionSvc.cxx.

77  {
78  ATH_MSG_INFO("Reader initialised from " << m_reader->source() << " in " << m_reader->format() << " format.");
79  return StatusCode::SUCCESS;
80 }

◆ formatOk()

bool HistogramDefinitionSvc::formatOk ( )
private

Definition at line 218 of file HistogramDefinitionSvc.cxx.

218  {
219  return (m_format < NFORMATS)and(m_format >= 0);
220 }

◆ histoType()

std::string HistogramDefinitionSvc::histoType ( const std::string &  name,
const std::string &  dirName = "" 
) const
final

Definition at line 94 of file HistogramDefinitionSvc.cxx.

94  {
95  std::string result {};
96  const auto pthisHistoPair(m_histoDefMap.find(SingleHistogramDefinition::stringIndex(name, dirName)));
97 
98  if (pthisHistoPair != m_histoDefMap.end()) {
99  result = pthisHistoPair->second.histoType;
100  }
101  return result;
102 }

◆ initialize()

StatusCode HistogramDefinitionSvc::initialize ( )
virtual

Definition at line 31 of file HistogramDefinitionSvc.cxx.

31  {
32  if (m_formatString.value() == defaultFormat) {
33  m_format = TEXT_PLAIN;
34  }
35  if (m_formatString.value() == xmlFormat) {
36  m_format = TEXT_XML;
37  }
38  if (m_format == UNKNOWN) {
39  ATH_MSG_ERROR("Unknown format for the input to the hdef service");
40  return StatusCode::FAILURE;
41  }
42  ATH_MSG_INFO("hdef source:" << m_source.value());
43  ATH_MSG_INFO("Set format:" << m_formatString.value());
44  ATH_MSG_INFO("format " << m_format);
45  if (m_format == TEXT_PLAIN) {
46  ATH_MSG_FATAL("Text format histogram definition files are deprecated.");
47  return StatusCode::FAILURE;
48  }
49  if (m_format == TEXT_XML) {
50  m_reader = std::make_unique<ReadFromXmlDom>(m_source.value());
51  }
52  ATH_MSG_INFO("Reader initialising from " << m_reader->source() << " in " << m_reader->format() << " format.");
53  bool ok = m_reader->initialize();
54  if (not ok) {
55  ATH_MSG_WARNING("Reader did not initialise");
56  }
57  ok = m_reader->histoDefinitionMap(m_histoDefMap);
58  bool allDefsOk(true);
59  for (auto& h:m_histoDefMap) {
60  if (not h.second.isValid()) {
61  ATH_MSG_WARNING("Invalid histogram definition: " << h.second.str());
62  allDefsOk = false;
63  }
64  }
65  if (ok and(not allDefsOk)) {
66  ATH_MSG_WARNING("Some histogram definitions were bad.");
67  return StatusCode::RECOVERABLE;
68  }
69  if (not ok) {
70  ATH_MSG_ERROR("The definition reader failed to read the histogram definitions.");
71  return StatusCode::FAILURE;
72  }
73  return StatusCode::SUCCESS;
74 }

◆ nBinsX()

unsigned int HistogramDefinitionSvc::nBinsX ( const std::string &  name,
const std::string &  dirName = "" 
) const
final

Definition at line 116 of file HistogramDefinitionSvc.cxx.

116  {
117  unsigned int nbins(0);
118  const auto pthisHistoPair(m_histoDefMap.find(SingleHistogramDefinition::stringIndex(name, dirName)));
119 
120  if (pthisHistoPair != m_histoDefMap.end()) {
121  nbins = pthisHistoPair->second.nBinsX;
122  }
123  return nbins;
124 }

◆ nBinsY()

unsigned int HistogramDefinitionSvc::nBinsY ( const std::string &  name,
const std::string &  dirName = "" 
) const
final

Definition at line 127 of file HistogramDefinitionSvc.cxx.

127  {
128  unsigned int nbins(0);
129  const auto pthisHistoPair(m_histoDefMap.find(SingleHistogramDefinition::stringIndex(name, dirName)));
130 
131  if (pthisHistoPair != m_histoDefMap.end()) {
132  nbins = pthisHistoPair->second.nBinsY;
133  }
134  return nbins;
135 }

◆ nBinsZ()

unsigned int HistogramDefinitionSvc::nBinsZ ( const std::string &  name,
const std::string &  dirName = "" 
) const
final

Definition at line 138 of file HistogramDefinitionSvc.cxx.

138  {
139  unsigned int nbins(0);
140  const auto pthisHistoPair(m_histoDefMap.find(SingleHistogramDefinition::stringIndex(name, dirName)));
141 
142  if (pthisHistoPair != m_histoDefMap.end()) {
143  nbins = pthisHistoPair->second.nBinsZ;
144  }
145  return nbins;
146 }

◆ sourceExists()

bool HistogramDefinitionSvc::sourceExists ( )
private

Definition at line 213 of file HistogramDefinitionSvc.cxx.

213  {
214  return m_reader->sourceExists();
215 }

◆ title()

std::string HistogramDefinitionSvc::title ( const std::string &  name,
const std::string &  dirName = "" 
) const
final

Definition at line 105 of file HistogramDefinitionSvc.cxx.

105  {
106  std::string result {};
107  const auto pthisHistoPair(m_histoDefMap.find(SingleHistogramDefinition::stringIndex(name, dirName)));
108 
109  if (pthisHistoPair != m_histoDefMap.end()) {
110  result = pthisHistoPair->second.title;
111  }
112  return result;
113 }

◆ xLimits()

IHistogramDefinitionSvc::axesLimits_t HistogramDefinitionSvc::xLimits ( const std::string &  name,
const std::string &  dirName = "" 
) const
final

Definition at line 149 of file HistogramDefinitionSvc.cxx.

149  {
150  axesLimits_t result(invalidLimits);
151  const auto pthisHistoPair(m_histoDefMap.find(SingleHistogramDefinition::stringIndex(name, dirName)));
152 
153  if (pthisHistoPair != m_histoDefMap.end()) {
154  result = pthisHistoPair->second.xAxis;
155  }
156  return result;
157 }

◆ xTitle()

std::string HistogramDefinitionSvc::xTitle ( const std::string &  name,
const std::string &  dirName = "" 
) const
final

Definition at line 182 of file HistogramDefinitionSvc.cxx.

182  {
183  std::string result {};
184  const auto pthisHistoPair(m_histoDefMap.find(SingleHistogramDefinition::stringIndex(name, dirName)));
185 
186  if (pthisHistoPair != m_histoDefMap.end()) {
187  result = pthisHistoPair->second.xTitle;
188  }
189  return result;
190 }

◆ yLimits()

IHistogramDefinitionSvc::axesLimits_t HistogramDefinitionSvc::yLimits ( const std::string &  name,
const std::string &  dirName = "" 
) const
final

Definition at line 160 of file HistogramDefinitionSvc.cxx.

160  {
161  axesLimits_t result(invalidLimits);
162  const auto pthisHistoPair(m_histoDefMap.find(SingleHistogramDefinition::stringIndex(name, dirName)));
163 
164  if (pthisHistoPair != m_histoDefMap.end()) {
165  result = pthisHistoPair->second.yAxis;
166  }
167  return result;
168 }

◆ yTitle()

std::string HistogramDefinitionSvc::yTitle ( const std::string &  name,
const std::string &  dirName = "" 
) const
final

Definition at line 193 of file HistogramDefinitionSvc.cxx.

193  {
194  std::string result {};
195  const auto pthisHistoPair(m_histoDefMap.find(SingleHistogramDefinition::stringIndex(name, dirName)));
196  if (pthisHistoPair != m_histoDefMap.end()) {
197  result = pthisHistoPair->second.yTitle;
198  }
199  return result;
200 }

◆ zLimits()

IHistogramDefinitionSvc::axesLimits_t HistogramDefinitionSvc::zLimits ( const std::string &  name,
const std::string &  dirName = "" 
) const
final

Definition at line 171 of file HistogramDefinitionSvc.cxx.

171  {
172  axesLimits_t result(invalidLimits);
173  const auto pthisHistoPair(m_histoDefMap.find(SingleHistogramDefinition::stringIndex(name, dirName)));
174 
175  if (pthisHistoPair != m_histoDefMap.end()) {
176  result = pthisHistoPair->second.zAxis;
177  }
178  return result;
179 }

◆ zTitle()

std::string HistogramDefinitionSvc::zTitle ( const std::string &  name,
const std::string &  dirName = "" 
) const
final

Definition at line 203 of file HistogramDefinitionSvc.cxx.

203  {
204  std::string result {};
205  const auto pthisHistoPair(m_histoDefMap.find(SingleHistogramDefinition::stringIndex(name, dirName)));
206  if (pthisHistoPair != m_histoDefMap.end()) {
207  result = pthisHistoPair->second.zTitle;
208  }
209  return result;
210 }

Member Data Documentation

◆ m_format

IHistogramDefinitionSvc::Formats HistogramDefinitionSvc::m_format
private

Definition at line 51 of file HistogramDefinitionSvc.h.

◆ m_formatString

StringProperty HistogramDefinitionSvc::m_formatString {this, "DefinitionFormat", "text/plain"}
private

Definition at line 50 of file HistogramDefinitionSvc.h.

◆ m_histoDefMap

std::map<std::string, SingleHistogramDefinition> HistogramDefinitionSvc::m_histoDefMap
private

Definition at line 52 of file HistogramDefinitionSvc.h.

◆ m_reader

std::unique_ptr<IReadHistoDef> HistogramDefinitionSvc::m_reader
private

Definition at line 53 of file HistogramDefinitionSvc.h.

◆ m_source

StringProperty HistogramDefinitionSvc::m_source {this, "DefinitionSource"}
private

Definition at line 49 of file HistogramDefinitionSvc.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
python.StoreID.UNKNOWN
int UNKNOWN
Definition: StoreID.py:16
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
get_generator_info.result
result
Definition: get_generator_info.py:21
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
HistogramDefinitionSvc::m_histoDefMap
std::map< std::string, SingleHistogramDefinition > m_histoDefMap
Definition: HistogramDefinitionSvc.h:52
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
HistogramDefinitionSvc::m_format
IHistogramDefinitionSvc::Formats m_format
Definition: HistogramDefinitionSvc.h:51
SingleHistogramDefinition
Almost-a-struct for holding the single histogram definition.
Definition: SingleHistogramDefinition.h:17
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
HistogramDefinitionSvc::m_formatString
StringProperty m_formatString
Definition: HistogramDefinitionSvc.h:50
SCT_CalibAlgs::nbins
@ nbins
Definition: SCT_CalibNumbers.h:10
h
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
HistogramDefinitionSvc::m_source
StringProperty m_source
Definition: HistogramDefinitionSvc.h:49
HistogramDefinitionSvc::m_reader
std::unique_ptr< IReadHistoDef > m_reader
Definition: HistogramDefinitionSvc.h:53