Garfield++ 5.0
A toolkit for the detailed simulation of particle detectors based on ionisation measurement in gases and semiconductors
Loading...
Searching...
No Matches
SolidTube.hh
Go to the documentation of this file.
1#ifndef G_SOLID_TUBE_H
2#define G_SOLID_TUBE_H
3
4#include <mutex>
5
6#include "Solid.hh"
7
8namespace Garfield {
9
10/// Cylindrical tube.
11
12class SolidTube : public Solid {
13 public:
14 /// Constructor from centre, outer radius, and half-length.
15 SolidTube(const double cx, const double cy, const double cz, const double r,
16 const double lz);
17 /// Constructor from centre, outer radius, half-length and orientation.
18 SolidTube(const double cx, const double cy, const double cz, const double r,
19 const double lz, const double dx, const double dy, const double dz);
20 /// Constructor from centre, inner radius, outer radius, and half-length.
21 SolidTube(const double cx, const double cy, const double cz,
22 const double ri, const double ro, const double lz);
23 /// Constructor from centre, inner radius, outer radius, half-length
24 /// and orientation.
25 SolidTube(const double cx, const double cy, const double cz,
26 const double ri, const double ro, const double lz,
27 const double dx, const double dy, const double dz);
28 /// Destructor
30
31 bool IsInside(const double x, const double y, const double z,
32 const bool tesselated) const override;
33 bool GetBoundingBox(double& xmin, double& ymin, double& zmin, double& xmax,
34 double& ymax, double& zmax) const override;
35 bool IsTube() const override { return true; }
36
37 /// Set the half-length of the tube.
38 void SetHalfLength(const double lz);
39 /// Set the outer radius.
40 void SetRadius(const double r);
41 /// Retrieve the half-length of the tube.
42 double GetHalfLengthZ() const override { return m_lZ; }
43 /// Retrieve the outer radius.
44 double GetRadius() const override { return m_rO; }
45 /// Retrieve the outer radius.
46 double GetOuterRadius() const override { return m_rO; }
47 /// Retrieve the inner radius.
48 double GetInnerRadius() const override { return m_rI; }
49
50 /// When calculating the surface panels, the cylinder is
51 /// approximated as a polygon with a finite number of panels.
52 /// The number of corners of the polygon equals \f$4(n - 1)\f$.
53 /// Thus, \f$n = 2\f$ will produce a square, \f$n = 3\f$ an octagon etc.
54 void SetSectors(const unsigned int n);
55 /// Specify a rotation angle (radian) of the cylinder.
56 /// Such a rotation is meaningful only if the number of sectors
57 /// (when approximating the circle with a polygon) has been chosen small.
58 void SetRotation(const double angle) { m_rot = angle; }
59 /// By default, the polygon used for approximating the cylinder when
60 /// calculating surface panels is inscribed in a circle
61 /// of the specified radius. If the "average-radius" flag is activated,
62 /// then the radius will be interpreted as the mean radius of the polygon
63 /// that approximates the cylinder.
64 void SetAverageRadius(const bool average) { m_average = average; }
65 /// Request the cylinder to be closed with a (polygonal) lid at +z.
66 void SetTopLid(const bool closed) { m_toplid = closed; }
67 /// Request the cylinder to be closed with a (polygonal) lid at -z.
68 void SetBottomLid(const bool closed) { m_botlid = closed; }
69
70 /// Return the number of sectors.
71 unsigned int GetSectors() const { return m_n; }
72 /// Return the current rotation angle.
73 double GetRotation() const { return m_rot; }
74 /// Return the status of the "average-radius" flag.
75 bool GetAverage() const { return m_average; }
76
77 bool SolidPanels(std::vector<Panel>& panels) override;
78 void SetDiscretisationLevel(const double dis) override { m_dis.fill(dis); }
79 double GetDiscretisationLevel(const Panel& panel) override;
80
81 void Cut(const double x0, const double y0, const double z0,
82 const double xn, const double yn, const double zn,
83 std::vector<Panel>& panels) override;
84
85 private:
86 /// Mutex.
87 std::mutex m_mutex;
88
89 /// Outer radius.
90 double m_rO;
91 /// Inner radius.
92 double m_rI = 0.;
93 /// Half-length
94 double m_lZ;
95
96 /// Rotation angle
97 double m_rot = 0.;
98 /// Number of sectors
99 unsigned int m_n = 2;
100 /// Average chord over the sectors.
101 bool m_average = false;
102 /// Radius of the outer approximating polygon.
103 double m_rpO;
104 /// Radius of the inner approximating polygon.
105 double m_rpI = 0.;
106 /// Inradius of the outer approximating polygon.
107 double m_riO;
108 /// Inradius of the inner approximating polygon.
109 double m_riI = 0.;
110 /// X-coordinates of the outer approximating polygon.
111 std::vector<double> m_xpO;
112 /// Y-coordinates of the outer approximating polygon.
113 std::vector<double> m_ypO;
114 /// X-coordinates of the inner approximating polygon.
115 std::vector<double> m_xpI;
116 /// Y-coordinates of the inner approximating polygon.
117 std::vector<double> m_ypI;
118
119 /// Have a top lid?
120 bool m_toplid = true;
121 /// Have a bottom lid?
122 bool m_botlid = true;
123
124 /// Discretisation levels.
125 std::array<double, 3> m_dis{{-1.,-1.,-1.}};
126
127 void UpdatePolygon();
128};
129}
130
131#endif
bool SolidPanels(std::vector< Panel > &panels) override
Retrieve the surface panels of the solid.
Definition SolidTube.cc:143
void SetBottomLid(const bool closed)
Request the cylinder to be closed with a (polygonal) lid at -z.
Definition SolidTube.hh:68
unsigned int GetSectors() const
Return the number of sectors.
Definition SolidTube.hh:71
double GetDiscretisationLevel(const Panel &panel) override
Retrieve the discretisation level of a panel.
Definition SolidTube.cc:349
bool IsTube() const override
Return true if the solid is a tube.
Definition SolidTube.hh:35
void SetSectors(const unsigned int n)
Definition SolidTube.cc:134
~SolidTube()
Destructor.
Definition SolidTube.hh:29
SolidTube(const double cx, const double cy, const double cz, const double r, const double lz)
Constructor from centre, outer radius, and half-length.
Definition SolidTube.cc:10
double GetHalfLengthZ() const override
Retrieve the half-length of the tube.
Definition SolidTube.hh:42
void SetHalfLength(const double lz)
Set the half-length of the tube.
Definition SolidTube.cc:125
void SetAverageRadius(const bool average)
Definition SolidTube.hh:64
void SetRadius(const double r)
Set the outer radius.
Definition SolidTube.cc:116
double GetRotation() const
Return the current rotation angle.
Definition SolidTube.hh:73
double GetOuterRadius() const override
Retrieve the outer radius.
Definition SolidTube.hh:46
void Cut(const double x0, const double y0, const double z0, const double xn, const double yn, const double zn, std::vector< Panel > &panels) override
Definition SolidTube.cc:363
double GetInnerRadius() const override
Retrieve the inner radius.
Definition SolidTube.hh:48
void SetRotation(const double angle)
Definition SolidTube.hh:58
bool GetAverage() const
Return the status of the "average-radius" flag.
Definition SolidTube.hh:75
bool IsInside(const double x, const double y, const double z, const bool tesselated) const override
Definition SolidTube.cc:71
void SetTopLid(const bool closed)
Request the cylinder to be closed with a (polygonal) lid at +z.
Definition SolidTube.hh:66
double GetRadius() const override
Retrieve the outer radius.
Definition SolidTube.hh:44
bool GetBoundingBox(double &xmin, double &ymin, double &zmin, double &xmax, double &ymax, double &zmax) const override
Return the bounding box of the solid.
Definition SolidTube.cc:94
void SetDiscretisationLevel(const double dis) override
Set the discretisation level (for all panels).
Definition SolidTube.hh:78
Solid()=delete
Default constructor.
Surface panel.
Definition Solid.hh:11