Mantid
Loading...
Searching...
No Matches
GridDetector.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2011 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#include "MantidGeometry/DllConfig.h"
13#include <string>
14#include <tuple>
15#include <vector>
16
17namespace Mantid {
18namespace Geometry {
19
20class ComponentVisitor;
33class MANTID_GEOMETRY_DLL GridDetector : public CompAssembly, public IObjComponent {
34 friend class GridDetectorPixel;
35
36public:
38 std::string type() const override { return "GridDetector"; }
39
41 GridDetector(const std::string &name, IComponent *reference = nullptr);
42
44 GridDetector(const GridDetector *base, const ParameterMap *map);
45
47 static bool compareName(const std::string &proposedMatch);
48
50 void initialize(std::shared_ptr<IObject> shape, int xpixels, double xstart, double xstep, int ypixels, double ystart,
51 double ystep, int zpixels, double zstart, double zstep, int idstart, const std::string &idFillOrder,
52 int idstepbyrow, int idstep = 1);
53
55 GridDetector *clone() const override;
56
57 detid_t getDetectorIDAtXYZ(const int x, const int y, const int z) const;
58 std::tuple<int, int, int> getXYZForDetectorID(const detid_t detectorID) const;
59
60 int const &xpixels() const;
61 int const &ypixels() const;
62 int const &zpixels() const;
63
64 double xstep() const;
65 double ystep() const;
66 double zstep() const;
67
68 double xstart() const;
69 double ystart() const;
70 double zstart() const;
71
73 double xsize() const;
75 double ysize() const;
77 double zsize() const;
78
79 int const &idstart() const;
80 int const &idstepbyrow() const;
81 int const &idstep() const;
83 bool const &idfillbyfirst_y() const;
84
85 Kernel::V3D getRelativePosAtXYZ(int const x, int const y, int const z) const;
87 detid_t const &minDetectorID() const;
89 detid_t const &maxDetectorID() const;
90 std::shared_ptr<const IComponent> getComponentByName(const std::string &cname, int nlevels = 0) const override;
91
92 Kernel::V3D getPosAtXYZ(int const x, int const y, int const z) const;
93
94 // This should inherit the getBoundingBox implementation from CompAssembly
95 // but the multiple inheritance seems to confuse it so we'll explicityly tell
96 // it that here
97 using CompAssembly::getBoundingBox;
98
99 void testIntersectionWithChildren(Track &testRay, std::deque<IComponent_const_sptr> &searchQueue) const override;
100
101 // ------------ IObjComponent methods ----------------
102
104 bool isValid(const Kernel::V3D &point) const override;
105
107 bool isOnSide(const Kernel::V3D &point) const override;
108
110 int interceptSurface(Track &track) const override;
111
114 double solidAngle(const Geometry::SolidAngleParams &params) const override;
116 void getBoundingBox(BoundingBox &assemblyBox) const override;
117
118 void getBoundingBoxAtXYZ(int const x, int const y, int const z, BoundingBox &box) const;
119
121 int getPointInObject(Kernel::V3D &point) const override;
122
123 // Rendering member functions
125 void draw() const override;
126
128 void drawObject() const override;
129
132 void initDraw() const override;
133
135 const std::shared_ptr<const IObject> shape() const override;
137 const Kernel::Material material() const override;
138
139 virtual size_t registerContents(class ComponentVisitor &componentVisitor) const override;
140
142 std::array<char, 3UL> const &idFillOrder() const;
143
144 bool inBoundsXYZ(const int x, const int y, const int z) const;
145
146 // ------------ End of IObjComponent methods ----------------
147protected:
149 void init();
150 void createLayer(const std::string &name, CompAssembly *parent, int iz, int &minDetID, int &maxDetID);
151
152 std::shared_ptr<Detector> getAtXYZ(const int x, const int y, const int z) const;
153
154private:
155 void initializeValues(std::shared_ptr<IObject> shape, int xpixels, double xstart, double xstep, int ypixels,
156 double ystart, double ystep, int zpixels, double zstart, double zstep, int idstart,
157 const std::string &idFillOrder, int idstepbyrow, int idstep);
158
159 void validateInput() const;
162 bool isParametrized() const override { return m_map && m_gridBase; }
165
172
174 double m_xsize;
176 double m_ysize;
178 double m_zsize;
179
181 double m_xstart;
183 double m_ystart;
185 double m_zstart;
186
188 double m_xstep;
190 double m_ystep;
192 double m_zstep;
193
195 std::shared_ptr<IObject> m_shape;
200
206 std::array<char, 3UL> m_idFillOrder;
211};
212
213MANTID_GEOMETRY_DLL std::ostream &operator<<(std::ostream &, const GridDetector &);
214
215using GridDetector_sptr = std::shared_ptr<GridDetector>;
216using GridDetector_const_sptr = std::shared_ptr<const GridDetector>;
217
218} // Namespace Geometry
219} // Namespace Mantid
std::string name
Definition Run.cpp:60
A simple structure that defines an axis-aligned cuboid shaped bounding box for a geometrical object.
Definition BoundingBox.h:33
Class for Assembly of geometric components.
ComponentVisitor : Visitor for IComponents.
GridrDetectorPixel: a sub-class of Detector that is one pixel inside a GridDetector.
GridDetector is a type of CompAssembly, an assembly of components.
double m_zstart
Z position of the 0-th pixel.
bool m_idfillbyfirst_y
IDs are filled in Y fastest.
int m_xpixels
The number of pixels in the X (horizontal) direction.
bool isParametrized() const override
Returns true if the Component is parametrized (has a parameter map)
double m_ysize
Size in Y of the detector.
std::shared_ptr< IObject > m_shape
Pointer to the shape of the pixels in this detector array.
int m_ypixels
The number of pixels in the Y (vertical) direction.
double m_ystart
Y position of the 0-th pixel.
int m_idstep
Step size in ID in each col.
double m_zstep
Step size in the Z direction of the detector.
GridDetector & operator=(const ICompAssembly &)
Private copy assignment operator.
detid_t m_minDetId
minimum detector id
double m_ystep
Step size in the Y direction of detector.
double m_xsize
Size in X of the detector.
const GridDetector * m_gridBase
Pointer to the base GridDetector, for parametrized instruments.
double m_xstart
X position of the 0-th pixel.
std::array< char, 3UL > m_idFillOrder
The order in which to fill IDs.
double m_zsize
Size in Z of the detector.
std::string type() const override
String description of the type of component.
double m_xstep
Step size in the X direction of detector.
int m_idstepbyrow
Step size in ID in each row.
int m_zpixels
The number of pixels in the Z (usually beam) direction.
detid_t m_maxDetId
maximum detector id
Class for Assembly of geometric components.
base class for Geometric IComponent
Definition IComponent.h:53
Object Component class, this class brings together the physical attributes of the component to the po...
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 3D vectors.
Definition V3D.h:34
std::shared_ptr< const GridDetector > GridDetector_const_sptr
MANTID_GEOMETRY_DLL std::ostream & operator<<(std::ostream &stream, const PointGroup &self)
Returns a streamed representation of the PointGroup object.
std::shared_ptr< GridDetector > GridDetector_sptr
Helper class which provides the Collimation Length for SANS instruments.
int32_t detid_t
Typedef for a detector ID.