The Gaudi Framework  v36r11 (bdb84f5f)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
HistogramArray.h
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2022 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 \***********************************************************************************/
11 #pragma once
12 
14 
15 #include <fmt/format.h>
16 
17 #include <utility>
18 
19 namespace Gaudi::Accumulators {
20 
21  namespace details {
22 
28  std::string_view text;
29  FormatHistDefault( std::string_view t ) : text{ t } {}
30  auto operator()( size_t n ) { return fmt::format( text, n ); }
31  };
32 
37  template <typename Histo, std::size_t N>
38  struct HistogramArrayInternal : std::array<Histo, N> {
40  template <typename OWNER, typename FormatName, typename FormatTitle, std::size_t... Ns, typename... Axis,
41  typename = typename std::enable_if_t<std::is_invocable_v<FormatName, int>>,
42  typename = typename std::enable_if_t<std::is_invocable_v<FormatTitle, int>>>
43  HistogramArrayInternal( OWNER* owner, FormatName&& fname, FormatTitle&& ftitle,
45  : std::array<Histo, N>{ Histo{ owner, fname( Ns ), ftitle( Ns ), allAxis... }... } {
46  static_assert( sizeof...( Ns ) < 1000, "Using HistogramArray with 1000 arrays or more is prohibited. This "
47  "would lead to very long compilation times" );
48  }
50  template <typename OWNER, std::size_t... Ns, typename... Axis>
51  HistogramArrayInternal( OWNER* owner, std::string_view name, std::string_view title,
53  : std::array<Histo, N>{
54  Histo{ owner, FormatHistDefault{ name }( Ns ), FormatHistDefault{ title }( Ns ), allAxis... }... } {
55  static_assert( sizeof...( Ns ) < 1000, "Using HistogramArray with 1000 arrays or more is prohibited. This "
56  "would lead to very long compilation times" );
57  }
58  };
59  } // namespace details
60 
73  template <typename Histo, std::size_t N, typename Seq>
75  template <typename Histo, std::size_t N, std::size_t... NDs>
76  struct HistogramArrayBase<Histo, N, std::index_sequence<NDs...>> : details::HistogramArrayInternal<Histo, N> {
77  template <typename OWNER, typename FormatName, typename FormatTitle>
78  HistogramArrayBase( OWNER* owner, FormatName&& fname, FormatTitle&& ftitle,
80  : details::HistogramArrayInternal<Histo, N>( owner, fname, ftitle, std::make_integer_sequence<std::size_t, N>{},
81  allAxis... ) {}
82  };
83  template <typename Histo, std::size_t N>
85 
86 } // namespace Gaudi::Accumulators
std::integer_sequence
Histogram.h
Gaudi::Accumulators::details::FormatHistDefault::text
std::string_view text
Definition: HistogramArray.h:28
Gaudi::Accumulators::details::FormatHistDefault
Default formating for histogram names and title, only calling fmt::format on the text given at constr...
Definition: HistogramArray.h:27
IOTest.N
int N
Definition: IOTest.py:115
Gaudi::Accumulators::details::alwaysT
T alwaysT
Definition: Histogram.h:30
Gaudi::Accumulators::Axis
Definition of an Histogram Axis.
Definition: Histogram.h:154
bug_34121.t
t
Definition: bug_34121.py:30
TimingHistograms.name
name
Definition: TimingHistograms.py:25
details
Definition: AnyDataWrapper.h:18
Gaudi::Accumulators::details::HistogramArrayInternal
internal class implementing an array of histograms
Definition: HistogramArray.h:38
Gaudi::Accumulators::details::HistogramArrayInternal::HistogramArrayInternal
HistogramArrayInternal(OWNER *owner, std::string_view name, std::string_view title, std::integer_sequence< std::size_t, Ns... >, Axis &&... allAxis)
constructor for strings, FormatHistDefault is used as the default callable
Definition: HistogramArray.h:51
Gaudi::Accumulators::details::HistogramArrayInternal::HistogramArrayInternal
HistogramArrayInternal(OWNER *owner, FormatName &&fname, FormatTitle &&ftitle, std::integer_sequence< std::size_t, Ns... >, Axis &&... allAxis)
constructor with callables for FormatName and FormatTitle
Definition: HistogramArray.h:43
std::array
STL class.
format
GAUDI_API std::string format(const char *,...)
MsgStream format utility "a la sprintf(...)".
Definition: MsgStream.cpp:119
GaudiPluginService.cpluginsvc.n
n
Definition: cpluginsvc.py:235
Gaudi::Accumulators
Definition: HistogramsTests.cpp:19
Containers::array
struct GAUDI_API array
Parametrisation class for redirection array - like implementation.
Definition: KeyedObjectManager.h:37
std
STL namespace.
Gaudi::Accumulators::details::FormatHistDefault::FormatHistDefault
FormatHistDefault(std::string_view t)
Definition: HistogramArray.h:29
std::size_t
Gaudi::Accumulators::HistogramArrayBase< Histo, N, std::index_sequence< NDs... > >::HistogramArrayBase
HistogramArrayBase(OWNER *owner, FormatName &&fname, FormatTitle &&ftitle, details::alwaysT< NDs, typename Histo::AxisType > &&... allAxis)
Definition: HistogramArray.h:78
Gaudi::Accumulators::HistogramArrayBase
generic class implementing an array of histograms The only addition to a raw array is the constructor...
Definition: HistogramArray.h:74
Gaudi::Accumulators::details::FormatHistDefault::operator()
auto operator()(size_t n)
Definition: HistogramArray.h:30