38 using Beamline::ComponentType;
39 std::queue<size_t> compQueue;
40 for (
auto const child : compInfo.children(compInfo.root()))
41 compQueue.push(child);
43 bool foundRect =
false;
44 while (!compQueue.empty()) {
45 size_t const index = compQueue.front();
54 if (
name ==
"chopper-position" ||
name.substr(0, 4) ==
"slit" ||
name ==
"supermirror")
58 if (type == ComponentType::Rectangular) {
60 }
else if (type == ComponentType::Unstructured || type == ComponentType::Grid ||
61 type == ComponentType::Structured || type == ComponentType::OutlineComposite) {
63 for (
auto const child : compInfo.children(
index))
64 compQueue.push(child);
75 const auto convention = Kernel::ConfigService::Instance().getString(
"Q.convention");
76 return (convention ==
"Crystallography") ? -1.0 : 1.0;
88 : m_usingFullRayTrace(containsOnlyRectDetectors(compInfo, detInfo)), m_crystallography_convention(
getQSign()),
89 m_compInfo(compInfo), m_detInfo(detInfo) {
104 m_rayTracer = std::make_unique<InstrumentRayTracer>(compInfo, detInfo);
111 std::vector<Eigen::Vector3d> points;
116 auto beam = frame->vecPointingAlongBeam();
117 auto up = frame->vecPointingUp();
119 for (
size_t pointNo = 0; pointNo <
m_detInfo.
size(); ++pointNo) {
127 const auto norm =
E1.norm();
134 Eigen::Vector3d point(
E1[0],
E1[1],
E1[2]);
137 if (point.hasNaN() || up.coLinear(beam, pos))
140 points.emplace_back(point);
158 return std::make_tuple(
false, 0);
179 auto const detIndex =
m_rayTracer->getDetectorResult();
182 return std::make_tuple(
false, 0);
184 return std::make_tuple(
true, detIndex);
202 if (neighbours.empty()) {
204 return std::make_tuple(
false, 0);
208 const auto hitDetector = std::get<0>(result);
209 const auto index = std::get<1>(result);
218 return std::make_tuple(
false, 0);
235 const auto gap =
static_cast<double>(gaps.front());
238 for (
int i = 0; i < 3; i++) {
239 auto gapDir =
V3D(0., 0., 0.);
242 auto beam1 =
normalize(detectorDir + gapDir);
244 const auto hit1 = std::get<0>(result1);
246 const auto beam2 =
normalize(detectorDir - gapDir);
248 const auto hit2 = std::get<0>(result2);
252 return std::make_tuple(
true,
m_indexMap[std::get<1>(result1)]);
257 return std::make_tuple(
false, 0);
271 for (
const auto &neighbour : neighbours) {
272 const auto index = std::get<1>(neighbour);
286 unRotate.
rotate(trackStart);
288 unRotate.
rotate(trackDirection);
293 return std::make_tuple(hitDetector,
index);
296 return std::make_tuple(
false, 0);
305 const auto norm_q = q.
norm();
307 const V3D refBeamDir = refFrame->vecPointingAlongBeam();
310 double one_over_wl = (norm_q * norm_q) / (2.0 * qBeam);
313 detectorDir[refFrame->pointingAlongBeam()] = one_over_wl - qBeam;
std::map< DeltaEMode::Type, std::string > index
DetectorSearcher(const Geometry::ComponentInfo &compInfo, const Geometry::DetectorInfo &detInfo)
Create a new DetectorSearcher with the given instrument & detectors.
DetectorSearchResult searchUsingNearestNeighbours(const Kernel::V3D &q)
Attempt to find a detector using a nearest neighbours search strategy.
DetectorSearchResult handleTubeGap(const Kernel::V3D &detectorDir, const Kernel::NearestNeighbours< 3 >::NearestNeighbourResults &neighbours)
Helper function to handle the tube gap parameter in tube instruments.
DetectorSearchResult findDetectorIndex(const Kernel::V3D &q)
Find a detector that intsects with the given Qlab vector.
std::tuple< bool, size_t > DetectorSearchResult
Search result type representing whether a detector was found and if so which detector index it was.
const double m_crystallography_convention
flag for whether the crystallography convention is to be used
std::unique_ptr< Geometry::InstrumentRayTracer > m_rayTracer
instrument ray tracer object for searching in rectangular detectors
DetectorSearchResult searchUsingInstrumentRayTracing(const Kernel::V3D &q)
Attempt to find a detector using a full instrument ray tracing strategy.
std::unique_ptr< Kernel::NearestNeighbours< 3 > > m_detectorCacheSearch
Detector search cache for fast look-up of detectors.
std::vector< size_t > m_indexMap
vector of detector indicies used in the search
Kernel::V3D convertQtoDirection(const Kernel::V3D &q) const
Helper function to convert a Qlab vector to a direction in detector space.
const Geometry::ComponentInfo & m_compInfo
component info for the instrument
std::tuple< bool, size_t > checkInteceptWithNeighbours(const Kernel::V3D &direction, const Kernel::NearestNeighbours< 3 >::NearestNeighbourResults &neighbours) const
Check whether the given direction in detector space intercepts with a detector.
const bool m_usingFullRayTrace
flag for whether to use InstrumentRayTracer or NearestNeighbours
const Geometry::DetectorInfo & m_detInfo
detector info for the instrument
void createDetectorCache()
Helper function to build the nearest neighbour tree.
A simple structure that defines an axis-aligned cuboid shaped bounding box for a geometrical object.
bool doesLineIntersect(const Track &track) const
Does a specified track intersect the bounding box.
ComponentInfo : Provides a component centric view on to the instrument.
std::shared_ptr< const ReferenceFrame > referenceFrame() const
The instrument's reference frame: which axes point up and along the beam, and its handedness.
bool hasParameter(const size_t componentIndex, const std::string &name, bool recursive=true) const
Returns empty (or false) if the ComponentInfo was built without parameters or the parameter is unset.
bool hasValidShape(const size_t componentIndex) const
std::vector< double > getNumberParameter(const size_t componentIndex, const std::string &name, bool recursive=true) const
bool isDetector(const size_t componentIndex) const
const std::string & name(const size_t componentIndex) const
static constexpr size_t invalidIndex
Returned by indexOfOrInvalid() for a component ID that is not part of this instrument.
const Geometry::IObject & shape(const size_t componentIndex) const
Beamline::ComponentType componentType(const size_t componentIndex) const
Geometry::DetectorInfo is an intermediate step towards a DetectorInfo that is part of Instrument-2....
Kernel::V3D samplePosition() const
Returns the sample position.
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.
Kernel::V3D position(const size_t index) const
Returns the position of the detector with given index.
size_t size() const
Returns the size of the DetectorInfo, i.e., the number of detectors in the instrument.
bool isMonitor(const size_t index) const
Returns true if the detector is a monitor.
virtual int interceptSurface(Geometry::Track &) const =0
This class is responsible for tracking rays and accumulating a list of objects that are intersected a...
Defines a track as a start point and a direction.
const Kernel::V3D & startPoint() const
Returns the starting point.
const Kernel::V3D & direction() const
Returns the direction as a unit vector.
Exception thrown when an attempt is made to dereference a null pointer.
The Logger class is in charge of the publishing messages from the framework through various channels.
void information(const std::string &msg)
Logs at information level.
std::vector< std::tuple< VectorType, size_t, double > > NearestNeighbourResults
void inverse()
Inverse a quaternion (in the sense of rotation inversion)
constexpr double scalar_prod(const V3D &v) const noexcept
Calculates the cross product.
double normalize()
Make a normalized vector (return norm value)
void rotate(const Matrix< double > &) noexcept
Rotate a point by a matrix.
double norm() const noexcept
bool nullVector(const double tolerance=1e-3) const noexcept
Determine if the point is null.
std::complex< double > MANTID_API_DLL E1(std::complex< double > z)
Integral for Gamma.
Kernel::Logger g_log("ExperimentInfo")
static logger object
MANTID_KERNEL_DLL V3D normalize(V3D v)
Normalizes a V3D.
Helper class which provides the Collimation Length for SANS instruments.