25 #include "daqdataformats/Fragment.hpp" 26 #include "detdataformats/ssp/SSPTypes.hpp" 31 class VDColdboxPDSDecoder;
53 const dunedaq::detdataformats::ssp::EventHeader * event_header,
54 size_t data_pos, uint8_t * data_ptr);
73 fDebug(
p.get<
bool>(
"Debug",
false)) {
81 using namespace dunedaq::detdataformats::ssp;
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>>();
91 const std::string & group_name = infoHandle->GetEventGroupName();
93 hid_t file_id = infoHandle->GetHDF5FileHandle();
101 fHDFFile = H5Fopen(file_name.data(), H5F_ACC_RDONLY, H5P_DEFAULT);
111 std::cout <<
"Got " << region_names.size() <<
" regions" <<
std::endl;
112 for (
const auto &
n : region_names) {
116 std::cout <<
"Got " << element_names.size() <<
" elements" <<
std::endl;
117 for (
const auto & element_name : element_names) {
120 hid_t dataset = H5Dopen(region_group, element_name.data(), H5P_DEFAULT);
121 hsize_t ds_size = H5Dget_storage_size(dataset);
124 std::vector<char> ds_data(ds_size);
125 H5Dread(dataset, H5T_STD_I8LE, H5S_ALL, H5S_ALL, H5P_DEFAULT,
129 Fragment frag(&ds_data[0], Fragment::BufferAdoptionMode::kReadOnlyMode);
131 std::cout <<
"\tMade fragment" <<
std::endl;
132 std::cout <<
"\t" << frag.get_header() <<
std::endl;
136 uint8_t * data_ptr =
reinterpret_cast<uint8_t*
>(frag.get_data());
140 while (data_pos < (frag.get_header().size -
sizeof(FragmentHeader))) {
141 EventHeader * event_header
142 =
reinterpret_cast<EventHeader*
>(data_ptr + data_pos);
144 std::cout <<
"\tEvent header " << event_header->length <<
std::endl;
149 output_wfs->emplace_back(wf_hit.first);
150 output_hits->emplace_back(wf_hit.second);
153 data_pos += event_header->length;
157 std::cout <<
"Iterated through " << iP <<
" packets " <<
std::endl;
159 H5Gclose(region_group);
167 std::pair<raw::OpDetWaveform, recob::OpHit>
169 const dunedaq::detdataformats::ssp::EventHeader * event_header,
170 size_t data_pos, uint8_t * data_ptr) {
172 using namespace dunedaq::detdataformats::ssp;
173 size_t nADC = (event_header->length -
sizeof(EventHeader))/2;
175 unsigned long ts = 0;
176 for (
unsigned int iword = 0; iword <= 3; ++iword) {
177 ts += ((
unsigned long)(event_header->timestamp[iword])) << 16 * iword;
184 unsigned short * adc_ptr =
reinterpret_cast<unsigned short *
>(
185 data_ptr + data_pos +
sizeof(EventHeader));
190 for (
size_t i = 0; i < nADC; ++i) {
191 wf.push_back(*(adc_ptr + i));
Handle< PROD > getHandle(SelectorBase const &) const
std::string fFileInfoLabel
EDProducer(fhicl::ParameterSet const &pset)
VDColdboxPDSDecoder & operator=(VDColdboxPDSDecoder const &)=delete
std::list< std::string > getMidLevelGroupNames(hid_t grp)
#define DEFINE_ART_MODULE(klass)
ProductID put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
std::pair< raw::OpDetWaveform, recob::OpHit > MakeWaveformAndHit(const dunedaq::detdataformats::ssp::EventHeader *event_header, size_t data_pos, uint8_t *data_ptr)
void produce(art::Event &e) override
hid_t getGroupFromPath(HDFFileInfoPtr &hdfFileInfoPtr, const std::string &path)
QTextStream & endl(QTextStream &s)
std::string fOutputDataLabel
VDColdboxPDSDecoder(fhicl::ParameterSet const &p)