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
 
StringProperty m_formatString
 
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{} {
27  declareProperty("DefinitionSource", m_source);
28  declareProperty("DefinitionFormat", m_formatString = "text/plain");
29 }

◆ ~HistogramDefinitionSvc()

HistogramDefinitionSvc::~HistogramDefinitionSvc ( )
virtualdefault

Member Function Documentation

◆ definition()

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

Definition at line 86 of file HistogramDefinitionSvc.cxx.

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

◆ finalize()

StatusCode HistogramDefinitionSvc::finalize ( )
virtual

Definition at line 80 of file HistogramDefinitionSvc.cxx.

80  {
81  ATH_MSG_INFO("Reader initialised from " << m_reader->source() << " in " << m_reader->format() << " format.");
82  return StatusCode::SUCCESS;
83 }

◆ formatOk()

bool HistogramDefinitionSvc::formatOk ( )
private

Definition at line 221 of file HistogramDefinitionSvc.cxx.

221  {
222  return (m_format < NFORMATS)and(m_format >= 0);
223 }

◆ histoType()

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

Definition at line 97 of file HistogramDefinitionSvc.cxx.

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

◆ initialize()

StatusCode HistogramDefinitionSvc::initialize ( )
virtual

Definition at line 34 of file HistogramDefinitionSvc.cxx.

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

◆ nBinsX()

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

Definition at line 119 of file HistogramDefinitionSvc.cxx.

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

◆ nBinsY()

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

Definition at line 130 of file HistogramDefinitionSvc.cxx.

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

◆ nBinsZ()

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

Definition at line 141 of file HistogramDefinitionSvc.cxx.

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

◆ sourceExists()

bool HistogramDefinitionSvc::sourceExists ( )
private

Definition at line 216 of file HistogramDefinitionSvc.cxx.

216  {
217  return m_reader->sourceExists();
218 }

◆ title()

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

Definition at line 108 of file HistogramDefinitionSvc.cxx.

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

◆ xLimits()

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

Definition at line 152 of file HistogramDefinitionSvc.cxx.

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

◆ xTitle()

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

Definition at line 185 of file HistogramDefinitionSvc.cxx.

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

◆ yLimits()

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

Definition at line 163 of file HistogramDefinitionSvc.cxx.

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

◆ yTitle()

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

Definition at line 196 of file HistogramDefinitionSvc.cxx.

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

◆ zLimits()

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

Definition at line 174 of file HistogramDefinitionSvc.cxx.

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

◆ zTitle()

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

Definition at line 206 of file HistogramDefinitionSvc.cxx.

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

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
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
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
SCT_CalibAlgs::nbins
@ nbins
Definition: SCT_CalibNumbers.h:10
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:221
HistogramDefinitionSvc::m_formatString
StringProperty m_formatString
Definition: HistogramDefinitionSvc.h:50
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