15#include <fmt/format.h>
28 template <
typename Key>
40 template <
typename Key,
typename Histo>
44 template <
typename OWNER, std::invocable<Key const&> FormatName, std::invocable<Key const&> FormatTitle>
46 typename Histo::AxisTupleType&& allAxis )
47 :
m_makeHisto{ [owner, fname, ftitle, allAxis, this]( Key const& k ) -> Histo& {
49 .emplace( std::piecewise_construct, std::forward_as_tuple( k ),
50 std::forward_as_tuple( owner, fname( k ), ftitle( k ), allAxis ) )
54 template <
typename OWNER>
56 typename Histo::AxisTupleType&& allAxis )
57 :
m_makeHisto{ [owner, name, title, allAxis, this]( Key const& k ) -> Histo& {
59 .emplace( std::piecewise_construct, std::forward_as_tuple( k ),
67 auto it =
m_map.find( k );
68 if ( it !=
m_map.end() )
return it->second;
73 mutable std::map<Key, Histo>
m_map;
123 template <
typename Key,
typename Histo,
124 typename Seq = std::make_integer_sequence<unsigned int, std::tuple_size_v<typename Histo::AxisTupleType>>>
126 template <
typename Key,
typename Histo,
unsigned int... ND>
129 template <
typename OWNER,
typename FormatName,
typename FormatTitle>
130 HistogramMap( OWNER* owner, FormatName&& fname, FormatTitle&& ftitle,
typename Histo::AxisTupleType&& allAxis )
132 std::forward<typename Histo::AxisTupleType>( allAxis ) ) {}
134 template <
unsigned int I>
135 using AxisType = std::tuple_element_t<I, typename Histo::AxisTupleType>;
137 template <
typename OWNER,
typename FormatName,
typename FormatTitle>
139 :
HistogramMap( owner, fname, ftitle,
std::make_tuple( allAxis... ) ) {}
internal class implementing a map of histograms
HistogramMapInternal(OWNER *owner, FormatName &&fname, FormatTitle &&ftitle, typename Histo::AxisTupleType &&allAxis)
constructor with callables for FormatName and FormatTitle
Histo & operator[](Key const &k) const
operator[] method, made thread safe and thus declared const
std::function< Histo &(Key const &)> m_makeHisto
std::map< Key, Histo > m_map
HistogramMapInternal(OWNER *owner, std::string_view name, std::string_view title, typename Histo::AxisTupleType &&allAxis)
constructor for strings, FormatHistDefaultT is used as the default callable
Efficient counter implementations for Gaudi.
generic class implementing a thread safe map of histograms
HistogramMap(OWNER *owner, FormatName &&fname, FormatTitle &&ftitle, AxisType< ND >... allAxis)
HistogramMap(OWNER *owner, FormatName &&fname, FormatTitle &&ftitle, typename Histo::AxisTupleType &&allAxis)
std::tuple_element_t< I, typename Histo::AxisTupleType > AxisType