Garfield++ 4.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 /// Destructor
22
23 bool IsInside(const double x, const double y, const double z,
24 const bool tesselated) const override;
25 bool GetBoundingBox(double& xmin, double& ymin, double& zmin, double& xmax,
26 double& ymax, double& zmax) const override;
27 bool IsTube() const override { return true; }
28
29 void SetHalfLength(const double lz);
30 void SetRadius(const double r);
31
32 double GetHalfLengthZ() const override { return m_lZ; }
33 double GetRadius() const override { return m_rMax; }
34
35 /// When calculating the surface panels, the cylinder is
36 /// approximated as a polygon with a finite number of panels.
37 /// The number of corners of the polygon equals \f$4(n - 1)\f$.
38 /// Thus, \f$n = 2\f$ will produce a square, \f$n = 3\f$ an octagon etc.
39 void SetSectors(const unsigned int n);
40 /// Specify a rotation angle (radian) of the cylinder.
41 /// Such a rotation is meaningful only if the number of sectors
42 /// (when approximating the circle with a polygon) has been chosen small.
43 void SetRotation(const double angle) { m_rot = angle; }
44 /// By default, the polygon used for approximating the cylinder when
45 /// calculating surface panels is inscribed in a circle
46 /// of the specified radius. If the "average-radius" flag is activated,
47 /// then the radius will be interpreted as the mean radius of the polygon
48 /// that approximates the cylinder.
49 void SetAverageRadius(const bool average) { m_average = average; }
50 /// Request the cylinder to be closed with a (polygonal) lid at +z.
51 void SetTopLid(const bool closed) { m_toplid = closed; }
52 /// Request the cylinder to be closed with a (polygonal) lid at -z.
53 void SetBottomLid(const bool closed) { m_botlid = closed; }
54
55 /// Return the number of sectors.
56 unsigned int GetSectors() const { return m_n; }
57 /// Return the current rotation angle.
58 double GetRotation() const { return m_rot; }
59 /// Return the status of the "average-radius" flag.
60 bool GetAverage() const { return m_average; }
61
62 bool SolidPanels(std::vector<Panel>& panels) override;
63 void SetDiscretisationLevel(const double dis) override { m_dis.fill(dis); }
64 double GetDiscretisationLevel(const Panel& panel) override;
65
66 void Cut(const double x0, const double y0, const double z0,
67 const double xn, const double yn, const double zn,
68 std::vector<Panel>& panels) override;
69
70 private:
71 /// Mutex.
72 std::mutex m_mutex;
73
74 /// Outer radius.
75 double m_rMax;
76 /// Half-length
77 double m_lZ;
78
79 /// Rotation angle
80 double m_rot = 0.;
81 /// Number of sectors
82 unsigned int m_n = 2;
83 /// Average chord over the sectors.
84 bool m_average = false;
85 /// Radius of the approximating polygon.
86 double m_rp;
87 /// Inradius of the approximating polygon.
88 double m_ri;
89 /// X-coordinates of the approximating polygon.
90 std::vector<double> m_xp;
91 /// Y-coordinates of the approximating polygon.
92 std::vector<double> m_yp;
93
94 /// Have a top lid?
95 bool m_toplid = true;
96 /// Have a bottom lid?
97 bool m_botlid = true;
98
99 /// Discretisation levels.
100 std::array<double, 3> m_dis{{-1.,-1.,-1.}};
101
102 void UpdatePolygon();
103};
104}
105
106#endif
Cylindrical tube.
Definition: SolidTube.hh:12
bool SolidPanels(std::vector< Panel > &panels) override
Retrieve the surface panels of the solid.
Definition: SolidTube.cc:118
void SetBottomLid(const bool closed)
Request the cylinder to be closed with a (polygonal) lid at -z.
Definition: SolidTube.hh:53
unsigned int GetSectors() const
Return the number of sectors.
Definition: SolidTube.hh:56
double GetDiscretisationLevel(const Panel &panel) override
Retrieve the discretisation level of a panel.
Definition: SolidTube.cc:228
bool IsTube() const override
Return true if the solid is a tube.
Definition: SolidTube.hh:27
void SetSectors(const unsigned int n)
Definition: SolidTube.cc:109
~SolidTube()
Destructor.
Definition: SolidTube.hh:21
double GetHalfLengthZ() const override
Return the half-length along z.
Definition: SolidTube.hh:32
void SetHalfLength(const double lz)
Definition: SolidTube.cc:100
void SetAverageRadius(const bool average)
Definition: SolidTube.hh:49
void SetRadius(const double r)
Definition: SolidTube.cc:91
double GetRotation() const
Return the current rotation angle.
Definition: SolidTube.hh:58
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:242
void SetRotation(const double angle)
Definition: SolidTube.hh:43
bool GetAverage() const
Return the status of the "average-radius" flag.
Definition: SolidTube.hh:60
bool IsInside(const double x, const double y, const double z, const bool tesselated) const override
Definition: SolidTube.cc:50
void SetTopLid(const bool closed)
Request the cylinder to be closed with a (polygonal) lid at +z.
Definition: SolidTube.hh:51
double GetRadius() const override
Return the radius.
Definition: SolidTube.hh:33
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:69
void SetDiscretisationLevel(const double dis) override
Set the discretisation level (for all panels).
Definition: SolidTube.hh:63
Abstract base class for solids.
Definition: Solid.hh:28
Surface panel.
Definition: Solid.hh:11