4 #include "detdataformats/wib/WIBFrame.hpp" 14 hdfFileInfoPtr->filePtr = H5Fopen(fileName.data(), H5F_ACC_RDONLY, H5P_DEFAULT);
15 hdfFileInfoPtr->bytesWritten = 0;
17 hdfFileInfoPtr->runNumber = 0;
18 hdfFileInfoPtr->dataFormatVersion = 0;
20 hid_t grp = H5Gopen(hdfFileInfoPtr->filePtr,
"/", H5P_DEFAULT);
23 hid_t ga = H5Aopen_name(grp,
"data_format_version");
24 H5Aread(ga, H5Aget_type(ga), &hdfFileInfoPtr->dataFormatVersion);
28 return hdfFileInfoPtr;
32 H5Fclose(hdfFileInfoPtr->filePtr);
33 hdfFileInfoPtr->filePtr = 0;
37 hid_t grp = H5Gopen(hdfFileInfoPtr->filePtr,
"/", H5P_DEFAULT);
44 std::deque<std::string> theList;
46 H5Gget_num_objs(grp, &nobj);
47 for (hsize_t idx = 0; idx < nobj; ++idx) {
48 hsize_t len = H5Gget_objname_by_idx(grp, idx, NULL, 0 );
49 char *memb_name =
new char(len+1);
50 H5Gget_objname_by_idx(grp, idx, memb_name, len+1 );
51 theList.emplace_back(memb_name);
60 int clock_period = 20;
61 uint64_t trigtime = trigTimeStamp * clock_period;
62 uint64_t million = 1e9;
63 uint64_t trigtime_sec = trigtime/million;
65 uint64_t trigtime_nanosec = trigtime % million;
66 uint64_t toReturn = (trigtime_sec << 32) | trigtime_nanosec;
74 void *old_client_data;
75 H5Eget_auto(H5E_DEFAULT,&old_func, &old_client_data);
78 H5Eset_auto(H5E_DEFAULT,NULL, NULL);
82 hid_t retval = H5Aopen_name(
object, attrname.data());
85 H5Eset_auto(H5E_DEFAULT,old_func, old_client_data);
87 bool result = (retval >= 0);
92 hid_t grp = H5Gopen(fd, path.data(), H5P_DEFAULT);
98 hid_t datasetid = H5Dopen(the_group, det_type.data(), H5P_DEFAULT);
99 hsize_t ds_size = H5Dget_storage_size(datasetid);
106 size_t narray = ds_size /
sizeof(char);
107 size_t rdr = ds_size %
sizeof(char);
108 if (rdr > 0 || narray == 0) narray++;
109 char *ds_data =
new char[narray];
110 H5Dread(datasetid, H5T_STD_I8LE, H5S_ALL, H5S_ALL,
111 H5P_DEFAULT, ds_data);
123 memcpy(&info.
version, &ds_data[4],4);
128 memcpy(&info.
trigNum, &ds_data[8],8);
138 memcpy(&info.
nReq, &ds_data[24],8);
143 memcpy(&info.
runNum, &ds_data[32], 4);
148 memcpy(&info.
errBits, &ds_data[36], 4);
std::unique_ptr< HDFFileInfo > HDFFileInfoPtr
std::deque< std::string > getMidLevelGroupNames(hid_t grp)
std::deque< std::string > getTopLevelGroupNames(HDFFileInfoPtr &hdfFileInfoPtr)
bool attrExists(hid_t object, const std::string &attrname)
hid_t getGroupFromPath(hid_t fd, const std::string &path)
void getHeaderInfo(hid_t the_group, const std::string &det_type, HeaderInfo &info)
uint64_t formatTrigTimeStamp(uint64_t trigTimeStamp)
HDFFileInfoPtr openFile(const std::string &fileName)
void closeFile(HDFFileInfoPtr hdfFileInfoPtr)