-
Notifications
You must be signed in to change notification settings - Fork 121
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #37214 from peterfpeterson/ewm3412_loadevent_accum…
…ulator LoadEventNexus with compression refactor - ornl-next
- Loading branch information
Showing
21 changed files
with
1,312 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
Framework/DataHandling/inc/MantidDataHandling/CompressEventAccumulator.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
// Mantid Repository : https://github.com/mantidproject/mantid | ||
// | ||
// Copyright © 2024 ISIS Rutherford Appleton Laboratory UKRI, | ||
// NScD Oak Ridge National Laboratory, European Spallation Source, | ||
// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS | ||
// SPDX - License - Identifier: GPL - 3.0 + | ||
#pragma once | ||
|
||
#include "MantidDataHandling/DllConfig.h" | ||
#include "MantidDataObjects/EventList.h" | ||
|
||
#include <vector> | ||
|
||
namespace Mantid { | ||
namespace DataHandling { | ||
|
||
enum class CompressBinningMode { LINEAR, LOGARITHMIC }; | ||
|
||
/** CompressEventAccumulator : TODO: DESCRIPTION | ||
*/ | ||
class MANTID_DATAHANDLING_DLL CompressEventAccumulator { | ||
public: | ||
// TODO parameter for expected number of events | ||
CompressEventAccumulator(std::shared_ptr<std::vector<double>> histogram_bin_edges, const double divisor, | ||
CompressBinningMode bin_mode); | ||
virtual ~CompressEventAccumulator() = default; // needed because this is an abstract base class | ||
|
||
virtual void addEvent(const float tof) = 0; | ||
virtual void createWeightedEvents(std::vector<Mantid::DataObjects::WeightedEventNoTime> *raw_events) const = 0; | ||
|
||
std::size_t numberHistBins() const; | ||
virtual double totalWeight() const = 0; | ||
virtual DataObjects::EventSortType getSortType() const = 0; | ||
|
||
protected: | ||
template <typename INT_TYPE> double getBinCenter(const INT_TYPE bin) const; | ||
boost::optional<size_t> findBin(const float tof) const; | ||
/// shared pointer for the histogram bin boundaries | ||
const std::shared_ptr<std::vector<double>> m_histogram_edges; | ||
|
||
private: | ||
/// keep track if the m_tof is already sorted | ||
// offset is applied after division | ||
// see EventList::findLinearBin for implementation on what that means | ||
double m_divisor; | ||
double m_offset; | ||
/// function pointer on how to find the bin boundaries | ||
boost::optional<size_t> (*m_findBin)(const MantidVec &, const double, const double, const double, const bool); | ||
|
||
protected: | ||
/// track whether this has allocated the "big" memory objects | ||
bool m_initialized; | ||
}; | ||
|
||
/** | ||
* @brief The CompressEventAccumulatorFactory Factory object that will create the correct type of | ||
* CompressEventAccumulator based on configuration information. | ||
*/ | ||
class MANTID_DATAHANDLING_DLL CompressEventAccumulatorFactory { | ||
public: | ||
CompressEventAccumulatorFactory(std::shared_ptr<std::vector<double>> histogram_bin_edges, const double divisor, | ||
CompressBinningMode bin_mode); | ||
std::unique_ptr<CompressEventAccumulator> create(const std::size_t num_events); | ||
|
||
private: | ||
double m_divisor; | ||
CompressBinningMode m_bin_mode; | ||
const std::shared_ptr<std::vector<double>> m_histogram_edges; | ||
}; | ||
|
||
} // namespace DataHandling | ||
} // namespace Mantid |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
94 changes: 94 additions & 0 deletions
94
Framework/DataHandling/inc/MantidDataHandling/ProcessBankCompressed.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
// Mantid Repository : https://github.com/mantidproject/mantid | ||
// | ||
// Copyright © 2024 ISIS Rutherford Appleton Laboratory UKRI, | ||
// NScD Oak Ridge National Laboratory, European Spallation Source, | ||
// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS | ||
// SPDX - License - Identifier: GPL - 3.0 + | ||
#pragma once | ||
|
||
#include "MantidDataHandling/BankPulseTimes.h" | ||
#include "MantidDataHandling/CompressEventAccumulator.h" | ||
#include "MantidDataHandling/DllConfig.h" | ||
#include "MantidDataObjects/EventList.h" | ||
#include "MantidKernel/Task.h" | ||
|
||
#include <vector> | ||
|
||
namespace Mantid { | ||
namespace API { | ||
class Progress; // forward declare | ||
} | ||
namespace DataHandling { | ||
class DefaultEventLoader; // forward declare | ||
class CompressEventAccumulatorFactory; | ||
|
||
/** ProcessBankCompressed : TODO: DESCRIPTION | ||
*/ | ||
class MANTID_DATAHANDLING_DLL ProcessBankCompressed : public Mantid::Kernel::Task { | ||
public: | ||
ProcessBankCompressed(DefaultEventLoader &m_loader, const std::string &entry_name, Mantid::API::Progress *prog, | ||
std::shared_ptr<std::vector<uint32_t>> event_detid, | ||
std::shared_ptr<std::vector<float>> event_tof, size_t startAt, | ||
std::shared_ptr<std::vector<uint64_t>> event_index, | ||
std::shared_ptr<BankPulseTimes> bankPulseTimes, detid_t min_detid, detid_t max_detid, | ||
std::shared_ptr<std::vector<double>> histogram_bin_edges, const double divisor); | ||
|
||
void run() override; | ||
|
||
void addEvent(const size_t period_index, const size_t event_index); | ||
|
||
void createWeightedEvents(const size_t period_index, const detid_t detid, | ||
std::vector<Mantid::DataObjects::WeightedEventNoTime> *raw_events); | ||
|
||
/// method only intended for testing | ||
double totalWeight() const; | ||
|
||
private: | ||
void createAccumulators(const bool precount); | ||
void collectEvents(); | ||
void addToEventLists(); | ||
|
||
// disable default constructor | ||
ProcessBankCompressed(); | ||
/// Algorithm being run | ||
DefaultEventLoader &m_loader; | ||
const std::string m_entry_name; | ||
/// Progress reporting | ||
API::Progress *m_prog; | ||
|
||
/// factory for creating accumulators | ||
std::unique_ptr<CompressEventAccumulatorFactory> m_factory; | ||
|
||
/// event pixel ID array | ||
std::shared_ptr<std::vector<uint32_t>> m_event_detid; | ||
/// event TOF array | ||
std::shared_ptr<std::vector<float>> m_event_tof; | ||
/// index of the first event from event_index | ||
const size_t m_firstEventIndex; | ||
/// vector of event index (length of # of pulses) | ||
std::shared_ptr<std::vector<uint64_t>> m_event_index; | ||
/// Pulse times for this bank | ||
std::shared_ptr<BankPulseTimes> m_bankPulseTimes; | ||
|
||
/** | ||
* Objects holding individual spectra. This is accessed as [periodIndex][detidIndex] | ||
*/ | ||
std::vector<std::vector<std::unique_ptr<DataHandling::CompressEventAccumulator>>> m_spectra_accum; | ||
|
||
/* | ||
* After events are added, this will contain the sorting information to set out the output event lists | ||
*/ | ||
std::vector<DataObjects::EventSortType> m_sorting; | ||
|
||
// inclusive | ||
const detid_t m_detid_min; | ||
// inclusive | ||
const detid_t m_detid_max; | ||
// inclusive | ||
const float m_tof_min; | ||
// exclusive | ||
const float m_tof_max; | ||
}; | ||
|
||
} // namespace DataHandling | ||
} // namespace Mantid |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.