Mantid
Loading...
Searching...
No Matches
StructuredDetector.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2016 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
9#include "MantidGeometry/DllConfig.h"
15#include <string>
16#include <vector>
17
18namespace Mantid {
19namespace Geometry {
20class ComponentVisitor;
32class MANTID_GEOMETRY_DLL StructuredDetector : public CompAssembly, public IObjComponent {
33public:
35 std::string type() const override { return "StructuredDetector"; }
36
38 static bool compareName(const std::string &proposedMatch);
39
42
44 StructuredDetector(const std::string &name, IComponent *reference = nullptr);
45
47 StructuredDetector(const StructuredDetector *base, const ParameterMap *map);
48
50 void initialize(size_t xPixels, size_t yPixels, std::vector<double> &&x, std::vector<double> &&y, bool isZBeam,
51 detid_t idStart, bool idFillByFirstY, int idStepByRow, int idStep = 1);
52
54 IComponent *clone() const override;
55
56 std::shared_ptr<Detector> getAtXY(const size_t x, const size_t y) const;
57
58 detid_t getDetectorIDAtXY(const size_t X, const size_t Y) const;
59 std::pair<size_t, size_t> getXYForDetectorID(const detid_t detectorID) const;
60
61 std::vector<double> const &getXValues() const;
62 std::vector<double> const &getYValues() const;
63
64 void setColors(const std::vector<int> &r, const std::vector<int> &g, const std::vector<int> &b) const;
65
66 std::vector<int> const &getR() const;
67 std::vector<int> const &getG() const;
68 std::vector<int> const &getB() const;
69
70 size_t xPixels() const;
71 size_t yPixels() const;
72 detid_t idStart() const;
73 bool idFillByFirstY() const;
74 int idStepByRow() const;
75 int idStep() const;
76
78 detid_t minDetectorID();
80 detid_t maxDetectorID();
81
82 std::shared_ptr<const IComponent> getComponentByName(const std::string &cname, int nlevels = 0) const override;
83
84 // This should inherit the getBoundingBox implementation from CompAssembly
85 // but
86 // the multiple inheritance seems to confuse it so we'll explicityly tell it
87 // that here
88 using CompAssembly::getBoundingBox;
89
90 // ------------ IObjComponent methods ----------------
91
93 bool isValid(const Kernel::V3D &point) const override;
94
96 bool isOnSide(const Kernel::V3D &point) const override;
97
99 int interceptSurface(Track &track) const override;
100
103 double solidAngle(const Kernel::V3D &observer) const override;
105 void getBoundingBox(BoundingBox &assemblyBox) const override;
106
108 int getPointInObject(Kernel::V3D &point) const override;
109
110 // Rendering member functions
112 void draw() const override;
113
115 void drawObject() const override;
116
119 void initDraw() const override;
120
122 const std::shared_ptr<const IObject> shape() const override;
124 const Kernel::Material material() const override;
125
127 virtual size_t registerContents(class ComponentVisitor &componentVisitor) const override;
128
129 // ------------ End of IObjComponent methods ----------------
130private:
132 void init();
133
134 void createDetectors();
135
136 Detector *addDetector(CompAssembly *parent, const std::string &name, size_t x, size_t y, detid_t id);
142
144 size_t m_xPixels;
146 size_t m_yPixels;
147
152
161
162 std::vector<double> m_xvalues;
163 std::vector<double> m_yvalues;
164
165 mutable std::vector<int> r;
166 mutable std::vector<int> g;
167 mutable std::vector<int> b;
168};
169
170MANTID_GEOMETRY_DLL std::ostream &operator<<(std::ostream &, const StructuredDetector &);
171
172using StructuredDetector_sptr = std::shared_ptr<StructuredDetector>;
173using StructuredDetector_const_sptr = std::shared_ptr<const StructuredDetector>;
174} // namespace Geometry
175} // 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.
This class represents a detector - i.e.
Definition: Detector.h:30
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
StructuredDetector is a type of CompAssembly, an assembly of components.
size_t m_xPixels
The number of pixels in the X (horizontal) direction;.
detid_t m_maxDetId
maximum detector id
size_t m_yPixels
The number of pixels in the Y (vertical) direction;.
const StructuredDetector * m_base
Pointer to the base RectangularDetector, for parametrized instruments.
int m_idStepByRow
Step size in ID in each row.
int m_idStep
Step size in ID in each col.
detid_t m_minDetId
minimum detector id
bool m_idFillByFirstY
IDs are filled in Y fastest.
std::string type() const override
String description of the type of component.
StructuredDetector & operator=(const ICompAssembly &)
Private copy assignment operator.
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< StructuredDetector > StructuredDetector_sptr
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< const StructuredDetector > StructuredDetector_const_sptr
Helper class which provides the Collimation Length for SANS instruments.
int32_t detid_t
Typedef for a detector ID.
Definition: SpectrumInfo.h:21