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 std::shared_ptr<Detector> getAtXYZ(const int x, const int y, const int z) const;
58
59 detid_t getDetectorIDAtXYZ(const int x, const int y, const int z) const;
60 std::tuple<int, int, int> getXYZForDetectorID(const detid_t detectorID) const;
61
62 int xpixels() const;
63 int ypixels() const;
64 int zpixels() const;
65
66 double xstep() const;
67 double ystep() const;
68 double zstep() const;
69
70 double xstart() const;
71 double ystart() const;
72 double zstart() const;
73
75 double xsize() const;
77 double ysize() const;
79 double zsize() const;
80
81 int idstart() const;
82 bool idfillbyfirst_y() const;
83 std::string idFillOrder() const;
84 int idstepbyrow() const;
85 int idstep() const;
86
87 Kernel::V3D getRelativePosAtXYZ(int x, int y, int z) const;
89 detid_t minDetectorID();
91 detid_t maxDetectorID();
92 std::shared_ptr<const IComponent> getComponentByName(const std::string &cname, int nlevels = 0) const override;
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
119 int getPointInObject(Kernel::V3D &point) const override;
120
121 // Rendering member functions
123 void draw() const override;
124
126 void drawObject() const override;
127
130 void initDraw() const override;
131
133 const std::shared_ptr<const IObject> shape() const override;
135 const Kernel::Material material() const override;
136
137 virtual size_t registerContents(class ComponentVisitor &componentVisitor) const override;
138
139 // ------------ End of IObjComponent methods ----------------
140protected:
142 void init();
143 void createLayer(const std::string &name, CompAssembly *parent, int iz, int &minDetID, int &maxDetID);
144
145private:
146 void initializeValues(std::shared_ptr<IObject> shape, int xpixels, double xstart, double xstep, int ypixels,
147 double ystart, double ystep, int zpixels, double zstart, double zstep, int idstart,
148 const std::string &idFillOrder, int idstepbyrow, int idstep);
149
150 void validateInput() const;
155
162
164 double m_xsize;
166 double m_ysize;
168 double m_zsize;
169
171 double m_xstart;
173 double m_ystart;
175 double m_zstart;
176
178 double m_xstep;
180 double m_ystep;
182 double m_zstep;
183
185 std::shared_ptr<IObject> m_shape;
190
196 std::string m_idFillOrder;
201};
202
203MANTID_GEOMETRY_DLL std::ostream &operator<<(std::ostream &, const GridDetector &);
204
205using GridDetector_sptr = std::shared_ptr<GridDetector>;
206using GridDetector_const_sptr = std::shared_ptr<const GridDetector>;
207
208} // Namespace Geometry
209} // 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.
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.
std::string m_idFillOrder
The order in which to fill IDs.
const GridDetector * m_gridBase
Pointer to the base GridDetector, for parametrized instruments.
double m_xstart
X position of the 0-th pixel.
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.