8#include "MantidBeamline/ComponentInfo.h"
9#include "MantidBeamline/DetectorInfo.h"
30std::shared_ptr<const std::unordered_map<detid_t, size_t>> makeDetIdToIndexMap(
const std::vector<detid_t> &detIds) {
32 const size_t nDetIds = detIds.size();
33 auto detIdToIndex = std::make_shared<std::unordered_map<detid_t, size_t>>();
34 detIdToIndex->reserve(nDetIds);
35 for (
size_t i = 0; i < nDetIds; ++i) {
36 (*detIdToIndex)[detIds[i]] = i;
41void clearLegacyParameters(ParameterMap *
pmap,
const IComponent &comp) {
55bool hasValidShape(
const ObjCompAssembly &
obj) {
56 const auto *shape =
obj.shape().get();
57 return shape !=
nullptr && shape->hasValidShape();
66 : m_orderedDetectorIds(
67 std::make_shared<
std::vector<
detid_t>>(instrument->getDetectorIDs(false ))),
68 m_componentIds(
std::make_shared<
std::vector<
ComponentID>>(m_orderedDetectorIds->size(), nullptr)),
69 m_assemblySortedDetectorIndices(
std::make_shared<
std::vector<size_t>>()),
70 m_assemblySortedComponentIndices(
std::make_shared<
std::vector<size_t>>()),
71 m_parentComponentIndices(
std::make_shared<
std::vector<size_t>>(m_orderedDetectorIds->size(), 0)),
72 m_children(
std::make_shared<
std::vector<
std::vector<size_t>>>()),
73 m_detectorRanges(
std::make_shared<
std::vector<
std::pair<size_t, size_t>>>()),
74 m_componentRanges(
std::make_shared<
std::vector<
std::pair<size_t, size_t>>>()),
76 m_detectorIdToIndexMap(makeDetIdToIndexMap(*m_orderedDetectorIds)),
77 m_positions(
std::make_shared<
std::vector<Eigen::Vector3d>>()),
78 m_detectorPositions(
std::make_shared<
std::vector<Eigen::Vector3d>>(m_orderedDetectorIds->size())),
79 m_rotations(
std::make_shared<
std::vector<Eigen::Quaterniond, Eigen::aligned_allocator<Eigen::Quaterniond>>>()),
81 std::make_shared<
std::vector<Eigen::Quaterniond, Eigen::aligned_allocator<Eigen::Quaterniond>>>(
82 m_orderedDetectorIds->size())),
83 m_monitorIndices(
std::make_shared<
std::vector<size_t>>()), m_instrument(
std::move(instrument)), m_pmap(nullptr),
86 std::make_shared<
std::vector<
std::shared_ptr<const
IObject>>>(m_orderedDetectorIds->size(), m_nullShape)),
88 std::make_shared<
std::vector<Eigen::Vector3d>>(m_orderedDetectorIds->size(), Eigen::Vector3d{1, 1, 1})),
89 m_componentType(
std::make_shared<
std::vector<Beamline::ComponentType>>()),
90 m_names(
std::make_shared<
std::vector<
std::string>>(m_orderedDetectorIds->size())) {
114 m_instrument->baseInstrument()->registerContents(*
this);
124 (*m_componentIdToIndexMap)[componentId] = componentIndex;
132 clearLegacyParameters(
m_pmap, component);
133 return componentIndex;
138 std::vector<IComponent_const_sptr> assemblyChildren;
143 std::vector<size_t> children(assemblyChildren.size());
144 for (
size_t i = 0; i < assemblyChildren.size(); ++i) {
146 children[i] = assemblyChildren[i]->registerContents(*
this);
162 for (
const auto &child : children) {
163 (*m_parentComponentIndices)[child] = componentIndex;
165 m_children->emplace_back(std::move(children));
166 return componentIndex;
185 m_componentRanges->emplace_back(std::make_pair(componentStart, componentStart + 1));
192 return componentIndex;
218 return componentIndex;
240 (*m_componentType)[rangesIndex] = Beamline::ComponentType::Rectangular;
252 (*m_componentType)[rangesIndex] = Beamline::ComponentType::Grid;
275 (*m_componentType)[rangesIndex] = Beamline::ComponentType::Structured;
282 if (hasValidShape(
obj)) {
284 (*m_componentType)[rangesIndex] = Beamline::ComponentType::OutlineComposite;
325 clearLegacyParameters(
m_pmap, detector);
360std::shared_ptr<const std::unordered_map<Mantid::Geometry::IComponent *, size_t>>
370 return std::make_unique<Mantid::Beamline::ComponentInfo>(
387 compInfo->setDetectorInfo(detInfo.get());
389 auto compInfoWrapper =
391 auto detInfoWrapper =
394 return {std::move(compInfoWrapper), std::move(detInfoWrapper)};
397std::pair<std::unique_ptr<ComponentInfo>, std::unique_ptr<DetectorInfo>>
400 const auto visiteeInstrument =
403 : std::shared_ptr<const Instrument>(&instrument,
NoDeleting());
std::map< DeltaEMode::Type, std::string > index
double obj
the value of the quadratic function
Constructive Solid Geometry object.
Class for Assembly of geometric components.
virtual void getChildren(std::vector< IComponent_const_sptr > &outVector, bool recursive) const =0
Get all children.
base class for Geometric IComponent
virtual Kernel::V3D getPos() const =0
Get the position of the IComponent. Tree structure is traverse through the.
virtual Kernel::Quat getRotation() const =0
Get the absolute orientation of the IComponent.
virtual Kernel::V3D getScaleFactor() const
Gets the scaling factor of the object for the Object Component.
virtual ComponentID getComponentID() const =0
Returns the ComponentID - a unique identifier of the component.
virtual std::string getName() const =0
Get the IComponent name.
Interface class for detector objects.
virtual detid_t getID() const =0
Get the detector ID.
Object Component class, this class brings together the physical attributes of the component to the po...
virtual const std::shared_ptr< const IObject > shape() const =0
Returns the shape of the Object.
IObject : Interface for geometry objects.
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.
int64_t m_sourceIndex
Source index to set.
std::shared_ptr< std::vector< size_t > > m_assemblySortedComponentIndices
Component indexes sorted by assembly.
std::unique_ptr< Beamline::ComponentInfo > componentInfo() const
Mantid::Geometry::ParameterMap * m_pmap
Parameter map to purge.
InstrumentVisitor(std::shared_ptr< const Instrument > instrument)
Constructor.
virtual size_t registerComponentAssembly(const Mantid::Geometry::ICompAssembly &assembly) override
std::shared_ptr< std::vector< detid_t > > m_orderedDetectorIds
Detector indices.
size_t size() const
InstrumentVisitor::size.
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.
virtual size_t registerGenericObjComponent(const Mantid::Geometry::IObjComponent &objComponent) override
InstrumentVisitor::registerGenericObjComponent.
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.
size_t commonRegistration(const Mantid::Geometry::IComponent &component)
Extract the common aspects relevant to all component types.
std::shared_ptr< std::vector< detid_t > > detectorIds() const
virtual size_t registerGridBank(const Mantid::Geometry::ICompAssembly &bank) override
Register a grid bank.
std::shared_ptr< std::vector< Eigen::Vector3d > > m_positions
Positions for non-detectors.
void markAsSourceOrSample(Mantid::Geometry::IComponent *componentId, const size_t componentIndex)
virtual size_t registerRectangularBank(const Mantid::Geometry::ICompAssembly &bank) override
Register a rectangular bank.
virtual size_t registerObjComponentAssembly(const ObjCompAssembly &obj) override
std::shared_ptr< std::vector< std::shared_ptr< const Mantid::Geometry::IObject > > > m_shapes
Shapes stored in fly-weight fashion.
virtual size_t registerDetector(const Mantid::Geometry::IDetector &detector) override
InstrumentVisitor::registerDetector.
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< const std::unordered_map< Mantid::Geometry::IComponent *, size_t > > componentIdToIndexMap() const
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< const std::unordered_map< detid_t, size_t > > detectorIdToIndexMap() const
std::pair< std::unique_ptr< ComponentInfo >, std::unique_ptr< DetectorInfo > > makeWrappers() const
Mantid::Geometry::IComponent * m_sourceId
Source id to look for.
std::unique_ptr< Beamline::DetectorInfo > detectorInfo() const
virtual size_t registerStructuredBank(const Mantid::Geometry::ICompAssembly &bank) override
Register a structured bank.
std::shared_ptr< const std::vector< Mantid::Geometry::IComponent * > > componentIds() const
InstrumentVisitor::componentIds.
std::shared_ptr< std::vector< std::string > > m_names
Component names.
virtual size_t registerInfiniteComponent(const Mantid::Geometry::IComponent &component) override
InstrumentVisitor::registerInfiniteComponent.
int64_t m_sampleIndex
Sample index to set.
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.
virtual size_t registerInfiniteObjComponent(const IObjComponent &objComponent) override
InstrumentVisitor::registerInfiniteObjComponent.
virtual size_t registerGenericComponent(const Mantid::Geometry::IComponent &component) override
InstrumentVisitor::registerGenericComponent.
std::shared_ptr< std::vector< Eigen::Quaterniond, Eigen::aligned_allocator< Eigen::Quaterniond > > > m_detectorRotations
Rotations for detectors.
Void deleter for shared pointers.
Class for Assembly of geometric components.
static std::shared_ptr< Instrument > createInstrument(const std::shared_ptr< const Instrument > &base, const std::shared_ptr< ParameterMap > &map)
Create a parameterized instrument from the given base and ParameterMap.
bool empty() const
Returns true if the map is empty, false otherwise.
static const std::string & scale()
static const std::string & rot()
static const std::string & posz()
static const std::string & pos()
Return string to be used in the map.
static const std::string & rotz()
static const std::string & posy()
static const std::string & posx()
static const std::string & rotx()
static const std::string & roty()
Eigen::Vector3d toVector3d(const Kernel::V3D &vec)
Converts Kernel::V3D to Eigen::Vector3d.
Eigen::Quaterniond toQuaterniond(const Kernel::Quat &quat)
Converts Kernel::Quat to Eigen::Quaterniond.
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.