10#include "MantidIndexing/IndexInfo.h"
11#include "MantidParallel/IO/EventLoader.h"
12#include "MantidTypes/Event/TofEvent.h"
13#include "MantidTypes/SpectrumDefinition.h"
19 const std::string &groupName,
const std::vector<std::string> &bankNames) {
23 const auto &idToBank = Parallel::IO::EventLoader::makeAnyEventIdToBankMap(filename, groupName, bankNames);
27 int32_t spectrumIndex{0};
28 std::vector<int32_t>
bankOffsets(bankNames.size(), 0);
29 for (
size_t i = 0; i < detInfo.size(); ++i) {
32 if (!detInfo.isMonitor(i)) {
39 if (idToBank.count(detId) == 1) {
40 size_t bank = idToBank.at(detId);
52 const std::string &groupName,
53 const std::vector<std::string> &bankNames) {
57 const auto &idToBank = Parallel::IO::EventLoader::makeAnyEventIdToBankMap(filename, groupName, bankNames);
60 const auto &specNums = ws.
indexInfo().spectrumNumbers();
61 int32_t spectrumIndex{0};
62 std::vector<int32_t> offsets(bankNames.size(), 0);
63 for (
auto i : specNums) {
69 if (idToBank.count(specNum) == 1) {
70 size_t bank = idToBank.at(specNum);
71 offsets[bank] = specNum - spectrumIndex;
81 std::vector<std::vector<Types::Event::TofEvent> *> eventLists(size,
nullptr);
82 for (
size_t i = 0; i < size; ++i)
88 const std::string &groupName,
const std::vector<std::string> &bankNames,
89 const bool eventIDIsSpectrumNumber) {
97 const std::string &groupName,
const std::vector<std::string> &bankNames,
98 const bool eventIDIsSpectrumNumber) {
99 std::vector<std::vector<Types::Event::TofEvent> *> eventLists =
getResultVector(ws);
100 std::vector<int32_t> offsets =
getOffsets(ws, filename, groupName, bankNames, eventIDIsSpectrumNumber);
101 Parallel::IO::EventLoader::load(ws.
indexInfo().communicator(), filename, groupName, bankNames, offsets, eventLists);
107 const std::string &groupName,
const std::vector<std::string> &bankNames,
108 const bool eventIDIsSpectrumNumber,
const bool precalcEvents) {
110 std::vector<int32_t> offsets =
getOffsets(ws, filename, groupName, bankNames, eventIDIsSpectrumNumber);
111 Parallel::IO::EventLoader::load(filename, groupName, bankNames, offsets, eventLists, precalcEvents);
This class is shared by a few Workspace types and holds information related to a particular experimen...
const Geometry::DetectorInfo & detectorInfo() const
Return a const reference to the DetectorInfo object.
Base MatrixWorkspace Abstract Class.
const Indexing::IndexInfo & indexInfo() const
Returns a const reference to the IndexInfo object of the workspace.
static void loadMPI(DataObjects::EventWorkspace &ws, const std::string &filename, const std::string &groupName, const std::vector< std::string > &bankNames, const bool eventIDIsSpectrumNumber)
Load events from given banks into given EventWorkspace using MPI.
static void loadMultiProcess(DataObjects::EventWorkspace &ws, const std::string &filename, const std::string &groupName, const std::vector< std::string > &bankNames, const bool eventIDIsSpectrumNumber, const bool precalcEvents)
Load events from given banks into given EventWorkspace using boost::interprocess.
This class is intended to fulfill the design specified in <https://github.com/mantidproject/documents...
EventList & getSpectrum(const size_t index) override
Return the underlying ISpectrum ptr at the given workspace index.
std::size_t getNumberHistograms() const override
Get the number of histograms, usually the same as the number of pixels or detectors.
const std::vector< detid_t > & detectorIDs() const
Returns a sorted vector of all detector IDs.
std::vector< int32_t > bankOffsets(const API::ExperimentInfo &ws, const std::string &filename, const std::string &groupName, const std::vector< std::string > &bankNames)
Return offset between global spectrum index and detector ID for given banks.
std::vector< std::vector< Types::Event::TofEvent > * > getResultVector(DataObjects::EventWorkspace &ws)
std::vector< int32_t > getOffsets(const DataObjects::EventWorkspace &ws, const std::string &filename, const std::string &groupName, const std::vector< std::string > &bankNames, const bool eventIDIsSpectrumNumber)
std::vector< int32_t > bankOffsetsSpectrumNumbers(const API::MatrixWorkspace &ws, const std::string &filename, const std::string &groupName, const std::vector< std::string > &bankNames)
Return offset between global spectrum index and spectrum number for given banks.
DLLExport void getEventsFrom(EventList &el, std::vector< Types::Event::TofEvent > *&events)
int32_t detid_t
Typedef for a detector ID.
int32_t specnum_t
Typedef for a spectrum Number.