The Gaudi Framework
master (9f3f8895)
Toggle main menu visibility
Loading...
Searching...
No Matches
HistogramArray.h
Go to the documentation of this file.
1
/***********************************************************************************\
2
* (c) Copyright 1998-2025 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
13
#include <
Gaudi/Accumulators/Histogram.h
>
14
15
#include <fmt/format.h>
16
17
#include <boost/container/static_vector.hpp>
18
19
#include <array>
20
#include <utility>
21
22
namespace
Gaudi::Accumulators
{
23
24
namespace
details
{
25
30
struct
FormatHistDefault
{
31
std::string_view
text
;
32
FormatHistDefault
( std::string_view t ) :
text
{ t } {}
33
auto
operator()
(
size_t
n ) {
return
fmt::format( fmt::runtime(
text
), n ); }
34
};
35
42
template
<
typename
Histo, std::
size_t
N>
43
struct
HistogramArrayInternal
: boost::container::static_vector<Histo, N> {
45
template
<
typename
OWNER, std::invocable<
int
> FormatName, std::invocable<
int
> FormatTitle>
46
HistogramArrayInternal
( OWNER* owner, FormatName&& fname, FormatTitle&& ftitle,
47
typename
Histo::AxisTupleType&& allAxis ) {
48
for
( std::size_t i = 0; i < N; i++ ) { this->emplace_back( owner, fname( i ), ftitle( i ), allAxis ); }
49
}
50
51
template
<
typename
OWNER>
52
HistogramArrayInternal
( OWNER* owner, std::string_view name, std::string_view title,
53
typename
Histo::AxisTupleType&& allAxis ) {
54
for
( std::size_t i = 0; i < N; i++ ) {
55
this->emplace_back( owner,
FormatHistDefault
{ name }( i ),
FormatHistDefault
{ title }( i ), allAxis );
56
}
57
}
58
};
59
}
// namespace details
60
96
template
<
typename
Histo, std::size_t N,
97
typename
Seq = std::make_integer_sequence<unsigned int, std::tuple_size_v<typename Histo::AxisTupleType>>>
98
struct
HistogramArray
;
99
template
<
typename
Histo, std::size_t N,
unsigned
int
... ND>
100
struct
HistogramArray
<Histo, N,
std
::integer_sequence<unsigned int, ND...>>
101
:
details::HistogramArrayInternal
<Histo, N> {
102
template
<
typename
OWNER,
typename
FormatName,
typename
FormatTitle, std::
size_t
M = N>
103
HistogramArray
( OWNER* owner, FormatName&& fname, FormatTitle&& ftitle,
typename
Histo::AxisTupleType&& allAxis )
104
:
details
::
HistogramArrayInternal
<Histo, N>( owner, fname, ftitle,
105
std
::forward<typename Histo::AxisTupleType>( allAxis ) ) {}
106
107
template
<
unsigned
int
I>
108
using
AxisType
= std::tuple_element_t<I, typename Histo::AxisTupleType>;
109
110
template
<
typename
OWNER,
typename
FormatName,
typename
FormatTitle>
111
HistogramArray
( OWNER* owner, FormatName&& fname, FormatTitle&& ftitle,
AxisType<ND>
... allAxis )
112
:
HistogramArray
( owner, fname, ftitle,
std
::make_tuple( allAxis... ) ) {}
113
};
114
115
}
// namespace Gaudi::Accumulators
Histogram.h
Gaudi::Accumulators::details
Definition
Accumulators.h:1177
Gaudi::Accumulators
Efficient counter implementations for Gaudi.
Definition
Accumulators.h:18
details
Definition
AnyDataWrapper.h:19
std
STL namespace.
Gaudi::Accumulators::HistogramArray< Histo, N, std::integer_sequence< unsigned int, ND... > >::HistogramArray
HistogramArray(OWNER *owner, FormatName &&fname, FormatTitle &&ftitle, typename Histo::AxisTupleType &&allAxis)
Definition
HistogramArray.h:103
Gaudi::Accumulators::HistogramArray< Histo, N, std::integer_sequence< unsigned int, ND... > >::AxisType
std::tuple_element_t< I, typename Histo::AxisTupleType > AxisType
Definition
HistogramArray.h:108
Gaudi::Accumulators::HistogramArray< Histo, N, std::integer_sequence< unsigned int, ND... > >::HistogramArray
HistogramArray(OWNER *owner, FormatName &&fname, FormatTitle &&ftitle, AxisType< ND >... allAxis)
Definition
HistogramArray.h:111
Gaudi::Accumulators::HistogramArray
generic class implementing an array of histograms The only addition to a raw array is the constructor...
Definition
HistogramArray.h:98
Gaudi::Accumulators::details::FormatHistDefault
Default formating for histogram names and title, only calling fmt::format on the text given at constr...
Definition
HistogramArray.h:30
Gaudi::Accumulators::details::FormatHistDefault::operator()
auto operator()(size_t n)
Definition
HistogramArray.h:33
Gaudi::Accumulators::details::FormatHistDefault::FormatHistDefault
FormatHistDefault(std::string_view t)
Definition
HistogramArray.h:32
Gaudi::Accumulators::details::FormatHistDefault::text
std::string_view text
Definition
HistogramArray.h:31
Gaudi::Accumulators::details::HistogramArrayInternal
internal class implementing an "array" of histograms
Definition
HistogramArray.h:43
Gaudi::Accumulators::details::HistogramArrayInternal::HistogramArrayInternal
HistogramArrayInternal(OWNER *owner, FormatName &&fname, FormatTitle &&ftitle, typename Histo::AxisTupleType &&allAxis)
constructor with callables for FormatName and FormatTitle
Definition
HistogramArray.h:46
Gaudi::Accumulators::details::HistogramArrayInternal::HistogramArrayInternal
HistogramArrayInternal(OWNER *owner, std::string_view name, std::string_view title, typename Histo::AxisTupleType &&allAxis)
constructor for strings, FormatHistDefault is used as the default callable
Definition
HistogramArray.h:52
GaudiKernel
include
Gaudi
Accumulators
HistogramArray.h
Generated on
for The Gaudi Framework by
1.17.0