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"
14#include <string>
15#include <tuple>
16#include <vector>
17
18namespace Mantid {
19namespace Geometry {
20
21class ComponentVisitor;
34class MANTID_GEOMETRY_DLL GridDetector : public CompAssembly, public IObjComponent {
35 friend class GridDetectorPixel;
36
37public:
39 std::string type() const override { return "GridDetector"; }
40
42 GridDetector(const std::string &name, IComponent *reference = nullptr);
43
45 GridDetector(const GridDetector *base, const ParameterMap *map);
46
48 static bool compareName(const std::string &proposedMatch);
49
51 void initialize(std::shared_ptr<IObject> shape, int xpixels, double xstart, double xstep, int ypixels, double ystart,
52 double ystep, int zpixels, double zstart, double zstep, int idstart, const std::string &idFillOrder,
53 int idstepbyrow, int idstep = 1);
54
56 GridDetector *clone() const override;
57
58 std::shared_ptr<Detector> getAtXYZ(const int x, const int y, const int z) const;
59
60 detid_t getDetectorIDAtXYZ(const int x, const int y, const int z) const;
61 std::tuple<int, int, int> getXYZForDetectorID(const detid_t detectorID) const;
62
63 int xpixels() const;
64 int ypixels() const;
65 int zpixels() const;
66
67 double xstep() const;
68 double ystep() const;
69 double zstep() const;
70
71 double xstart() const;
72 double ystart() const;
73 double zstart() const;
74
76 double xsize() const;
78 double ysize() const;
80 double zsize() const;
81
82 int idstart() const;
83 bool idfillbyfirst_y() const;
84 std::string idFillOrder() const;
85 int idstepbyrow() const;
86 int idstep() const;
87
88 Kernel::V3D getRelativePosAtXYZ(int x, int y, int z) const;
90 detid_t minDetectorID();
92 detid_t maxDetectorID();
93 std::shared_ptr<const IComponent> getComponentByName(const std::string &cname, int nlevels = 0) const override;
94
95 // This should inherit the getBoundingBox implementation from CompAssembly
96 // but the multiple inheritance seems to confuse it so we'll explicityly tell
97 // it that here
98 using CompAssembly::getBoundingBox;
99
100 void testIntersectionWithChildren(Track &testRay, std::deque<IComponent_const_sptr> &searchQueue) const override;
101
102 // ------------ IObjComponent methods ----------------
103
105 bool isValid(const Kernel::V3D &point) const override;
106
108 bool isOnSide(const Kernel::V3D &point) const override;
109
111 int interceptSurface(Track &track) const override;
112
115 double solidAngle(const Kernel::V3D &observer) const override;
117 void getBoundingBox(BoundingBox &assemblyBox) const override;
118
120 int getPointInObject(Kernel::V3D &point) const override;
121
122 // Rendering member functions
124 void draw() const override;
125
127 void drawObject() const override;
128
131 void initDraw() const override;
132
134 const std::shared_ptr<const IObject> shape() const override;
136 const Kernel::Material material() const override;
137
138 virtual size_t registerContents(class ComponentVisitor &componentVisitor) const override;
139
140 // ------------ End of IObjComponent methods ----------------
141protected:
143 void init();
144 void createLayer(const std::string &name, CompAssembly *parent, int iz, int &minDetID, int &maxDetID);
145
146private:
147 void initializeValues(std::shared_ptr<IObject> shape, int xpixels, double xstart, double xstep, int ypixels,
148 double ystart, double ystep, int zpixels, double zstart, double zstep, int idstart,
149 const std::string &idFillOrder, int idstepbyrow, int idstep);
150
151 void validateInput() const;
156
163
165 double m_xsize;
167 double m_ysize;
169 double m_zsize;
170
172 double m_xstart;
174 double m_ystart;
176 double m_zstart;
177
179 double m_xstep;
181 double m_ystep;
183 double m_zstep;
184
186 std::shared_ptr<IObject> m_shape;
191
197 std::string m_idFillOrder;
202};
203
204MANTID_GEOMETRY_DLL std::ostream &operator<<(std::ostream &, const GridDetector &);
205
206using GridDetector_sptr = std::shared_ptr<GridDetector>;
207using GridDetector_const_sptr = std::shared_ptr<const GridDetector>;
208
209} // Namespace Geometry
210} // Namespace Mantid
A simple structure that defines an axis-aligned cuboid shaped bounding box for a geometrical object.
Definition: BoundingBox.h:34
Class for Assembly of geometric components.
Definition: CompAssembly.h:31
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.
Definition: GridDetector.h:34
double m_zstart
Z position of the 0-th pixel.
Definition: GridDetector.h:176
bool m_idfillbyfirst_y
IDs are filled in Y fastest.
Definition: GridDetector.h:195
int m_xpixels
The number of pixels in the X (horizontal) direction.
Definition: GridDetector.h:158
double m_ysize
Size in Y of the detector.
Definition: GridDetector.h:167
std::shared_ptr< IObject > m_shape
Pointer to the shape of the pixels in this detector array.
Definition: GridDetector.h:186
int m_ypixels
The number of pixels in the Y (vertical) direction.
Definition: GridDetector.h:160
double m_ystart
Y position of the 0-th pixel.
Definition: GridDetector.h:174
int m_idstep
Step size in ID in each col.
Definition: GridDetector.h:201
double m_zstep
Step size in the Z direction of the detector.
Definition: GridDetector.h:183
GridDetector & operator=(const ICompAssembly &)
Private copy assignment operator.
detid_t m_minDetId
minimum detector id
Definition: GridDetector.h:188
double m_ystep
Step size in the Y direction of detector.
Definition: GridDetector.h:181
double m_xsize
Size in X of the detector.
Definition: GridDetector.h:165
std::string m_idFillOrder
The order in which to fill IDs.
Definition: GridDetector.h:197
const GridDetector * m_gridBase
Pointer to the base GridDetector, for parametrized instruments.
Definition: GridDetector.h:153
double m_xstart
X position of the 0-th pixel.
Definition: GridDetector.h:172
double m_zsize
Size in Z of the detector.
Definition: GridDetector.h:169
int m_idstart
IDs start here.
Definition: GridDetector.h:193
std::string type() const override
String description of the type of component.
Definition: GridDetector.h:39
double m_xstep
Step size in the X direction of detector.
Definition: GridDetector.h:179
int m_idstepbyrow
Step size in ID in each row.
Definition: GridDetector.h:199
int m_zpixels
The number of pixels in the Z (usually beam) direction.
Definition: GridDetector.h:162
detid_t m_maxDetId
maximum detector id
Definition: GridDetector.h:190
Class for Assembly of geometric components.
Definition: ICompAssembly.h:30
base class for Geometric IComponent
Definition: IComponent.h:51
Object Component class, this class brings together the physical attributes of the component to the po...
Definition: IObjComponent.h:37
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
Definition: GridDetector.h:207
MANTID_GEOMETRY_DLL std::ostream & operator<<(std::ostream &stream, const PointGroup &self)
Returns a streamed representation of the PointGroup object.
Definition: PointGroup.cpp:312
std::shared_ptr< GridDetector > GridDetector_sptr
Definition: GridDetector.h:206
Helper class which provides the Collimation Length for SANS instruments.
int32_t detid_t
Typedef for a detector ID.
Definition: SpectrumInfo.h:21