The Gaudi Framework  master (37c0b60a)
HistoDef.cpp
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2024 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 // ============================================================================
12 // Include files
13 // ============================================================================
14 // ST D& STL
15 // ============================================================================
16 #include <ostream>
17 // ============================================================================
18 // GaudiKernel
19 // ============================================================================
20 #include <GaudiKernel/HistoDef.h>
22 #include <GaudiKernel/ToStream.h>
23 // ============================================================================
29 // ============================================================================
30 /* full constructor from edges, #bins and the title
31  * @param low the low edge of the histogram
32  * @param high the high edge of the histogram
33  * @param bins number of bins
34  * @param title the histogram title
35  */
36 // ============================================================================
37 Gaudi::Histo1DDef::Histo1DDef( const double low, const double high, const int bins, std::string title )
38  : m_title( std::move( title ) ), m_low( low ), m_high( high ), m_bins( bins ) {}
39 // ============================================================================
40 /* full constructor from edges, #bins and the title
41  * @param title the histogram title
42  * @param low the low edge of the histogram
43  * @param high the high edge of the histogram
44  * @param bins number of bins
45  */
46 // ============================================================================
47 Gaudi::Histo1DDef::Histo1DDef( std::string title, const double low, const double high, const int bins )
48  : m_title( std::move( title ) ), m_low( low ), m_high( high ), m_bins( bins ) {}
49 // ============================================================================
50 // printout of the histogram definition
51 // ============================================================================
53  return o << "(" << Gaudi::Utils::toString( title() ) << "," << lowEdge() << "," << highEdge() << "," << bins() << ")";
54 }
55 namespace Gaudi {
56  // ============================================================================
57  // ordering operator (to please BoundedVerifier)
58  // ============================================================================
59  bool operator<( const Gaudi::Histo1DDef& left, const Gaudi::Histo1DDef& right ) {
60  return std::tie( left.m_title, left.m_low, left.m_high, left.m_bins ) <
61  std::tie( right.m_title, right.m_low, right.m_high, right.m_bins );
62  }
63  // ============================================================================
64  // the streamer operator for class Gaudi::Histo1DDef
65  // ============================================================================
66  std::ostream& operator<<( std::ostream& o, const Gaudi::Histo1DDef& histo ) { return histo.fillStream( o ); }
67 } // namespace Gaudi
68 // ============================================================================
69 
70 // ============================================================================
71 /* helper function to book 1D-histogram
72  * @param svc pointer to Histogram Service
73  * @param path full path in Histogram Data Store
74  * @param hist histogram desctriprion
75  */
76 // ============================================================================
77 AIDA::IHistogram1D* Gaudi::Histos::book( IHistogramSvc* svc, const std::string& path, const Gaudi::Histo1DDef& hist ) {
78  return svc ? svc->book( path, hist.title(), hist.bins(), hist.lowEdge(), hist.highEdge() ) : nullptr;
79 }
80 // ============================================================================
81 /* helper function to book 1D-histogram
82  * @param svc pointer to Histogram Service
83  * @param dir directory path in Histogram Data Store
84  * @param id histogram identifier
85  * @param hist histogram desctriprion
86  */
87 // ============================================================================
88 AIDA::IHistogram1D* Gaudi::Histos::book( IHistogramSvc* svc, const std::string& dir, const std::string& id,
89  const Gaudi::Histo1DDef& hist ) {
90  return svc ? svc->book( dir, id, hist.title(), hist.bins(), hist.lowEdge(), hist.highEdge() ) : nullptr;
91 }
92 // ============================================================================
93 /* helper function to book 1D-histogram
94  * @param svc pointer to Histogram Service
95  * @param dir directory path in Histogram Data Store
96  * @param id histogram identifier
97  * @param hist histogram desctriprion
98  */
99 // ============================================================================
100 AIDA::IHistogram1D* Gaudi::Histos::book( IHistogramSvc* svc, const std::string& dir, const int id,
101  const Gaudi::Histo1DDef& hist ) {
102  return svc ? svc->book( dir, id, hist.title(), hist.bins(), hist.lowEdge(), hist.highEdge() ) : nullptr;
103 }
104 // ============================================================================
105 
106 // ============================================================================
107 // The END
108 // ============================================================================
std::string
STL class.
IHistogramSvc
Definition: IHistogramSvc.h:56
AtlasMCRecoFullPrecedenceDump.path
path
Definition: AtlasMCRecoFullPrecedenceDump.py:49
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:52
std::tie
T tie(T... args)
Gaudi::Histo1DDef
Definition: HistoDef.h:41
std::ostream
STL class.
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:77
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:65
Gaudi::Utils::toString
std::string toString(const TYPE &obj)
the generic implementation of the type conversion to the string
Definition: ToStream.h:353
std
STL namespace.
Gaudi::operator<
bool operator<(const Gaudi::Histo1DDef &left, const Gaudi::Histo1DDef &right)
Definition: HistoDef.cpp:59
Gaudi::Histo1DDef::lowEdge
double lowEdge() const
get the low edge
Definition: HistoDef.h:63
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:208
Gaudi::Histo1DDef::bins
int bins() const
get the number of bins
Definition: HistoDef.h:67
Gaudi::Histo1DDef::title
const std::string & title() const
get the title
Definition: HistoDef.h:69
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:37