28 const size_t grainsize_event, std::shared_ptr<API::Progress> &progress)
29 :
ProcessBankTaskBase(bankEntryNames, loader, calibFactory), m_h5file(h5file), m_processingData(processingData),
30 m_events_per_chunk(events_per_chunk), m_grainsize_event(grainsize_event), m_progress(progress) {}
33 auto entry =
m_h5file.openGroup(
"entry");
34 for (
size_t bank_index = range.begin(); bank_index < range.end(); ++bank_index) {
45 auto event_group = entry.openGroup(
bankName);
49 const int64_t total_events =
static_cast<size_t>(tof_SDS.getSpace().getSelectNpoints());
50 if (total_events == 0) {
68 auto event_detid = std::make_unique<std::vector<uint32_t>>();
69 auto event_time_of_flight = std::make_unique<std::vector<float>>();
72 while (!eventRanges.empty()) {
76 std::vector<size_t> offsets;
77 std::vector<size_t> slabsizes;
79 size_t total_events_to_read = 0;
83 auto eventRange = eventRanges.top();
86 size_t range_size = eventRange.second - eventRange.first;
90 if (range_size > remaining_chunk) {
92 offsets.push_back(eventRange.first);
93 slabsizes.push_back(remaining_chunk);
94 total_events_to_read += remaining_chunk;
96 eventRanges.emplace(eventRange.first + remaining_chunk, eventRange.second);
99 offsets.push_back(eventRange.first);
100 slabsizes.push_back(range_size);
101 total_events_to_read += range_size;
109 if (total_events_to_read == 0) {
114 this->
loadEvents(detID_SDS, tof_SDS, offsets, slabsizes, event_detid, event_time_of_flight);
119 [&](
const tbb::blocked_range<size_t> &output_range) {
120 for (size_t output_index = output_range.begin(); output_index < output_range.end(); ++output_index) {
122 ProcessEventsTask task(event_detid.get(), event_time_of_flight.get(), &calibrations.at(output_index),
123 m_processingData.binedges[output_index]);
125 const tbb::blocked_range<size_t> range_info(0, event_time_of_flight->size(), m_grainsize_event);
126 tbb::parallel_reduce(range_info, task);
130 for (size_t i = 0; i < m_processingData.counts[output_index].size(); ++i) {
131 m_processingData.counts[output_index][i].fetch_add(task.y_temp[i], std::memory_order_relaxed);
void loadEvents(H5::DataSet &detID_SDS, H5::DataSet &tof_SDS, const std::vector< size_t > &offsets, const std::vector< size_t > &slabsizes, std::unique_ptr< std::vector< uint32_t > > &detId_vec, std::unique_ptr< std::vector< float > > &tof_vec) const
Load detid and tof at the same time.
ProcessBankTask(std::vector< std::string > &bankEntryNames, H5::H5File &h5file, std::shared_ptr< NexusLoader > loader, SpectraProcessingData &processingData, const BankCalibrationFactory &calibFactory, const size_t events_per_chunk, const size_t grainsize_event, std::shared_ptr< API::Progress > &progress)