able to get headers from multiple modules as well

This commit is contained in:
2025-06-04 15:59:27 +02:00
parent 5681e18403
commit d9cbf0f481
6 changed files with 69 additions and 33 deletions

View File

@@ -43,9 +43,8 @@ struct H5Handles {
}
// header virtual datasets
else if (rank == 2) {
hsize_t dimsm[1] = {dims[1]};
memspace = std::make_unique<H5::DataSpace>(1, dimsm);
count.push_back(dims[1]);
memspace = std::make_unique<H5::DataSpace>(H5S_SCALAR);
count.push_back(1);
offset.push_back(0);
}
// data dataset
@@ -67,11 +66,19 @@ struct H5Handles {
};
void get_frame_into(size_t frame_index, std::byte *frame_buffer) {
seek(frame_index);
offset[0] = frame_index;
LOG(logDEBUG) << "data offset:" << offset << " count:" << count;
dataspace.selectHyperslab(H5S_SELECT_SET, count.data(), offset.data());
dataset.read(frame_buffer, datatype, *memspace, dataspace);
};
void get_header_into(size_t frame_index, int part_index, std::byte *header_buffer) {
offset[0] = frame_index;
offset[1] = part_index;
LOG(logDEBUG) << "header offset:" << offset << " count:" << count;
dataspace.selectHyperslab(H5S_SELECT_SET, count.data(), offset.data());
dataset.read(header_buffer, datatype, *memspace, dataspace);
};
};
/**
@@ -120,8 +127,7 @@ class Hdf5File : public FileInterface {
size_t cols() const override;
size_t bitdepth() const override;
xy geometry();
size_t n_mod() const;
size_t n_modules() const;
Hdf5MasterFile master() const;
DetectorType detector_type() const override;
@@ -145,9 +151,10 @@ class Hdf5File : public FileInterface {
/**
* @brief read the header at the given frame index into the header buffer
* @param frame_index frame number to read
* @param part_index part index to read (for virtual datasets)
* @param header buffer to store the header
*/
void get_header_into(size_t frame_index, DetectorHeader *header);
void get_header_into(size_t frame_index, int part_index, DetectorHeader *header);
/**
* @brief get the frame at the given frame index

View File

@@ -143,6 +143,7 @@ class Hdf5MasterFile {
size_t total_frames_expected() const;
xy geometry() const;
size_t n_modules() const;
std::optional<size_t> analog_samples() const;
std::optional<size_t> digital_samples() const;

View File

@@ -11,6 +11,7 @@
#include <string_view>
#include <variant>
#include <vector>
#include <iostream>
/**
@@ -267,4 +268,17 @@ template <> std::string ToString(FrameDiscardPolicy arg);
using DataTypeVariants = std::variant<uint16_t, uint32_t>;
template <typename T>
std::ostream &operator<<(std::ostream &os, const std::vector<T> &vec) {
os << "[";
for (size_t i = 0; i < vec.size(); ++i) {
os << vec[i];
if (i != vec.size() - 1)
os << ", ";
}
os << "]";
return os;
}
} // namespace aare