The Gaudi Framework  master (d98a2936)
HistoDef.cpp
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2025 CERN for the benefit of the LHCb and ATLAS collaborations *
3 * *
4 * This software is distributed under the terms of the Apache version 2 licence, *
5 * copied verbatim in the file "LICENSE". *
6 * *
7 * In applying this licence, CERN does not waive the privileges and immunities *
8 * granted to it by virtue of its status as an Intergovernmental Organization *
9 * or submit itself to any jurisdiction. *
10 \***********************************************************************************/
11 #include <GaudiKernel/HistoDef.h>
13 #include <GaudiKernel/ToStream.h>
14 #include <ostream>
15 
22 /* full constructor from edges, #bins and the title
23  * @param low the low edge of the histogram
24  * @param high the high edge of the histogram
25  * @param bins number of bins
26  * @param title the histogram title
27  */
28 Gaudi::Histo1DDef::Histo1DDef( const double low, const double high, const int bins, std::string title )
29  : m_title( std::move( title ) ), m_low( low ), m_high( high ), m_bins( bins ) {}
30 /* full constructor from edges, #bins and the title
31  * @param title the histogram title
32  * @param low the low edge of the histogram
33  * @param high the high edge of the histogram
34  * @param bins number of bins
35  */
36 Gaudi::Histo1DDef::Histo1DDef( std::string title, const double low, const double high, const int bins )
37  : m_title( std::move( title ) ), m_low( low ), m_high( high ), m_bins( bins ) {}
38 // printout of the histogram definition
39 std::ostream& Gaudi::Histo1DDef::fillStream( std::ostream& o ) const {
40  return o << "(" << Gaudi::Utils::toString( title() ) << "," << lowEdge() << "," << highEdge() << "," << bins() << ")";
41 }
42 namespace Gaudi {
43  // ordering operator (to please BoundedVerifier)
44  bool operator<( const Gaudi::Histo1DDef& left, const Gaudi::Histo1DDef& right ) {
45  return std::tie( left.m_title, left.m_low, left.m_high, left.m_bins ) <
46  std::tie( right.m_title, right.m_low, right.m_high, right.m_bins );
47  }
48  // the streamer operator for class Gaudi::Histo1DDef
49  std::ostream& operator<<( std::ostream& o, const Gaudi::Histo1DDef& histo ) { return histo.fillStream( o ); }
50 } // namespace Gaudi
51 
52 /* helper function to book 1D-histogram
53  * @param svc pointer to Histogram Service
54  * @param path full path in Histogram Data Store
55  * @param hist histogram desctriprion
56  */
57 AIDA::IHistogram1D* Gaudi::Histos::book( IHistogramSvc* svc, const std::string& path, const Gaudi::Histo1DDef& hist ) {
58  return svc ? svc->book( path, hist.title(), hist.bins(), hist.lowEdge(), hist.highEdge() ) : nullptr;
59 }
60 /* helper function to book 1D-histogram
61  * @param svc pointer to Histogram Service
62  * @param dir directory path in Histogram Data Store
63  * @param id histogram identifier
64  * @param hist histogram desctriprion
65  */
66 AIDA::IHistogram1D* Gaudi::Histos::book( IHistogramSvc* svc, const std::string& dir, const std::string& id,
67  const Gaudi::Histo1DDef& hist ) {
68  return svc ? svc->book( dir, id, hist.title(), hist.bins(), hist.lowEdge(), hist.highEdge() ) : nullptr;
69 }
70 /* helper function to book 1D-histogram
71  * @param svc pointer to Histogram Service
72  * @param dir directory path in Histogram Data Store
73  * @param id histogram identifier
74  * @param hist histogram desctriprion
75  */
76 AIDA::IHistogram1D* Gaudi::Histos::book( IHistogramSvc* svc, const std::string& dir, const int id,
77  const Gaudi::Histo1DDef& hist ) {
78  return svc ? svc->book( dir, id, hist.title(), hist.bins(), hist.lowEdge(), hist.highEdge() ) : nullptr;
79 }
IHistogramSvc
Definition: IHistogramSvc.h:53
AtlasMCRecoFullPrecedenceDump.path
path
Definition: AtlasMCRecoFullPrecedenceDump.py:49
GaudiPartProp.decorators.std
std
Definition: decorators.py:32
Gaudi::Histo1DDef::m_high
double m_high
High Edge.
Definition: HistoDef.h:72
Gaudi::Histo1DDef::m_low
double m_low
Low Edge.
Definition: HistoDef.h:71
IHistogramSvc::book
virtual AIDA::IHistogram1D * book(const std::string &fullPath, const std::string &title, int binsX, double lowX, double highX)=0
Book histogram and register it with the histogram data store.
ToStream.h
HistoDef.h
Gaudi::Histo1DDef::fillStream
std::ostream & fillStream(std::ostream &o) const
printout of the histogram definition
Definition: HistoDef.cpp:39
Gaudi::Histo1DDef
Definition: HistoDef.h:30
Gaudi::Histos::book
GAUDI_API AIDA::IHistogram1D * book(IHistogramSvc *svc, const std::string &path, const Gaudi::Histo1DDef &hist)
helper function to book 1D-histogram
Definition: HistoDef.cpp:57
Gaudi
This file provides a Grammar for the type Gaudi::Accumulators::Axis It allows to use that type from p...
Definition: __init__.py:1
Gaudi::Histo1DDef::highEdge
double highEdge() const
get the high edge
Definition: HistoDef.h:49
Gaudi::Utils::toString
std::string toString(const TYPE &obj)
the generic implementation of the type conversion to the string
Definition: ToStream.h:326
Gaudi::Histo1DDef::m_bins
int m_bins
Number of bins.
Definition: HistoDef.h:73
Gaudi::Histo1DDef::m_title
std::string m_title
Histogram title.
Definition: HistoDef.h:70
Gaudi::operator<
bool operator<(const Gaudi::Histo1DDef &left, const Gaudi::Histo1DDef &right)
Definition: HistoDef.cpp:44
Gaudi::Histo1DDef::lowEdge
double lowEdge() const
get the low edge
Definition: HistoDef.h:47
Gaudi::operator<<
std::ostream & operator<<(std::ostream &o, const Gaudi::StringKey &key)
printout of the object reply on the native printout for the string
Definition: StringKey.h:176
Gaudi::Histo1DDef::bins
int bins() const
get the number of bins
Definition: HistoDef.h:51
Gaudi::Histo1DDef::title
const std::string & title() const
get the title
Definition: HistoDef.h:53
IHistogramSvc.h
Gaudi::Histo1DDef::Histo1DDef
Histo1DDef(double low, double high, int bins=100, std::string title="")
full constructor from edges, bins and the title
Definition: HistoDef.cpp:28