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 &, double weight, double errorSquared);
121 WeightedEventNoTime(const Types::Event::TofEvent &, float weight, float errorSquared);
122
124
125 WeightedEventNoTime(const Types::Event::TofEvent &);
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 Mantid::Types::Core::DateAndTime pulseTime() const;
148 double weight() const;
149 double error() const;
150 double errorSquared() const;
151
153 friend std::ostream &operator<<(std::ostream &os, const WeightedEvent &event);
154};
155#pragma pack(pop)
156
157//==========================================================================================
158// WeightedEvent inlined member function definitions
159//==========================================================================================
160
162inline double WeightedEvent::weight() const { return m_weight; }
163
169inline double WeightedEvent::error() const { return std::sqrt(double(m_errorSquared)); }
170
174inline double WeightedEvent::errorSquared() const { return m_errorSquared; }
175
176//==========================================================================================
177// WeightedEventNoTime inlined member function definitions
178//==========================================================================================
179
180inline double WeightedEventNoTime::operator()() const { return m_tof; }
181
183inline double WeightedEventNoTime::tof() const { return m_tof; }
184
188inline Types::Core::DateAndTime WeightedEventNoTime::pulseTime() const { return 0; }
189
191inline double WeightedEventNoTime::weight() const { return m_weight; }
192
194inline double WeightedEventNoTime::error() const { return std::sqrt(double(m_errorSquared)); }
195
197inline double WeightedEventNoTime::errorSquared() const { return m_errorSquared; }
198
199} // namespace DataObjects
200} // namespace Mantid
const std::vector< double > & rhs
double error
Definition: IndexPeaks.cpp:133
std::ostream & operator<<(std::ostream &out, const MantidQt::MantidWidgets::IndexType< i > &index)
Definition: IndexTypes.h:103
A class for holding :
Definition: EventList.h:56
Info about a single neutron detection event, including a weight and error value, but excluding the pu...
Definition: Events.h:91
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:183
double error() const
Return the error of the neutron, as a double (it is saved as a float).
Definition: Events.h:194
WeightedEventNoTime(const Types::Event::TofEvent &, float weight, float errorSquared)
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:191
WeightedEventNoTime(const Types::Event::TofEvent &, double weight, double errorSquared)
double errorSquared() const
Return the squared error of the neutron, as a double.
Definition: Events.h:197
float m_errorSquared
The SQUARE of the error that this neutron contributes.
Definition: Events.h:107
WeightedEventNoTime(const Types::Event::TofEvent &)
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:188
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:162
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)