ATLAS Offline Software
Loading...
Searching...
No Matches
StandaloneDataIO::EventInformation Struct Reference

#include <StandaloneDataIO.h>

Collaboration diagram for StandaloneDataIO::EventInformation:

Static Public Member Functions

static ErrorState read_cluster_info (const std::filesystem::path &file, CaloRecGPU::Helpers::CPU_object< CaloRecGPU::ClusterInfoArr > &clusters, const bool report=false)
static ErrorState read_cell_info (const std::filesystem::path &file, CaloRecGPU::Helpers::CPU_object< CaloRecGPU::CellInfoArr > &cell_info, const bool report=false)
static ErrorState write_cluster_info (std::filesystem::path file, const CaloRecGPU::Helpers::CPU_object< CaloRecGPU::ClusterInfoArr > &clusters, const bool report=false)
static ErrorState write_cell_info (std::filesystem::path file, const CaloRecGPU::Helpers::CPU_object< CaloRecGPU::CellInfoArr > &cell_info, const bool report=false)

Friends

struct StandaloneDataIO

Detailed Description

Definition at line 111 of file StandaloneDataIO.h.

Member Function Documentation

◆ read_cell_info()

ErrorState StandaloneDataIO::EventInformation::read_cell_info ( const std::filesystem::path & file,
CaloRecGPU::Helpers::CPU_object< CaloRecGPU::CellInfoArr > & cell_info,
const bool report = false )
inlinestatic

Definition at line 200 of file StandaloneDataIO.h.

203 {
204 std::ifstream in(file.native(), std::ios_base::binary);
205 cell_info.binary_input(in);
206 if (in.fail())
207 {
208 report_error(file, "reading cell info", report);
210 }
211 in.close();
212 return ErrorState::OK;
213 }
static void report_error(const std::filesystem::path &file, const std::string &kind, const bool really_report=false)
TFile * file

◆ read_cluster_info()

ErrorState StandaloneDataIO::EventInformation::read_cluster_info ( const std::filesystem::path & file,
CaloRecGPU::Helpers::CPU_object< CaloRecGPU::ClusterInfoArr > & clusters,
const bool report = false )
inlinestatic

Definition at line 116 of file StandaloneDataIO.h.

119 {
120 clusters.allocate();
121
122 std::ifstream in(file.native(), std::ios_base::binary);
123
124 auto reader = [&](auto * ptr, const auto & size)
125 {
126 in.read(reinterpret_cast<char *>(ptr), sizeof(*ptr) * size);
127 };
128
129 reader(static_cast<CaloRecGPU::ClusterBaseInfo *>(clusters), 1);
130
131 if (in.fail() || clusters->number < 0 || clusters->number > CaloRecGPU::NMaxClusters)
132 {
133 report_error(file, "reading clusters", report);
135 }
136
137 if (clusters->has_basic_info())
138 {
139 reader(clusters->clusterEnergy, clusters->number);
140 reader(clusters->clusterEt, clusters->number);
141 reader(clusters->clusterEta, clusters->number);
142 reader(clusters->clusterPhi, clusters->number);
143 reader(clusters->seedCellIndex, clusters->number);
144 }
145
146 switch (clusters->state)
147 {
149 [[fallthrough]];
152 break;
154 [[fallthrough]];
156 [[fallthrough]];
158 [[fallthrough]];
160 reader(clusters->cellsPrefixSum, clusters->number + 1);
161 reader(clusters->cells.indices, clusters->number_cells);
162 reader(clusters->cellWeights, clusters->number_cells);
163 reader(clusters->clusterIndices, clusters->number_cells);
164 break;
165 default:
166 break;
167 }
168
169 if (clusters->has_moments())
170 {
171 clusters->for_all_moments([&](auto & arr)
172 {
173 unsigned long long base_size;
174 if constexpr (std::is_pointer_v<std::decay_t<decltype(*arr)>>)
175 {
176 base_size = sizeof(**arr) * sizeof(arr)/sizeof(*arr);
177 }
178 else
179 {
180 base_size = sizeof(*arr);
181 }
182 in.read(reinterpret_cast<char *>(arr), base_size * clusters->number);
183 });
184 }
185
186 if (in.fail())
187 {
188 report_error(file, "reading clusters", report);
190 }
191
192 in.close();
193
194 return ErrorState::OK;
195
196 }
constexpr int NCaloCells
constexpr int NMaxClusters
reader
read the goodrunslist xml file(s)
Definition collisions.py:22
void * ptr(T *p)
Definition SGImplSvc.cxx:74

◆ write_cell_info()

ErrorState StandaloneDataIO::EventInformation::write_cell_info ( std::filesystem::path file,
const CaloRecGPU::Helpers::CPU_object< CaloRecGPU::CellInfoArr > & cell_info,
const bool report = false )
inlinestatic

Definition at line 290 of file StandaloneDataIO.h.

293 {
294 file.replace_extension(".cellinfo");
295 std::ofstream out(file, std::ios_base::binary);
296 cell_info.binary_output(out);
297 if (out.fail())
298 {
299 report_error(file, "writing cell info", report);
301 }
302 out.close();
303 return ErrorState::OK;
304 }

◆ write_cluster_info()

ErrorState StandaloneDataIO::EventInformation::write_cluster_info ( std::filesystem::path file,
const CaloRecGPU::Helpers::CPU_object< CaloRecGPU::ClusterInfoArr > & clusters,
const bool report = false )
inlinestatic

Definition at line 215 of file StandaloneDataIO.h.

218 {
219 file.replace_extension(".clusterinfo");
220 std::ofstream out(file, std::ios_base::binary);
221
222 auto writer = [&](const auto * ptr, const auto & size)
223 {
224 out.write(reinterpret_cast<const char *>(ptr), sizeof(*ptr) * size);
225 };
226
227
228 out.write(reinterpret_cast<const char *>(static_cast<const CaloRecGPU::ClusterBaseInfo *>(clusters)), sizeof(CaloRecGPU::ClusterBaseInfo));
229
230 if (clusters->has_basic_info())
231 {
232 writer(clusters->clusterEnergy, clusters->number);
233 writer(clusters->clusterEt, clusters->number);
234 writer(clusters->clusterEta, clusters->number);
235 writer(clusters->clusterPhi, clusters->number);
236 writer(clusters->seedCellIndex, clusters->number);
237 }
238
239 switch (clusters->state)
240 {
242 [[fallthrough]];
245 break;
247 [[fallthrough]];
249 [[fallthrough]];
251 [[fallthrough]];
253 writer(clusters->cellsPrefixSum, clusters->number + 1);
254 writer(clusters->cells.indices, clusters->number_cells);
255 writer(clusters->cellWeights, clusters->number_cells);
256 writer(clusters->clusterIndices, clusters->number_cells);
257 break;
258 default:
259 break;
260 }
261
262 if (clusters->has_moments())
263 {
264 clusters->for_all_moments([&](const auto & arr)
265 {
266 unsigned long long base_size;
267 if constexpr (std::is_pointer_v<std::decay_t<decltype(*arr)>>)
268 {
269 base_size = sizeof(**arr) * sizeof(arr)/sizeof(*arr);
270 }
271 else
272 {
273 base_size = sizeof(*arr);
274 }
275 out.write(reinterpret_cast<const char *>(arr), base_size * clusters->number);
276 });
277 }
278
279 if (out.fail())
280 {
281 report_error(file, "writing clusters", report);
283 }
284 out.close();
285 return ErrorState::OK;
286 }
writer
show summary of content
Definition example.py:36

◆ StandaloneDataIO

friend struct StandaloneDataIO
friend

Definition at line 113 of file StandaloneDataIO.h.


The documentation for this struct was generated from the following file: