19 bool event_id_is_spec, std::vector<std::string> bankNames,
20 const std::vector<int> &periodLog,
const std::string &classType,
21 std::vector<std::size_t> bankNumEvents,
const bool oldNeXusFileNames,
const bool precount,
22 const int chunk,
const int totalChunks) {
25 auto bankRange = loader.
setupChunking(bankNames, bankNumEvents);
30 auto diskIOMutex = std::make_shared<std::mutex>();
33 size_t numProg = bankNames.size() * (1 + 3);
35 numProg += bankNames.size() * 3;
36 auto prog = std::make_unique<API::Progress>(loader.
alg, 0.3, 1.0, numProg);
38 for (
size_t i = bankRange.first; i < bankRange.second; i++) {
39 if (bankNumEvents[i] > 0)
40 pool.
schedule(std::make_shared<LoadBankFromDiskTask>(loader, bankNames[i], classType, bankNumEvents[i],
41 oldNeXusFileNames, prog.get(), diskIOMutex, *scheduler,
50 bool event_id_is_spec,
const size_t numBanks,
const bool precount,
51 const int chunk,
const int totalChunks)
52 : m_haveWeights(haveWeights), event_id_is_spec(event_id_is_spec), precount(precount), chunk(chunk),
53 totalChunks(totalChunks), firstChunkForBank(1), eventsPerChunk(0), alg(alg), m_ws(ws) {
77 std::vector<std::size_t> &bankNumEvents) {
79 size_t bankn = bankNames.size();
82 const size_t total_events = std::accumulate(bankNumEvents.cbegin(), bankNumEvents.cend(),
static_cast<size_t>(0));
87 for (
size_t i = 0; i < bankn; i++)
88 for (
size_t j = 0; j < bankn - 1; j++)
89 if (bankNumEvents[j] < bankNumEvents[j + 1]) {
90 tmp = bankNumEvents[j];
91 bankNumEvents[j] = bankNumEvents[j + 1];
92 bankNumEvents[j + 1] =
tmp;
94 bankNames[j] = bankNames[j + 1];
95 bankNames[j + 1] = stmp;
98 for (
size_t i = 0; i < bankn; i++)
105 static_cast<size_t>((
static_cast<double>(bigBanks) /
static_cast<double>(
totalChunks) * 0.5 + 0.05) *
107 double partialChunk = 0.;
109 for (
int chunki = 1; chunki <=
chunk; chunki++) {
110 if (partialChunk > 1.) {
115 if (bankNumEvents[bank0] > 1) {
116 partialChunk +=
static_cast<double>(
eventsPerChunk) /
static_cast<double>(bankNumEvents[bank0]);
121 bankn = bankNames.size();
123 bankn +=
static_cast<size_t>(partialChunk) - 1;
124 if (bankn > bankNames.size())
125 bankn = bankNames.size();
127 for (
size_t i = bank0; i < bankn; i++) {
129 size_t stop_event = bankNumEvents[i];
133 bankNumEvents[i] = stop_event - start_event;
136 return {bank0, bankn};
Helper class for LoadEventNexus that is specific to the current default loading code for NXevent_data...
std::vector< std::vector< std::vector< Mantid::Types::Event::TofEvent > * > > eventVectors
Vector where index = event_id; value = ptr to std::vector<TofEvent> in the event list.
static void load(LoadEventNexus *alg, EventWorkspaceCollection &ws, bool haveWeights, bool event_id_is_spec, std::vector< std::string > bankNames, const std::vector< int > &periodLog, const std::string &classType, std::vector< std::size_t > bankNumEvents, const bool oldNeXusFileNames, const bool precount, const int chunk, const int totalChunks)
int totalChunks
number of chunks
bool precount
Do we pre-count the # of events in each pixel ID?
std::vector< size_t > pixelID_to_wi_vector
Vector where (index = pixel ID+pixelID_to_wi_offset), value = workspace index)
std::vector< std::vector< std::vector< Mantid::DataObjects::WeightedEvent > * > > weightedEventVectors
Vector where index = event_id; value = ptr to std::vector<WeightedEvent> in the event list.
detid_t pixelID_to_wi_offset
Offset in the pixelID_to_wi_vector to use.
bool splitProcessing
whether or not to launch multiple ProcessBankData jobs per bank
DefaultEventLoader(LoadEventNexus *alg, EventWorkspaceCollection &ws, bool haveWeights, bool event_id_is_spec, const size_t numBanks, const bool precount, const int chunk, const int totalChunks)
size_t eventsPerChunk
number of chunks per bank
bool event_id_is_spec
True if the event_id is spectrum no not pixel ID.
std::pair< size_t, size_t > setupChunking(std::vector< std::string > &bankNames, std::vector< std::size_t > &bankNumEvents)
int firstChunkForBank
for multiple chunks per bank
EventWorkspaceCollection & m_ws
void makeMapToEventLists(std::vector< std::vector< T > > &vectors)
Map detector IDs to event lists.
EventWorkspaceCollection : Collection of EventWorspaces to give backward-forward compatibility around...
std::vector< size_t > getDetectorIDToWorkspaceIndexVector(Mantid::specnum_t &offset, bool dothrow) const
const DataObjects::EventList & getSpectrum(const size_t workspace_index, const size_t periodNumber) const
size_t getNumberHistograms() const
std::vector< size_t > getSpectrumToWorkspaceIndexVector(Mantid::specnum_t &offset) const
void switchTo(Mantid::API::EventType newType) override
Switch the EventList to use the given EventType (TOF, WEIGHTED, or WEIGHTED_NOTIME)
A Thread Pool implementation that keeps a certain number of threads running (normally,...
void schedule(const std::shared_ptr< Task > &task, bool start=false)
Schedule a task for later execution.
void joinAll()
Wait for all threads that have started to finish.
static size_t getNumPhysicalCores()
Return the number of physical cores available on the system.
ThreadSchedulerMutexes : Version of a ThreadSchedulerLargestCost that also makes sure to not try to s...
constexpr int EMPTY_INT() noexcept
Returns what we consider an "empty" integer within a property.