17namespace DataObjects {
52 enum { is_full_mdevent =
true };
64 MDEvent(
const float signal,
const float errorSquared)
65 :
MDLeanEvent<nd>(signal, errorSquared), expInfoIndex(0), goniometerIndex(0), detectorId(0) {}
73 MDEvent(
const double signal,
const double errorSquared)
74 :
MDLeanEvent<nd>(signal, errorSquared), expInfoIndex(0), goniometerIndex(0), detectorId(0) {}
87 MDEvent(
const double signal,
const double errorSquared,
const uint16_t expInfoIndex,
const uint16_t goniometerIndex,
88 const int32_t detectorId)
89 :
MDLeanEvent<nd>(signal, errorSquared), expInfoIndex(expInfoIndex), goniometerIndex(goniometerIndex),
90 detectorId(detectorId) {}
103 MDEvent(
const float signal,
const float errorSquared,
const uint16_t expInfoIndex,
const uint16_t goniometerIndex,
104 const int32_t detectorId)
105 :
MDLeanEvent<nd>(signal, errorSquared), expInfoIndex(expInfoIndex), goniometerIndex(goniometerIndex),
106 detectorId(detectorId) {}
117 :
MDLeanEvent<nd>(signal, errorSquared, centers), expInfoIndex(0), goniometerIndex(0), detectorId(0) {}
127 :
MDLeanEvent<nd>(signal, errorSquared, centers), expInfoIndex(0), goniometerIndex(0), detectorId(0) {}
142 MDEvent(
const float signal,
const float errorSquared,
const uint16_t expInfoIndex,
const uint16_t goniometerIndex,
143 const int32_t detectorId,
const coord_t *centers)
144 :
MDLeanEvent<nd>(signal, errorSquared, centers), expInfoIndex(expInfoIndex), goniometerIndex(goniometerIndex),
145 detectorId(detectorId) {}
147 MDEvent(
const double signal,
const double 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#ifdef COORDT_IS_FLOAT
167 MDEvent(
const float signal,
const float errorSquared,
const uint16_t expInfoIndex,
const uint16_t goniometerIndex,
168 const int32_t detectorId,
const double *centers)
169 :
MDLeanEvent<nd>(signal, errorSquared, centers), expInfoIndex(expInfoIndex), goniometerIndex(goniometerIndex),
170 detectorId(detectorId) {}
212 double &totalSignal,
double &totalErrSq) {
214 size_t nEvents = events.size();
215 data.resize(nEvents *
ncols);
221 for (
const auto &event : events) {
222 float signal =
event.signal;
223 float errorSquared =
event.errorSquared;
227 data[
index++] =
static_cast<coord_t>(
event.expInfoIndex);
228 data[
index++] =
static_cast<coord_t>(
event.goniometerIndex);
230 for (
size_t d = 0;
d < nd;
d++)
231 data[
index++] = event.center[
d];
234 totalErrSq +=
signal_t(errorSquared);
245 bool reserveMemory =
true) {
248 size_t numColumns = (nd + 5);
249 size_t numEvents = data.size() / numColumns;
250 if (
numEvents * numColumns != data.size())
251 throw(std::invalid_argument(
"wrong input array of data to convert to "
252 "lean events, suspected column data for "
253 "different dimensions/(type of) events "));
263 size_t ii = i * numColumns;
266 coord_t const *
const centers = &(data[ii + 5]);
270 events.emplace_back(
static_cast<signal_t>(data[ii]),
static_cast<signal_t>(data[ii + 1]),
271 static_cast<uint16_t
>(data[ii + 2]),
static_cast<uint16_t
>(data[ii + 3]),
272 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, const NexusHDF5Descriptor &descriptor)
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.