Garfield++ 4.0
A toolkit for the detailed simulation of particle detectors based on ionisation measurement in gases and semiconductors
Loading...
Searching...
No Matches
SolidHole.hh
Go to the documentation of this file.
1#ifndef G_SOLID_HOLE_H
2#define G_SOLID_HOLE_H
3
4#include <mutex>
5
6#include "Solid.hh"
7
8namespace Garfield {
9
10/// Box with a cylindrical hole.
11
12class SolidHole : public Solid {
13 public:
14 /// Constructor from centre, upper/lower radii, half-lengths of the box.
15 SolidHole(const double cx, const double cy, const double cz,
16 const double rup, const double rlow,
17 const double lx, const double ly, const double lz);
18 /// Constructor from centre, upper/lower radii, half-lengths of the box
19 /// and orientation.
20 SolidHole(const double cx, const double cy, const double cz,
21 const double rup, const double rlow,
22 const double lx, const double ly, const double lz,
23 const double dx, const double dy, const double dz);
24 /// Destructor
26
27 bool IsInside(const double x, const double y, const double z,
28 const bool tesselated) const override;
29 bool GetBoundingBox(double& xmin, double& ymin, double& zmin, double& xmax,
30 double& ymax, double& zmax) const override;
31 bool IsHole() const override { return true; }
32
33 /// Set the half-length of the box along x.
34 void SetHalfLengthX(const double lx);
35 /// Set the half-length of the box along y.
36 void SetHalfLengthY(const double ly);
37 /// Set the half-length of the box along z.
38 void SetHalfLengthZ(const double lz);
39 /// Set the radius at z = +lz.
40 void SetUpperRadius(const double r);
41 /// Set the radius at z = -lz.
42 void SetLowerRadius(const double r);
43
44 double GetHalfLengthX() const override { return m_lX; }
45 double GetHalfLengthY() const override { return m_lY; }
46 double GetHalfLengthZ() const override { return m_lZ; }
47 double GetUpperRadius() const override { return m_rUp; }
48 double GetLowerRadius() const override { return m_rLow; }
49
50 /// When calculating the surface panels, the hole 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 /// By default, the polygon used for approximating the hole when
56 /// calculating surface panels is inscribed in a circle
57 /// of the specified radius. If the "average-radius" flag is activated,
58 /// then the radius will be interpreted as the mean radius of the polygon
59 /// that approximates the cylinder.
60 void SetAverageRadius(const bool average) {
61 m_average = average;
62 Update();
63 }
64
65 /// Return the order of the approximating polygon.
66 unsigned int GetSectors() const { return m_n; }
67 /// Return the state of the "average-radius" flag.
68 bool GetAverage() const { return m_average; }
69
70 bool SolidPanels(std::vector<Panel>& panels) override;
71 void SetDiscretisationLevel(const double dis) override {
72 m_dis.fill(dis);
73 }
74 double GetDiscretisationLevel(const Panel& panel) override;
75
76 void Cut(const double x0, const double y0, const double z0,
77 const double xn, const double yn, const double zn,
78 std::vector<Panel>& panels) override;
79
80 private:
81 /// Mutex.
82 std::mutex m_mutex;
83
84 /// Upper radius.
85 double m_rUp;
86 /// Lower radius.
87 double m_rLow;
88 /// Half-length in x.
89 double m_lX;
90 /// Half-length in y.
91 double m_lY;
92 /// Half-length in z.
93 double m_lZ;
94
95 /// Number of sectors.
96 unsigned int m_n = 2;
97 /// Average chord over the sectors.
98 bool m_average = false;
99
100 /// Ratio between the approximating polygon's radius and the hole radius.
101 double m_fp = 1.;
102 /// Ratio between inradius and exradius of the approximating polygon.
103 double m_fi = 1.;
104
105 /// Discretisation levels.
106 std::array<double, 7> m_dis{{-1., -1., -1., -1., -1., -1., -1.}};
107
108 void Update();
109};
110}
111
112#endif
Box with a cylindrical hole.
Definition: SolidHole.hh:12
void SetHalfLengthY(const double ly)
Set the half-length of the box along y.
Definition: SolidHole.cc:173
bool GetBoundingBox(double &xmin, double &ymin, double &zmin, double &xmax, double &ymax, double &zmax) const override
Return the bounding box of the solid.
Definition: SolidHole.cc:127
bool IsHole() const override
Return true if the solid is a hole.
Definition: SolidHole.hh:31
double GetHalfLengthY() const override
Return the half-length along y.
Definition: SolidHole.hh:45
~SolidHole()
Destructor.
Definition: SolidHole.hh:25
double GetDiscretisationLevel(const Panel &panel) override
Retrieve the discretisation level of a panel.
Definition: SolidHole.cc:397
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: SolidHole.cc:428
double GetHalfLengthZ() const override
Return the half-length along z.
Definition: SolidHole.hh:46
void SetSectors(const unsigned int n)
Definition: SolidHole.cc:189
void SetHalfLengthX(const double lx)
Set the half-length of the box along x.
Definition: SolidHole.cc:165
void SetLowerRadius(const double r)
Set the radius at z = -lz.
Definition: SolidHole.cc:157
bool IsInside(const double x, const double y, const double z, const bool tesselated) const override
Definition: SolidHole.cc:93
bool SolidPanels(std::vector< Panel > &panels) override
Retrieve the surface panels of the solid.
Definition: SolidHole.cc:198
bool GetAverage() const
Return the state of the "average-radius" flag.
Definition: SolidHole.hh:68
void SetHalfLengthZ(const double lz)
Set the half-length of the box along z.
Definition: SolidHole.cc:181
void SetUpperRadius(const double r)
Set the radius at z = +lz.
Definition: SolidHole.cc:149
double GetLowerRadius() const override
Return the lower radius (of a hole).
Definition: SolidHole.hh:48
void SetAverageRadius(const bool average)
Definition: SolidHole.hh:60
double GetUpperRadius() const override
Return the upper radius (of a hole).
Definition: SolidHole.hh:47
double GetHalfLengthX() const override
Return the half-length along x.
Definition: SolidHole.hh:44
void SetDiscretisationLevel(const double dis) override
Set the discretisation level (for all panels).
Definition: SolidHole.hh:71
unsigned int GetSectors() const
Return the order of the approximating polygon.
Definition: SolidHole.hh:66
Abstract base class for solids.
Definition: Solid.hh:28
Surface panel.
Definition: Solid.hh:11