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 "MantidGeometry/DllConfig.h"
12#include <Eigen/Geometry>
13#include <Eigen/StdVector>
14#include <cstddef>
15#include <memory>
16#include <unordered_map>
17#include <utility>
18
19namespace Mantid {
20using detid_t = int32_t;
21namespace Beamline {
22class ComponentInfo;
23class DetectorInfo;
24} // namespace Beamline
25namespace Geometry {
26class ComponentInfo;
27class DetectorInfo;
28class ICompAssembly;
29class IComponent;
30class IDetector;
31class IObjComponent;
32class Instrument;
33class IObject;
34class ParameterMap;
35class RectangularDetector;
36class ObjCompAssembly;
37
47class MANTID_GEOMETRY_DLL InstrumentVisitor : public Mantid::Geometry::ComponentVisitor {
48private:
50 std::shared_ptr<std::vector<detid_t>> m_orderedDetectorIds;
51
53 std::shared_ptr<std::vector<Mantid::Geometry::IComponent *>> m_componentIds;
54
56 std::shared_ptr<std::vector<size_t>> m_assemblySortedDetectorIndices;
57
59 std::shared_ptr<std::vector<size_t>> m_assemblySortedComponentIndices;
60
62 std::shared_ptr<std::vector<size_t>> m_parentComponentIndices;
63
65 std::shared_ptr<std::vector<std::vector<size_t>>> m_children;
66
68 std::shared_ptr<std::vector<std::pair<size_t, size_t>>> m_detectorRanges;
69
71 std::shared_ptr<std::vector<std::pair<size_t, size_t>>> m_componentRanges;
72
74 std::shared_ptr<std::unordered_map<Mantid::Geometry::IComponent *, size_t>> m_componentIdToIndexMap;
75
77 std::shared_ptr<const std::unordered_map<detid_t, size_t>> m_detectorIdToIndexMap;
78
80 std::shared_ptr<std::vector<Eigen::Vector3d>> m_positions;
81
83 std::shared_ptr<std::vector<Eigen::Vector3d>> m_detectorPositions;
84
86 std::shared_ptr<std::vector<Eigen::Quaterniond, Eigen::aligned_allocator<Eigen::Quaterniond>>> m_rotations;
87
89 std::shared_ptr<std::vector<Eigen::Quaterniond, Eigen::aligned_allocator<Eigen::Quaterniond>>> m_detectorRotations;
90
92 std::shared_ptr<std::vector<size_t>> m_monitorIndices;
93
95 std::shared_ptr<const Mantid::Geometry::Instrument> m_instrument;
96
99
102
105
107 int64_t m_sourceIndex = -1;
108
110 int64_t m_sampleIndex = -1;
111
113 std::shared_ptr<const Mantid::Geometry::IObject> m_nullShape;
114
116 std::shared_ptr<std::vector<std::shared_ptr<const Mantid::Geometry::IObject>>> m_shapes;
117
119 std::shared_ptr<std::vector<Eigen::Vector3d>> m_scaleFactors;
120
122 std::shared_ptr<std::vector<Beamline::ComponentType>> m_componentType;
123
125 std::shared_ptr<std::vector<std::string>> m_names;
126
127 void markAsSourceOrSample(Mantid::Geometry::IComponent *componentId, const size_t componentIndex);
128
129 std::pair<std::unique_ptr<ComponentInfo>, std::unique_ptr<DetectorInfo>> makeWrappers() const;
130
132 size_t commonRegistration(const Mantid::Geometry::IComponent &component);
133
134public:
135 InstrumentVisitor(std::shared_ptr<const Instrument> instrument);
136
137 void walkInstrument();
138
139 virtual size_t registerComponentAssembly(const Mantid::Geometry::ICompAssembly &assembly) override;
140
141 virtual size_t registerGenericComponent(const Mantid::Geometry::IComponent &component) override;
142
143 virtual size_t registerInfiniteComponent(const Mantid::Geometry::IComponent &component) override;
144
145 virtual size_t registerGenericObjComponent(const Mantid::Geometry::IObjComponent &objComponent) override;
146
147 virtual size_t registerGridBank(const Mantid::Geometry::ICompAssembly &bank) override;
148
149 virtual size_t registerRectangularBank(const Mantid::Geometry::ICompAssembly &bank) override;
150
151 virtual size_t registerInfiniteObjComponent(const IObjComponent &objComponent) override;
152
153 virtual size_t registerStructuredBank(const Mantid::Geometry::ICompAssembly &bank) override;
154
155 virtual size_t registerDetector(const Mantid::Geometry::IDetector &detector) override;
156
157 virtual size_t registerObjComponentAssembly(const ObjCompAssembly &obj) override;
158
159 std::shared_ptr<const std::vector<Mantid::Geometry::IComponent *>> componentIds() const;
160
161 std::shared_ptr<const std::unordered_map<Mantid::Geometry::IComponent *, size_t>> componentIdToIndexMap() const;
162
163 std::shared_ptr<const std::unordered_map<detid_t, size_t>> detectorIdToIndexMap() const;
164 size_t size() const;
165
166 bool isEmpty() const;
167
168 std::unique_ptr<Beamline::ComponentInfo> componentInfo() const;
169 std::unique_ptr<Beamline::DetectorInfo> detectorInfo() const;
170
171 std::shared_ptr<std::vector<detid_t>> detectorIds() const;
172
173 static std::pair<std::unique_ptr<ComponentInfo>, std::unique_ptr<DetectorInfo>>
174 makeWrappers(const Instrument &instrument, ParameterMap *pmap = nullptr);
175};
176} // namespace Geometry
177} // namespace Mantid
double obj
the value of the quadratic function
ComponentVisitor : Visitor for IComponents.
Class for Assembly of geometric components.
Definition: ICompAssembly.h:30
base class for Geometric IComponent
Definition: IComponent.h:51
Interface class for detector objects.
Definition: IDetector.h:43
Object Component class, this class brings together the physical attributes of the component to the po...
Definition: IObjComponent.h:37
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::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::vector< Eigen::Vector3d > > m_scaleFactors
Scale factors.
std::shared_ptr< std::unordered_map< Mantid::Geometry::IComponent *, size_t > > m_componentIdToIndexMap
Component ID -> Component Index map.
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.
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::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:47
Class for Assembly of geometric components.
Helper class which provides the Collimation Length for SANS instruments.
int32_t detid_t
Typedef for a detector ID.
Definition: SpectrumInfo.h:21
Generate a tableworkspace to store the calibration results.