18 #include "detdataformats/wib/WIBFrame.hpp" 30 std::cout <<
"Got infos? " << infoHandle <<
std::endl;
32 const std::string & toplevel_groupname = infoHandle->GetEventGroupName();
34 hid_t file_id = infoHandle->GetHDF5FileHandle();
36 std::cout <<
"Top-Level Group Name: " << toplevel_groupname <<
std::endl;
37 std::cout <<
"HDF5 FileName: " << file_name <<
std::endl;
44 for (
auto& detectorTypeName : detectorTypeNames)
46 if (detectorTypeName ==
"TPC" && detectorTypeName !=
"TriggerRecordHeader")
48 std::cout <<
" Detector type: " << detectorTypeName <<
std::endl;
49 std::string geoPath = toplevel_groupname +
"/" + detectorTypeName;
54 for (
auto& apaName : apaNames)
57 std::cout <<
" Geo path: " << apaGroupPath <<
std::endl;
62 for (
auto& linkName : linkNames)
64 std::string dataSetPath = apaGroupPath +
"/" + linkName;
65 std::cout <<
" Data Set Path: " << dataSetPath <<
std::endl;
66 hid_t datasetid = H5Dopen(linkGroup,linkName.data(),H5P_DEFAULT);
67 hsize_t ds_size = H5Dget_storage_size(datasetid);
68 std::cout <<
" Data Set Size (bytes): " << ds_size <<
std::endl;
70 if (ds_size < 80)
continue;
72 size_t narray = ds_size /
sizeof(char);
73 size_t rdr = ds_size %
sizeof(char);
74 if (rdr > 0 || narray == 0) narray++;
75 char *ds_data =
new char[narray];
76 herr_t ecode = H5Dread(datasetid, H5T_STD_I8LE, H5S_ALL, H5S_ALL, H5P_DEFAULT, ds_data);
77 int firstbyte = ds_data[0];
79 int lastbyte = ds_data[narray-1];
82 std::cout <<
std::hex <<
" Retrieved data: ecode: " << ecode <<
" first byte: " << firstbyte
87 memcpy(&magic_word,&ds_data[0],4);
91 memcpy(&version, &ds_data[4],4);
95 memcpy(&fragsize, &ds_data[8],8);
99 memcpy(&trignum, &ds_data[16],8);
102 uint64_t trig_timestamp=0;
103 memcpy(&trig_timestamp, &ds_data[24],8);
106 uint64_t windowbeg=0;
107 memcpy(&windowbeg, &ds_data[32],8);
110 uint64_t windowend=0;
111 memcpy(&windowend, &ds_data[40],8);
115 memcpy(&runno, &ds_data[48], 4);
119 memcpy(&errbits, &ds_data[52], 4);
123 memcpy(&fragtype, &ds_data[56], 4);
127 memcpy(&fragtype, &ds_data[60], 4);
131 memcpy(&geoidversion, &ds_data[64], 4);
134 unsigned short geoidtype;
135 memcpy(&geoidtype, &ds_data[70], 1);
136 std::cout <<
" GeoID type: " << geoidtype <<
std::endl;
138 unsigned short geoidregion=0;
139 memcpy(&geoidregion, &ds_data[71], 1);
143 memcpy(&geoidelement, &ds_data[72], 4);
147 memcpy(&geoidpadding, &ds_data[76], 4);
161 : fForceOpen(p.
get<
bool>(
"ForceOpen", false)),
162 fFileInfoLabel(p.
get<
std::
string>(
"FileInfoLabel",
"daq")),
163 fMaxChan(p.
get<
int>(
"MaxChan",1000000)) {
169 std::vector<raw::RawDigit> &raw_digits,
170 std::vector<raw::RDTimeStamp> &rd_timestamps,
171 std::vector<raw::RDStatus> &rdstatuses) {
177 std::vector<raw::RawDigit> &raw_digits,
178 std::vector<raw::RDTimeStamp> &rd_timestamps,
179 std::vector<raw::RDStatus> &rdstatuses,
180 std::vector<int> &apalist)
184 const std::string & toplevel_groupname = infoHandle->GetEventGroupName();
186 hid_t file_id = infoHandle->GetHDF5FileHandle();
188 std::cout <<
"HDF5 FileName: " << file_name <<
std::endl;
189 std::cout <<
"Top-Level Group Name: " << toplevel_groupname <<
std::endl;
198 fHDFFile = H5Fopen(file_name.data(), H5F_ACC_RDONLY, H5P_DEFAULT);
208 std::cout <<
"Retrieving Data for " << apalist.size() <<
" APA " <<
std::endl;
213 for (
const int & i : apalist)
216 std::cout <<
"apano: " << i <<
std::endl;
222 rdstatuses.emplace_back(
false,
false, 0);
233 std::vector<raw::RawDigit> &raw_digits,
234 std::vector<raw::RDTimeStamp> &rd_timestamps,
235 std::vector<raw::RDStatus> &rdstatuses,
236 std::vector<int> &apalist) {
245 int apano,
int maxchan) {
248 using dunedaq::detdataformats::wib::WIBFrame;
249 using dunedaq::detdataformats::wib::WIBHeader;
253 std::deque<std::string> det_types
256 for (
const auto & det : det_types)
258 if (det !=
"TPC")
continue;
261 std::deque<std::string> apaNames
264 std::cout <<
"Size of apaNames: " << apaNames.size() <<
std::endl;
265 std::cout <<
"apaNames[apano]: " << apaNames[apano-1] <<
std::endl;
269 std::deque<std::string> linkNames
271 for (
const auto &
t : linkNames)
273 hid_t dataset = H5Dopen(linkGroup,
t.data(), H5P_DEFAULT);
274 hsize_t ds_size = H5Dget_storage_size(dataset);
275 if (ds_size <=
sizeof(FragmentHeader))
continue;
277 std::vector<char> ds_data(ds_size);
278 H5Dread(dataset, H5T_STD_I8LE, H5S_ALL, H5S_ALL, H5P_DEFAULT,
283 Fragment frag(&ds_data[0], Fragment::BufferAdoptionMode::kReadOnlyMode);
284 size_t n_frames = (ds_size -
sizeof(FragmentHeader))/
sizeof(WIBFrame);
285 std::vector<raw::RawDigit::ADCvector_t> adc_vectors(256);
286 uint32_t slot = 0, fiber = 0;
287 for (
size_t i = 0; i < n_frames; ++i)
289 auto frame =
reinterpret_cast<WIBFrame*
>(
static_cast<uint8_t*
>(frag.get_data()) + i*
sizeof(WIBFrame));
290 for (
size_t j = 0; j < adc_vectors.size(); ++j)
292 adc_vectors[j].push_back(frame->get_channel(j));
297 slot = frame->get_wib_header()->slot_no;
298 fiber = frame->get_wib_header()->fiber_no;
302 for (
size_t iChan = 0; iChan < 256; ++iChan)
308 if (offline_chan < 0)
continue;
309 if (offline_chan > maxchan)
continue;
311 timestamps.push_back(rd_ts);
313 float median = 0., sigma = 0.;
317 raw_digits.push_back(rd);
330 size_t asiz = v_adc.size();
339 imed = TMath::Median(asiz,v_adc.data()) + 0.01;
341 sigma = TMath::RMS(asiz,v_adc.data());
347 for (
size_t i = 0; i < asiz; ++i) {
348 if (v_adc.at(i) < imed) s1++;
349 if (v_adc.at(i) == imed) sm++;
352 float mcorr = (-0.5 + (0.5*(
float) asiz - (
float) s1)/ ((
float) sm) );
Collection of charge vs time digitized from a single readout channel.
int retrieveDataAPAListWithLabels(art::Event &evt, std::string inputlabel, std::vector< raw::RawDigit > &raw_digits, std::vector< raw::RDTimeStamp > &rd_timestamps, std::vector< raw::RDStatus > &rdstatuses, std::vector< int > &apalist)
Handle< PROD > getHandle(SelectorBase const &) const
int retrieveData(art::Event &evt, std::string inputlabel, std::vector< raw::RawDigit > &raw_digits, std::vector< raw::RDTimeStamp > &rd_timestamps, std::vector< raw::RDStatus > &rdstatuses)
std::vector< short > ADCvector_t
Type representing a (compressed) vector of ADC counts.
std::vector< raw::RawDigit > RawDigits
std::deque< std::string > getMidLevelGroupNames(hid_t grp)
std::string fFileInfoLabel
QTextStream & hex(QTextStream &s)
int retrieveDataForSpecifiedAPAs(art::Event &evt, std::vector< raw::RawDigit > &raw_digits, std::vector< raw::RDTimeStamp > &rd_timestamps, std::vector< raw::RDStatus > &rdstatuses, std::vector< int > &apalist)
std::vector< raw::RDTimeStamp > RDTimeStamps
std::list< std::string > getMidLevelGroupNames(hid_t grp)
VDColdboxDataInterface(fhicl::ParameterSet const &ps)
void getFragmentsForEvent(hid_t the_group, RawDigits &raw_digits, RDTimeStamps ×tamps, int apano, int maxchan)
QTextStream & dec(QTextStream &s)
void getMedianSigma(const raw::RawDigit::ADCvector_t &v_adc, float &median, float &sigma)
hid_t getGroupFromPath(hid_t fd, const std::string &path)
void SetPedestal(float ped, float sigma=1.)
Set pedestal and its RMS (the latter is 0 by default)
int getOfflChanFromSlotFiberChan(int slot, int fiber, int chan)
auto const & get(AssnsNode< L, R, D > const &r)
hid_t getGroupFromPath(HDFFileInfoPtr &hdfFileInfoPtr, const std::string &path)
double median(sqlite3 *db, std::string const &table_name, std::string const &column_name)
QTextStream & endl(QTextStream &s)