Mantid
Loading...
Searching...
No Matches
FilterEvents.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
12#include "MantidAlgorithms/DllConfig.h"
18
19namespace Mantid {
20namespace Algorithms {
21
22class TimeAtSampleStrategy;
23
29class MANTID_ALGORITHMS_DLL FilterEvents final : public API::Algorithm {
30
31 enum TOFCorrectionType { NoneCorrect, CustomizedCorrect, DirectCorrect, ElasticCorrect, IndirectCorrect };
32 enum TOFCorrectionOp { MultiplyOp, ShiftOp };
33 enum EVENTFILTERSKIP { EventFilterSkipNoDet, EventFilterSkipNoDetTOFCorr };
34
35public:
37
39 const std::string name() const override { return "FilterEvents"; }
41 const std::string summary() const override {
42 return "Filter events from an EventWorkspace to one or multiple "
43 "EventWorkspaces according to a series of splitters.";
44 }
45
47 int version() const override { return 1; }
48 const std::vector<std::string> seeAlso() const override {
49 return {"GenerateEventsFilter", "FilterByTime", "FilterByLogValue"};
50 }
51
53 const std::string category() const override { return "Events\\EventFiltering"; }
54 std::map<std::string, std::string> validateInputs() override;
55
56private:
57 // Implement abstract Algorithm methods
58 void init() override;
59 // Implement abstract Algorithm methods
60 void exec() override;
61
63 void processAlgorithmProperties();
64
66 void processSplittersWorkspace();
67
68 void processTableSplittersWorkspace();
69
71 void processMatrixSplitterWorkspace();
72
74 std::shared_ptr<DataObjects::EventWorkspace> createEventWorkspaceNoLog();
76 void createOutputWorkspacesSplitters();
78 void createOutputWorkspacesTableSplitterCase();
81 void createOutputWorkspacesMatrixCase();
82
84 void setupDetectorTOFCalibration();
85
87 TimeAtSampleStrategy *setupElasticTOFCorrection() const;
88
91 TimeAtSampleStrategy *setupDirectTOFCorrection() const;
92
95 TimeAtSampleStrategy *setupIndirectTOFCorrection() const;
96
98 void setupCustomizedTOFCorrection();
99
101 void filterEventsBySplitters(double progressamount);
102
104 void filterEventsByVectorSplitters(double progressamount);
105
107 void examineAndSortEventWS();
108
111 void convertSplittersWorkspaceToVectors();
112
113 void splitTimeSeriesLogs(const std::vector<Kernel::TimeSeriesProperty<int> *> &int_tsp_vector,
114 const std::vector<Kernel::TimeSeriesProperty<double> *> &dbl_tsp_vector,
115 const std::vector<Kernel::TimeSeriesProperty<bool> *> &bool_tsp_vector,
116 const std::vector<Kernel::TimeSeriesProperty<std::string> *> &string_tsp_vector);
117
120 std::vector<std::string> getTimeSeriesLogNames();
121
122 void generateSplitterTSP(std::vector<std::unique_ptr<Kernel::TimeSeriesProperty<int>>> &split_tsp_vec);
123
124 void generateSplitterTSPalpha(std::vector<std::unique_ptr<Kernel::TimeSeriesProperty<int>>> &split_tsp_vec);
125
127 void mapSplitterTSPtoWorkspaces(std::vector<std::unique_ptr<Kernel::TimeSeriesProperty<int>>> &split_tsp_vec);
128
129 void copyNoneSplitLogs(std::vector<Kernel::TimeSeriesProperty<int> *> &int_tsp_name_vector,
130 std::vector<Kernel::TimeSeriesProperty<double> *> &dbl_tsp_name_vector,
131 std::vector<Kernel::TimeSeriesProperty<bool> *> &bool_tsp_name_vector,
132 std::vector<Kernel::TimeSeriesProperty<std::string> *> &string_tsp_vector);
133
134 template <typename TYPE>
135 void splitTimeSeriesProperty(Kernel::TimeSeriesProperty<TYPE> *tsp,
136 std::vector<Types::Core::DateAndTime> &split_datetime_vec, const int max_target_index);
137
138 void groupOutputWorkspace();
139
142 double calculate_duration(std::unique_ptr<Kernel::TimeSeriesProperty<int>> &splitter_tsp);
143
149
153
157 std::map<int, DataObjects::EventWorkspace_sptr> m_outputWorkspacesMap;
158 std::vector<std::string> m_wsNames;
159
160 std::vector<double> m_detTofOffsets;
161 std::vector<double> m_detTofFactors;
162
164
167
169
172
175 std::map<std::string, int> m_targetIndexMap;
176 std::map<int, std::string> m_wsGroupIndexTargetMap;
177
179 std::map<int, uint32_t> m_yIndexMap;
180 std::map<uint32_t, int> m_wsGroupdYMap;
181
184
187 std::vector<int64_t> m_vecSplitterTime;
189 std::vector<int> m_vecSplitterGroup;
190
193
197
200
204 std::vector<bool> m_vecSkip;
205
206 // Flag to have relative time in splitters workspace
208 // Starting time for starting time of event filters
209 Types::Core::DateAndTime m_filterStartTime;
210 // EventWorkspace (aka. run)'s starting time
211 Types::Core::DateAndTime m_runStartTime;
212};
213
214} // namespace Algorithms
215} // namespace Mantid
Base class from which all concrete algorithm classes should be derived.
Definition: Algorithm.h:85
FilterEvents : Filter Events in EventWorkspace to multiple EventsWorkspace by Splitters.
Definition: FilterEvents.h:29
std::vector< std::string > m_wsNames
Definition: FilterEvents.h:158
DataObjects::SplittersWorkspace_sptr m_splittersWorkspace
Definition: FilterEvents.h:145
std::vector< double > m_detTofOffsets
Definition: FilterEvents.h:160
Kernel::TimeSplitterType m_splitters
Definition: FilterEvents.h:156
std::vector< bool > m_vecSkip
Vector for skip information.
Definition: FilterEvents.h:204
std::map< int, std::string > m_wsGroupIndexTargetMap
Definition: FilterEvents.h:176
std::vector< double > m_detTofFactors
Definition: FilterEvents.h:161
Types::Core::DateAndTime m_filterStartTime
Definition: FilterEvents.h:209
bool m_toGroupWS
Flag to group workspace.
Definition: FilterEvents.h:183
int version() const override
Algorithm's version for identification overriding a virtual method.
Definition: FilterEvents.h:47
std::set< int > m_targetWorkspaceIndexSet
Definition: FilterEvents.h:154
std::map< int, DataObjects::EventWorkspace_sptr > m_outputWorkspacesMap
Definition: FilterEvents.h:157
std::map< std::string, int > m_targetIndexMap
TableWorkspace splitters: from target map to vector workspace group-index These 2 maps are compliment...
Definition: FilterEvents.h:175
std::shared_ptr< DataObjects::EventWorkspace > createEventWorkspaceNoLog()
create event workspace
std::map< int, uint32_t > m_yIndexMap
MatrixWorkspace splitters:
Definition: FilterEvents.h:179
std::vector< int > m_vecSplitterGroup
Vector for splitting group.
Definition: FilterEvents.h:189
std::string m_outputWSNameBase
Base of output workspace's name.
Definition: FilterEvents.h:171
EVENTFILTERSKIP m_specSkipType
Spectrum skip type.
Definition: FilterEvents.h:202
API::MatrixWorkspace_const_sptr m_matrixSplitterWS
Definition: FilterEvents.h:147
std::vector< int64_t > m_vecSplitterTime
Vector for splitting time FIXME - shall we convert this to DateAndTime???.
Definition: FilterEvents.h:187
std::map< uint32_t, int > m_wsGroupdYMap
Definition: FilterEvents.h:180
DataObjects::TableWorkspace_sptr m_informationWS
Definition: FilterEvents.h:165
TOFCorrectionType m_tofCorrType
TOF detector/sample correction type.
Definition: FilterEvents.h:199
Types::Core::DateAndTime m_runStartTime
Definition: FilterEvents.h:211
DataObjects::TableWorkspace_sptr m_detCorrectWorkspace
Definition: FilterEvents.h:148
DataObjects::EventWorkspace_sptr m_eventWS
Definition: FilterEvents.h:144
const std::string summary() const override
Summary of algorithms purpose.
Definition: FilterEvents.h:41
bool m_useSplittersWorkspace
Flag to use matrix splitters or table splitters.
Definition: FilterEvents.h:151
const std::string category() const override
Algorithm's category for identification overriding a virtual method.
Definition: FilterEvents.h:53
bool m_splitSampleLogs
Flag to split sample logs.
Definition: FilterEvents.h:192
const std::vector< std::string > seeAlso() const override
Function to return all of the seeAlso algorithms related to this algorithm.
Definition: FilterEvents.h:48
DataObjects::TableWorkspace_sptr m_splitterTableWorkspace
Definition: FilterEvents.h:146
const std::string name() const override
Algorithm's name for identification overriding a virtual method.
Definition: FilterEvents.h:39
TimeAtSampleStrategy : Strategy (technique dependent) for determining Time At Sample.
A specialised Property class for holding a series of time-value pairs.
std::shared_ptr< const MatrixWorkspace > MatrixWorkspace_const_sptr
shared pointer to the matrix workspace base class (const version)
std::shared_ptr< SplittersWorkspace > SplittersWorkspace_sptr
std::shared_ptr< TableWorkspace > TableWorkspace_sptr
shared pointer to Mantid::DataObjects::TableWorkspace
std::shared_ptr< EventWorkspace > EventWorkspace_sptr
shared pointer to the EventWorkspace class
std::vector< SplittingInterval > TimeSplitterType
A typedef for splitting events according their pulse time.
Definition: LogManager.h:31
Helper class which provides the Collimation Length for SANS instruments.