ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
AnalysisCommon
HDF5Utils
HDF5Utils
HistCommon.h
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#ifndef HDF5Utils_HistCommon_H
6
#define HDF5Utils_HistCommon_H
7
8
#include "
HDF5Utils/HistAxis.h
"
9
10
#include "H5Cpp.h"
11
12
#include <cstdint>
13
#include <string>
14
#include <string_view>
15
#include <vector>
16
#include <utility>
//std::pair
17
18
namespace
H5Utils::hist::detail
{
19
20
// Error check helper
21
void
chkerr
(herr_t code, std::string_view error);
22
23
// Attribute write helpers
24
void
write_str_attr
(H5::H5Object& obj,
25
const
std::string& key,
26
const
std::string& val);
27
void
write_bool_attr
(H5::H5Object& obj,
28
const
char
* key,
29
bool
val);
30
void
write_int_attr
(H5::H5Object& obj,
31
const
std::string& key,
32
int64_t val);
33
void
write_double_attr
(H5::H5Object& obj,
34
const
std::string& key,
35
double
val);
36
37
// Write the ref_axes group and the "axes" object-reference dataset.
38
// The histogram group hist_grp must already exist.
39
void
write_axes
(H5::Group& hist_grp,
const
std::vector<Axis>& axes);
40
41
// n_bins overloads: number of data bins (excluding underflow/overflow) for
42
// each variant alternative of Axis::edges_t.
43
size_t
n_bins
(
const
regular_axis_t
&
r
);
// r.n_bins
44
size_t
n_bins
(
const
std::vector<double>& edges);
// edges.size() - 1
45
size_t
n_bins
(
const
std::vector<int64_t>& vals);
// vals.size()
46
size_t
n_bins
(
const
std::vector<std::string>& labels);
// labels.size()
47
size_t
n_bins
(
const
std::pair<int64_t,int64_t>& range);
// range.second - range.first + 1
48
49
// Write a 1-D dataset of variable-length strings.
50
void
write_str_dataset
(H5::Group& parent,
51
const
std::string& name,
52
const
std::vector<std::string>& values);
53
54
// H5 type mapping — must be inline to avoid ODR violations when this
55
// header is included in multiple translation units.
56
template
<
typename
T>
57
extern
const
H5::DataType
hdf5_t
;
58
59
template
<>
inline
const
H5::DataType
hdf5_t<double>
60
= H5::PredType::NATIVE_DOUBLE;
61
template
<>
inline
const
H5::DataType
hdf5_t<float>
62
= H5::PredType::NATIVE_FLOAT;
63
template
<>
inline
const
H5::DataType
hdf5_t<int>
64
= H5::PredType::NATIVE_INT;
65
template
<>
inline
const
H5::DataType
hdf5_t<long>
66
= H5::PredType::NATIVE_LONG;
67
template
<>
inline
const
H5::DataType
hdf5_t<long long>
68
= H5::PredType::NATIVE_LLONG;
69
template
<>
inline
const
H5::DataType
hdf5_t<unsigned long>
70
= H5::PredType::NATIVE_ULONG;
71
template
<>
inline
const
H5::DataType
hdf5_t<unsigned long long>
72
= H5::PredType::NATIVE_ULLONG;
73
template
<>
inline
const
H5::DataType
hdf5_t<unsigned char>
74
= H5::PredType::NATIVE_UCHAR;
75
template
<>
inline
const
H5::DataType
hdf5_t<unsigned short>
76
= H5::PredType::NATIVE_USHORT;
77
78
}
//> end namespace H5Utils::hist::detail
79
80
#endif
//> !HDF5Utils_HistCommon_H
HistAxis.h
r
int r
Definition
globals.cxx:22
H5Utils::hist::detail
Definition
HistAxis.h:14
H5Utils::hist::detail::n_bins
size_t n_bins(const regular_axis_t &r)
Definition
HistCommon.cxx:59
H5Utils::hist::detail::write_axes
void write_axes(H5::Group &hist_grp, const std::vector< Axis > &axes)
Definition
HistCommon.cxx:131
H5Utils::hist::detail::write_str_attr
void write_str_attr(H5::H5Object &obj, const std::string &key, const std::string &val)
Definition
HistCommon.cxx:17
H5Utils::hist::detail::write_str_dataset
void write_str_dataset(H5::Group &parent, const std::string &name, const std::vector< std::string > &values)
Definition
HistCommon.cxx:65
H5Utils::hist::detail::chkerr
void chkerr(herr_t code, std::string_view error)
Definition
HistCommon.cxx:13
H5Utils::hist::detail::hdf5_t
const H5::DataType hdf5_t
H5Utils::hist::detail::write_int_attr
void write_int_attr(H5::H5Object &obj, const std::string &key, int64_t val)
Definition
HistCommon.cxx:39
H5Utils::hist::detail::write_double_attr
void write_double_attr(H5::H5Object &obj, const std::string &key, double val)
Definition
HistCommon.cxx:49
H5Utils::hist::detail::write_bool_attr
void write_bool_attr(H5::H5Object &obj, const char *key, bool val)
Definition
HistCommon.cxx:28
H5Utils::hist::detail::regular_axis_t
Definition
HistAxis.h:16
Generated on
for ATLAS Offline Software by
1.17.0