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 <vector>
13
14namespace Mantid {
15namespace DataHandling {
16
18
21class MANTID_DATAHANDLING_DLL CompressEventAccumulator {
22public:
23 // TODO parameter for expected number of events
24 CompressEventAccumulator(std::shared_ptr<std::vector<double>> histogram_bin_edges, const double divisor,
25 CompressBinningMode bin_mode);
26 virtual ~CompressEventAccumulator() = default; // needed because this is an abstract base class
27
28 virtual void addEvent(const float tof) = 0;
29 virtual void createWeightedEvents(std::vector<Mantid::DataObjects::WeightedEventNoTime> *raw_events) const = 0;
30
31 std::size_t numberHistBins() const;
32 virtual double totalWeight() const = 0;
34
35protected:
36 template <typename INT_TYPE> double getBinCenter(const INT_TYPE bin) const;
37 std::optional<size_t> findBin(const float tof) const;
39 const std::shared_ptr<std::vector<double>> m_histogram_edges;
40
41private:
43 // offset is applied after division
44 // see EventList::findLinearBin for implementation on what that means
45 double m_divisor;
46 double m_offset;
48 std::optional<size_t> (*m_findBin)(const MantidVec &, const double, const double, const double, const bool);
49
50protected:
53};
54
59class MANTID_DATAHANDLING_DLL CompressEventAccumulatorFactory {
60public:
61 CompressEventAccumulatorFactory(std::shared_ptr<std::vector<double>> histogram_bin_edges, const double divisor,
62 CompressBinningMode bin_mode);
63 std::unique_ptr<CompressEventAccumulator> create(const std::size_t num_events);
64
65private:
66 double m_divisor;
68 const std::shared_ptr<std::vector<double>> m_histogram_edges;
69};
70
71} // namespace DataHandling
72} // 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:32
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.
std::vector< double > MantidVec
typedef for the data storage used in Mantid matrix workspaces
Definition cow_ptr.h:172