HDFFileReader.hh
Go to the documentation of this file.
1 #ifndef dune_raw_data_HDFUtils_HDFFileReader_hh
2 #define dune_raw_data_HDFUtils_HDFFileReader_hh
3 
4 #include "artdaq-core/Data/Fragment.hh"
5 #include <hdf5.h>
6 #include <memory>
7 #include <string>
8 
9 namespace dune {
10  namespace HDFFileReader {
11 
12  // *****************************************
13  // *** General-purpose data and routines ***
14  // *****************************************
15 
16  struct HDFFileInfo {
17  hid_t filePtr;
18  size_t bytesWritten;
20  int runNumber;
22  };
23  typedef std::unique_ptr<HDFFileInfo> HDFFileInfoPtr;
24 
25  typedef std::map<std::string, std::unique_ptr<artdaq::Fragments> > FragmentListsByType;
26 
27  /**
28  * Opens an HDF file (for reading) with the specified filename (including path information).
29  */
30  HDFFileInfoPtr openFile(const std::string& fileName);
31 
32  /**
33  * Closes and re-opens the specified file.
34  */
35  HDFFileInfoPtr reopenFile(HDFFileInfoPtr oldHdfFileInfoPtr);
36 
37  /**
38  * Closes the specified HDF file. To call this method, user code should use
39  * closeFile(std::move(fileInfoPtr));
40  * The intention behind this is to make it clear that the user code is
41  * relinquishing control.
42  */
43  void closeFile(HDFFileInfoPtr hdfFileInfoPtr);
44 
45  std::list<std::string> getTopLevelGroupNames(HDFFileInfoPtr& hdfFileInfoPtr);
46 
47  std::list<std::string> getMidLevelGroupNames(hid_t gid);
48 
49  /**
50  * Gets the requested Group ID from the specified file and group path.
51  */
52  hid_t getGroupFromPath(HDFFileInfoPtr& hdfFileInfoPtr, const std::string& groupPath);
53 
54  bool attrExists(hid_t object, const std::string& attrname);
55 
56  // ***************************************
57  // *** TPC-related data and routines ***
58  // ***************************************
59 
60  const std::string TPC_GROUP_NAME = "TPC";
61 
62 
63  // ***************************************
64  // *** PDS-related data and routines ***
65  // ***************************************
66 
67  typedef uint64_t PDS_DATASET_DATATYPE;
68  const std::string PDS_GROUP_NAME = "PHOTON";
69 
70 
71  // ************************************************
72  // *** Trigger-Record-related data and routines ***
73  // ************************************************
74 
75  FragmentListsByType getFragmentsForEvent(HDFFileInfoPtr& hdfFileInfoPtr, const std::string& topLevelGroupName);
76 
77 
78  } // namespace HDFFileReader
79 } // namespace dune
80 
81 #endif /* dune_raw_data_HDFUtils_HDFFileReader_hh */
HDFFileInfoPtr reopenFile(HDFFileInfoPtr oldHdfFileInfoPtr)
HDFFileInfoPtr openFile(const std::string &fileName)
std::string string
Definition: nybbler.cc:12
std::list< std::string > getTopLevelGroupNames(HDFFileInfoPtr &hdfFileInfoPtr)
std::list< std::string > getMidLevelGroupNames(hid_t grp)
const std::string PDS_GROUP_NAME
FragmentListsByType getFragmentsForEvent(HDFFileInfoPtr &hdfFileInfoPtr, const std::string &topLevelGroupName)
const std::string TPC_GROUP_NAME
std::unique_ptr< HDFFileInfo > HDFFileInfoPtr
std::map< std::string, std::unique_ptr< artdaq::Fragments > > FragmentListsByType
uint64_t PDS_DATASET_DATATYPE
void closeFile(HDFFileInfoPtr hdfFileInfoPtr)
hid_t getGroupFromPath(HDFFileInfoPtr &hdfFileInfoPtr, const std::string &path)
bool attrExists(hid_t object, const std::string &attrname)