Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patch/fddaq v4.4.x #100

Merged
merged 11 commits into from
Jul 10, 2024
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.12 FATAL_ERROR)
project(hdf5libs VERSION 2.8.4)
project(hdf5libs VERSION 2.8.5)

find_package(daq-cmake REQUIRED)

Expand Down
5 changes: 5 additions & 0 deletions include/hdf5libs/HDF5FileLayout.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,11 @@ class HDF5FileLayout
*/
std::vector<std::string> 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
*/
Expand Down
2 changes: 2 additions & 0 deletions include/hdf5libs/HDF5RawDataFile.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

/**
Expand Down
13 changes: 13 additions & 0 deletions src/HDF5FileLayout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
3 changes: 3 additions & 0 deletions src/HDF5RawDataFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
18 changes: 7 additions & 11 deletions src/HDF5SourceIDHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,13 @@ HDF5SourceIDHandler::rebuild_srcidgeoidmap(const source_id_geo_id_map_t& the_map
for( const auto& [sid, geoids] : the_map ) {
// There could be more than one, but we don't want to think about that
uint64_t geoid = *geoids.begin();
m.emplace_back(hdf5rawdatafile::SrcIDGeoIDEntry{
sid.id,
hdf5rawdatafile::GeoID{
.det_id = (geoid >> 0) & 0xff,
.crate_id = (geoid >> 16) & 0xff,
.slot_id = (geoid >> 32) & 0xff,
.stream_id = (geoid >> 48) & 0xff,
}
}
);
}
hdf5rawdatafile::GeoID gid;
gid.det_id = (int)((geoid >> 0) & 0xff);
gid.crate_id = (int)((geoid >> 16) & 0xff);
gid.slot_id = (int)((geoid >> 32) & 0xff);
gid.stream_id = (int)((geoid >> 48) & 0xff);
m.emplace_back(hdf5rawdatafile::SrcIDGeoIDEntry{sid.id,gid});
}

return m;
}
Expand Down
5 changes: 3 additions & 2 deletions test/apps/HDF5LIBS_TestDumpRecord.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<DetID::Subdetector>(det_id))
<< " (" << det_id << ")"
<< ", crate " << crate_id << ", slot " << slot_id << ", link " << link_id;
}
}
Expand Down Expand Up @@ -273,7 +274,7 @@ main(int argc, char** argv)
if (input_low != 0) { // Skip printing the positions if the value is 0.
ss << ", Input Low Bit Positions = ";
bit_sniff = 1;
for (bit_pos = 0; bit_pos < 32, num_bits > 0; bit_pos++) {
for (bit_pos = 0; bit_pos < 32 && num_bits > 0; bit_pos++) {
if (input_low & bit_sniff) {
if (num_bits == 1)
ss << bit_pos;
Expand All @@ -292,7 +293,7 @@ main(int argc, char** argv)
if (input_high != 0) {
ss << ", Input High Bit Positions = ";
bit_sniff = 1;
for (bit_pos = 0; bit_pos < 32, num_bits > 0; bit_pos++) {
for (bit_pos = 0; bit_pos < 32 && num_bits > 0; bit_pos++) {
if (input_high & bit_sniff) {
if (num_bits == 1)
ss << bit_pos;
Expand Down
Loading