ATLAS Offline Software
Classes | Macros | Typedefs | Functions
test-hdf5-writer.cxx File Reference
#include "HDF5Utils/Writer.h"
Include dependency graph for test-hdf5-writer.cxx:

Go to the source code of this file.

Classes

struct  out_t
 

Macros

#define ADD(NAME)   consumers.add(#NAME, [](const out_t& o){ return o.NAME;}, 0)
 

Typedefs

using consumer_t = H5Utils::Consumers< const out_t & >
 

Functions

consumer_t getConsumers ()
 
std::vector< out_tgetOutputs (int offset, size_t length, float factor)
 
template<size_t N>
auto nestOutputs (int offset, size_t length)
 
template<>
auto nestOutputs< 1 > (int offset, size_t length)
 
int main (int, char *[])
 

Macro Definition Documentation

◆ ADD

#define ADD (   NAME)    consumers.add(#NAME, [](const out_t& o){ return o.NAME;}, 0)

Typedef Documentation

◆ consumer_t

Definition at line 25 of file test-hdf5-writer.cxx.

Function Documentation

◆ getConsumers()

consumer_t getConsumers ( )

Definition at line 27 of file test-hdf5-writer.cxx.

27  {
28  consumer_t consumers;
30  consumers.add("half" , [](const out_t& o) { return o.ftype; }, 0, half);
31  consumers.add("dhalf", [](const out_t& o) { return o.dtype; }, 0, half);
32 #define ADD(NAME) consumers.add(#NAME, [](const out_t& o){ return o.NAME;}, 0)
33  ADD(ftype);
34  ADD(dtype);
35  ADD(btype);
36  ADD(ctype);
37  ADD(stype);
38  ADD(itype);
39  ADD(ltype);
40  ADD(lltype);
41  ADD(uctype);
42  ADD(ustype);
43  ADD(uitype);
44  ADD(ultype);
45  ADD(ulltype);
46 #undef ADD
47  return consumers;
48 }

◆ getOutputs()

std::vector<out_t> getOutputs ( int  offset,
size_t  length,
float  factor 
)

Definition at line 53 of file test-hdf5-writer.cxx.

53  {
54  std::vector<out_t> outvec;
55  for (size_t n = 0; n < length; n++) {
56  out_t out;
57  long long int shifted = n + offset;
58  double factored = shifted*factor;
59  out.dtype = factored;
60  out.ftype = factored;
61  out.ctype = shifted;
62  out.stype = shifted;
63  out.itype = shifted;
64  out.ltype = shifted;
65  out.lltype = shifted;
66  out.uctype = shifted;
67  out.ustype = shifted;
68  out.uitype = shifted;
69  out.ultype = shifted;
70  out.ulltype = shifted;
71  out.btype = n % 2;
72  outvec.push_back(out);
73  }
74  return outvec;
75 }

◆ main()

int main ( int  ,
char *  [] 
)

Definition at line 95 of file test-hdf5-writer.cxx.

95  {
96  // make the output file
97  H5::H5File out_file("output.h5", H5F_ACC_TRUNC);
98 
99  // scalar output
100  using scalar_writer_t = H5Utils::Writer<0, consumer_t::input_type>;
101  scalar_writer_t::configuration_type scalar_config;
102  scalar_config.name = "scalar";
103  consumer_t consumers = getConsumers();
104  scalar_writer_t scalar(out_file, consumers, scalar_config);
105  scalar.fill(getOutputs(1, 1, 0.5).at(0));
106 
107  // 1d output
109  d1_t::configuration_type d1_config;
110  d1_config.name = "1d";
111  d1_config.extent = {10};
112  d1_config.chunks = {5};
113  d1_t d1(out_file, consumers, d1_config);
114  d1.fill(getOutputs(0, 10, 0.5));
115 
116  // 4d output
118  d4_t::configuration_type d4_config;
119  d4_config.name = "4d";
120  d4_config.extent = {2,3,4,5};
121  d4_config.chunks = {1,2,1,2};
122  d4_t d4(out_file, consumers, d4_config);
123  d4.fill(nestOutputs<4>(0,3));
124 
125  return 0;
126 }

◆ nestOutputs()

template<size_t N>
auto nestOutputs ( int  offset,
size_t  length 
)

Definition at line 78 of file test-hdf5-writer.cxx.

78  {
79  using ret_t = decltype(
80  nestOutputs<N-1>(std::declval<int>(),std::declval<size_t>()));
81  std::vector<ret_t> ret;
82  for (size_t n = 0; n < length; n++) {
83  ret.push_back(nestOutputs<N-1>(n + offset, length));
84  }
85  return ret;
86 }

◆ nestOutputs< 1 >()

template<>
auto nestOutputs< 1 > ( int  offset,
size_t  length 
)

Definition at line 88 of file test-hdf5-writer.cxx.

88  {
89  return getOutputs(offset, length, 0.5);
90 }
H5Utils::Consumers::add
void add(const std::string &name, const std::function< T(I)> &, const T &default_value=T(), Compression=Compression::STANDARD)
This should be the only method you need in this class.
Definition: Writer.h:164
getOutputs
std::vector< out_t > getOutputs(int offset, size_t length, float factor)
Definition: test-hdf5-writer.cxx:53
PlotCalibFromCool.dtype
dtype
Definition: PlotCalibFromCool.py:495
python.AthDsoLogger.out
out
Definition: AthDsoLogger.py:71
dq_defect_virtual_defect_validation.d1
d1
Definition: dq_defect_virtual_defect_validation.py:79
getConsumers
consumer_t getConsumers()
Definition: test-hdf5-writer.cxx:27
H5Utils::Compression::HALF_PRECISION
@ HALF_PRECISION
H5Utils::Writer
Writer.
Definition: Writer.h:349
out_t::dtype
double dtype
Definition: test-hdf5-writer.cxx:11
ret
T ret(T t)
Definition: rootspy.cxx:260
beamspotman.n
n
Definition: beamspotman.py:731
out_t
Definition: test-hdf5-writer.cxx:10
H5Utils::Consumers
Definition: Writer.h:129
convertTimingResiduals.offset
offset
Definition: convertTimingResiduals.py:71
out_t::ftype
float ftype
Definition: test-hdf5-writer.cxx:12
length
double length(const pvec &v)
Definition: FPGATrackSimLLPDoubletHoughTransformTool.cxx:26
ADD
#define ADD(NAME)