Mantid
Loading...
Searching...
No Matches
DetectorGroup.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2008 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
11#include <map>
12#include <vector>
13
14namespace Mantid {
15namespace Geometry {
27class MANTID_GEOMETRY_DLL DetectorGroup : public virtual IDetector {
28public:
30 DetectorGroup(const std::vector<IDetector_const_sptr> &dets);
31
32 void addDetector(const IDetector_const_sptr &det);
33
34 // IDetector methods
35 IDetector *cloneParameterized(const ParameterMap *) const override { return nullptr; }
36 detid_t getID() const override;
37 std::size_t nDets() const override;
38 Kernel::V3D getPos() const override;
39 std::optional<Kernel::V2D> getSideBySideViewPos() const override;
40 double getDistance(const IComponent &comp) const override;
41 double getTwoTheta(const Kernel::V3D &observer, const Kernel::V3D &axis) const override;
42 double getSignedTwoTheta(const Kernel::V3D &observer, const Kernel::V3D &axis,
43 const Kernel::V3D &instrumentUp) const override;
44 double getPhi() const override;
45 double getPhiOffset(const double &offset) const override;
46 double solidAngle(const Geometry::SolidAngleParams &params) const override;
47 bool isParametrized() const override;
48 bool isValid(const Kernel::V3D &point) const override;
49 bool isOnSide(const Kernel::V3D &point) const override;
51 int getPointInObject(Kernel::V3D &point) const override;
53 void getBoundingBox(BoundingBox &boundingBox) const override;
54
56 std::vector<detid_t> getDetectorIDs() const;
58 std::vector<IDetector_const_sptr> getDetectors() const;
59
62 // 06/05/2010 MG: Templated virtual functions cannot be defined so we have to
63 // resort to
64 // one for each type, luckily there won't be too many
66 std::set<std::string> getParameterNames(bool recursive = true) const override;
68 std::map<std::string, ComponentID> getParameterNamesByComponent() const override;
70 bool hasParameter(const std::string &name, bool recursive = true) const override;
71 // Hack used untill Geomertry can not exprot different types parematers
72 // properly
73 std::string getParameterType(const std::string &name, bool recursive = true) const override;
81 std::vector<double> getNumberParameter(const std::string &pname, bool recursive = true) const override;
89 std::vector<Kernel::V3D> getPositionParameter(const std::string &pname, bool recursive = true) const override;
97 std::vector<Kernel::Quat> getRotationParameter(const std::string &pname, bool recursive = true) const override;
98
106 std::vector<std::string> getStringParameter(const std::string &pname, bool recursive = true) const override;
107
115 std::vector<int> getIntParameter(const std::string &pname, bool recursive = true) const override;
116
124 std::vector<bool> getBoolParameter(const std::string &pname, bool recursive = true) const override;
125
133 std::string getParameterAsString(const std::string &pname, bool recursive = true) const override;
134
141 bool getParameterVisible(const std::string &pname, bool recursive = true) const override;
142
146 det_topology getTopology(Kernel::V3D &center) const override;
147
149 std::string getNameSeparator() const { return ";"; }
154 IComponent const *getBaseComponent() const override { return const_cast<const DetectorGroup *>(this); }
155
156 const ParameterMap &parameterMap() const override;
157 size_t index() const override;
158 virtual size_t registerContents(class ComponentVisitor &visitor) const override;
159
160protected:
162 int m_id;
165 // May want to change this to a hash_map in due course
166 using DetCollection = std::map<int, IDetector_const_sptr>;
177
178 // functions inherited from IComponent
179 Component *clone() const override { return nullptr; }
180 ComponentID getComponentID() const override { return nullptr; }
181 std::shared_ptr<const IComponent> getParent() const override { return std::shared_ptr<const IComponent>(); }
182 const IComponent *getBareParent() const override { return nullptr; }
183 std::vector<std::shared_ptr<const IComponent>> getAncestors() const override {
184 return std::vector<std::shared_ptr<const IComponent>>();
185 }
186 std::string getName() const override;
187 std::string getFullName() const override;
188 void setParent(IComponent *) override {}
189 void setName(const std::string &) override {}
190
191 void setPos(double, double, double) override {}
192 void setPos(const Kernel::V3D &) override {}
193 void setSideBySideViewPos(const Kernel::V2D &) override {}
194 void setRot(const Kernel::Quat &) override {}
195 void copyRot(const IComponent &) {}
196 int interceptSurface(Track &) const override { return -10; }
197 void translate(const Kernel::V3D &) override {}
198 void translate(double, double, double) override {}
199 void rotate(const Kernel::Quat &) override {}
200 void rotate(double, const Kernel::V3D &) override {}
201 Kernel::V3D getRelativePos() const override {
202 throw std::runtime_error("Cannot call getRelativePos on a DetectorGroup");
203 }
204 Kernel::Quat getRelativeRot() const override {
205 throw std::runtime_error("Cannot call getRelativeRot on a DetectorGroup");
206 }
207 Kernel::Quat getRotation() const override { return Kernel::Quat(); }
208 void printSelf(std::ostream &) const override {}
209
210 // functions inherited from IObjComponent
211
212 void getBoundingBox(double &, double &, double &, double &, double &, double &) const {}
213
214 void draw() const override {}
215 void drawObject() const override {}
216 void initDraw() const override {}
217
219 const std::shared_ptr<const IObject> shape() const override { return std::shared_ptr<const IObject>(); }
221 const Kernel::Material material() const override;
222
223private:
228
230 void calculateGroupTopology() const;
231};
232
234using DetectorGroup_sptr = std::shared_ptr<DetectorGroup>;
236using DetectorGroup_const_sptr = std::shared_ptr<const DetectorGroup>;
237
238} // namespace Geometry
239} // namespace Mantid
std::string name
Definition Run.cpp:60
std::map< DeltaEMode::Type, std::string > index
std::string getName(const IMDDimension &self)
A simple structure that defines an axis-aligned cuboid shaped bounding box for a geometrical object.
Definition BoundingBox.h:33
ComponentVisitor : Visitor for IComponents.
Component is a wrapper for a Component which can modify some of its parameters, e....
Definition Component.h:42
Holds a collection of detectors.
std::vector< std::shared_ptr< const IComponent > > getAncestors() const override
Return an array of all ancestors, the nearest first.
IDetector * cloneParameterized(const ParameterMap *) const override
Create a cloned instance with a parameter map applied.
DetectorGroup(const DetectorGroup &)
Private, unimplemented copy constructor.
void setPos(const Kernel::V3D &) override
Set the position of the component The position is with respect to the parent component.
DetCollection m_detectors
The collection of grouped detectors.
void setPos(double, double, double) override
Set the IComponent position, x, y, z respective to parent (if present)
void setParent(IComponent *) override
Assign a parent IComponent. Previous parent link is lost.
void translate(double, double, double) override
Translate the IComponent (x,y,z form). This is relative to parent if.
Kernel::V3D groupCentre
group centre is the geometrical centre of the detectors group calculated when the calculate group top...
DetectorGroup & operator=(const DetectorGroup &)
Private, unimplemented copy assignment operator.
int interceptSurface(Track &) const override
Checks whether the track given will pass through this Component.
std::map< int, IDetector_const_sptr > DetCollection
The type of collection used for the detectors.
void getBoundingBox(double &, double &, double &, double &, double &, double &) const
Kernel::Quat getRotation() const override
Get the absolute orientation of the IComponent.
const std::shared_ptr< const IObject > shape() const override
Returns the shape of the Object.
void initDraw() const override
Initializes the ObjComponent for rendering, this function should be called before rendering.
void setRot(const Kernel::Quat &) override
Set the orientation Kernel::Quaternion relative to parent (if present)
Kernel::Quat getRelativeRot() const override
Get the relative Orientation.
void rotate(const Kernel::Quat &) override
Rotate the IComponent. This is relative to parent.
std::string getNameSeparator() const
Return separator for list of names of detectors.
void setSideBySideViewPos(const Kernel::V2D &) override
void translate(const Kernel::V3D &) override
Copy the Rotation from another IComponent.
void drawObject() const override
Draws the Object.
void setName(const std::string &) override
Set the IComponent name.
ComponentID getComponentID() const override
Returns the ComponentID - a unique identifier of the component.
Component * clone() const override
Virtual Copy Constructor.
IComponent const * getBaseComponent() const override
Returns const pointer to itself.
Kernel::V3D getRelativePos() const override
Get the position relative to the parent IComponent (absolute if no parent)
void printSelf(std::ostream &) const override
Prints a text representation of itself.
int m_id
The ID of this effective detector.
void rotate(double, const Kernel::V3D &) override
Rotate the IComponent by an angle in degrees with respect to an axis.
void draw() const override
Draws the objcomponent.
void copyRot(const IComponent &)
std::shared_ptr< const IComponent > getParent() const override
Return a pointer to the current parent.
const IComponent * getBareParent() const override
Returns the bare pointer to the IComponent parent.
det_topology group_topology
the parameter describes the topology of the detector's group namely if detectors form a box or a ring...
base class for Geometric IComponent
Definition IComponent.h:53
Interface class for detector objects.
Definition IDetector.h:43
Defines a track as a start point and a direction.
Definition Track.h:165
A material is defined as being composed of a given element, defined as a PhysicalConstants::NeutronAt...
Definition Material.h:50
Class for quaternions.
Definition Quat.h:39
Implements a 2-dimensional vector embedded in a 3D space, i.e.
Definition V2D.h:29
Class for 3D vectors.
Definition V3D.h:34
std::shared_ptr< const DetectorGroup > DetectorGroup_const_sptr
Typedef for shared pointer to a const object.
std::shared_ptr< const Mantid::Geometry::IDetector > IDetector_const_sptr
Shared pointer to IDetector (const version)
Definition IDetector.h:102
det_topology
Describes the topology of a detectors group used to calculate angular position and angular measures f...
Definition IDetector.h:31
std::shared_ptr< DetectorGroup > DetectorGroup_sptr
Typedef for shared pointer.
Helper class which provides the Collimation Length for SANS instruments.
int32_t detid_t
Typedef for a detector ID.