The Gaudi Framework  v33r0 (d5ea422b)
Gaudi::Accumulators::Histogram< HistogramType > Struct Template Reference

Counter class for histogram storage. More...

#include <Gaudi/Accumulators/Histogram.h>

Inheritance diagram for Gaudi::Accumulators::Histogram< HistogramType >:
Collaboration diagram for Gaudi::Accumulators::Histogram< HistogramType >:

Public Types

using Adapter = Details::HistogramAdapter< HistogramType >
 

Public Member Functions

 Histogram (HistogramType h)
 
template<class OWNER >
 Histogram (OWNER *o, const std::string &tag, HistogramType h)
 
std::ostreamprint (std::ostream &s, bool tableFormat=false) const override
 
MsgStreamprint (MsgStream &s, bool tableFormat=true) const override
 
bool toBePrinted () const override
 
template<class... Ts>
Histogramoperator() (const Ts &... ts)
 
template<typename T = HistogramType, typename INC = typename Details::HistogramAdapter<T>::increment_t>
Histogramoperator+= (const INC &x)
 
template<class... Ts>
Histogramfill (const Ts &... ts)
 
HistogramType & hist ()
 
const HistogramType & hist () const
 

Private Attributes

Adapter m_hist
 

Detailed Description

template<typename HistogramType>
struct Gaudi::Accumulators::Histogram< HistogramType >

Counter class for histogram storage.

(EXPERIMENTAL)

It is an experimental feature and the interface may change.

This Gaudi::Accumulator class can be used to add histograms as data members of algorithms, similar to the simpler counters.

For example:

class MyAlgorithm: public Gaudi::Algorithm {
// ...
StatusCode execute( const EventContext& ) const {
// ...
m_myHisto( aValue );
// ...
}
// ...
this, "histogram_id", {"Histogram Title", {100, -5, 5}}};
};

Known issues:

  • No I/O support (writing to ROOT files or any other persistency should be done by hand)
  • ROOT7 2D histograms can be created and filled, but not saved to disk (https://sft.its.cern.ch/jira/browse/ROOT-10143)
  • Boost histograms are a bit cumbersome to declare (see GaudiExamples/src/Histograms/Boost.cpp)
  • No explicit thread safety (depends on the underlying implementation)

Definition at line 132 of file Histogram.h.

Member Typedef Documentation

◆ Adapter

template<typename HistogramType >
using Gaudi::Accumulators::Histogram< HistogramType >::Adapter = Details::HistogramAdapter<HistogramType>

Definition at line 133 of file Histogram.h.

Constructor & Destructor Documentation

◆ Histogram() [1/2]

template<typename HistogramType >
Gaudi::Accumulators::Histogram< HistogramType >::Histogram ( HistogramType  h)
inline

Definition at line 135 of file Histogram.h.

135 : m_hist{std::move( h )} {}
T move(T... args)

◆ Histogram() [2/2]

template<typename HistogramType >
template<class OWNER >
Gaudi::Accumulators::Histogram< HistogramType >::Histogram ( OWNER *  o,
const std::string tag,
HistogramType  h 
)
inline

Definition at line 138 of file Histogram.h.

138  : Histogram{std::move( h )} {
139  o->declareCounter( tag, *this );
140  }
Histogram(HistogramType h)
Definition: Histogram.h:135
T move(T... args)

Member Function Documentation

◆ fill()

template<typename HistogramType >
template<class... Ts>
Histogram& Gaudi::Accumulators::Histogram< HistogramType >::fill ( const Ts &...  ts)
inline

Definition at line 155 of file Histogram.h.

155  {
156  m_hist.fill( ts... );
157  return *this;
158  }

◆ hist() [1/2]

template<typename HistogramType >
HistogramType& Gaudi::Accumulators::Histogram< HistogramType >::hist ( )
inline

Accessor to the underlying histogram object.

Definition at line 163 of file Histogram.h.

163 { return m_hist.hist; }

◆ hist() [2/2]

template<typename HistogramType >
const HistogramType& Gaudi::Accumulators::Histogram< HistogramType >::hist ( ) const
inline

Definition at line 164 of file Histogram.h.

164 { return m_hist.hist; }

◆ operator()()

template<typename HistogramType >
template<class... Ts>
Histogram& Gaudi::Accumulators::Histogram< HistogramType >::operator() ( const Ts &...  ts)
inline

Add something to the histogram (see documentation of the histogram implementation).

Definition at line 145 of file Histogram.h.

145  {
146  m_hist( ts... );
147  return *this;
148  }

◆ operator+=()

template<typename HistogramType >
template<typename T = HistogramType, typename INC = typename Details::HistogramAdapter<T>::increment_t>
Histogram& Gaudi::Accumulators::Histogram< HistogramType >::operator+= ( const INC &  x)
inline

Definition at line 150 of file Histogram.h.

150  {
151  m_hist += x;
152  return *this;
153  }

◆ print() [1/2]

template<typename HistogramType >
std::ostream& Gaudi::Accumulators::Histogram< HistogramType >::print ( std::ostream s,
bool  tableFormat = false 
) const
inlineoverride

Definition at line 169 of file Histogram.h.

169  {
170  return m_hist.printImpl( s, tableFormat );
171  }
string s
Definition: gaudirun.py:328

◆ print() [2/2]

template<typename HistogramType >
MsgStream& Gaudi::Accumulators::Histogram< HistogramType >::print ( MsgStream s,
bool  tableFormat = true 
) const
inlineoverride

Definition at line 172 of file Histogram.h.

172  {
173  return m_hist.printImpl( s, tableFormat );
174  }
string s
Definition: gaudirun.py:328

◆ toBePrinted()

template<typename HistogramType >
bool Gaudi::Accumulators::Histogram< HistogramType >::toBePrinted ( ) const
inlineoverride

Definition at line 175 of file Histogram.h.

175 { return m_hist; }

Member Data Documentation

◆ m_hist

template<typename HistogramType >
Adapter Gaudi::Accumulators::Histogram< HistogramType >::m_hist
private

Definition at line 178 of file Histogram.h.


The documentation for this struct was generated from the following file: