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
12#include <map>
13#include <vector>
14
15namespace Mantid {
16namespace Geometry {
28class MANTID_GEOMETRY_DLL DetectorGroup : public virtual IDetector {
29public:
31 DetectorGroup(const std::vector<IDetector_const_sptr> &dets);
32
33 void addDetector(const IDetector_const_sptr &det);
34
35 // IDetector methods
36 IDetector *cloneParameterized(const ParameterMap *) const override { return nullptr; }
37 detid_t getID() const override;
38 std::size_t nDets() const override;
39 Kernel::V3D getPos() 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 Kernel::V3D &observer) 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 setRot(const Kernel::Quat &) override {}
194 void copyRot(const IComponent &) {}
195 int interceptSurface(Track &) const override { return -10; }
196 void translate(const Kernel::V3D &) override {}
197 void translate(double, double, double) override {}
198 void rotate(const Kernel::Quat &) override {}
199 void rotate(double, const Kernel::V3D &) override {}
200 Kernel::V3D getRelativePos() const override {
201 throw std::runtime_error("Cannot call getRelativePos on a DetectorGroup");
202 }
203 Kernel::Quat getRelativeRot() const override {
204 throw std::runtime_error("Cannot call getRelativeRot on a DetectorGroup");
205 }
206 Kernel::Quat getRotation() const override { return Kernel::Quat(); }
207 void printSelf(std::ostream &) const override {}
208
209 // functions inherited from IObjComponent
210
211 void getBoundingBox(double &, double &, double &, double &, double &, double &) const {}
212
213 void draw() const override {}
214 void drawObject() const override {}
215 void initDraw() const override {}
216
218 const std::shared_ptr<const IObject> shape() const override { return std::shared_ptr<const IObject>(); }
220 const Kernel::Material material() const override;
221
222private:
227
229 void calculateGroupTopology() const;
230};
231
233using DetectorGroup_sptr = std::shared_ptr<DetectorGroup>;
235using DetectorGroup_const_sptr = std::shared_ptr<const DetectorGroup>;
236
237} // namespace Geometry
238} // namespace Mantid
std::map< DeltaEMode::Type, std::string > index
Definition: DeltaEMode.cpp:19
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:34
ComponentVisitor : Visitor for IComponents.
Component is a wrapper for a Component which can modify some of its parameters, e....
Definition: Component.h:41
Holds a collection of detectors.
Definition: DetectorGroup.h:28
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.
Definition: DetectorGroup.h:36
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 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:51
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
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.
Definition: SpectrumInfo.h:21