Garfield++ 3.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 "Solid.hh"
5
6namespace Garfield {
7
8/// Box with a cylindrical hole.
9
10class SolidHole : public Solid {
11 public:
12 /// Constructor from centre, upper/lower radii, half-lengths of the box.
13 SolidHole(const double cx, const double cy, const double cz,
14 const double rup, const double rlow,
15 const double lx, const double ly, const double lz);
16 /// Constructor from centre, upper/lower radii, half-lengths of the box
17 /// and orientation.
18 SolidHole(const double cx, const double cy, const double cz,
19 const double rup, const double rlow,
20 const double lx, const double ly, const double lz,
21 const double dx, const double dy, const double dz);
22 /// Destructor
24
25 bool IsInside(const double x, const double y, const double z) const override;
26 bool GetBoundingBox(double& xmin, double& ymin, double& zmin, double& xmax,
27 double& ymax, double& zmax) const override;
28 bool IsHole() const override { return true; }
29
30 /// Set the half-length of the box along x.
31 void SetHalfLengthX(const double lx);
32 /// Set the half-length of the box along y.
33 void SetHalfLengthY(const double ly);
34 /// Set the half-length of the box along z.
35 void SetHalfLengthZ(const double lz);
36 /// Set the radius at z = +lz.
37 void SetUpperRadius(const double r);
38 /// Set the radius at z = -lz.
39 void SetLowerRadius(const double r);
40
41 double GetHalfLengthX() const override { return m_lX; }
42 double GetHalfLengthY() const override { return m_lY; }
43 double GetHalfLengthZ() const override { return m_lZ; }
44 double GetUpperRadius() const override { return m_rUp; }
45 double GetLowerRadius() const override { return m_rLow; }
46
47 /// When calculating the surface panels, the hole is
48 /// approximated as a polygon with a finite number of panels.
49 /// The number of corners of the polygon equals \f$4(n - 1)\f$.
50 /// Thus, \f$n = 2\f$ will produce a square, \f$n = 3\f$ an octagon etc.
51 void SetSectors(const unsigned int n);
52 /// By default, the polygon used for approximating the hole when
53 /// calculating surface panels is inscribed in a circle
54 /// of the specified radius. If the "average-radius" flag is activated,
55 /// then the radius will be interpreted as the mean radius of the polygon
56 /// that approximates the cylinder.
57 void SetAverageRadius(const bool average) { m_average = average; }
58
59 /// Return the order of the approximating polygon.
60 unsigned int GetSectors() const { return m_n; }
61 /// Return the state of the "average-radius" flag.
62 bool GetAverage() const { return m_average; }
63
64 bool SolidPanels(std::vector<Panel>& panels) override;
65 double GetDiscretisationLevel(const Panel& panel) override;
66
67 private:
68 // Upper and lower radius
69 double m_rUp;
70 double m_rLow;
71 // Half-lengths
72 double m_lX;
73 double m_lY;
74 double m_lZ;
75
76 /// Number of sectors
77 unsigned int m_n = 2;
78 /// Average chord over the sectors.
79 bool m_average = false;
80
81 /// Discretisation levels.
82 std::array<double, 7> m_dis{{-1., -1., -1., -1., -1., -1., -1.}};
83};
84}
85
86#endif
Box with a cylindrical hole.
Definition: SolidHole.hh:10
void SetHalfLengthY(const double ly)
Set the half-length of the box along y.
Definition: SolidHole.cc:102
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:56
bool IsHole() const override
Return true if the solid is a hole.
Definition: SolidHole.hh:28
double GetHalfLengthY() const override
Return the half-length along y.
Definition: SolidHole.hh:42
~SolidHole()
Destructor.
Definition: SolidHole.hh:23
double GetDiscretisationLevel(const Panel &panel) override
Retrieve the discretization level of a panel.
Definition: SolidHole.cc:327
double GetHalfLengthZ() const override
Return the half-length along z.
Definition: SolidHole.hh:43
void SetSectors(const unsigned int n)
Definition: SolidHole.cc:118
void SetHalfLengthX(const double lx)
Set the half-length of the box along x.
Definition: SolidHole.cc:94
void SetLowerRadius(const double r)
Set the radius at z = -lz.
Definition: SolidHole.cc:86
bool SolidPanels(std::vector< Panel > &panels) override
Retrieve the surface panels of the solid.
Definition: SolidHole.cc:126
bool GetAverage() const
Return the state of the "average-radius" flag.
Definition: SolidHole.hh:62
void SetHalfLengthZ(const double lz)
Set the half-length of the box along z.
Definition: SolidHole.cc:110
bool IsInside(const double x, const double y, const double z) const override
Check whether a given point is inside the solid.
Definition: SolidHole.cc:27
void SetUpperRadius(const double r)
Set the radius at z = +lz.
Definition: SolidHole.cc:78
double GetLowerRadius() const override
Return the lower radius (of a hole).
Definition: SolidHole.hh:45
void SetAverageRadius(const bool average)
Definition: SolidHole.hh:57
double GetUpperRadius() const override
Return the upper radius (of a hole).
Definition: SolidHole.hh:44
double GetHalfLengthX() const override
Return the half-length along x.
Definition: SolidHole.hh:41
unsigned int GetSectors() const
Return the order of the approximating polygon.
Definition: SolidHole.hh:60
Abstract base class for solids.
Definition: Solid.hh:28
Surface panel.
Definition: Solid.hh:11