The Gaudi Framework  master (b9786168)
Loading...
Searching...
No Matches
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\***********************************************************************************/
14#include <ostream>
15
21
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 */
28Gaudi::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 */
36Gaudi::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
39std::ostream& Gaudi::Histo1DDef::fillStream( std::ostream& o ) const {
40 return o << "(" << Gaudi::Utils::toString( title() ) << "," << lowEdge() << "," << highEdge() << "," << bins() << ")";
41}
42namespace 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 */
57AIDA::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 */
66AIDA::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 */
76AIDA::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}
implementation of various functions for streaming.
Simple helper class for description of 1D-histogram The class is targeted to act as the primary "hist...
Definition HistoDef.h:30
double m_high
High Edge.
Definition HistoDef.h:72
int m_bins
Number of bins.
Definition HistoDef.h:73
int bins() const
get the number of bins
Definition HistoDef.h:51
const std::string & title() const
get the title
Definition HistoDef.h:53
double highEdge() const
get the high edge
Definition HistoDef.h:49
double m_low
Low Edge.
Definition HistoDef.h:71
std::string m_title
Histogram title.
Definition HistoDef.h:70
Histo1DDef(double low, double high, int bins=100, std::string title="")
full constructor from edges, bins and the title
Definition HistoDef.cpp:28
std::ostream & fillStream(std::ostream &o) const
printout of the histogram definition
Definition HistoDef.cpp:39
double lowEdge() const
get the low edge
Definition HistoDef.h:47
Definition of the IHistogramSvc interface class.
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.
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
std::string toString(const TYPE &obj)
the generic implementation of the type conversion to the string
Definition ToStream.h:326
This file provides a Grammar for the type Gaudi::Accumulators::Axis It allows to use that type from p...
Definition __init__.py:1
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
bool operator<(const Gaudi::Histo1DDef &left, const Gaudi::Histo1DDef &right)
Definition HistoDef.cpp:44
STL namespace.