Mantid
Loading...
Searching...
No Matches
InstrumentVisitor.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2017 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#include "MantidBeamline/ComponentType.h"
10#include "MantidBeamline/PixelGridComponent.h"
11#include "MantidBeamline/StructuredGridComponent.h"
12#include "MantidGeometry/DllConfig.h"
14#include <Eigen/Geometry>
15#include <Eigen/StdVector>
16#include <cstddef>
17#include <map>
18#include <memory>
19#include <unordered_map>
20#include <utility>
21
22namespace Mantid {
23using detid_t = int32_t;
24namespace Beamline {
25class ComponentInfo;
26class DetectorInfo;
27} // namespace Beamline
28namespace Geometry {
29class ComponentInfo;
30class DetectorInfo;
31class ICompAssembly;
32class IComponent;
33class IDetector;
34class IObjComponent;
35class Instrument;
36class IObject;
37class ParameterInfo;
38class ParameterMap;
39class RectangularDetector;
40class ObjCompAssembly;
41
51class MANTID_GEOMETRY_DLL InstrumentVisitor : public Mantid::Geometry::ComponentVisitor {
52private:
54 std::shared_ptr<std::vector<detid_t>> m_orderedDetectorIds;
55
57 std::shared_ptr<std::vector<Mantid::Geometry::IComponent *>> m_componentIds;
58
60 std::shared_ptr<std::vector<size_t>> m_assemblySortedDetectorIndices;
61
63 std::shared_ptr<std::vector<size_t>> m_assemblySortedComponentIndices;
64
66 std::shared_ptr<std::vector<size_t>> m_parentComponentIndices;
67
69 std::shared_ptr<std::vector<std::vector<size_t>>> m_children;
70
72 std::shared_ptr<std::vector<std::pair<size_t, size_t>>> m_detectorRanges;
73
75 std::shared_ptr<std::vector<std::pair<size_t, size_t>>> m_componentRanges;
76
78 std::shared_ptr<std::unordered_map<Mantid::Geometry::IComponent const *, size_t>> m_componentIdToIndexMap;
79
81 std::shared_ptr<const std::unordered_map<detid_t, size_t>> m_detectorIdToIndexMap;
82
84 std::shared_ptr<std::vector<Eigen::Vector3d>> m_positions;
85
87 std::shared_ptr<std::vector<Eigen::Vector3d>> m_detectorPositions;
88
90 std::shared_ptr<std::vector<Eigen::Quaterniond, Eigen::aligned_allocator<Eigen::Quaterniond>>> m_rotations;
91
93 std::shared_ptr<std::vector<Eigen::Quaterniond, Eigen::aligned_allocator<Eigen::Quaterniond>>> m_detectorRotations;
94
96 std::shared_ptr<std::vector<size_t>> m_monitorIndices;
97
99 std::shared_ptr<const Mantid::Geometry::Instrument> m_instrument;
100
103
106
109
111 int64_t m_sourceIndex = -1;
112
114 int64_t m_sampleIndex = -1;
115
117 std::shared_ptr<const Mantid::Geometry::IObject> m_nullShape;
118
120 std::shared_ptr<std::vector<std::shared_ptr<const Mantid::Geometry::IObject>>> m_shapes;
121
123 std::shared_ptr<std::vector<Eigen::Vector3d>> m_scaleFactors;
124
126 std::shared_ptr<std::vector<Beamline::ComponentType>> m_componentType;
127
129 std::shared_ptr<std::vector<std::string>> m_names;
130
132 std::shared_ptr<std::map<size_t, Eigen::Vector2d>> m_sideBySideViewPositions;
133
135 std::shared_ptr<std::map<size_t, Beamline::PixelGridComponent>> m_pixelGridComponents;
136
138 std::shared_ptr<std::map<size_t, Beamline::StructuredGridComponent>> m_structuredGridComponents;
139
140 void markAsSourceOrSample(Mantid::Geometry::IComponent *componentId, const size_t componentIndex);
141
143 std::shared_ptr<ParameterInfo> makeParameterInfo() const;
144
146 size_t commonRegistration(const Mantid::Geometry::IComponent &component);
147
148public:
149 InstrumentVisitor(std::shared_ptr<const Instrument> instrument);
150
151 void walkInstrument();
152
153 virtual size_t registerComponentAssembly(const Mantid::Geometry::ICompAssembly &assembly) override;
154
155 virtual size_t registerGenericComponent(const Mantid::Geometry::IComponent &component) override;
156
157 virtual size_t registerInfiniteComponent(const Mantid::Geometry::IComponent &component) override;
158
159 virtual size_t registerGenericObjComponent(const Mantid::Geometry::IObjComponent &objComponent) override;
160
161 virtual size_t registerGridBank(const Mantid::Geometry::ICompAssembly &bank) override;
162
163 virtual size_t registerRectangularBank(const Mantid::Geometry::ICompAssembly &bank) override;
164
165 virtual size_t registerInfiniteObjComponent(const IObjComponent &objComponent) override;
166
167 virtual size_t registerStructuredBank(const Mantid::Geometry::ICompAssembly &bank) override;
168
169 virtual size_t registerDetector(const Mantid::Geometry::IDetector &detector) override;
170
171 virtual size_t registerObjComponentAssembly(const ObjCompAssembly &obj) override;
172
173 std::shared_ptr<const std::vector<Mantid::Geometry::IComponent *>> componentIds() const;
174
175 std::shared_ptr<const std::unordered_map<Mantid::Geometry::IComponent const *, size_t>> componentIdToIndexMap() const;
176
177 std::shared_ptr<const std::unordered_map<detid_t, size_t>> detectorIdToIndexMap() const;
178 size_t size() const;
179
180 bool isEmpty() const;
181
182 std::unique_ptr<Beamline::ComponentInfo> componentInfo() const;
183 std::unique_ptr<Beamline::DetectorInfo> detectorInfo() const;
184
185 std::shared_ptr<std::vector<detid_t>> detectorIds() const;
186
189 std::pair<std::unique_ptr<ComponentInfo>, std::unique_ptr<DetectorInfo>> makeWrappers() const;
190
191 static std::pair<std::unique_ptr<ComponentInfo>, std::unique_ptr<DetectorInfo>>
192 makeWrappers(const Instrument &instrument, ParameterMap *pmap = nullptr);
193};
194} // namespace Geometry
195} // namespace Mantid
double obj
the value of the quadratic function
ComponentVisitor : Visitor for IComponents.
Class for Assembly of geometric components.
base class for Geometric IComponent
Definition IComponent.h:53
Interface class for detector objects.
Definition IDetector.h:37
Object Component class, this class brings together the physical attributes of the component to the po...
InstrumentVisitor : Visitor for components with access to Info wrapping features.
std::shared_ptr< std::vector< std::pair< size_t, size_t > > > m_detectorRanges
Only Assemblies and other NON-detectors yield detector ranges.
std::shared_ptr< const std::unordered_map< detid_t, size_t > > m_detectorIdToIndexMap
Detector ID -> index mappings.
std::shared_ptr< std::vector< size_t > > m_assemblySortedComponentIndices
Component indexes sorted by assembly.
Mantid::Geometry::ParameterMap * m_pmap
Parameter map to purge.
std::shared_ptr< std::map< size_t, Beamline::StructuredGridComponent > > m_structuredGridComponents
Pixel counts, ID numbering and pixel vertices of Structured banks, keyed by component index.
std::shared_ptr< std::vector< detid_t > > m_orderedDetectorIds
Detector indices.
std::shared_ptr< const Mantid::Geometry::IObject > m_nullShape
Null shared (empty shape)
std::shared_ptr< std::vector< Eigen::Quaterniond, Eigen::aligned_allocator< Eigen::Quaterniond > > > m_rotations
Rotations for non-detectors.
std::shared_ptr< std::vector< size_t > > m_assemblySortedDetectorIndices
Detector indexes sorted by assembly.
std::shared_ptr< std::vector< std::pair< size_t, size_t > > > m_componentRanges
Component ranges.
std::shared_ptr< std::vector< Eigen::Vector3d > > m_positions
Positions for non-detectors.
std::shared_ptr< std::vector< std::shared_ptr< const Mantid::Geometry::IObject > > > m_shapes
Shapes stored in fly-weight fashion.
std::shared_ptr< std::vector< std::vector< size_t > > > m_children
Stores instrument tree structure by storing children of all Components.
std::shared_ptr< std::map< size_t, Eigen::Vector2d > > m_sideBySideViewPositions
Side-by-side (unwrapped) instrument-view positions when declared in the IDF.
std::shared_ptr< std::vector< Eigen::Vector3d > > m_scaleFactors
Scale factors.
std::shared_ptr< std::vector< Mantid::Geometry::IComponent * > > m_componentIds
Detectors components always specified first.
std::shared_ptr< std::vector< Eigen::Vector3d > > m_detectorPositions
Positions for detectors.
std::shared_ptr< std::vector< Beamline::ComponentType > > m_componentType
Structured bank flag.
std::shared_ptr< std::map< size_t, Beamline::PixelGridComponent > > m_pixelGridComponents
Rectangular/Grid bank pixel-grid metadata.
Mantid::Geometry::IComponent * m_sourceId
Source id to look for.
std::shared_ptr< std::vector< std::string > > m_names
Component names.
Mantid::Geometry::IComponent * m_sampleId
Sample id to look for.
std::shared_ptr< const Mantid::Geometry::Instrument > m_instrument
Instrument to build around.
std::shared_ptr< std::vector< size_t > > m_parentComponentIndices
Index of the parent component.
std::shared_ptr< std::unordered_map< Mantid::Geometry::IComponent const *, size_t > > m_componentIdToIndexMap
Component ID -> Component Index map.
std::shared_ptr< std::vector< size_t > > m_monitorIndices
Monitor indexes for detectors.
std::shared_ptr< std::vector< Eigen::Quaterniond, Eigen::aligned_allocator< Eigen::Quaterniond > > > m_detectorRotations
Rotations for detectors.
Base Instrument Class.
Definition Instrument.h:50
Class for Assembly of geometric components.
Parameter map iterator typedef.
Helper class which provides the Collimation Length for SANS instruments.
int32_t detid_t
Typedef for a detector ID.
Generate a tableworkspace to store the calibration results.