Mantid
Loading...
Searching...
No Matches
Events.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2018 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#ifdef _WIN32 /* _WIN32 */
10#include <time.h>
11#endif
12#include "MantidAPI/MatrixWorkspace_fwd.h" // get MantidVec declaration
13#include "MantidDataObjects/DllConfig.h"
16#include "MantidTypes/Event/TofEvent.h"
17#include <cstddef>
18#include <iosfwd>
19#include <set>
20#include <vector>
21
22namespace Mantid {
23// Forward declaration needed while this needs to be a friend of TofEvent (see
24// below)
25namespace DataHandling {
26class LoadEventNexus;
27}
28
29namespace DataObjects {
30//==========================================================================================
38#pragma pack(push, 4) // Ensure the structure is no larger than it needs to
39class MANTID_DATAOBJECTS_DLL WeightedEvent : public Types::Event::TofEvent {
40
42 friend class EventList;
43 friend class WeightedEventNoTime;
44 friend class tofGreaterOrEqual;
45 friend class tofGreater;
46
47public:
49 float m_weight;
50
53
54public:
56 WeightedEvent(double time_of_flight);
57
59 WeightedEvent(double tof, const Mantid::Types::Core::DateAndTime pulsetime, double weight, double errorSquared);
60 WeightedEvent(double tof, const Mantid::Types::Core::DateAndTime pulsetime, float weight, float errorSquared);
61
62 WeightedEvent(const TofEvent &, double weight, double errorSquared);
63 WeightedEvent(const TofEvent &, float weight, float errorSquared);
64
65 WeightedEvent(const TofEvent &);
66
68
69 bool operator==(const WeightedEvent &rhs) const;
70 bool equals(const WeightedEvent &rhs, const double tolTof, const double tolWeight, const int64_t tolPulse) const;
71
72 double weight() const;
73 double error() const;
74 double errorSquared() const;
75
77 friend std::ostream &operator<<(std::ostream &os, const WeightedEvent &event);
78};
79#pragma pack(pop)
80
81//==========================================================================================
90#pragma pack(push, 4) // Ensure the structure is no larger than it needs to
91class MANTID_DATAOBJECTS_DLL WeightedEventNoTime {
92
94 friend class EventList;
95 friend class tofGreaterOrEqual;
96 friend class tofGreater;
97
98protected:
100 double m_tof;
101
102public:
104 float m_weight;
105
108
109public:
111 WeightedEventNoTime(double time_of_flight);
112
114 WeightedEventNoTime(double tof, double weight, double errorSquared);
115 WeightedEventNoTime(double tof, float weight, float errorSquared);
116
117 WeightedEventNoTime(double tof, const Mantid::Types::Core::DateAndTime pulsetime, double weight, double errorSquared);
118 WeightedEventNoTime(double tof, const Mantid::Types::Core::DateAndTime pulsetime, float weight, float errorSquared);
119
120 WeightedEventNoTime(const Types::Event::TofEvent &rhs, double weight, double errorSquared);
121 WeightedEventNoTime(const Types::Event::TofEvent &rhs, float weight, float errorSquared);
122
124
125 WeightedEventNoTime(const Types::Event::TofEvent &rhs);
126
128
129 bool operator==(const WeightedEventNoTime &rhs) const;
130
135 bool operator<(const WeightedEventNoTime &rhs) const { return (this->m_tof < rhs.m_tof); }
136
141 bool operator<(const double rhs_tof) const { return (this->m_tof < rhs_tof); }
142
143 bool equals(const WeightedEventNoTime &rhs, const double tolTof, const double tolWeight) const;
144
145 double operator()() const;
146 double tof() const;
147 const Mantid::Types::Core::DateAndTime &pulseTime() const;
148 Mantid::Types::Core::DateAndTime pulseTOFTime() const;
149 Mantid::Types::Core::DateAndTime pulseTOFTimeAtSample(const double &factor, const double &shift) const;
150 double weight() const;
151 double error() const;
152 double errorSquared() const;
153
155 friend std::ostream &operator<<(std::ostream &os, const WeightedEvent &event);
156
157private:
158 inline static const Mantid::Types::Core::DateAndTime UNSET_DATEANDTIME = Mantid::Types::Core::DateAndTime(0);
159};
160#pragma pack(pop)
161
162//==========================================================================================
163// WeightedEvent inlined member function definitions
164//==========================================================================================
165
167inline double WeightedEvent::weight() const { return m_weight; }
168
174inline double WeightedEvent::error() const { return std::sqrt(double(m_errorSquared)); }
175
179inline double WeightedEvent::errorSquared() const { return m_errorSquared; }
180
181//==========================================================================================
182// WeightedEventNoTime inlined member function definitions
183//==========================================================================================
184
185inline double WeightedEventNoTime::operator()() const { return m_tof; }
186
188inline double WeightedEventNoTime::tof() const { return m_tof; }
189
191inline const Types::Core::DateAndTime &WeightedEventNoTime::pulseTime() const { return UNSET_DATEANDTIME; }
193inline Types::Core::DateAndTime WeightedEventNoTime::pulseTOFTime() const { return UNSET_DATEANDTIME; }
195inline Types::Core::DateAndTime WeightedEventNoTime::pulseTOFTimeAtSample(const double &factor,
196 const double &shift) const {
197 UNUSED_ARG(factor);
198 UNUSED_ARG(shift);
199 return 0;
200}
201
203inline double WeightedEventNoTime::weight() const { return m_weight; }
204
206inline double WeightedEventNoTime::error() const { return std::sqrt(double(m_errorSquared)); }
207
209inline double WeightedEventNoTime::errorSquared() const { return m_errorSquared; }
210
211} // namespace DataObjects
212} // namespace Mantid
const std::vector< double > & rhs
double error
#define UNUSED_ARG(x)
Function arguments are sometimes unused in certain implmentations but are required for documentation ...
Definition System.h:48
A class for holding :
Definition EventList.h:57
Info about a single neutron detection event, including a weight and error value, but excluding the pu...
Definition Events.h:91
Mantid::Types::Core::DateAndTime pulseTOFTime() const
Return the pulse time; this returns 0 since this type of Event has no time associated.
Definition Events.h:193
double m_tof
The 'x value' (e.g. time-of-flight) of this neutron.
Definition Events.h:100
double tof() const
Return the time-of-flight of the neutron, as a double.
Definition Events.h:188
double error() const
Return the error of the neutron, as a double (it is saved as a float).
Definition Events.h:206
const Mantid::Types::Core::DateAndTime & pulseTime() const
Return the pulse time; this returns 0 since this type of Event has no time associated.
Definition Events.h:191
float m_weight
The weight of this neutron.
Definition Events.h:104
double weight() const
Return the weight of the neutron, as a double (it is saved as a float).
Definition Events.h:203
double errorSquared() const
Return the squared error of the neutron, as a double.
Definition Events.h:209
float m_errorSquared
The SQUARE of the error that this neutron contributes.
Definition Events.h:107
static const Mantid::Types::Core::DateAndTime UNSET_DATEANDTIME
Definition Events.h:158
Mantid::Types::Core::DateAndTime pulseTOFTimeAtSample(const double &factor, const double &shift) const
Return the pulse time; this returns 0 since this type of Event has no time associated.
Definition Events.h:195
bool operator<(const double rhs_tof) const
< comparison operator, using the TOF to do the comparison.
Definition Events.h:141
bool operator<(const WeightedEventNoTime &rhs) const
< comparison operator, using the TOF to do the comparison.
Definition Events.h:135
Info about a single neutron detection event, including a weight and error value:
Definition Events.h:39
double weight() const
Return the weight of the neutron, as a double (it is saved as a float).
Definition Events.h:167
float m_errorSquared
The SQUARE of the error that this neutron contributes.
Definition Events.h:52
float m_weight
The weight of this neutron.
Definition Events.h:49
bool MANTID_API_DLL equals(const MatrixWorkspace_sptr &lhs, const MatrixWorkspace_sptr &rhs, double tolerance=0.0)
Performs a comparison operation on two workspaces, using the CompareWorkspaces algorithm.
Helper class which provides the Collimation Length for SANS instruments.
constexpr bool operator==(const wide_integer< Bits, Signed > &lhs, const wide_integer< Bits2, Signed2 > &rhs)
constexpr wide_integer< Bits, Signed > operator<<(const wide_integer< Bits, Signed > &lhs, T2 n) noexcept