ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
AnalysisCommon
HDF5Utils
Root
WriterCommon.cxx
Go to the documentation of this file.
1
// this is -*- C++ -*-
2
/*
3
Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
4
*/
5
#include "
HDF5Utils/Writer.h
"
6
7
#include "H5Cpp.h"
8
9
#include <cassert>
10
#include <iostream>
// for printing errors in the destructor
11
12
13
namespace
H5Utils
{
14
namespace
internal
{
15
// packing utility
16
H5::CompType
packed
(H5::CompType in) {
17
// TODO: Figure out why a normal copy constructor doesn't work here.
18
// The normal one seems to create shallow copies.
19
H5::CompType out(H5Tcopy(in.getId()));
20
out.pack();
21
return
out;
22
}
23
24
void
printDestructorError
(
const
std::string&
msg
) {
25
std::cerr <<
"ERROR: an exception was thrown in the destructor of an "
26
"HDF5 file, the output buffer may be corrupted"
;
27
std::cerr <<
" (error message: "
<<
msg
<<
")"
<< std::endl;
28
}
29
30
// new functions
31
H5::DataSpace
getUnlimitedSpace
(
const
std::vector<hsize_t>& extent) {
32
std::vector<hsize_t> initial{0};
33
initial.insert(initial.end(), extent.begin(), extent.end());
34
std::vector<hsize_t> eventual{H5S_UNLIMITED};
35
eventual.insert(eventual.end(), extent.begin(), extent.end());
36
return
H5::DataSpace(eventual.size(), initial.data(), eventual.data());
37
}
38
std::vector<hsize_t>
getStriding
(std::vector<hsize_t> extent) {
39
// calculate striding
40
extent.push_back(1);
41
for
(
size_t
iii = extent.size(); iii - 1 != 0; iii--) {
42
extent.at(iii-2) = extent.at(iii-2) * extent.at(iii-1);
43
}
44
return
extent;
45
}
46
void
throwIfExists
(
const
std::string& name,
const
H5::Group& in_group) {
47
if
(H5Lexists(in_group.getLocId(), name.c_str(), H5P_DEFAULT)) {
48
throw
std::logic_error(
"tried to overwrite '"
+ name +
"'"
);
49
}
50
}
51
52
53
54
}
55
56
}
Writer.h
H5Utils::internal
clssses to add type traits for H5
Definition
CompressedTypes.h:18
H5Utils::internal::packed
H5::CompType packed(H5::CompType in)
Definition
WriterCommon.cxx:16
H5Utils::internal::getStriding
std::vector< hsize_t > getStriding(std::vector< hsize_t > max_length)
Definition
WriterCommon.cxx:38
H5Utils::internal::getUnlimitedSpace
H5::DataSpace getUnlimitedSpace(const std::vector< hsize_t > &max_length)
Definition
WriterCommon.cxx:31
H5Utils::internal::printDestructorError
void printDestructorError(const std::string &msg)
Definition
WriterCommon.cxx:24
H5Utils::internal::throwIfExists
void throwIfExists(const std::string &name, const H5::Group &in_group)
Definition
WriterCommon.cxx:46
H5Utils
HDF5 Tuple Writer.
Definition
CompressedTypes.h:16
msg
MsgStream & msg
Definition
testRead.cxx:32
Generated on
for ATLAS Offline Software by
1.17.0