Mantid
Loading...
Searching...
No Matches
TimeSplitter.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2012 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
10#include "MantidDataObjects/DllConfig.h"
14
15#include <set>
16
17namespace Mantid {
18
19using Types::Core::DateAndTime;
20
21namespace Kernel {
22class TimeROI; // Forward declaration
23}
24
25namespace DataObjects {
26
27class EventList; // Forward declaration
28
29class MANTID_DATAOBJECTS_DLL TimeSplitter {
30
31public:
32 static constexpr int NO_TARGET{-1}; // no target (a.k.a. destination) workspace for filtered out events
33 TimeSplitter() = default;
34 TimeSplitter(const TimeSplitter &other);
35 TimeSplitter &operator=(const TimeSplitter &other);
36
37 TimeSplitter(const DateAndTime &start, const DateAndTime &stop, const int value = DEFAULT_TARGET);
38 TimeSplitter(const Mantid::API::MatrixWorkspace_sptr &ws, const DateAndTime &offset = DateAndTime::GPS_EPOCH);
39 TimeSplitter(const TableWorkspace_sptr &tws, const DateAndTime &offset = DateAndTime::GPS_EPOCH);
41
42 const std::map<DateAndTime, int> &getSplittersMap() const;
43 std::string getWorkspaceIndexName(const int workspaceIndex, const int numericalShift = 0) const;
45 int valueAtTime(const DateAndTime &time) const;
46 void addROI(const DateAndTime &start, const DateAndTime &stop, const int value);
48 bool empty() const;
49 std::set<int> outputWorkspaceIndices() const;
50 const Kernel::TimeROI &getTimeROI(const int workspaceIndex) const;
51 const Kernel::SplittingIntervalVec &getSplittingIntervals(const bool includeNoTarget = true) const;
52
54 std::size_t numRawValues() const;
55 const std::map<std::string, int> &getNameTargetMap() const;
56 const std::map<int, std::string> &getTargetNameMap() const;
57
59 void splitEventList(const EventList &events, std::map<int, EventList *> &partials, const bool pulseTof = false,
60 const bool tofCorrect = false, const double factor = 1.0, const double shift = 0.0) const;
62 std::vector<std::pair<int, std::pair<size_t, size_t>>>
63 calculate_target_indices(const std::vector<DateAndTime> &times) const;
64 // Return a TimeROI that covers all the time intervals for all targets
65 const Kernel::TimeROI combinedTimeROI(const int64_t start_offset = 0) const;
66
68 std::string debugPrint() const;
69
70private:
71 static constexpr int DEFAULT_TARGET{0};
72 void clearAndReplace(const DateAndTime &start, const DateAndTime &stop, const int value);
74 template <typename EventType>
75 void splitEventVec(const std::vector<EventType> &events, std::map<int, EventList *> &partials, const bool pulseTof,
76 const bool tofCorrect, const double factor, const double shift) const;
77 template <typename EventType>
78 void splitEventVec(const std::function<const DateAndTime(const EventType &)> &timeCalc,
79 const std::vector<EventType> &events, std::map<int, EventList *> &partials) const;
80
81 void resetCache();
82 void resetCachedPartialTimeROIs() const;
83 void resetCachedSplittingIntervals() const;
84
85 void rebuildCachedPartialTimeROIs() const;
86 void rebuildCachedSplittingIntervals(const bool includeNoTarget = true) const;
87
88private:
89 std::map<DateAndTime, int> m_roi_map;
90 // These 2 maps are complementary to each other
91 std::map<std::string, int> m_name_index_map;
92 std::map<int, std::string> m_index_name_map;
93
94 mutable std::map<int, Kernel::TimeROI> m_cachedPartialTimeROIs;
96
97 mutable bool m_validCachedPartialTimeROIs{false};
98 mutable bool m_validCachedSplittingIntervals_All{false};
99 mutable bool m_validCachedSplittingIntervals_WithValidTargets{false};
100
101 mutable std::mutex m_mutex;
102};
103} // namespace DataObjects
104} // namespace Mantid
double value
The value of the point.
Definition FitMW.cpp:51
A class for holding :
Definition EventList.h:57
std::map< DateAndTime, int > m_roi_map
std::map< int, std::string > m_index_name_map
std::map< std::string, int > m_name_index_map
Kernel::SplittingIntervalVec m_cachedSplittingIntervals
std::map< int, Kernel::TimeROI > m_cachedPartialTimeROIs
TimeROI : Object that holds information about when the time measurement was active.
Definition TimeROI.h:18
EventType
What kind of event list is being stored.
Definition IEventList.h:18
std::shared_ptr< MatrixWorkspace > MatrixWorkspace_sptr
shared pointer to the matrix workspace base class
std::shared_ptr< SplittersWorkspace > SplittersWorkspace_sptr
std::shared_ptr< TableWorkspace > TableWorkspace_sptr
shared pointer to Mantid::DataObjects::TableWorkspace
std::vector< SplittingInterval > SplittingIntervalVec
A typedef for splitting events according their pulse time.
Definition LogManager.h:28
Helper class which provides the Collimation Length for SANS instruments.