The Gaudi Framework  v36r16 (ea80daf8)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
HistoDef.cpp
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2019 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 // equality operator
65 // ============================================================================
66 #ifdef __ICC
67 // disable icc remark #1572: floating-point equality and inequality comparisons are unreliable
68 # pragma warning( push )
69 # pragma warning( disable : 1572 )
70 #endif
71  bool operator==( const Gaudi::Histo1DDef& left, const Gaudi::Histo1DDef& right ) {
72  return std::tie( left.m_title, left.m_low, left.m_high, left.m_bins ) ==
73  std::tie( right.m_title, right.m_low, right.m_high, right.m_bins );
74  }
75 #ifdef __ICC
76 // re-enable icc remark #1572
77 # pragma warning( pop )
78 #endif
79  // ============================================================================
80  // non-equality
81  // ============================================================================
82  bool operator!=( const Gaudi::Histo1DDef& left, const Gaudi::Histo1DDef& right ) { return !( left == right ); }
83  // ============================================================================
84  // the streamer operator for class Gaudi::Histo1DDef
85  // ============================================================================
86  std::ostream& operator<<( std::ostream& o, const Gaudi::Histo1DDef& histo ) { return histo.fillStream( o ); }
87 } // namespace Gaudi
88 // ============================================================================
89 
90 // ============================================================================
91 /* helper function to book 1D-histogram
92  * @param svc pointer to Histogram Service
93  * @param path full path in Histogram Data Store
94  * @param hist histogram desctriprion
95  */
96 // ============================================================================
97 AIDA::IHistogram1D* Gaudi::Histos::book( IHistogramSvc* svc, const std::string& path, const Gaudi::Histo1DDef& hist ) {
98  return svc ? svc->book( path, hist.title(), hist.bins(), hist.lowEdge(), hist.highEdge() ) : nullptr;
99 }
100 // ============================================================================
101 /* helper function to book 1D-histogram
102  * @param svc pointer to Histogram Service
103  * @param dir directory path in Histogram Data Store
104  * @param id histogram identifier
105  * @param hist histogram desctriprion
106  */
107 // ============================================================================
108 AIDA::IHistogram1D* Gaudi::Histos::book( IHistogramSvc* svc, const std::string& dir, const std::string& id,
109  const Gaudi::Histo1DDef& hist ) {
110  return svc ? svc->book( dir, id, hist.title(), hist.bins(), hist.lowEdge(), hist.highEdge() ) : nullptr;
111 }
112 // ============================================================================
113 /* helper function to book 1D-histogram
114  * @param svc pointer to Histogram Service
115  * @param dir directory path in Histogram Data Store
116  * @param id histogram identifier
117  * @param hist histogram desctriprion
118  */
119 // ============================================================================
120 AIDA::IHistogram1D* Gaudi::Histos::book( IHistogramSvc* svc, const std::string& dir, const int id,
121  const Gaudi::Histo1DDef& hist ) {
122  return svc ? svc->book( dir, id, hist.title(), hist.bins(), hist.lowEdge(), hist.highEdge() ) : nullptr;
123 }
124 // ============================================================================
125 
126 // ============================================================================
127 // The END
128 // ============================================================================
std::string
STL class.
IHistogramSvc
Definition: IHistogramSvc.h:56
AtlasMCRecoFullPrecedenceDump.path
path
Definition: AtlasMCRecoFullPrecedenceDump.py:49
HistoEx.histo
histo
Definition: HistoEx.py:103
Gaudi::operator==
bool operator==(const T &v, const Property< TP, V, H > &p)
delegate (value == property) to property operator==
Definition: Property.h:431
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:97
Gaudi
Header file for std:chrono::duration-based Counters.
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::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
Gaudi::operator!=
bool operator!=(const T &v, const Property< TP, V, H > &p)
delegate (value != property) to property operator!=
Definition: Property.h:437
IHistogramSvc.h
Gaudi::operator<<
std::ostream & operator<<(std::ostream &o, const RootAddress &addr)
Definition: MIHelpers.h:20
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