The Gaudi Framework  v41r0 (bdbe7744)
Loading...
Searching...
No Matches
Gaudi::Accumulators::HistogramWrapperInternal< HistogramType, std::integer_sequence< unsigned int, ND... > > Class Template Reference

#include </builds/gaudi/Gaudi/GaudiKernel/include/Gaudi/Accumulators/HistogramWrapper.h>

Collaboration diagram for Gaudi::Accumulators::HistogramWrapperInternal< HistogramType, std::integer_sequence< unsigned int, ND... > >:

Public Types

using AxisTupleType = typename HistogramType::AxisTupleType
using AxisArithmeticType = typename HistogramType::AxisArithmeticType
using BufferType = typename HistogramType::BufferType
template<unsigned int I>
using AxisType = std::tuple_element_t<I, AxisTupleType>

Public Member Functions

template<typename OWNER>
 HistogramWrapperInternal (OWNER *owner, std::string const &name, std::string const &title="", typename HistogramType::AxisTupleType axis={}, bool doNotInitialize=false)
 constructor, only creates a set of Properties
template<typename OWNER>
 HistogramWrapperInternal (OWNER const *owner, std::string const &name, std::string const &title="", typename HistogramType::AxisTupleType axis={})
 constructor with const owner (i.e.
template<typename OWNER>
 HistogramWrapperInternal (OWNER *owner, std::string const &name, std::string const &title, AxisType< ND >... allAxis)
 constructor with more natural syntax for axis
auto operator[] (typename HistogramType::AxisTupleArithmeticType v)
 override of operator[] with extra checking that initialization happened
template<typename OWNER>
void createHistogram (OWNER &owner)
 creation of the internal histogram, from the properties
void setTitle (std::string const &title)
template<unsigned int N>
void setAxis (std::tuple_element_t< N, typename HistogramType::AxisTupleType > const &axis)
template<unsigned int N>
auto & axis () const
auto & axis () const
void reset ()
auto buffer ()

Private Member Functions

std::string basePropertyName () const
std::string titlePropertyName () const
template<unsigned int N>
std::string axisPropertyName () const

Private Attributes

std::string m_name {}
std::string m_title {}
HistogramType::AxisTupleType m_axis {}
std::optional< HistogramType > m_histo {}

Friends

void to_json (nlohmann::json &j, HistogramWrapperInternal const &h)

Detailed Description

template<typename HistogramType, unsigned int... ND>
class Gaudi::Accumulators::HistogramWrapperInternal< HistogramType, std::integer_sequence< unsigned int, ND... > >

Definition at line 43 of file HistogramWrapper.h.

Member Typedef Documentation

◆ AxisArithmeticType

template<typename HistogramType, unsigned int... ND>
using Gaudi::Accumulators::HistogramWrapperInternal< HistogramType, std::integer_sequence< unsigned int, ND... > >::AxisArithmeticType = typename HistogramType::AxisArithmeticType

Definition at line 46 of file HistogramWrapper.h.

◆ AxisTupleType

template<typename HistogramType, unsigned int... ND>
using Gaudi::Accumulators::HistogramWrapperInternal< HistogramType, std::integer_sequence< unsigned int, ND... > >::AxisTupleType = typename HistogramType::AxisTupleType

Definition at line 45 of file HistogramWrapper.h.

◆ AxisType

template<typename HistogramType, unsigned int... ND>
template<unsigned int I>
using Gaudi::Accumulators::HistogramWrapperInternal< HistogramType, std::integer_sequence< unsigned int, ND... > >::AxisType = std::tuple_element_t<I, AxisTupleType>

Definition at line 49 of file HistogramWrapper.h.

◆ BufferType

template<typename HistogramType, unsigned int... ND>
using Gaudi::Accumulators::HistogramWrapperInternal< HistogramType, std::integer_sequence< unsigned int, ND... > >::BufferType = typename HistogramType::BufferType

Definition at line 47 of file HistogramWrapper.h.

Constructor & Destructor Documentation

◆ HistogramWrapperInternal() [1/3]

template<typename HistogramType, unsigned int... ND>
template<typename OWNER>
Gaudi::Accumulators::HistogramWrapperInternal< HistogramType, std::integer_sequence< unsigned int, ND... > >::HistogramWrapperInternal ( OWNER * owner,
std::string const & name,
std::string const & title = "",
typename HistogramType::AxisTupleType axis = {},
bool doNotInitialize = false )
inline

constructor, only creates a set of Properties

Definition at line 53 of file HistogramWrapper.h.

54 {}, bool doNotInitialize = false )
55 : m_name{ name }, m_title{ title }, m_axis{ axis } {
56 // Create associated properties
57 owner->declareProperty( titlePropertyName(), m_title, std::format( "Title of histogram {}", name ) )
58 ->template setOwnerType<OWNER>();
59 ( owner
60 ->declareProperty( axisPropertyName<ND>(), std::get<ND>( m_axis ),
61 std::format( "Axis {} of histogram {}", ND, name ) )
62 ->template setOwnerType<OWNER>(),
63 ... );
64 // register creation of the Histogram at initialization time
65 if ( !doNotInitialize ) {
66 if ( owner->FSMState() >= Gaudi::StateMachine::INITIALIZED ) {
67 // if the owner is already initialized (e.g. the histogram is being created during `start()`)
68 // it is too late to register the callback
70 } else {
71 owner->registerCallBack( StateMachine::INITIALIZE, [this, owner]() { createHistogram( *owner ); } );
72 }
73 }
74 }
void createHistogram(OWNER &owner)
creation of the internal histogram, from the properties
A Wrapper of a static Histogram base class using Properties to define title and axis.

◆ HistogramWrapperInternal() [2/3]

template<typename HistogramType, unsigned int... ND>
template<typename OWNER>
Gaudi::Accumulators::HistogramWrapperInternal< HistogramType, std::integer_sequence< unsigned int, ND... > >::HistogramWrapperInternal ( OWNER const * owner,
std::string const & name,
std::string const & title = "",
typename HistogramType::AxisTupleType axis = {} )
inline

constructor with const owner (i.e.

outside of constructor or initialize), equivalent to the StaticHistogram case (create immediately)

Definition at line 78 of file HistogramWrapper.h.

79 {} )
80 : m_name{ name }, m_title{ title }, m_axis{ axis } {
82 }

◆ HistogramWrapperInternal() [3/3]

template<typename HistogramType, unsigned int... ND>
template<typename OWNER>
Gaudi::Accumulators::HistogramWrapperInternal< HistogramType, std::integer_sequence< unsigned int, ND... > >::HistogramWrapperInternal ( OWNER * owner,
std::string const & name,
std::string const & title,
AxisType< ND >... allAxis )
inline

constructor with more natural syntax for axis

Definition at line 85 of file HistogramWrapper.h.

HistogramWrapperInternal(OWNER *owner, std::string const &name, std::string const &title="", typename HistogramType::AxisTupleType axis={}, bool doNotInitialize=false)
constructor, only creates a set of Properties

Member Function Documentation

◆ axis() [1/2]

template<typename HistogramType, unsigned int... ND>
auto & Gaudi::Accumulators::HistogramWrapperInternal< HistogramType, std::integer_sequence< unsigned int, ND... > >::axis ( ) const
inline

Definition at line 132 of file HistogramWrapper.h.

132 {
133 if ( !m_histo )
134 throw std::logic_error(
135 std::format( "Cannot get axis of histogram {} before it has been initialized", m_name ) );
136 return m_histo->axis();
137 }

◆ axis() [2/2]

template<typename HistogramType, unsigned int... ND>
template<unsigned int N>
auto & Gaudi::Accumulators::HistogramWrapperInternal< HistogramType, std::integer_sequence< unsigned int, ND... > >::axis ( ) const
inline

Definition at line 125 of file HistogramWrapper.h.

125 {
126 if ( !m_histo )
127 throw std::logic_error(
128 std::format( "Cannot get axis {} of histogram {} before it has been initialized", N, m_name ) );
129 return m_histo->template axis<N>();
130 }

◆ axisPropertyName()

template<typename HistogramType, unsigned int... ND>
template<unsigned int N>
std::string Gaudi::Accumulators::HistogramWrapperInternal< HistogramType, std::integer_sequence< unsigned int, ND... > >::axisPropertyName ( ) const
inlineprivate

◆ basePropertyName()

template<typename HistogramType, unsigned int... ND>
std::string Gaudi::Accumulators::HistogramWrapperInternal< HistogramType, std::integer_sequence< unsigned int, ND... > >::basePropertyName ( ) const
inlineprivate

Definition at line 149 of file HistogramWrapper.h.

149 {
150 // properties are used as identifiers in python and thus cannot anything alse than _, letters and numbers
151 // we thus replace anything else with '_' in the property names
154 begin( name ), end( name ), []( auto& c ) { return !std::isalnum( c ); }, '_' );
155 return name;
156 }

◆ buffer()

template<typename HistogramType, unsigned int... ND>
auto Gaudi::Accumulators::HistogramWrapperInternal< HistogramType, std::integer_sequence< unsigned int, ND... > >::buffer ( )
inline

Definition at line 142 of file HistogramWrapper.h.

142 {
143 if ( !m_histo )
144 throw std::logic_error( std::format( "`buffer()` called on histogram {} before being initialized", m_name ) );
145 return m_histo->buffer();
146 }

◆ createHistogram()

template<typename HistogramType, unsigned int... ND>
template<typename OWNER>
void Gaudi::Accumulators::HistogramWrapperInternal< HistogramType, std::integer_sequence< unsigned int, ND... > >::createHistogram ( OWNER & owner)
inline

creation of the internal histogram, from the properties

Definition at line 98 of file HistogramWrapper.h.

98 {
99 m_histo.emplace( &owner, m_name, m_title, m_axis );
100 }

◆ operator[]()

template<typename HistogramType, unsigned int... ND>
auto Gaudi::Accumulators::HistogramWrapperInternal< HistogramType, std::integer_sequence< unsigned int, ND... > >::operator[] ( typename HistogramType::AxisTupleArithmeticType v)
inlinenodiscard

override of operator[] with extra checking that initialization happened

Definition at line 89 of file HistogramWrapper.h.

89 {
90 if ( !m_histo ) {
91 throw std::logic_error( std::format( "Histogram {} is used before being initialized", m_name ) );
92 }
93 return m_histo.value()[v];
94 }

◆ reset()

template<typename HistogramType, unsigned int... ND>
void Gaudi::Accumulators::HistogramWrapperInternal< HistogramType, std::integer_sequence< unsigned int, ND... > >::reset ( )
inline

Definition at line 139 of file HistogramWrapper.h.

139{ m_histo.reset(); }

◆ setAxis()

template<typename HistogramType, unsigned int... ND>
template<unsigned int N>
void Gaudi::Accumulators::HistogramWrapperInternal< HistogramType, std::integer_sequence< unsigned int, ND... > >::setAxis ( std::tuple_element_t< N, typename HistogramType::AxisTupleType > const & axis)
inline

Definition at line 117 of file HistogramWrapper.h.

117 {
118 if ( m_histo )
119 throw std::logic_error(
120 std::format( "Cannot modify axis {} of histogram {} after it has been initialized", N, m_name ) );
122 }

◆ setTitle()

template<typename HistogramType, unsigned int... ND>
void Gaudi::Accumulators::HistogramWrapperInternal< HistogramType, std::integer_sequence< unsigned int, ND... > >::setTitle ( std::string const & title)
inline

Definition at line 110 of file HistogramWrapper.h.

110 {
111 if ( m_histo )
112 throw std::logic_error(
113 std::format( "Cannot modify title of histogram {} after it has been initialized", m_name ) );
114 m_title = title;
115 }

◆ titlePropertyName()

template<typename HistogramType, unsigned int... ND>
std::string Gaudi::Accumulators::HistogramWrapperInternal< HistogramType, std::integer_sequence< unsigned int, ND... > >::titlePropertyName ( ) const
inlineprivate

Definition at line 157 of file HistogramWrapper.h.

157{ return std::format( "{}_Title", basePropertyName() ); }

◆ to_json

template<typename HistogramType, unsigned int... ND>
void to_json ( nlohmann::json & j,
HistogramWrapperInternal< HistogramType, std::integer_sequence< unsigned int, ND... > > const & h )
friend

Definition at line 102 of file HistogramWrapper.h.

102 {
103 if ( !h.m_histo ) {
104 throw std::logic_error( std::format( "Histogram {} is converted to json before being initialized", h.m_name ) );
105 }
106 j = h.m_histo.value();
107 }

Member Data Documentation

◆ m_axis

template<typename HistogramType, unsigned int... ND>
HistogramType::AxisTupleType Gaudi::Accumulators::HistogramWrapperInternal< HistogramType, std::integer_sequence< unsigned int, ND... > >::m_axis {}
private

Definition at line 166 of file HistogramWrapper.h.

166{};

◆ m_histo

template<typename HistogramType, unsigned int... ND>
std::optional<HistogramType> Gaudi::Accumulators::HistogramWrapperInternal< HistogramType, std::integer_sequence< unsigned int, ND... > >::m_histo {}
private

Definition at line 167 of file HistogramWrapper.h.

167{};

◆ m_name

template<typename HistogramType, unsigned int... ND>
std::string Gaudi::Accumulators::HistogramWrapperInternal< HistogramType, std::integer_sequence< unsigned int, ND... > >::m_name {}
private

Definition at line 164 of file HistogramWrapper.h.

164{};

◆ m_title

template<typename HistogramType, unsigned int... ND>
std::string Gaudi::Accumulators::HistogramWrapperInternal< HistogramType, std::integer_sequence< unsigned int, ND... > >::m_title {}
private

Definition at line 165 of file HistogramWrapper.h.

165{};

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