From be12611a59a1fd7369fee7eeeb29ca3e25f513bf Mon Sep 17 00:00:00 2001 From: Kurt Biery Date: Tue, 2 Jul 2024 09:05:35 -0500 Subject: [PATCH 1/3] Added a method to HDF5FileLayout that returns the path to a TimeSliceHeader DataSet as a single string. This will be used to check if a TSH already exists for a given time slice and not waste time trying to create it again. --- include/hdf5libs/HDF5FileLayout.hpp | 5 +++++ src/HDF5FileLayout.cpp | 13 +++++++++++++ 2 files changed, 18 insertions(+) diff --git a/include/hdf5libs/HDF5FileLayout.hpp b/include/hdf5libs/HDF5FileLayout.hpp index 066a224..1e95082 100644 --- a/include/hdf5libs/HDF5FileLayout.hpp +++ b/include/hdf5libs/HDF5FileLayout.hpp @@ -127,6 +127,11 @@ class HDF5FileLayout */ std::vector get_path_elements(const daqdataformats::FragmentHeader& fh) const; + /** + * @brief get the path for the TimeSliceHeader as a single string (e.g. /a/b/c) + */ + std::string get_path_string(const daqdataformats::TimeSliceHeader& tsh) const; + /** * @brief extract Fragment GeoID given path elements */ diff --git a/src/HDF5FileLayout.cpp b/src/HDF5FileLayout.cpp index 936992a..bc2e183 100644 --- a/src/HDF5FileLayout.cpp +++ b/src/HDF5FileLayout.cpp @@ -152,6 +152,19 @@ HDF5FileLayout::get_path_elements(const daqdataformats::FragmentHeader& fh) cons return path_elements; } +/** + * @brief get the path for the TimeSliceHeader as a single string + */ +std::string +HDF5FileLayout::get_path_string(const daqdataformats::TimeSliceHeader& tsh) const +{ + std::ostringstream path_string; + path_string << "/" << get_timeslice_number_string(tsh.timeslice_number) + << "/" << m_conf_params.raw_data_group_name + << "/" << tsh.element_id.to_string() << "_" << m_conf_params.record_header_dataset_name; + return path_string.str(); +} + /** * @brief get the full path for a record header dataset based on trig/seq number */ From fc37396122e0e3a88866cc479032de20b2fe5baa Mon Sep 17 00:00:00 2001 From: Kurt Biery Date: Tue, 2 Jul 2024 09:07:18 -0500 Subject: [PATCH 2/3] Added the printout of the detector ID number in some of the HDF5LIBS_TestDumpRecord output so that expert users can verify that the correct number is present. --- test/apps/HDF5LIBS_TestDumpRecord.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/test/apps/HDF5LIBS_TestDumpRecord.cpp b/test/apps/HDF5LIBS_TestDumpRecord.cpp index 3c5e182..92de346 100644 --- a/test/apps/HDF5LIBS_TestDumpRecord.cpp +++ b/test/apps/HDF5LIBS_TestDumpRecord.cpp @@ -190,6 +190,7 @@ main(int argc, char** argv) uint16_t link_id = (geo_id >> 48) & 0xffff; ss << "\n\t\t\t" << "subdetector " << DetID::subdetector_to_string(static_cast(det_id)) + << " (" << det_id << ")" << ", crate " << crate_id << ", slot " << slot_id << ", link " << link_id; } } From 24e2fac0501b13e8ecce3eca1ccfa9b045fb7dc6 Mon Sep 17 00:00:00 2001 From: Kurt Biery Date: Tue, 2 Jul 2024 09:10:23 -0500 Subject: [PATCH 3/3] Modified the write(TimeSlice) method in HDF5RawDataFile so that it doesn't try to write a TimeSlice that already exists. It now throws a special exception instead so that callers can react appropriately. --- include/hdf5libs/HDF5RawDataFile.hpp | 2 ++ src/HDF5RawDataFile.cpp | 3 +++ 2 files changed, 5 insertions(+) diff --git a/include/hdf5libs/HDF5RawDataFile.hpp b/include/hdf5libs/HDF5RawDataFile.hpp index 0ef5859..de43941 100644 --- a/include/hdf5libs/HDF5RawDataFile.hpp +++ b/include/hdf5libs/HDF5RawDataFile.hpp @@ -101,6 +101,8 @@ ERS_DECLARE_ISSUE(hdf5libs, InvalidHDF5Attribute, "Attribute " << name << " not ERS_DECLARE_ISSUE(hdf5libs, HDF5AttributeExists, "Attribute " << name << " already exists.", ((std::string)name)) +ERS_DECLARE_ISSUE(hdf5libs, TimeSliceAlreadyExists, "The TimeSlice record for " << name << " already exists.", ((std::string)name)) + namespace hdf5libs { /** diff --git a/src/HDF5RawDataFile.cpp b/src/HDF5RawDataFile.cpp index aa977c0..e7055cb 100644 --- a/src/HDF5RawDataFile.cpp +++ b/src/HDF5RawDataFile.cpp @@ -151,6 +151,9 @@ HDF5RawDataFile::write(const daqdataformats::TriggerRecord& tr) void HDF5RawDataFile::write(const daqdataformats::TimeSlice& ts) { + std::string tsh_path = m_file_layout_ptr->get_path_string(ts.get_header()); + if (m_file_ptr->exist(tsh_path)) {throw TimeSliceAlreadyExists(ERS_HERE, tsh_path);} + // the source_id_path map that we will build up as we write the TR header // and fragments (and then write the map into the HDF5 TR_record Group) HDF5SourceIDHandler::source_id_path_map_t source_id_path_map;