Mantid
Loading...
Searching...
No Matches
DetectorInfo.cpp
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#include <utility>
8
9#include "MantidBeamline/DetectorInfo.h"
18#include "MantidKernel/Unit.h"
20
21#include <cmath>
22
23namespace Mantid::Geometry {
24namespace {
25double angleFromObserver(const Kernel::V3D &position, const Kernel::V3D &observer, const Kernel::V3D &axis) {
26 return (position - observer).angle(axis);
27}
28
29double signedAngleFromObserver(const Kernel::V3D &position, const Kernel::V3D &observer, const Kernel::V3D &axis,
30 const Kernel::V3D &instrumentUp) {
31 const auto observerDetVec = position - observer;
32 double angle = observerDetVec.angle(axis);
33
34 const auto cross = axis.cross_prod(observerDetVec);
35 const auto normToSurface = axis.cross_prod(instrumentUp);
36 if (normToSurface.scalar_prod(cross) < 0) {
37 angle *= -1;
38 }
39 return angle;
40}
41
42double phiOfPosition(const Kernel::V3D &position) { return std::atan2(position.Y(), position.X()); }
43
44double applyPhiOffset(const double phi, const double offset) { return phi < 0 ? -(offset + phi) : offset - phi; }
45} // namespace
46
53DetectorInfo::DetectorInfo(std::unique_ptr<Beamline::DetectorInfo> detectorInfo,
54 std::shared_ptr<const Geometry::Instrument> instrument,
55 std::shared_ptr<const std::vector<detid_t>> detectorIds,
56 std::shared_ptr<const std::unordered_map<detid_t, size_t>> detIdToIndexMap,
57 std::shared_ptr<ParameterInfo> parameterInfo,
58 std::shared_ptr<ReferenceFrame const> referenceFrame)
59 : m_detectorInfo(std::move(detectorInfo)), m_instrument(std::move(instrument)),
60 m_detectorIDs(std::move(detectorIds)), m_detIDToIndex(std::move(detIdToIndexMap)),
61 m_parameterInfo(std::move(parameterInfo)), m_referenceFrame(std::move(referenceFrame)),
62 m_lastDetector(PARALLEL_GET_MAX_THREADS), m_lastIndex(PARALLEL_GET_MAX_THREADS, -1) {
63
64 // Note: This does not seem possible currently (the instrument objects is
65 // always allocated, even if it is empty), so this will not fail.
66 if (!m_instrument)
67 throw std::invalid_argument("DetectorInfo::DetectorInfo Workspace does not contain an instrument!");
68
69 if (m_detectorIDs->size() != m_detIDToIndex->size()) {
70 throw std::invalid_argument("DetectorInfo::DetectorInfo: ID and ID->index map do not match");
71 }
72}
73
79 : m_detectorInfo(std::make_unique<Beamline::DetectorInfo>(*other.m_detectorInfo)), m_instrument(other.m_instrument),
80 m_detectorIDs(other.m_detectorIDs), m_detIDToIndex(other.m_detIDToIndex), m_parameterInfo(other.m_parameterInfo),
81 m_referenceFrame(other.m_referenceFrame), m_lastDetector(PARALLEL_GET_MAX_THREADS),
82 m_lastIndex(PARALLEL_GET_MAX_THREADS, -1) {}
83
86 if (*m_detectorIDs != *rhs.m_detectorIDs)
87 throw std::runtime_error("DetectorInfo::operator=: Detector IDs in "
88 "assignment do not match. Assignment not "
89 "possible");
90 // Do NOT assign anything in the "wrapping" part of DetectorInfo. We simply
91 // assign the underlying Beamline::DetectorInfo.
92 *m_detectorInfo = *rhs.m_detectorInfo;
93 return *this;
94}
95
96// Defined as default in source for forward declaration with std::unique_ptr.
98
108bool DetectorInfo::isEquivalent(const DetectorInfo &other) const {
109 return m_detectorInfo->isEquivalent(*other.m_detectorInfo);
110}
111
114size_t DetectorInfo::size() const { return m_detectorInfo->size(); }
115
117bool DetectorInfo::isScanning() const { return m_detectorInfo->isScanning(); }
118
120bool DetectorInfo::isMonitor(const size_t index) const { return m_detectorInfo->isMonitor(index); }
121
123bool DetectorInfo::isMonitor(const std::pair<size_t, size_t> &index) const { return m_detectorInfo->isMonitor(index); }
124
126bool DetectorInfo::isMasked(const size_t index) const { return m_detectorInfo->isMasked(index); }
127
129bool DetectorInfo::isMasked(const std::pair<size_t, size_t> &index) const { return m_detectorInfo->isMasked(index); }
130
132bool DetectorInfo::hasMaskedDetectors() const { return m_detectorInfo->hasMaskedDetectors(); }
133
139double DetectorInfo::l2(const size_t index) const {
140 if (!isMonitor(index))
141 return position(index).distance(samplePosition());
142 else
143 return position(index).distance(sourcePosition()) - l1();
144}
145
151double DetectorInfo::l2(const std::pair<size_t, size_t> &index) const {
152 if (!isMonitor(index))
153 return position(index).distance(samplePosition());
154 else
155 return position(index).distance(sourcePosition()) - l1();
156}
157
159double DetectorInfo::twoTheta(const size_t index) const {
160 if (isMonitor(index))
161 throw std::logic_error("Two theta (scattering angle) is not defined for monitors.");
162
163 const auto samplePos = samplePosition();
164 const auto beamLine = samplePos - sourcePosition();
165
166 if (beamLine.nullVector()) {
167 throw Kernel::Exception::InstrumentDefinitionError("Source and sample are at same position!");
168 }
169
170 const auto sampleDetVec = position(index) - samplePos;
171 return sampleDetVec.angle(beamLine);
172}
173
175double DetectorInfo::twoTheta(const std::pair<size_t, size_t> &index) const {
176 if (isMonitor(index))
177 throw std::logic_error("Two theta (scattering angle) is not defined for monitors.");
178
179 const auto samplePos = samplePosition();
180 const auto beamLine = samplePos - sourcePosition();
181
182 if (beamLine.nullVector()) {
183 throw Kernel::Exception::InstrumentDefinitionError("Source and sample are at same position!");
184 }
185
186 const auto sampleDetVec = position(index) - samplePos;
187 return sampleDetVec.angle(beamLine);
188}
189
191double DetectorInfo::signedTwoTheta(const size_t index) const {
192 if (isMonitor(index))
193 throw std::logic_error("Two theta (scattering angle) is not defined for monitors.");
194
195 const auto samplePos = samplePosition();
196 const auto beamLine = samplePos - sourcePosition();
197
198 if (beamLine.nullVector()) {
199 throw Kernel::Exception::InstrumentDefinitionError("Source and sample are at same position!");
200 }
201 // Get the axis defining the sign
202 const auto &instrumentUpAxis = m_referenceFrame->vecThetaSign();
203
204 const auto sampleDetVec = position(index) - samplePos;
205 double angle = sampleDetVec.angle(beamLine);
206
207 const auto cross = beamLine.cross_prod(sampleDetVec);
208 const auto normToSurface = beamLine.cross_prod(instrumentUpAxis);
209 if (normToSurface.scalar_prod(cross) < 0) {
210 angle *= -1;
211 }
212 return angle;
213}
214
216double DetectorInfo::signedTwoTheta(const std::pair<size_t, size_t> &index) const {
217 if (isMonitor(index))
218 throw std::logic_error("Two theta (scattering angle) is not defined for monitors.");
219
220 const auto samplePos = samplePosition();
221 const auto beamLine = samplePos - sourcePosition();
222
223 if (beamLine.nullVector()) {
224 throw Kernel::Exception::InstrumentDefinitionError("Source and sample are at same position!");
225 }
226 // Get the axis defining the sign
227 const auto &instrumentUpAxis = m_referenceFrame->vecThetaSign();
228
229 const auto sampleDetVec = position(index) - samplePos;
230 double angle = sampleDetVec.angle(beamLine);
231
232 const auto cross = beamLine.cross_prod(sampleDetVec);
233 const auto normToSurface = beamLine.cross_prod(instrumentUpAxis);
234 if (normToSurface.scalar_prod(cross) < 0) {
235 angle *= -1;
236 }
237 return angle;
238}
239
240double DetectorInfo::azimuthal(const size_t index) const {
241 if (isMonitor(index))
242 throw std::logic_error("Azimuthal angle is not defined for monitors");
243
244 const auto samplePos = samplePosition();
245 const auto beamLine = samplePos - sourcePosition();
246
247 if (beamLine.nullVector()) {
248 throw Kernel::Exception::InstrumentDefinitionError("Source and sample are at same position!");
249 }
250
251 const auto sampleDetVec = position(index) - samplePos;
252 const auto beamLineNormalized = Kernel::normalize(beamLine);
253
254 // generate the vertical axis
255 const auto origHorizontal = m_referenceFrame->vecPointingHorizontal();
256 const auto vertical = beamLineNormalized.cross_prod(origHorizontal);
257 if (vertical.scalar_prod(m_referenceFrame->vecPointingUp()) <= 0.)
258 throw std::runtime_error("Failed to create up axis orthogonal to the beam direction");
259
260 // generate the horizontal axis perpendicular to the other two
261 const auto horizontal = vertical.cross_prod(beamLineNormalized);
262 if (origHorizontal.scalar_prod(horizontal) <= 0.)
263 throw std::runtime_error("Failed to create horizontal axis orthogonal to the beam direction");
264
265 const double dotHorizontal = sampleDetVec.scalar_prod(horizontal);
266 const double dotVertical = sampleDetVec.scalar_prod(vertical);
267
268 return atan2(dotVertical, dotHorizontal);
269}
270
271double DetectorInfo::azimuthal(const std::pair<size_t, size_t> &index) const {
272 if (isMonitor(index))
273 throw std::logic_error("Azimuthal angle is not defined for monitors");
274
275 const auto samplePos = samplePosition();
276 const auto beamLine = samplePos - sourcePosition();
277
278 if (beamLine.nullVector()) {
279 throw Kernel::Exception::InstrumentDefinitionError("Source and sample are at same position!");
280 }
281
282 const auto sampleDetVec = position(index) - samplePos;
283 const auto beamLineNormalized = Kernel::normalize(beamLine);
284
285 // generate the vertical axis
286 const auto origHorizontal = m_referenceFrame->vecPointingHorizontal();
287 const auto vertical = beamLineNormalized.cross_prod(origHorizontal);
288 if (vertical.scalar_prod(m_referenceFrame->vecPointingUp()) <= 0.)
289 throw std::runtime_error("Failed to create up axis orthogonal to the beam direction");
290
291 // generate the horizontal axis perpendicular to the other two
292 const auto horizontal = vertical.cross_prod(beamLineNormalized);
293 if (origHorizontal.scalar_prod(horizontal) <= 0.)
294 throw std::runtime_error("Failed to create horizontal axis orthogonal to the beam direction");
295
296 const double dotHorizontal = sampleDetVec.scalar_prod(horizontal);
297 const double dotVertical = sampleDetVec.scalar_prod(vertical);
298
299 return atan2(dotVertical, dotHorizontal);
300}
301
307double DetectorInfo::twoTheta(const size_t index, const Kernel::V3D &observer, const Kernel::V3D &axis) const {
308 return angleFromObserver(position(index), observer, axis);
309}
310
312double DetectorInfo::twoTheta(const std::pair<size_t, size_t> &index, const Kernel::V3D &observer,
313 const Kernel::V3D &axis) const {
314 return angleFromObserver(position(index), observer, axis);
315}
316
322double DetectorInfo::signedTwoTheta(const size_t index, const Kernel::V3D &observer, const Kernel::V3D &axis,
323 const Kernel::V3D &instrumentUp) const {
324 return signedAngleFromObserver(position(index), observer, axis, instrumentUp);
325}
326
328double DetectorInfo::signedTwoTheta(const std::pair<size_t, size_t> &index, const Kernel::V3D &observer,
329 const Kernel::V3D &axis, const Kernel::V3D &instrumentUp) const {
330 return signedAngleFromObserver(position(index), observer, axis, instrumentUp);
331}
332
335double DetectorInfo::signedTwoTheta(const size_t index, const Kernel::V3D &observer, const Kernel::V3D &axis) const {
336 return signedTwoTheta(index, observer, axis, m_referenceFrame->vecThetaSign());
337}
338
341double DetectorInfo::signedTwoTheta(const std::pair<size_t, size_t> &index, const Kernel::V3D &observer,
342 const Kernel::V3D &axis) const {
343 return signedTwoTheta(index, observer, axis, m_referenceFrame->vecThetaSign());
344}
345
351double DetectorInfo::phi(const size_t index) const { return phiOfPosition(position(index)); }
352
354double DetectorInfo::phi(const std::pair<size_t, size_t> &index) const { return phiOfPosition(position(index)); }
355
360double DetectorInfo::phiOffset(const size_t index, const double offset) const {
361 return applyPhiOffset(phi(index), offset);
362}
363
365double DetectorInfo::phiOffset(const std::pair<size_t, size_t> &index, const double offset) const {
366 return applyPhiOffset(phi(index), offset);
367}
368
369std::tuple<double, double, double> DetectorInfo::diffractometerConstants(const size_t index,
370 std::vector<detid_t> &calibratedDets,
371 std::vector<detid_t> &uncalibratedDets) const {
372 const detid_t detectorId = detid(index);
373 auto par = m_parameterInfo->get(index, "DIFC", "double");
374 if (par) {
375 double difc = par->value<double>();
376 calibratedDets.push_back(detectorId);
377 double difa = 0., tzero = 0.;
378 par = m_parameterInfo->get(index, "DIFA", "double");
379 if (par)
380 difa = par->value<double>();
381 par = m_parameterInfo->get(index, "TZERO", "double");
382 if (par)
383 tzero = par->value<double>();
384 return {difa, difc, tzero};
385 } else {
386 // if calibrated difc not available, revert to uncalibrated difc with other
387 // two constants=0
388 uncalibratedDets.push_back(detectorId);
389 double difc = difcUncalibrated(index);
390 return {0., difc, 0.};
391 }
392}
393
394double DetectorInfo::difcUncalibrated(const size_t index) const {
396}
397
398std::pair<double, double> DetectorInfo::geographicalAngles(const size_t index) const {
399 const auto samplePos = samplePosition();
400 const auto sampleDetVec = position(index) - samplePos;
401 const double upCoord = sampleDetVec[m_referenceFrame->pointingUp()];
402 const double beamCoord = sampleDetVec[m_referenceFrame->pointingAlongBeam()];
403 const double leftoverCoord = sampleDetVec[m_referenceFrame->pointingHorizontal()];
404 const double lat = std::atan2(upCoord, std::hypot(leftoverCoord, beamCoord));
405 const double lon = std::atan2(leftoverCoord, beamCoord);
406 return std::pair<double, double>(lat, lon);
407}
408
409std::pair<double, double> DetectorInfo::geographicalAngles(const std::pair<size_t, size_t> &index) const {
410 const auto samplePos = samplePosition();
411 const auto sampleDetVec = position(index) - samplePos;
412 const double upCoord = sampleDetVec[m_referenceFrame->pointingUp()];
413 const double beamCoord = sampleDetVec[m_referenceFrame->pointingAlongBeam()];
414 const double leftoverCoord = sampleDetVec[m_referenceFrame->pointingHorizontal()];
415 const double lat = std::atan2(upCoord, std::hypot(leftoverCoord, beamCoord));
416 const double lon = std::atan2(leftoverCoord, beamCoord);
417 return std::pair<double, double>(lat, lon);
418}
419
422
424Kernel::V3D DetectorInfo::position(const std::pair<size_t, size_t> &index) const {
425 return Kernel::toV3D(m_detectorInfo->position(index));
426}
427
429std::vector<Kernel::V3D> DetectorInfo::allPositions() const {
430 std::vector<Kernel::V3D> positions;
431 positions.reserve(size());
432 for (size_t i = 0; i < size(); ++i) {
433 positions.push_back(position(i));
434 }
435 return positions;
436}
437
440 return Kernel::toQuat(m_detectorInfo->rotation(index));
441}
442
444Kernel::Quat DetectorInfo::rotation(const std::pair<size_t, size_t> &index) const {
445 return Kernel::toQuat(m_detectorInfo->rotation(index));
446}
447
449std::vector<Kernel::Quat> DetectorInfo::allRotations() const {
450 std::vector<Kernel::Quat> rotations;
451 rotations.reserve(size());
452 for (size_t i = 0; i < size(); ++i) {
453 rotations.push_back(rotation(i));
454 }
455 return rotations;
456}
457
459std::vector<Kernel::V3D> DetectorInfo::allScaleFactors() const {
460 std::vector<Kernel::V3D> scaleFactors;
461 scaleFactors.reserve(size());
462 for (size_t i = 0; i < size(); ++i) {
463 const auto scale = m_detectorInfo->scaleFactor(i);
464 scaleFactors.push_back(Kernel::toV3D(scale));
465 }
466 return scaleFactors;
467}
468
470void DetectorInfo::setMasked(const size_t index, bool masked) { m_detectorInfo->setMasked(index, masked); }
471
473void DetectorInfo::setMasked(const std::pair<size_t, size_t> &index, bool masked) {
474 m_detectorInfo->setMasked(index, masked);
475}
476
482 for (size_t i = 0; i < size(); ++i)
483 m_detectorInfo->setMasked(i, false);
484}
485
492
494void DetectorInfo::setPosition(const std::pair<size_t, size_t> &index, const Kernel::V3D &position) {
497}
498
499// Clear any parameters whose value is only valid for specific positions
500// Currently diffractometer constants
502 m_parameterInfo->clearParametersByName(index, "DIFA");
503 m_parameterInfo->clearParametersByName(index, "DIFC");
504 m_parameterInfo->clearParametersByName(index, "TZERO");
505}
506
511
513void DetectorInfo::setRotation(const std::pair<size_t, size_t> &index, const Kernel::Quat &rotation) {
515}
516
519 GNU_DIAG_OFF("deprecated-declarations")
520 MSVC_DIAG_OFF(4996)
521 return getDetector(index);
522 MSVC_DIAG_ON(4996)
523 GNU_DIAG_ON("deprecated-declarations")
524}
525
528
531
533double DetectorInfo::l1() const { return m_detectorInfo->l1(); }
534
536const std::vector<detid_t> &DetectorInfo::detectorIDs() const { return *m_detectorIDs; }
537
538std::size_t DetectorInfo::indexOf(const detid_t id) const {
539 try {
540 return m_detIDToIndex->at(id);
541 } catch (const std::out_of_range &) {
542 std::stringstream msg;
543 msg << "Failed to find detector with id=" << id;
544 throw std::out_of_range(msg.str());
545 }
546}
547
550detid_t DetectorInfo::detid(const size_t index) const {
551 return (*m_detectorIDs).at(m_detectorInfo->compactDetectorIndex(index));
552}
553
555size_t DetectorInfo::scanCount() const { return m_detectorInfo->scanCount(); }
556
561const std::vector<std::pair<Types::Core::DateAndTime, Types::Core::DateAndTime>> DetectorInfo::scanIntervals() const {
562 const auto &intervals = m_detectorInfo->scanIntervals();
563 return {intervals.begin(), intervals.end()};
564}
565
567
569
571 auto thread = static_cast<size_t>(PARALLEL_THREAD_NUMBER);
572 if (m_lastIndex[thread] != index) {
573 m_lastIndex[thread] = index;
574 try {
575 m_lastDetector[thread] = m_instrument->getDetector(detid(index));
576 } catch (...) {
577 // Reset so a future call for this index retries rather than returning
578 // whatever stale pointer m_lastDetector holds from a previous access.
579 m_lastIndex[thread] = -1;
580 throw;
581 }
582 }
583
584 return *m_lastDetector[thread];
585}
586
588std::shared_ptr<const Geometry::IDetector> DetectorInfo::getDetectorPtr(const size_t index) const {
589 auto thread = static_cast<size_t>(PARALLEL_THREAD_NUMBER);
590 GNU_DIAG_OFF("deprecated-declarations")
591 MSVC_DIAG_OFF(4996)
592 static_cast<void>(getDetector(index));
593 MSVC_DIAG_ON(4996)
594 GNU_DIAG_ON("deprecated-declarations")
595 return m_lastDetector[thread];
596}
597
598// Begin method for iterator
600
601// End method for iterator
603
608 const size_t n = size();
609 // Beamline::DetectorInfo holds the core position/rotation/flag arrays
610 const size_t beamlineMem = m_detectorInfo->getMemorySize();
611 // m_detectorIDs: shared_ptr<const vector<detid_t>> — count the heap-allocated vector object + its buffer
612 const size_t detectorIDsMem = sizeof(std::vector<detid_t>) + n * sizeof(detid_t);
613 // m_detIDToIndex: shared_ptr<const unordered_map<detid_t, size_t>>
614 // Count the heap-allocated map object + each node (key + value + ~2 pointers for bucket/chain overhead)
615 const size_t detIDToIndexMem =
616 sizeof(std::unordered_map<detid_t, size_t>) + n * (sizeof(detid_t) + sizeof(size_t) + 2 * sizeof(void *));
617 // m_lastDetector and m_lastIndex: one slot per OpenMP thread
618 const size_t cacheMem = m_lastDetector.capacity() * sizeof(std::shared_ptr<const Geometry::IDetector>) +
619 m_lastIndex.capacity() * sizeof(size_t);
620
621 // m_parameterInfo is a shared_ptr to the ParameterMap already held in ComponentInfo; only count the pointer wrapper
622 const size_t paramInfoSize = sizeof(std::shared_ptr<Geometry::ParameterInfo>);
623 // m_referenceFrame is a shared_ptr to the ReferenceFrame already held by instrument; only count the pointer wrapper
624 const size_t refFrameSize = sizeof(std::shared_ptr<Geometry::ReferenceFrame const>);
625 // m_instrument is a shared_ptr to an Instrument owned by the workspace; its memory is counted in
626 // Instrument::getMemorySize() and excluded here to avoid double-counting.
627 return sizeof(*this) + beamlineMem + detectorIDsMem + detIDToIndexMem + cacheMem + paramInfoSize + refFrameSize;
628}
629
630} // namespace Mantid::Geometry
const std::vector< double > & rhs
double position
Definition GetAllEi.cpp:154
std::map< DeltaEMode::Type, std::string > index
#define PARALLEL_THREAD_NUMBER
#define PARALLEL_GET_MAX_THREADS
Mantid::Kernel::Quat(ComponentInfo::* rotation)(const size_t) const
#define MSVC_DIAG_ON(x)
#define MSVC_DIAG_OFF(x)
#define GNU_DIAG_ON(x)
#define GNU_DIAG_OFF(x)
This is a collection of macros for turning compiler warnings off in a controlled manner.
Geometry::DetectorInfo is an intermediate step towards a DetectorInfo that is part of Instrument-2....
void clearPositionDependentParameters(const size_t index)
double twoTheta(const size_t index) const
Returns 2 theta (scattering angle w.r.t. to beam direction).
std::shared_ptr< std::vector< detid_t > const > m_detectorIDs
size_t scanCount() const
Returns the scan count of the detector with given detector index.
void setPosition(const size_t index, const Kernel::V3D &position)
Set the absolute position of the detector with given index. Not thread safe.
double l2(const size_t index) const
Returns L2 (distance from sample to spectrum).
std::vector< Kernel::Quat > allRotations() const
Returns the absolute rotations of all detectors in a vector ordered by index.
const Geometry::IDetector & getDetector(const size_t index) const
std::shared_ptr< Geometry::ReferenceFrame const > m_referenceFrame
Kernel::V3D samplePosition() const
Returns the sample position.
std::pair< double, double > geographicalAngles(const size_t index) const
std::shared_ptr< std::unordered_map< detid_t, size_t > const > m_detIDToIndex
DetectorInfo(std::unique_ptr< Beamline::DetectorInfo > detectorInfo, std::shared_ptr< const Geometry::Instrument > instrument, std::shared_ptr< const std::vector< detid_t > > detectorIds, std::shared_ptr< const std::unordered_map< detid_t, size_t > > detIdToIndexMap, std::shared_ptr< ParameterInfo > parameterInfo, std::shared_ptr< ReferenceFrame const > referenceFrame)
Construct DetectorInfo based on an Instrument.
double phiOffset(const size_t index, const double offset) const
Returns phi() reflected about offset (radians): offset - phi for phi >= 0 and -(offset + phi) otherwi...
DetectorInfoIterator< DetectorInfo > end()
bool hasMaskedDetectors() const
Returns true if there are masked detectors.
Kernel::Quat rotation(const size_t index) const
Returns the rotation of the detector with given index.
bool isMasked(const size_t index) const
Returns true if the detector is masked.
void setMasked(const size_t index, bool masked)
Set the mask flag of the detector with given index. Not thread safe.
std::vector< Kernel::V3D > allPositions() const
Returns the absolute positions of all detectors in a vector ordered by index.
const std::vector< detid_t > & detectorIDs() const
Returns a sorted vector of all detector IDs.
Kernel::V3D position(const size_t index) const
Returns the position of the detector with given index.
size_t getMemorySize() const
Return memory used by the detector info, in bytes.
std::shared_ptr< Geometry::Instrument const > m_instrument
std::shared_ptr< Geometry::ParameterInfo > m_parameterInfo
void clearMaskFlags()
Sets all mask flags to false (unmasked).
bool isEquivalent(const DetectorInfo &other) const
Returns true if the content of this is equivalent to the content of other.
const DetectorInfoIterator< const DetectorInfo > cend() const
std::vector< std::shared_ptr< const Geometry::IDetector > > m_lastDetector
double signedTwoTheta(const size_t index) const
Returns signed 2 theta (signed scattering angle w.r.t. to beam direction).
double l1() const
Returns L1 (distance from source to sample).
void setRotation(const size_t index, const Kernel::Quat &rotation)
Set the absolute rotation of the detector with given index. Not thread safe.
std::vector< size_t > m_lastIndex
double phi(const size_t index) const
Returns the angle of the detector position about the lab-frame z axis, atan2(y, x),...
Kernel::V3D sourcePosition() const
Returns the source position.
std::tuple< double, double, double > diffractometerConstants(const size_t index, std::vector< detid_t > &calibratedDets, std::vector< detid_t > &uncalibratedDets) const
const Geometry::IDetector & detector(const size_t index) const
Return a const reference to the detector with given index.
const DetectorInfoIterator< const DetectorInfo > cbegin() const
std::vector< Kernel::V3D > allScaleFactors() const
Returns the scale factors of all detectors in a vector ordered by index.
size_t indexOf(const detid_t id) const
Returns the index of the detector with the given detector ID.
size_t size() const
Returns the size of the DetectorInfo, i.e., the number of detectors in the instrument.
DetectorInfoIterator< DetectorInfo > begin()
std::unique_ptr< Beamline::DetectorInfo > m_detectorInfo
Pointer to the actual DetectorInfo object (non-wrapping part).
bool isMonitor(const size_t index) const
Returns true if the detector is a monitor.
bool isScanning() const
Returns true if the beamline has scanning detectors.
double azimuthal(const size_t index) const
DetectorInfo & operator=(const DetectorInfo &rhs)
Assigns the contents of the non-wrapping part of rhs to this.
double difcUncalibrated(const size_t index) const
detid_t detid(const size_t index) const
Returns the detector ID for the given logical detector index.
const std::vector< std::pair< Types::Core::DateAndTime, Types::Core::DateAndTime > > scanIntervals() const
Returns the scan interval of the detector with given index.
std::shared_ptr< const Geometry::IDetector > getDetectorPtr(const size_t index) const
Helper used by SpectrumInfo.
Interface class for detector objects.
Definition IDetector.h:37
Exception for errors associated with the instrument definition.
Definition Exception.h:220
Class for quaternions.
Definition Quat.h:38
Class for 3D vectors.
Definition V3D.h:35
DetectorInfoIterator< DetectorInfo > DetectorInfoIt
DetectorInfoIterator< const DetectorInfo > DetectorInfoConstIt
MANTID_KERNEL_DLL double tofToDSpacingFactor(const double l1, const double l2, const double twoTheta, const double offset)
Calculate and return conversion factor from tof to d-spacing.
Definition Unit.cpp:589
Kernel::Quat toQuat(const Eigen::Quaterniond &quat)
Converts Eigen::Quaterniond to Kernel::Quat.
Eigen::Vector3d toVector3d(const Kernel::V3D &vec)
Converts Kernel::V3D to Eigen::Vector3d.
Kernel::V3D toV3D(const Eigen::Vector3d &vec)
This header provides conversion helpers between vector and rotation types in MantidKernel and equival...
MANTID_KERNEL_DLL V3D normalize(V3D v)
Normalizes a V3D.
Definition V3D.h:353
Eigen::Quaterniond toQuaterniond(const Kernel::Quat &quat)
Converts Kernel::Quat to Eigen::Quaterniond.
int32_t detid_t
Typedef for a detector ID.
STL namespace.