|
Mantid
|
#include <TimeSplitter.h>
Public Member Functions | |
| void | addROI (const DateAndTime &start, const DateAndTime &stop, const int value) |
| std::vector< std::pair< int, std::pair< size_t, size_t > > > | calculate_target_indices (const std::vector< DateAndTime > ×) const |
| Given a list of times, calculate the corresponding indices in the TimeSplitter. | |
| const Kernel::TimeROI | combinedTimeROI (const int64_t start_offset=0) const |
| Returns a combined TimeROI covering all intervals. | |
| std::string | debugPrint () const |
| Print the (destination index | DateAndTime boundary) pairs of this splitter. | |
| bool | empty () const |
| Check if the TimeSplitter is empty. | |
| const std::map< std::string, int > & | getNameTargetMap () const |
| const std::map< DateAndTime, int > & | getSplittersMap () const |
| const Kernel::SplittingIntervalVec & | getSplittingIntervals (const bool includeNoTarget=true) const |
| Returns a vector of splitting intervals corresponding to the m_roi_map. | |
| const std::map< int, std::string > & | getTargetNameMap () const |
| const Kernel::TimeROI & | getTimeROI (const int workspaceIndex) const |
| Returns a TimeROI for the requested workspace index. | |
| std::string | getWorkspaceIndexName (const int workspaceIndex, const int numericalShift=0) const |
| std::size_t | numRawValues () const |
| these methods are to aid in testing and not intended for use elsewhere | |
| TimeSplitter & | operator= (const TimeSplitter &other) |
| std::set< int > | outputWorkspaceIndices () const |
| Return a set of the output workspace indices. | |
| void | splitEventList (const EventList &events, std::map< int, EventList * > &partials, const bool pulseTof=false, const bool tofCorrect=false, const double factor=1.0, const double shift=0.0) const |
| Split a list of events according to Pulse time or Pulse + TOF time. | |
| TimeSplitter ()=default | |
| TimeSplitter (const DateAndTime &start, const DateAndTime &stop, const int value=DEFAULT_TARGET) | |
| TimeSplitter (const Mantid::API::MatrixWorkspace_sptr &ws, const DateAndTime &offset=DateAndTime::GPS_EPOCH) | |
| Note: The amount of X values in input MatrixWorkspace must be 1 larger than the amount of Y values. | |
| TimeSplitter (const SplittersWorkspace_sptr &sws) | |
| TimeSplitter (const TableWorkspace_sptr &tws, const DateAndTime &offset=DateAndTime::GPS_EPOCH) | |
| TimeSplitter (const TimeSplitter &other) | |
| int | valueAtTime (const DateAndTime &time) const |
| Find the destination index for an event with a given time. | |
Static Public Attributes | |
| static constexpr int | NO_TARGET {-1} |
Private Member Functions | |
| void | clearAndReplace (const DateAndTime &start, const DateAndTime &stop, const int value) |
| void | rebuildCachedPartialTimeROIs () const |
| void | rebuildCachedSplittingIntervals (const bool includeNoTarget=true) const |
| void | resetCache () |
| void | resetCachedPartialTimeROIs () const |
| void | resetCachedSplittingIntervals () const |
| template<typename EventType > | |
| void | splitEventVec (const std::function< const DateAndTime(const EventType &)> &timeCalc, const std::vector< EventType > &events, std::map< int, EventList * > &partials) const |
| template<typename EventType > | |
| void | splitEventVec (const std::vector< EventType > &events, std::map< int, EventList * > &partials, const bool pulseTof, const bool tofCorrect, const double factor, const double shift) const |
| Distribute a list of events by comparing a vector of times against the splitter boundaries. | |
Private Attributes | |
| std::map< int, Kernel::TimeROI > | m_cachedPartialTimeROIs |
| Kernel::SplittingIntervalVec | m_cachedSplittingIntervals |
| std::map< int, std::string > | m_index_name_map |
| std::mutex | m_mutex |
| std::map< std::string, int > | m_name_index_map |
| std::map< DateAndTime, int > | m_roi_map |
| bool | m_validCachedPartialTimeROIs {false} |
| bool | m_validCachedSplittingIntervals_All {false} |
| bool | m_validCachedSplittingIntervals_WithValidTargets {false} |
Static Private Attributes | |
| static constexpr int | DEFAULT_TARGET {0} |
Definition at line 29 of file TimeSplitter.h.
|
default |
| Mantid::DataObjects::TimeSplitter::TimeSplitter | ( | const TimeSplitter & | other | ) |
Definition at line 35 of file TimeSplitter.cpp.
References m_index_name_map, m_name_index_map, and m_roi_map.
| Mantid::DataObjects::TimeSplitter::TimeSplitter | ( | const DateAndTime & | start, |
| const DateAndTime & | stop, | ||
| const int | value = DEFAULT_TARGET |
||
| ) |
Definition at line 51 of file TimeSplitter.cpp.
References clearAndReplace(), and value.
| Mantid::DataObjects::TimeSplitter::TimeSplitter | ( | const Mantid::API::MatrixWorkspace_sptr & | ws, |
| const DateAndTime & | offset = DateAndTime::GPS_EPOCH |
||
| ) |
Note: The amount of X values in input MatrixWorkspace must be 1 larger than the amount of Y values.
There are NO undefined split regions here.
Definition at line 59 of file TimeSplitter.cpp.
References addROI(), Mantid::API::g_log, m_index_name_map, m_name_index_map, NO_TARGET, std::to_string(), valueAtTime(), Mantid::Kernel::Logger::warning(), Mantid::Geometry::X, and Mantid::Geometry::Y.
| Mantid::DataObjects::TimeSplitter::TimeSplitter | ( | const TableWorkspace_sptr & | tws, |
| const DateAndTime & | offset = DateAndTime::GPS_EPOCH |
||
| ) |
Definition at line 90 of file TimeSplitter.cpp.
References addROI(), Mantid::API::g_log, Mantid::Kernel::Logger::information(), m_index_name_map, m_name_index_map, NO_TARGET, valueAtTime(), and Mantid::Kernel::Logger::warning().
| Mantid::DataObjects::TimeSplitter::TimeSplitter | ( | const SplittersWorkspace_sptr & | sws | ) |
Definition at line 169 of file TimeSplitter.cpp.
References addROI(), Mantid::API::g_log, Mantid::Kernel::SplittingInterval::index(), m_index_name_map, m_name_index_map, NO_TARGET, Mantid::Kernel::TimeInterval::start(), Mantid::Kernel::TimeInterval::stop(), std::to_string(), valueAtTime(), and Mantid::Kernel::Logger::warning().
| void Mantid::DataObjects::TimeSplitter::addROI | ( | const DateAndTime & | start, |
| const DateAndTime & | stop, | ||
| const int | value | ||
| ) |
Definition at line 230 of file TimeSplitter.cpp.
References clearAndReplace(), Mantid::Kernel::Logger::debug(), Mantid::API::g_log, m_roi_map, NO_TARGET, resetCache(), value, and valueAtTime().
Referenced by TimeSplitter(), TimeSplitter(), and TimeSplitter().
| std::vector< std::pair< int, std::pair< size_t, size_t > > > Mantid::DataObjects::TimeSplitter::calculate_target_indices | ( | const std::vector< DateAndTime > & | times | ) | const |
Given a list of times, calculate the corresponding indices in the TimeSplitter.
Calculate the target indices for a given set of times.
Returns a vector of pairs, where each pair contains a target index and a pair of size_t representing the start and stop indices in the input times vector that correspond to that target.
| times |
Definition at line 691 of file TimeSplitter.cpp.
References getSplittingIntervals().
Referenced by Mantid::DataHandling::AlignAndFocusPowderSlim::AlignAndFocusPowderSlim::determinePulseIndicesTargets().
|
private |
Definition at line 312 of file TimeSplitter.cpp.
References m_roi_map, NO_TARGET, resetCache(), and value.
Referenced by addROI(), and TimeSplitter().
| const TimeROI Mantid::DataObjects::TimeSplitter::combinedTimeROI | ( | const int64_t | start_offset = 0 | ) | const |
Returns a combined TimeROI covering all intervals.
| start_offset | Offset in nanoseconds to subtract from interval start times. This accounts for TOF (Time-of-Flight) values that may extend before the pulse time. Pass 0 if no offset is required. |
Definition at line 724 of file TimeSplitter.cpp.
References Mantid::Kernel::TimeROI::addROI(), m_roi_map, and NO_TARGET.
| std::string Mantid::DataObjects::TimeSplitter::debugPrint | ( | ) | const |
Print the (destination index | DateAndTime boundary) pairs of this splitter.
Definition at line 188 of file TimeSplitter.cpp.
References m_roi_map.
| bool Mantid::DataObjects::TimeSplitter::empty | ( | ) | const |
Check if the TimeSplitter is empty.
Definition at line 310 of file TimeSplitter.cpp.
References m_roi_map.
Referenced by rebuildCachedPartialTimeROIs(), rebuildCachedSplittingIntervals(), and splitEventList().
| const std::map< std::string, int > & Mantid::DataObjects::TimeSplitter::getNameTargetMap | ( | ) | const |
Definition at line 502 of file TimeSplitter.cpp.
References m_name_index_map.
| const std::map< DateAndTime, int > & Mantid::DataObjects::TimeSplitter::getSplittersMap | ( | ) | const |
Definition at line 195 of file TimeSplitter.cpp.
References m_roi_map.
Referenced by Mantid::Algorithms::FilterEvents::partialROI().
| const Kernel::SplittingIntervalVec & Mantid::DataObjects::TimeSplitter::getSplittingIntervals | ( | const bool | includeNoTarget = true | ) | const |
Returns a vector of splitting intervals corresponding to the m_roi_map.
For efficiency, the actual vector calculation should be done only on demand ("lazy") and only when the current vector is invalid.
| includeNoTarget | : if true/false, the calculated vector will/will not include intervals with NO_TARGET. |
Definition at line 490 of file TimeSplitter.cpp.
References m_cachedSplittingIntervals, m_mutex, m_validCachedSplittingIntervals_All, m_validCachedSplittingIntervals_WithValidTargets, and rebuildCachedSplittingIntervals().
Referenced by calculate_target_indices(), and splitEventVec().
| const std::map< int, std::string > & Mantid::DataObjects::TimeSplitter::getTargetNameMap | ( | ) | const |
Definition at line 503 of file TimeSplitter.cpp.
References m_index_name_map.
| const TimeROI & Mantid::DataObjects::TimeSplitter::getTimeROI | ( | const int | workspaceIndex | ) | const |
Returns a TimeROI for the requested workspace index.
If the workspace index does not exist in the TimeSplitter, the returned TimeROI will be empty, meaning any time datapoint will pass through the given ROI filter. For efficiency, the first call to this method, after TimeSplitter is built, will trigger calculation of all TimeROIs. The following calls to this method will look up and return the corresponding TimeROI without spending time on building it.
| workspaceIndex | : target, a.k.a. partial workspace, or destination, index, for which to get a TimeROI. |
Definition at line 468 of file TimeSplitter.cpp.
References m_cachedPartialTimeROIs, m_mutex, m_validCachedPartialTimeROIs, NO_TARGET, rebuildCachedPartialTimeROIs(), and Mantid::Kernel::TimeROI::USE_ALL.
Referenced by Mantid::Algorithms::FilterEvents::createOutputWorkspaces(), and Mantid::Algorithms::FilterEvents::partialROI().
| std::string Mantid::DataObjects::TimeSplitter::getWorkspaceIndexName | ( | const int | workspaceIndex, |
| const int | numericalShift = 0 |
||
| ) | const |
Definition at line 198 of file TimeSplitter.cpp.
References m_index_name_map, and m_name_index_map.
Referenced by Mantid::Algorithms::FilterEvents::createOutputWorkspaces().
| std::size_t Mantid::DataObjects::TimeSplitter::numRawValues | ( | ) | const |
these methods are to aid in testing and not intended for use elsewhere
Definition at line 501 of file TimeSplitter.cpp.
References m_roi_map.
| TimeSplitter & Mantid::DataObjects::TimeSplitter::operator= | ( | const TimeSplitter & | other | ) |
Definition at line 41 of file TimeSplitter.cpp.
References m_index_name_map, m_name_index_map, m_roi_map, and resetCache().
| std::set< int > Mantid::DataObjects::TimeSplitter::outputWorkspaceIndices | ( | ) | const |
Return a set of the output workspace indices.
Definition at line 445 of file TimeSplitter.cpp.
References m_roi_map, and NO_TARGET.
Referenced by Mantid::Algorithms::FilterEvents::parseInputSplitters().
|
private |
Definition at line 347 of file TimeSplitter.cpp.
References empty(), m_cachedPartialTimeROIs, m_roi_map, m_validCachedPartialTimeROIs, NO_TARGET, and resetCachedPartialTimeROIs().
Referenced by getTimeROI().
|
private |
Definition at line 380 of file TimeSplitter.cpp.
References empty(), m_cachedSplittingIntervals, m_roi_map, m_validCachedSplittingIntervals_All, m_validCachedSplittingIntervals_WithValidTargets, NO_TARGET, and resetCachedSplittingIntervals().
Referenced by getSplittingIntervals().
|
private |
Definition at line 323 of file TimeSplitter.cpp.
References resetCachedPartialTimeROIs(), and resetCachedSplittingIntervals().
Referenced by addROI(), clearAndReplace(), and operator=().
|
private |
Definition at line 329 of file TimeSplitter.cpp.
References m_cachedPartialTimeROIs, and m_validCachedPartialTimeROIs.
Referenced by rebuildCachedPartialTimeROIs(), and resetCache().
|
private |
Definition at line 337 of file TimeSplitter.cpp.
References m_cachedSplittingIntervals, m_validCachedSplittingIntervals_All, and m_validCachedSplittingIntervals_WithValidTargets.
Referenced by rebuildCachedSplittingIntervals(), and resetCache().
| void Mantid::DataObjects::TimeSplitter::splitEventList | ( | const EventList & | events, |
| std::map< int, EventList * > & | partials, | ||
| const bool | pulseTof = false, |
||
| const bool | tofCorrect = false, |
||
| const double | factor = 1.0, |
||
| const double | shift = 0.0 |
||
| ) | const |
Split a list of events according to Pulse time or Pulse + TOF time.
This does not clear out the partial EventLists.
Events with masked times are allocated to destination index -1.
| events | : list of input events |
| partials | : resulting partial lists of events |
| pulseTof | : if True, split according to Pulse + TOF time, otherwise split by Pulse time |
| tofCorrect | : rescale and shift the TOF values (factor*TOF + shift) |
| factor | : rescale the TOF values by a dimensionless factor. |
| shift | : shift the TOF values after rescaling, in units of microseconds. |
| invalid_argument | : the event list is of type Mantid::API::EventType::WEIGHTED_NOTIME |
Definition at line 522 of file TimeSplitter.cpp.
References empty(), Mantid::DataObjects::EventList::getEvents(), Mantid::DataObjects::EventList::getEventType(), Mantid::DataObjects::EventList::getWeightedEvents(), Mantid::DataObjects::PULSETIME_SORT, Mantid::DataObjects::PULSETIMETOF_SORT, Mantid::DataObjects::EventList::sortPulseTime(), Mantid::DataObjects::EventList::sortPulseTimeTOF(), and splitEventVec().
Referenced by Mantid::Algorithms::FilterEvents::filterEvents().
|
private |
Definition at line 599 of file TimeSplitter.cpp.
References getSplittingIntervals(), and NO_TARGET.
|
private |
Distribute a list of events by comparing a vector of times against the splitter boundaries.
Distribute a list of events by comparing event times against the splitter boundaries.
For each event in events we calculate the event time using a timeCalc function. The function definition depends on the input flags (pulseTof, tofCorrect) and input parameters (factor, shift). The calculated time is then used to find a destination index for the event in the TimeSplitter object. The destination index, in turn, is the key to find the target event list in the partials map.
| EventType | : one of EventType::TOF or EventType::WEIGHTED |
| events | : list of input events |
| partials | : target list of partial event lists associated with different destination indexes |
| pulseTof | : if true, split according to Pulse + TOF time, otherwise split by Pulse time |
| tofCorrect | : rescale and shift the TOF values (factor*TOF + shift) |
| factor | : rescale the TOF values by a dimensionless factor. |
| shift | : shift the TOF values after rescaling, in units of microseconds. |
Definition at line 579 of file TimeSplitter.cpp.
References splitEventVec().
Referenced by splitEventList(), and splitEventVec().
| int Mantid::DataObjects::TimeSplitter::valueAtTime | ( | const DateAndTime & | time | ) | const |
Find the destination index for an event with a given time.
| time | : event time |
Definition at line 411 of file TimeSplitter.cpp.
References m_roi_map, and NO_TARGET.
Referenced by addROI(), TimeSplitter(), TimeSplitter(), and TimeSplitter().
|
staticconstexprprivate |
Definition at line 71 of file TimeSplitter.h.
|
mutableprivate |
Definition at line 94 of file TimeSplitter.h.
Referenced by getTimeROI(), rebuildCachedPartialTimeROIs(), and resetCachedPartialTimeROIs().
|
mutableprivate |
Definition at line 95 of file TimeSplitter.h.
Referenced by getSplittingIntervals(), rebuildCachedSplittingIntervals(), and resetCachedSplittingIntervals().
|
private |
Definition at line 92 of file TimeSplitter.h.
Referenced by getTargetNameMap(), getWorkspaceIndexName(), operator=(), TimeSplitter(), TimeSplitter(), TimeSplitter(), and TimeSplitter().
|
mutableprivate |
Definition at line 101 of file TimeSplitter.h.
Referenced by getSplittingIntervals(), and getTimeROI().
|
private |
Definition at line 91 of file TimeSplitter.h.
Referenced by getNameTargetMap(), getWorkspaceIndexName(), operator=(), TimeSplitter(), TimeSplitter(), TimeSplitter(), and TimeSplitter().
|
private |
Definition at line 89 of file TimeSplitter.h.
Referenced by addROI(), clearAndReplace(), combinedTimeROI(), debugPrint(), empty(), getSplittersMap(), numRawValues(), operator=(), outputWorkspaceIndices(), rebuildCachedPartialTimeROIs(), rebuildCachedSplittingIntervals(), TimeSplitter(), and valueAtTime().
|
mutableprivate |
Definition at line 97 of file TimeSplitter.h.
Referenced by getTimeROI(), rebuildCachedPartialTimeROIs(), and resetCachedPartialTimeROIs().
|
mutableprivate |
Definition at line 98 of file TimeSplitter.h.
Referenced by getSplittingIntervals(), rebuildCachedSplittingIntervals(), and resetCachedSplittingIntervals().
|
mutableprivate |
Definition at line 99 of file TimeSplitter.h.
Referenced by getSplittingIntervals(), rebuildCachedSplittingIntervals(), and resetCachedSplittingIntervals().
|
staticconstexpr |
Definition at line 32 of file TimeSplitter.h.
Referenced by addROI(), clearAndReplace(), combinedTimeROI(), Mantid::Algorithms::FilterEvents::createOutputWorkspaces(), getTimeROI(), outputWorkspaceIndices(), Mantid::Algorithms::FilterEvents::parseInputSplitters(), Mantid::Algorithms::FilterEvents::partialROI(), rebuildCachedPartialTimeROIs(), rebuildCachedSplittingIntervals(), splitEventVec(), TimeSplitter(), TimeSplitter(), TimeSplitter(), and valueAtTime().