17namespace DataObjects {
38template <
size_t nd>
class MDEvent :
public MDLeanEvent<nd> {
57 enum { is_full_mdevent =
true };
69 MDEvent(
const float signal,
const float errorSquared)
70 :
MDLeanEvent<nd>(signal, errorSquared), expInfoIndex(0), goniometerIndex(0), detectorId(0) {}
78 MDEvent(
const double signal,
const double errorSquared)
79 :
MDLeanEvent<nd>(signal, errorSquared), expInfoIndex(0), goniometerIndex(0), detectorId(0) {}
92 MDEvent(
const double signal,
const double errorSquared,
const uint16_t expInfoIndex,
const uint16_t goniometerIndex,
93 const int32_t detectorId)
94 :
MDLeanEvent<nd>(signal, errorSquared), expInfoIndex(expInfoIndex), goniometerIndex(goniometerIndex),
95 detectorId(detectorId) {}
108 MDEvent(
const float signal,
const float errorSquared,
const uint16_t expInfoIndex,
const uint16_t goniometerIndex,
109 const int32_t detectorId)
110 :
MDLeanEvent<nd>(signal, errorSquared), expInfoIndex(expInfoIndex), goniometerIndex(goniometerIndex),
111 detectorId(detectorId) {}
122 :
MDLeanEvent<nd>(signal, errorSquared, centers), expInfoIndex(0), goniometerIndex(0), detectorId(0) {}
132 :
MDLeanEvent<nd>(signal, errorSquared, centers), expInfoIndex(0), goniometerIndex(0), detectorId(0) {}
147 MDEvent(
const float signal,
const float errorSquared,
const uint16_t expInfoIndex,
const uint16_t goniometerIndex,
148 const int32_t detectorId,
const coord_t *centers)
149 :
MDLeanEvent<nd>(signal, errorSquared, centers), expInfoIndex(expInfoIndex), goniometerIndex(goniometerIndex),
150 detectorId(detectorId) {}
152 MDEvent(
const double signal,
const double errorSquared,
const uint16_t expInfoIndex,
const uint16_t goniometerIndex,
153 const int32_t detectorId,
const coord_t *centers)
154 :
MDLeanEvent<nd>(signal, errorSquared, centers), expInfoIndex(expInfoIndex), goniometerIndex(goniometerIndex),
155 detectorId(detectorId) {}
157#ifdef COORDT_IS_FLOAT
172 MDEvent(
const float signal,
const float errorSquared,
const uint16_t expInfoIndex,
const uint16_t goniometerIndex,
173 const int32_t detectorId,
const double *centers)
174 :
MDLeanEvent<nd>(signal, errorSquared, centers), expInfoIndex(expInfoIndex), goniometerIndex(goniometerIndex),
175 detectorId(detectorId) {}
217 double &totalSignal,
double &totalErrSq) {
219 size_t nEvents = events.size();
220 data.resize(nEvents *
ncols);
226 for (
const auto &event : events) {
227 float signal =
event.signal;
228 float errorSquared =
event.errorSquared;
232 data[
index++] =
static_cast<coord_t>(
event.expInfoIndex);
233 data[
index++] =
static_cast<coord_t>(
event.goniometerIndex);
235 for (
size_t d = 0;
d < nd;
d++)
236 data[
index++] = event.center[
d];
239 totalErrSq +=
signal_t(errorSquared);
250 bool reserveMemory =
true) {
253 size_t numColumns = (nd + 5);
254 size_t numEvents = data.size() / numColumns;
255 if (
numEvents * numColumns != data.size())
256 throw(std::invalid_argument(
"wrong input array of data to convert to "
257 "lean events, suspected column data for "
258 "different dimensions/(type of) events "));
268 size_t ii = i * numColumns;
271 coord_t const *
const centers = &(data[ii + 5]);
275 events.emplace_back(
static_cast<signal_t>(data[ii]),
static_cast<signal_t>(data[ii + 1]),
276 static_cast<uint16_t
>(data[ii + 2]),
static_cast<uint16_t
>(data[ii + 3]),
277 static_cast<int32_t
>(data[ii + 4]), centers);
std::map< DeltaEMode::Type, std::string > index
Templated class holding data about a neutron detection event in N-dimensions (for example,...
void setGoniometerIndex(uint16_t index)
Sets the expInfoIndex of this event.
static std::string getTypeName()
static void eventsToData(const std::vector< MDEvent< nd > > &events, std::vector< coord_t > &data, size_t &ncols, double &totalSignal, double &totalErrSq)
uint16_t getExpInfoIndex() const
MDEvent(const double signal, const double errorSquared, const uint16_t expInfoIndex, const uint16_t goniometerIndex, const int32_t detectorId, const coord_t *centers)
MDEvent(const float signal, const float errorSquared, const uint16_t expInfoIndex, const uint16_t goniometerIndex, const int32_t detectorId, const coord_t *centers)
Constructor with signal and error and an array of centers, and the expInfoIndex and detectorID.
MDEvent()
Empty constructor.
uint16_t expInfoIndex
0-based index of which run this event belongs to.
MDEvent(const float signal, const float errorSquared, const coord_t *centers)
Constructor with signal and error and an array of centers.
void setDetectorId(int32_t id)
Sets the detectorId of this event.
MDEvent(const float signal, const float errorSquared, const uint16_t expInfoIndex, const uint16_t goniometerIndex, const int32_t detectorId)
Constructor with signal, error, expInfoIndex and detectorId.
void setExpInfoIndex(uint16_t index)
Sets the expInfoIndex of this event.
int32_t detectorId
Detector ID of the pixel that measured this event.
int32_t getDetectorID() const
MDEvent(const double signal, const double errorSquared, const coord_t *centers)
Constructor with signal and error and an array of centers.
MDEvent(const double signal, const double errorSquared, const uint16_t expInfoIndex, const uint16_t goniometerIndex, const int32_t detectorId)
Constructor with signal, error, expInfoIndex and detectorId.
uint16_t goniometerIndex
0-based index determines the goniometer settings when this event occurred
MDEvent(const float signal, const float errorSquared)
Constructor with signal and error.
uint16_t getGoniometerIndex() const
static void dataToEvents(const std::vector< coord_t > &data, std::vector< MDEvent< nd > > &events, bool reserveMemory=true)
MDEvent(const double signal, const double errorSquared)
Constructor with signal and error.
Templated class holding data about a neutron detection event in N-dimensions (for example,...
std::size_t numEvents(Nexus::File &file, bool &hasTotalCounts, bool &oldNeXusFileNames, const std::string &prefix)
Get the number of events in the currently opened group.
Helper class which provides the Collimation Length for SANS instruments.
float coord_t
Typedef for the data type to use for coordinate axes in MD objects such as MDBox, MDEventWorkspace,...
double signal_t
Typedef for the signal recorded in a MDBox, etc.