Public Member Functions | Private Attributes | List of all members
dune::HDF5RawInputDetail Class Reference

#include <HDF5RawInput.h>

Public Member Functions

 HDF5RawInputDetail (fhicl::ParameterSet const &ps, art::ProductRegistryHelper &rh, art::SourceHelper const &sh)
 
void readFile (std::string const &filename, art::FileBlock *&fb)
 
bool readNext (art::RunPrincipal const *const inR, art::SubRunPrincipal const *const inSR, art::RunPrincipal *&outR, art::SubRunPrincipal *&outSR, art::EventPrincipal *&outE)
 
void closeCurrentFile ()
 

Private Attributes

std::unique_ptr< dune::HDF5Utils::HDFFileInfohdf_file_
 
std::deque< std::stringunprocessedEventList_
 
std::string pretend_module_name
 
int fLogLevel
 
art::SourceHelper const & pmaker
 

Detailed Description

Definition at line 28 of file HDF5RawInput.h.

Constructor & Destructor Documentation

dune::HDF5RawInputDetail::HDF5RawInputDetail ( fhicl::ParameterSet const &  ps,
art::ProductRegistryHelper rh,
art::SourceHelper const &  sh 
)

Definition at line 8 of file HDF5RawInput_source.cc.

12  : pretend_module_name(ps.get<std::string>("raw_data_label", "daq")),
13  fLogLevel(ps.get<int>("LogLevel", 0)),
14  pmaker(sh) {
17 }
std::string string
Definition: nybbler.cc:12
art::SourceHelper const & pmaker
Definition: HDF5RawInput.h:52
TypeLabel const & reconstitutes(std::string const &modLabel, std::string const &instanceName={})
static constexpr double ps
Definition: Units.h:99
std::string pretend_module_name
Definition: HDF5RawInput.h:50

Member Function Documentation

void dune::HDF5RawInputDetail::closeCurrentFile ( )
inline

Definition at line 42 of file HDF5RawInput.h.

42  {
43  if (hdf_file_->filePtr)
45  };
def move(depos, offset)
Definition: depos.py:107
std::unique_ptr< dune::HDF5Utils::HDFFileInfo > hdf_file_
Definition: HDF5RawInput.h:45
void closeFile(HDFFileInfoPtr hdfFileInfoPtr)
Definition: HDF5Utils.cc:31
void dune::HDF5RawInputDetail::readFile ( std::string const &  filename,
art::FileBlock *&  fb 
)

Definition at line 19 of file HDF5RawInput_source.cc.

20  {
24  MF_LOG_INFO("HDF5")
25  << "HDF5 opened HDF file with run number " <<
26  hdf_file_->runNumber << " and " <<
27  unprocessedEventList_.size() << " events";
28  for (const auto & e : unprocessedEventList_)
29  MF_LOG_INFO("HDF5") << e;
30 
31  fb = new art::FileBlock(art::FileFormatVersion(1, "RawEvent2011"),
32  filename);
33 }
std::deque< std::string > unprocessedEventList_
Definition: HDF5RawInput.h:49
string filename
Definition: train.py:213
std::deque< std::string > getTopLevelGroupNames(HDFFileInfoPtr &hdfFileInfoPtr)
Definition: HDF5Utils.cc:36
const double e
#define MF_LOG_INFO(category)
HDFFileInfoPtr openFile(const std::string &fileName)
Definition: HDF5Utils.cc:12
std::unique_ptr< dune::HDF5Utils::HDFFileInfo > hdf_file_
Definition: HDF5RawInput.h:45
bool dune::HDF5RawInputDetail::readNext ( art::RunPrincipal const *const  inR,
art::SubRunPrincipal const *const  inSR,
art::RunPrincipal *&  outR,
art::SubRunPrincipal *&  outSR,
art::EventPrincipal *&  outE 
)

Definition at line 35 of file HDF5RawInput_source.cc.

40 {
41  using namespace dune::HDF5Utils;
42 
43  // Establish default 'results'
44  outR = 0;
45  outSR = 0;
46  outE = 0;
47 
48  if (unprocessedEventList_.empty()) {return false;}
49  std::string nextEventGroupName = unprocessedEventList_.front();
50  unprocessedEventList_.pop_front();
51 
52  size_t run_id = 999; //runNumber can be 0,
53  //but this seems like an issue
54  //with art
55 
56  //Accessing run number
57  hid_t the_group = getGroupFromPath (hdf_file_->filePtr, nextEventGroupName);
58  HeaderInfo header_info;
59  std::string det_type = "TriggerRecordHeader";
60 
61  getHeaderInfo(the_group, det_type, header_info);
62  if (fLogLevel > 0) {
63  std::cout << " Magic word: 0x" << std::hex << header_info.magicWord <<
65  std::cout << " Version: " << std::dec << header_info.version <<
67  std::cout << " Trig Num: " << std::dec << header_info.trigNum <<
69  std::cout << " Trig Timestamp: " << std::dec <<
70  header_info.trigTimestamp << std::dec << std::endl;
71  std::cout << " No. of requested components: " << std::dec <<
72  header_info.nReq << std::dec << std::endl;
73  std::cout << " Run Number: " << std::dec << header_info.runNum <<
74  std::endl;
75  std::cout << " Error bits: " << std::dec << header_info.errBits <<
76  std::endl;
77  std::cout << " Trigger type: " << std::dec << header_info.triggerType <<
78  std::endl;
79  }
80  MF_LOG_INFO("HDF5") << "header_info.trigTimestamp :" << header_info.trigTimestamp << std::endl;
81 
82  // trigTimeStamp is NOT time but Clock-tick since the epoch.
83  uint64_t trigTimeStamp = header_info.trigTimestamp;
84 
85  uint64_t getTrigTime = formatTrigTimeStamp (trigTimeStamp);
86  // std::cout << "getTrigTime :" << getTrigTime << std::endl;
87 
88  art::Timestamp artTrigStamp (getTrigTime);
89  // std::cout << "artTrigStamp :" << artTrigStamp.value() << std::endl;
90 
91  run_id = header_info.runNum;
92  std::unique_ptr<raw::RDTimeStamp> rd_timestamp(
93  new raw::RDTimeStamp(header_info.trigTimestamp));
94 
95  // make new run if inR is 0 or if the run has changed
96  if (inR == 0 || inR->run() != run_id) {
97  outR = pmaker.makeRunPrincipal(run_id,artTrigStamp);
98  }
99 
100  // make new subrun if inSR is 0 or if the subrun has changed
101  art::SubRunID subrun_check(run_id, 1);
102  if (inSR == 0 || subrun_check != inSR->subRunID()) {
103  outSR = pmaker.makeSubRunPrincipal(run_id, 1, artTrigStamp);
104  }
105 
106  //Where to get event number?
107  //For now -- parse from input record
108  std::string event_str = nextEventGroupName;
109  std::string trig = "TriggerRecord";
110  auto pos = event_str.begin() + event_str.find(trig);
111  event_str.erase(pos, pos + trig.size());
112  int event = std::stoi(event_str);
113  outE = pmaker.makeEventPrincipal(run_id, 1, event, artTrigStamp);
114  //std::cout << "Event Time Stamp :" << event.time() << std::endl;
115 
116  std::unique_ptr<raw::DUNEHDF5FileInfo> the_info(
117  new raw::DUNEHDF5FileInfo(hdf_file_->fileName, hdf_file_->filePtr,
118  0, nextEventGroupName));
119 
121  "");
123  "trigger");
124 
125  return true;
126 }
std::string string
Definition: nybbler.cc:12
std::deque< std::string > unprocessedEventList_
Definition: HDF5RawInput.h:49
SubRunPrincipal * makeSubRunPrincipal(SubRunAuxiliary const &subRunAux) const
art::SourceHelper const & pmaker
Definition: HDF5RawInput.h:52
QTextStream & hex(QTextStream &s)
RunPrincipal * makeRunPrincipal(RunAuxiliary const &runAux) const
Definition: SourceHelper.cc:92
def move(depos, offset)
Definition: depos.py:107
#define MF_LOG_INFO(category)
std::string pretend_module_name
Definition: HDF5RawInput.h:50
QTextStream & dec(QTextStream &s)
std::enable_if_t<!detail::range_sets_supported(P::branch_type)> put_product_in_principal(std::unique_ptr< T > &&product, P &principal, std::string const &module_label, std::string const &instance_name={})
void getHeaderInfo(hid_t the_group, const std::string &det_type, HeaderInfo &info)
Definition: HDF5Utils.cc:96
uint64_t formatTrigTimeStamp(uint64_t trigTimeStamp)
Definition: HDF5Utils.cc:58
EventPrincipal * makeEventPrincipal(EventAuxiliary const &eventAux, std::unique_ptr< History > &&history) const
hid_t getGroupFromPath(HDFFileInfoPtr &hdfFileInfoPtr, const std::string &path)
std::unique_ptr< dune::HDF5Utils::HDFFileInfo > hdf_file_
Definition: HDF5RawInput.h:45
QTextStream & endl(QTextStream &s)
Event finding and building.

Member Data Documentation

int dune::HDF5RawInputDetail::fLogLevel
private

Definition at line 51 of file HDF5RawInput.h.

std::unique_ptr<dune::HDF5Utils::HDFFileInfo> dune::HDF5RawInputDetail::hdf_file_
private

Definition at line 45 of file HDF5RawInput.h.

art::SourceHelper const& dune::HDF5RawInputDetail::pmaker
private

Definition at line 52 of file HDF5RawInput.h.

std::string dune::HDF5RawInputDetail::pretend_module_name
private

Definition at line 50 of file HDF5RawInput.h.

std::deque<std::string> dune::HDF5RawInputDetail::unprocessedEventList_
private

Definition at line 49 of file HDF5RawInput.h.


The documentation for this class was generated from the following files: