Public Member Functions | Private Member Functions | Private Attributes | List of all members
dune::VDColdboxPDSDecoder Class Reference
Inheritance diagram for dune::VDColdboxPDSDecoder:
art::EDProducer art::detail::Producer art::detail::LegacyModule art::Modifier art::ModuleBase art::ProductRegistryHelper

Public Member Functions

 VDColdboxPDSDecoder (fhicl::ParameterSet const &p)
 
 VDColdboxPDSDecoder (VDColdboxPDSDecoder const &)=delete
 
 VDColdboxPDSDecoder (VDColdboxPDSDecoder &&)=delete
 
VDColdboxPDSDecoderoperator= (VDColdboxPDSDecoder const &)=delete
 
VDColdboxPDSDecoderoperator= (VDColdboxPDSDecoder &&)=delete
 
void produce (art::Event &e) override
 
- Public Member Functions inherited from art::EDProducer
 EDProducer (fhicl::ParameterSet const &pset)
 
template<typename Config >
 EDProducer (Table< Config > const &config)
 
std::string workerType () const
 
- Public Member Functions inherited from art::detail::Producer
virtual ~Producer () noexcept
 
 Producer (fhicl::ParameterSet const &)
 
 Producer (Producer const &)=delete
 
 Producer (Producer &&)=delete
 
Produceroperator= (Producer const &)=delete
 
Produceroperator= (Producer &&)=delete
 
void doBeginJob (SharedResources const &resources)
 
void doEndJob ()
 
void doRespondToOpenInputFile (FileBlock const &fb)
 
void doRespondToCloseInputFile (FileBlock const &fb)
 
void doRespondToOpenOutputFiles (FileBlock const &fb)
 
void doRespondToCloseOutputFiles (FileBlock const &fb)
 
bool doBeginRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doEndRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doBeginSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEndSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEvent (EventPrincipal &ep, ModuleContext const &mc, std::atomic< std::size_t > &counts_run, std::atomic< std::size_t > &counts_passed, std::atomic< std::size_t > &counts_failed)
 
- Public Member Functions inherited from art::Modifier
 ~Modifier () noexcept
 
 Modifier ()
 
 Modifier (Modifier const &)=delete
 
 Modifier (Modifier &&)=delete
 
Modifieroperator= (Modifier const &)=delete
 
Modifieroperator= (Modifier &&)=delete
 
- Public Member Functions inherited from art::ModuleBase
virtual ~ModuleBase () noexcept
 
 ModuleBase ()
 
ModuleDescription const & moduleDescription () const
 
void setModuleDescription (ModuleDescription const &)
 
std::array< std::vector< ProductInfo >, NumBranchTypes > const & getConsumables () const
 
void sortConsumables (std::string const &current_process_name)
 
template<typename T , BranchType BT>
ViewToken< T > consumesView (InputTag const &tag)
 
template<typename T , BranchType BT>
ViewToken< T > mayConsumeView (InputTag const &tag)
 

Private Member Functions

std::pair< raw::OpDetWaveform, recob::OpHitMakeWaveformAndHit (const dunedaq::detdataformats::ssp::EventHeader *event_header, size_t data_pos, uint8_t *data_ptr)
 

Private Attributes

hid_t fPrevStoredHandle = -1
 
hid_t fHDFFile = -1
 
std::string fOutputDataLabel
 
std::string fFileInfoLabel
 
bool fForceOpen
 
bool fDebug
 

Additional Inherited Members

- Public Types inherited from art::EDProducer
using ModuleType = EDProducer
 
using WorkerType = WorkerT< EDProducer >
 
- Public Types inherited from art::detail::Producer
template<typename UserConfig , typename KeysToIgnore = void>
using Table = Modifier::Table< UserConfig, KeysToIgnore >
 
- Public Types inherited from art::Modifier
template<typename UserConfig , typename UserKeysToIgnore = void>
using Table = ProducerTable< UserConfig, detail::ModuleConfig, UserKeysToIgnore >
 
- Static Public Member Functions inherited from art::EDProducer
static void commitEvent (EventPrincipal &ep, Event &e)
 
- Protected Member Functions inherited from art::ModuleBase
ConsumesCollectorconsumesCollector ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > consumes (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > consumesView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void consumesMany ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > mayConsume (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > mayConsumeView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void mayConsumeMany ()
 

Detailed Description

Definition at line 35 of file VDColdboxPDSDecoder_module.cc.

Constructor & Destructor Documentation

dune::VDColdboxPDSDecoder::VDColdboxPDSDecoder ( fhicl::ParameterSet const &  p)
explicit

Definition at line 68 of file VDColdboxPDSDecoder_module.cc.

69  : EDProducer{p},
70  fOutputDataLabel{p.get<std::string>("OutputDataLabel")},
71  fFileInfoLabel{p.get<std::string>("FileInfoLabel", "daq")},
72  fForceOpen(p.get<bool>("ForceOpen", false)),
73  fDebug(p.get<bool>("Debug", false)) {
74  produces<std::vector<raw::OpDetWaveform>>(fOutputDataLabel);
75  produces<std::vector<recob::OpHit>>(fOutputDataLabel);
76 }
std::string string
Definition: nybbler.cc:12
EDProducer(fhicl::ParameterSet const &pset)
Definition: EDProducer.h:20
p
Definition: test.py:223
dune::VDColdboxPDSDecoder::VDColdboxPDSDecoder ( VDColdboxPDSDecoder const &  )
delete
dune::VDColdboxPDSDecoder::VDColdboxPDSDecoder ( VDColdboxPDSDecoder &&  )
delete

Member Function Documentation

std::pair< raw::OpDetWaveform, recob::OpHit > dune::VDColdboxPDSDecoder::MakeWaveformAndHit ( const dunedaq::detdataformats::ssp::EventHeader *  event_header,
size_t  data_pos,
uint8_t *  data_ptr 
)
private

Definition at line 168 of file VDColdboxPDSDecoder_module.cc.

170  {
171 
172  using namespace dunedaq::detdataformats::ssp;
173  size_t nADC = (event_header->length - sizeof(EventHeader))/2;
174  if (fDebug) std::cout << "\tnADC: " << nADC << std::endl;
175  unsigned long ts = 0;
176  for (unsigned int iword = 0; iword <= 3; ++iword) {
177  ts += ((unsigned long)(event_header->timestamp[iword])) << 16 * iword;
178  }
179 
180  //Need time, channel
181  raw::OpDetWaveform wf(ts, event_header->group2, nADC);
182 
183  //Iterate to the start of the adc data
184  unsigned short * adc_ptr = reinterpret_cast<unsigned short *>(
185  data_ptr + data_pos + sizeof(EventHeader));
186 
187  //size_t peak_tick = 0;
188  //unsigned short max_adc = 0;
189 
190  for (size_t i = 0; i < nADC; ++i) {
191  wf.push_back(*(adc_ptr + i));
192  //max_adc = std::max(max_adc, *(adc_ptr + i));
193  //if(max_adc == *(adc_ptr + i)) peak_tick = i;
194  }
195  //std::cout << "Max adc, peak tick: " << max_adc << ", " << peak_tick <<
196  // std::endl;
197 
198  return {wf, recob::OpHit()};
199 }
QTextStream & endl(QTextStream &s)
VDColdboxPDSDecoder& dune::VDColdboxPDSDecoder::operator= ( VDColdboxPDSDecoder const &  )
delete
VDColdboxPDSDecoder& dune::VDColdboxPDSDecoder::operator= ( VDColdboxPDSDecoder &&  )
delete
void dune::VDColdboxPDSDecoder::produce ( art::Event e)
overridevirtual

Implements art::EDProducer.

Definition at line 78 of file VDColdboxPDSDecoder_module.cc.

78  {
79 
80  using namespace dune::HDF5Utils;
81  using namespace dunedaq::detdataformats::ssp;
82 
83  //To-do: put in sizes here?
84  std::unique_ptr<std::vector<raw::OpDetWaveform>> output_wfs
85  = std::make_unique<std::vector<raw::OpDetWaveform>>();
86  std::unique_ptr<std::vector<recob::OpHit>> output_hits
87  = std::make_unique<std::vector<recob::OpHit>>();
88 
89 
90  auto infoHandle = e.getHandle<raw::DUNEHDF5FileInfo>(fFileInfoLabel);
91  const std::string & group_name = infoHandle->GetEventGroupName();
92  const std::string & file_name = infoHandle->GetFileName();
93  hid_t file_id = infoHandle->GetHDF5FileHandle();
94 
95  //If the fcl file said to force open the file
96  //(i.e. because one is just running DataPrep), then open
97  //but only if we are on a new file -- identified by if the handle
98  //stored in the event is different
99  if (fForceOpen && (file_id != fPrevStoredHandle)) {
100  std::cout << "Opening" << std::endl;
101  fHDFFile = H5Fopen(file_name.data(), H5F_ACC_RDONLY, H5P_DEFAULT);
102  }//If the handle is the same, fHDFFile won't change
103  else if (!fForceOpen) {
104  fHDFFile = file_id;
105  }
106  fPrevStoredHandle = file_id;
107 
108  hid_t PDS_group = getGroupFromPath(fHDFFile, group_name + "/PDS");
109  std::deque<std::string> region_names = getMidLevelGroupNames(PDS_group);
110  if (fDebug)
111  std::cout << "Got " << region_names.size() << " regions" << std::endl;
112  for (const auto & n : region_names) {
113  hid_t region_group = getGroupFromPath(PDS_group, n);
114  std::deque<std::string> element_names = getMidLevelGroupNames(region_group);
115  if (fDebug)
116  std::cout << "Got " << element_names.size() << " elements" << std::endl;
117  for (const auto & element_name : element_names) {
118  if (fDebug) std::cout << element_name << std::endl;
119 
120  hid_t dataset = H5Dopen(region_group, element_name.data(), H5P_DEFAULT);
121  hsize_t ds_size = H5Dget_storage_size(dataset);
122  if (fDebug) std::cout << "\tDataset size: " << ds_size << std::endl;
123 
124  std::vector<char> ds_data(ds_size);
125  H5Dread(dataset, H5T_STD_I8LE, H5S_ALL, H5S_ALL, H5P_DEFAULT,
126  ds_data.data());
127  H5Dclose(dataset);
128 
129  Fragment frag(&ds_data[0], Fragment::BufferAdoptionMode::kReadOnlyMode);
130  if (fDebug) {
131  std::cout << "\tMade fragment" << std::endl;
132  std::cout << "\t" << frag.get_header() << std::endl;
133  }
134 
135 
136  uint8_t * data_ptr = reinterpret_cast<uint8_t*>(frag.get_data());
137 
138  size_t iP = 0;
139  size_t data_pos = 0;
140  while (data_pos < (frag.get_header().size - sizeof(FragmentHeader))) {
141  EventHeader * event_header
142  = reinterpret_cast<EventHeader*>(data_ptr + data_pos);
143  if (fDebug) {
144  std::cout << "\tEvent header " << event_header->length << std::endl;
145  std::cout << "\t" << iP << std::endl;
146  }
147 
148  auto wf_hit = MakeWaveformAndHit(event_header, data_pos, data_ptr);
149  output_wfs->emplace_back(wf_hit.first);
150  output_hits->emplace_back(wf_hit.second);
151 
152  //Iterate position in the data
153  data_pos += event_header->length;
154  ++iP;
155  }
156  if (fDebug)
157  std::cout << "Iterated through " << iP << " packets " << std::endl;
158  }
159  H5Gclose(region_group);
160  }
161  H5Gclose(PDS_group);
162 
163  e.put(std::move(output_wfs), fOutputDataLabel);
164  e.put(std::move(output_hits), fOutputDataLabel);
165 }
Handle< PROD > getHandle(SelectorBase const &) const
Definition: DataViewImpl.h:382
std::string string
Definition: nybbler.cc:12
QCString file_name
std::list< std::string > getMidLevelGroupNames(hid_t grp)
std::void_t< T > n
def move(depos, offset)
Definition: depos.py:107
ProductID put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
Definition: DataViewImpl.h:686
std::pair< raw::OpDetWaveform, recob::OpHit > MakeWaveformAndHit(const dunedaq::detdataformats::ssp::EventHeader *event_header, size_t data_pos, uint8_t *data_ptr)
hid_t getGroupFromPath(HDFFileInfoPtr &hdfFileInfoPtr, const std::string &path)
QTextStream & endl(QTextStream &s)

Member Data Documentation

bool dune::VDColdboxPDSDecoder::fDebug
private

Definition at line 61 of file VDColdboxPDSDecoder_module.cc.

std::string dune::VDColdboxPDSDecoder::fFileInfoLabel
private

Definition at line 59 of file VDColdboxPDSDecoder_module.cc.

bool dune::VDColdboxPDSDecoder::fForceOpen
private

Definition at line 60 of file VDColdboxPDSDecoder_module.cc.

hid_t dune::VDColdboxPDSDecoder::fHDFFile = -1
private

Definition at line 57 of file VDColdboxPDSDecoder_module.cc.

std::string dune::VDColdboxPDSDecoder::fOutputDataLabel
private

Definition at line 58 of file VDColdboxPDSDecoder_module.cc.

hid_t dune::VDColdboxPDSDecoder::fPrevStoredHandle = -1
private

Definition at line 56 of file VDColdboxPDSDecoder_module.cc.


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