38  template <
typename HistogramType,
 
   40                std::make_integer_sequence<unsigned int, std::tuple_size_v<typename HistogramType::AxisTupleType>>>
 
   42  template <
typename HistogramType, 
unsigned int... ND>
 
   48    template <
unsigned int I>
 
   49    using AxisType = std::tuple_element_t<I, AxisTupleType>;
 
   52    template <
typename OWNER>
 
   54                              typename HistogramType::AxisTupleType 
axis = {}, 
bool doNotInitialize = false )
 
   55        : m_name{ name }, m_title{ title }, m_axis{ axis } {
 
   57      owner->declareProperty( titlePropertyName(), m_title, std::format( 
"Title of histogram {}", name ) )
 
   58          ->template setOwnerType<OWNER>();
 
   60            ->declareProperty( axisPropertyName<ND>(), std::get<ND>( m_axis ),
 
   61                               std::format( 
"Axis {} of histogram {}", ND, name ) )
 
   62            ->
template setOwnerType<OWNER>(),
 
   65      if ( !doNotInitialize ) {
 
   69          createHistogram( *owner );
 
 
   77    template <
typename OWNER>
 
   79                              typename HistogramType::AxisTupleType 
axis = {} )
 
   80        : m_name{ name }, m_title{ title }, m_axis{ axis } {
 
   81      createHistogram( *owner );
 
 
   84    template <
typename OWNER>
 
   89    [[nodiscard]] 
auto operator[]( 
typename HistogramType::AxisTupleArithmeticType v ) {
 
   91        throw std::logic_error( std::format( 
"Histogram {} is used before being initialized", 
m_name ) );
 
 
   97    template <
typename OWNER>
 
  104        throw std::logic_error( std::format( 
"Histogram {} is converted to json before being initialized", h.m_name ) );
 
  106      j = h.m_histo.value();
 
 
  112        throw std::logic_error(
 
  113            std::format( 
"Cannot modify title of histogram {} after it has been initialized", 
m_name ) );
 
 
  116    template <
unsigned int N>
 
  117    void setAxis( std::tuple_element_t<N, typename HistogramType::AxisTupleType> 
const& 
axis ) {
 
  119        throw std::logic_error(
 
  120            std::format( 
"Cannot modify axis {} of histogram {} after it has been initialized", N, 
m_name ) );
 
 
  124    template <
unsigned int N>
 
  127        throw std::logic_error(
 
  128            std::format( 
"Cannot get axis {} of histogram {} before it has been initialized", N, 
m_name ) );
 
 
  134        throw std::logic_error(
 
  135            std::format( 
"Cannot get axis of histogram {} before it has been initialized", 
m_name ) );
 
 
  144        throw std::logic_error( std::format( 
"`buffer()` called on histogram {} before being initialized", 
m_name ) );
 
 
  152      std::string name = 
m_name;
 
  154          begin( name ), end( name ), []( 
auto& c ) { 
return !std::isalnum( c ); }, 
'_' );
 
 
  158    template <
unsigned int N>
 
  166    typename HistogramType::AxisTupleType 
m_axis{};
 
 
  170  template <
typename HistogramType>
 
A Wrapper of a static Histogram base class using Properties to define title and axis.
void setTitle(std::string const &title)
std::tuple_element_t< I, AxisTupleType > AxisType
void setAxis(std::tuple_element_t< N, typename HistogramType::AxisTupleType > const &axis)
HistogramWrapperInternal(OWNER *owner, std::string const &name, std::string const &title, AxisType< ND >... allAxis)
constructor with more natural syntax for axis
HistogramType::AxisTupleType m_axis
typename HistogramType::AxisTupleType AxisTupleType
std::string titlePropertyName() const
void createHistogram(OWNER &owner)
creation of the internal histogram, from the properties
auto operator[](typename HistogramType::AxisTupleArithmeticType v)
override of operator[] with extra checking that initialization happened
friend void to_json(nlohmann::json &j, HistogramWrapperInternal const &h)
typename HistogramType::BufferType BufferType
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
std::string axisPropertyName() const
std::optional< HistogramType > m_histo
std::string basePropertyName() const
HistogramWrapperInternal(OWNER const *owner, std::string const &name, std::string const &title="", typename HistogramType::AxisTupleType axis={})
constructor with const owner (i.e.
typename HistogramType::AxisArithmeticType AxisArithmeticType
Efficient counter implementations for Gaudi.
HistogramWrapperInternal< HistogramType > HistogramWrapper