Add detector name to datasets to mimic the old style

This commit is contained in:
2020-06-19 10:36:38 +02:00
parent ed23b58332
commit e730b0cab3
2 changed files with 48 additions and 27 deletions
+2
View File
@@ -9,6 +9,7 @@
class JFH5Writer {
const std::string detector_name_;
const size_t n_modules_;
const uint64_t start_pulse_id_;
const uint64_t stop_pulse_id_;
@@ -32,6 +33,7 @@ class JFH5Writer {
public:
JFH5Writer(const std::string& output_file,
const std::string& detector_name,
const size_t n_modules,
const uint64_t start_pulse_id,
const uint64_t stop_pulse_id,
+46 -27
View File
@@ -18,10 +18,12 @@ using namespace writer_config;
using namespace buffer_config;
JFH5Writer::JFH5Writer(const string& output_file,
const string& detector_name,
const size_t n_modules,
const uint64_t start_pulse_id,
const uint64_t stop_pulse_id,
const int pulse_id_step) :
detector_name_(detector_name),
n_modules_(n_modules),
start_pulse_id_(start_pulse_id),
stop_pulse_id_(stop_pulse_id),
@@ -60,7 +62,7 @@ JFH5Writer::JFH5Writer(const string& output_file,
// &(compression_prop[0]));
image_dataset_ = file_.createDataSet(
"image",
"/data/" + detector_name_ + "/data",
H5::PredType::NATIVE_UINT16,
image_dataspace);
@@ -131,25 +133,29 @@ void JFH5Writer::close_file()
// TODO: Setup block and stride.
auto pulse_id_dataset = file_.createDataSet(
"pulse_id", H5::PredType::NATIVE_UINT64, f_m_space);
"/data/" + detector_name_ + "/pulse_id",
H5::PredType::NATIVE_UINT64, f_m_space);
pulse_id_dataset.write(
b_pulse_id_, H5::PredType::NATIVE_UINT64, b_m_space, f_m_space);
pulse_id_dataset.close();
auto frame_index_dataset = file_.createDataSet(
"frame_index", H5::PredType::NATIVE_UINT64, f_m_space);
"/data/" + detector_name_ + "/frame_index",
H5::PredType::NATIVE_UINT64, f_m_space);
frame_index_dataset.write(
b_frame_index_, H5::PredType::NATIVE_UINT64, b_m_space, f_m_space);
frame_index_dataset.close();
auto daq_rec_dataset = file_.createDataSet(
"daq_rec", H5::PredType::NATIVE_UINT32, f_m_space);
"/data/" + detector_name_ + "/daq_rec",
H5::PredType::NATIVE_UINT32, f_m_space);
daq_rec_dataset.write(
b_daq_rec_, H5::PredType::NATIVE_UINT32, b_m_space, f_m_space);
daq_rec_dataset.close();
auto is_good_frame_dataset = file_.createDataSet(
"is_good_frame", H5::PredType::NATIVE_UINT8, f_m_space);
"/data/" + detector_name_ + "/is_good_frame",
H5::PredType::NATIVE_UINT8, f_m_space);
is_good_frame_dataset.write(
b_is_good_frame_, H5::PredType::NATIVE_UINT8, b_m_space, f_m_space);
is_good_frame_dataset.close();
@@ -178,29 +184,42 @@ void JFH5Writer::write(
throw runtime_error("Received unexpected block for stop_pulse_id.");
}
// hsize_t b_i_dims[3] = {BUFFER_BLOCK_SIZE,
// MODULE_Y_SIZE * n_modules_,
// MODULE_X_SIZE};
// H5::DataSpace b_i_space(3, b_i_dims);
// hsize_t b_i_count[] = {n_images_to_copy,
// MODULE_Y_SIZE * n_modules_,
// MODULE_X_SIZE};
// hsize_t b_i_start[] = {n_images_offset, 0, 0};
// b_i_space.selectHyperslab(H5S_SELECT_SET, b_i_count, b_i_start);
//
// hsize_t f_i_dims[3] = {n_images_,
// MODULE_Y_SIZE * n_modules_,
// MODULE_X_SIZE};
// H5::DataSpace f_i_space(3, f_i_dims);
// hsize_t f_i_count[] = {n_images_to_copy,
// MODULE_Y_SIZE * n_modules_,
// MODULE_X_SIZE};
// hsize_t f_i_start[] = {current_write_index_, 0, 0};
// f_i_space.selectHyperslab(H5S_SELECT_SET, f_i_count, f_i_start);
//
// image_dataset_.write(
// data, H5::PredType::NATIVE_UINT16, b_i_space, f_i_space);
hsize_t b_i_dims[3] = {BUFFER_BLOCK_SIZE,
MODULE_Y_SIZE * n_modules_,
MODULE_X_SIZE};
H5::DataSpace b_i_space(3, b_i_dims);
hsize_t b_i_count[] = {n_images_to_copy,
MODULE_Y_SIZE * n_modules_,
MODULE_X_SIZE};
hsize_t b_i_start[] = {n_images_offset, 0, 0};
b_i_space.selectHyperslab(H5S_SELECT_SET, b_i_count, b_i_start);
hsize_t f_i_dims[3] = {n_images_,
MODULE_Y_SIZE * n_modules_,
MODULE_X_SIZE};
H5::DataSpace f_i_space(3, f_i_dims);
hsize_t f_i_count[] = {n_images_to_copy,
MODULE_Y_SIZE * n_modules_,
MODULE_X_SIZE};
hsize_t f_i_start[] = {data_write_index_, 0, 0};
f_i_space.selectHyperslab(H5S_SELECT_SET, f_i_count, f_i_start);
image_dataset_.write(
data, H5::PredType::NATIVE_UINT16, b_i_space, f_i_space);
// TODO: Can the i_image++ be made more efficient?
for (size_t i_image=n_images_offset;
i_image < n_images_offset + n_images_to_copy;
i_image++) {
if (i_image % pulse_id_step_ != 0) {
continue;
}
// TODO: Write block.
data_write_index_++;
}
// pulse_id
{