Mantid
Loading...
Searching...
No Matches
CompressEventAccumulator.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2024 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
7#pragma once
8
9#include "MantidDataHandling/DllConfig.h"
11
12#include <span>
13#include <vector>
14
15namespace Mantid {
16namespace DataHandling {
17
19
22class MANTID_DATAHANDLING_DLL CompressEventAccumulator {
23public:
24 // TODO parameter for expected number of events
25 CompressEventAccumulator(std::shared_ptr<std::vector<double>> histogram_bin_edges, const double divisor,
26 CompressBinningMode bin_mode);
27 virtual ~CompressEventAccumulator() = default; // needed because this is an abstract base class
28
29 virtual void addEvent(const float tof) = 0;
30 virtual void createWeightedEvents(std::vector<Mantid::DataObjects::WeightedEventNoTime> *raw_events) const = 0;
31
32 std::size_t numberHistBins() const;
33 virtual double totalWeight() const = 0;
35
36protected:
37 template <typename INT_TYPE> double getBinCenter(const INT_TYPE bin) const;
38 std::optional<size_t> findBin(const float tof) const;
40 const std::shared_ptr<std::vector<double>> m_histogram_edges;
41
42private:
44 // offset is applied after division
45 // see EventList::findLinearBin for implementation on what that means
46 double m_divisor;
47 double m_offset;
49 std::optional<size_t> (*m_findBin)(std::span<double const>, const double, const double, const double, const bool);
50
51protected:
54};
55
60class MANTID_DATAHANDLING_DLL CompressEventAccumulatorFactory {
61public:
62 CompressEventAccumulatorFactory(std::shared_ptr<std::vector<double>> histogram_bin_edges, const double divisor,
63 CompressBinningMode bin_mode);
64 std::unique_ptr<CompressEventAccumulator> create(const std::size_t num_events);
65
66private:
67 double m_divisor;
69 const std::shared_ptr<std::vector<double>> m_histogram_edges;
70};
71
72} // namespace DataHandling
73} // namespace Mantid
The CompressEventAccumulatorFactory Factory object that will create the correct type of CompressEvent...
const std::shared_ptr< std::vector< double > > m_histogram_edges
CompressEventAccumulator : TODO: DESCRIPTION.
virtual void createWeightedEvents(std::vector< Mantid::DataObjects::WeightedEventNoTime > *raw_events) const =0
virtual DataObjects::EventSortType getSortType() const =0
virtual void addEvent(const float tof)=0
bool m_initialized
track whether this has allocated the "big" memory objects
const std::shared_ptr< std::vector< double > > m_histogram_edges
shared pointer for the histogram bin boundaries
double m_divisor
keep track if the m_tof is already sorted
EventSortType
How the event list is sorted.
Definition EventList.h:33
std::unique_ptr< T > create(const P &parent, const IndexArg &indexArg, const HistArg &histArg)
This is the create() method that all the other create() methods call.
Helper class which provides the Collimation Length for SANS instruments.