Garfield++ 3.0
A toolkit for the detailed simulation of particle detectors based on ionisation measurement in gases and semiconductors
Loading...
Searching...
No Matches
Garfield::SolidRidge Class Reference

Triangular prism (Toblerone bar). More...

#include <SolidRidge.hh>

+ Inheritance diagram for Garfield::SolidRidge:

Public Member Functions

 SolidRidge (const double cx, const double cy, const double cz, const double lx, const double ly, const double hz, const double offsetx)
 Constructor from centre, half-lengths, height and x-offset.
 
 SolidRidge (const double cx, const double cy, const double cz, const double lx, const double ly, const double hz, const double offsetx, const double dx, const double dy, const double dz)
 Constructor from centre, half-lengths, height, x-offset and orientation.
 
 ~SolidRidge ()
 Destructor.
 
bool IsInside (const double x, const double y, const double z) const override
 Check whether a given point is inside the solid.
 
bool GetBoundingBox (double &xmin, double &ymin, double &zmin, double &xmax, double &ymax, double &zmax) const override
 Return the bounding box of the solid.
 
bool IsRidge () const override
 Return true if the solid is a ridge.
 
void SetHalfLengthX (const double lx)
 Set the half-length along x.
 
void SetHalfLengthY (const double ly)
 Set the half-length along y.
 
void SetRidgeHeight (const double hz)
 Set the height of the ridge.
 
void SetRidgeOffset (const double dx)
 Set the x-offset of the ridge.
 
double GetHalfLengthX () const override
 Return the half-length along x.
 
double GetHalfLengthY () const override
 Return the half-length along y.
 
double GetRidgeHeight () const override
 Return the height of a ridge.
 
double GetRidgeOffset () const override
 Return the x-offset of a ridge.
 
bool SolidPanels (std::vector< Panel > &panels) override
 Retrieve the surface panels of the solid.
 
double GetDiscretisationLevel (const Panel &panel) override
 Retrieve the discretization level of a panel.
 
- Public Member Functions inherited from Garfield::Solid
 Solid ()=delete
 Default constructor.
 
 Solid (const double cx, const double cy, const double cz, const std::string &name)
 Constructor.
 
virtual ~Solid ()
 Destructor.
 
virtual bool IsInside (const double x, const double y, const double z) const =0
 Check whether a given point is inside the solid.
 
virtual bool GetBoundingBox (double &xmin, double &ymin, double &zmin, double &xmax, double &ymax, double &zmax) const =0
 Return the bounding box of the solid.
 
virtual bool IsBox () const
 Return true if the solid is a box.
 
virtual bool IsTube () const
 Return true if the solid is a tube.
 
virtual bool IsSphere () const
 Return true if the solid is a sphere.
 
virtual bool IsHole () const
 Return true if the solid is a hole.
 
virtual bool IsRidge () const
 Return true if the solid is a ridge.
 
bool GetCentre (double &x, double &y, double &z) const
 Retrieve the centre point of the solid.
 
bool GetOrientation (double &ctheta, double &stheta, double &cphi, double &sphi) const
 Retrieve the orientation (azimuthal and polar angles) of the solid.
 
virtual double GetHalfLengthX () const
 Return the half-length along x.
 
virtual double GetHalfLengthY () const
 Return the half-length along y.
 
virtual double GetHalfLengthZ () const
 Return the half-length along z.
 
virtual double GetInnerRadius () const
 Return the inner radius.
 
virtual double GetOuterRadius () const
 Return the outer radius.
 
virtual double GetRadius () const
 Return the radius.
 
virtual double GetLowerRadius () const
 Return the lower radius (of a hole).
 
virtual double GetUpperRadius () const
 Return the upper radius (of a hole).
 
virtual double GetRidgeOffset () const
 Return the x-offset of a ridge.
 
virtual double GetRidgeHeight () const
 Return the height of a ridge.
 
unsigned int GetId () const
 Get the ID of the solid.
 
virtual bool SolidPanels (std::vector< Panel > &panels)=0
 Retrieve the surface panels of the solid.
 
virtual double GetDiscretisationLevel (const Panel &panel)=0
 Retrieve the discretization level of a panel.
 
void SetBoundaryPotential (const double v)
 Apply Dirichlet boundary conditions (fixed voltage).
 
void SetBoundaryChargeDensity (const double q)
 Apply fixed-charge boundary conditions.
 
void SetBoundaryFloat ()
 Make the potential at the surface of the solid floating.
 
void SetBoundaryDielectric ()
 Make the surfaces of the solid dielectric-dielectric interfaces.
 
void SetBoundaryParallelField ()
 
void SetBoundaryPerpendicularField ()
 
BoundaryCondition GetBoundaryConditionType () const
 Retrieve the type of boundary condition.
 
double GetBoundaryPotential () const
 Retrieve the potential.
 
double GetBoundaryChargeDensity () const
 Retrieve the surface charge density.
 
void EnableDebugging (const bool on=true)
 Switch debugging messages on/off.
 

Additional Inherited Members

- Public Types inherited from Garfield::Solid
enum  BoundaryCondition {
  Voltage = 1 , Charge , Float , Dielectric ,
  DielectricCharge , ParallelField , PerpendicularField
}
 
- Protected Member Functions inherited from Garfield::Solid
void ToLocal (const double x, const double y, const double z, double &u, double &v, double &w) const
 
void ToGlobal (const double u, const double v, const double w, double &x, double &y, double &z) const
 
void VectorToLocal (const double x, const double y, const double z, double &u, double &v, double &w)
 Transform a vector from global to local coordinates.
 
void SetDirection (const double dx, const double dy, const double dz)
 
- Protected Attributes inherited from Garfield::Solid
double m_cX = 0.
 Centre of the solid.
 
double m_cY = 0.
 
double m_cZ = 0.
 
double m_dX = 0.
 Direction vector.
 
double m_dY = 0.
 
double m_dZ = 1.
 
double m_cPhi = 1.
 Azimuthal angle.
 
double m_sPhi = 0.
 
double m_cTheta = 1.
 Polar angle.
 
double m_sTheta = 0.
 
std::string m_className = "Solid"
 Class name.
 
bool m_debug = false
 Debug flag.
 
BoundaryCondition m_bctype = Voltage
 Type of boundary condition.
 
double m_volt = 0.
 Potential at the surface.
 
double m_charge = 0.
 Surface charge density.
 
double m_eps = 0.
 Dielectric constant.
 

Detailed Description

Triangular prism (Toblerone bar).

Definition at line 10 of file SolidRidge.hh.

Constructor & Destructor Documentation

◆ SolidRidge() [1/2]

Garfield::SolidRidge::SolidRidge ( const double  cx,
const double  cy,
const double  cz,
const double  lx,
const double  ly,
const double  hz,
const double  offsetx 
)

Constructor from centre, half-lengths, height and x-offset.

Definition at line 9 of file SolidRidge.cc.

12 : Solid(cx, cy, cz, "SolidRidge"),
13 m_lX(lx),
14 m_lY(ly),
15 m_hz(hz),
16 m_hx(hx) {}
Solid()=delete
Default constructor.

◆ SolidRidge() [2/2]

Garfield::SolidRidge::SolidRidge ( const double  cx,
const double  cy,
const double  cz,
const double  lx,
const double  ly,
const double  hz,
const double  offsetx,
const double  dx,
const double  dy,
const double  dz 
)

Constructor from centre, half-lengths, height, x-offset and orientation.

Definition at line 18 of file SolidRidge.cc.

22 : SolidRidge(cx, cy, cz, lx, ly, hz, hx) {
23 SetDirection(dx, dy, dz);
24}
SolidRidge(const double cx, const double cy, const double cz, const double lx, const double ly, const double hz, const double offsetx)
Constructor from centre, half-lengths, height and x-offset.
Definition: SolidRidge.cc:9
void SetDirection(const double dx, const double dy, const double dz)
Definition: Solid.cc:12

◆ ~SolidRidge()

Garfield::SolidRidge::~SolidRidge ( )
inline

Destructor.

Definition at line 22 of file SolidRidge.hh.

22{}

Member Function Documentation

◆ GetBoundingBox()

bool Garfield::SolidRidge::GetBoundingBox ( double &  xmin,
double &  ymin,
double &  zmin,
double &  xmax,
double &  ymax,
double &  zmax 
) const
overridevirtual

Return the bounding box of the solid.

Implements Garfield::Solid.

Definition at line 50 of file SolidRidge.cc.

51 {
52 if (m_cTheta == 1. && m_cPhi == 1.) {
53 xmin = m_cX - m_lX;
54 xmax = m_cX + m_lX;
55 ymin = m_cY - m_lY;
56 ymax = m_cY + m_lY;
57 zmin = m_cZ;
58 zmax = m_cZ + m_hz;
59 return true;
60 }
61
62 const double dd = sqrt(m_lX * m_lX + m_lY * m_lY + m_hz * m_hz);
63 xmin = m_cX - dd;
64 xmax = m_cX + dd;
65 ymin = m_cY - dd;
66 ymax = m_cY + dd;
67 zmin = m_cZ - dd;
68 zmax = m_cZ + dd;
69 return true;
70}
double m_cZ
Definition: Solid.hh:164
double m_cTheta
Polar angle.
Definition: Solid.hh:171
double m_cY
Definition: Solid.hh:164
double m_cX
Centre of the solid.
Definition: Solid.hh:164
double m_cPhi
Azimuthal angle.
Definition: Solid.hh:169
DoubleAc sqrt(const DoubleAc &f)
Definition: DoubleAc.cpp:314

◆ GetDiscretisationLevel()

double Garfield::SolidRidge::GetDiscretisationLevel ( const Panel panel)
overridevirtual

Retrieve the discretization level of a panel.

Implements Garfield::Solid.

Definition at line 177 of file SolidRidge.cc.

177 {
178
179 // Transform the normal vector to local coordinates.
180 double u = 0., v = 0., w = 0.;
181 VectorToLocal(panel.a, panel.b, panel.c, u, v, w);
182 // Identify the vector.
183 if (v > std::max(std::abs(u), std::abs(w))) {
184 return m_dis[2];
185 } else if (v < -std::max(std::abs(u), std::abs(w))) {
186 return m_dis[3];
187 } else if (w < -std::max(std::abs(u), std::abs(v))) {
188 return m_dis[4];
189 } else if (u > 0) {
190 return m_dis[0];
191 } else if (u < 0) {
192 return m_dis[1];
193 }
194 if (m_debug) {
195 std::cout << m_className << "::GetDiscretisationLevel:\n"
196 << " Found no match for the panel; return first value.\n";
197 }
198 return m_dis[0];
199}
void VectorToLocal(const double x, const double y, const double z, double &u, double &v, double &w)
Transform a vector from global to local coordinates.
Definition: Solid.hh:209
bool m_debug
Debug flag.
Definition: Solid.hh:177
std::string m_className
Class name.
Definition: Solid.hh:174

◆ GetHalfLengthX()

double Garfield::SolidRidge::GetHalfLengthX ( ) const
inlineoverridevirtual

Return the half-length along x.

Reimplemented from Garfield::Solid.

Definition at line 38 of file SolidRidge.hh.

38{ return m_lX; }

◆ GetHalfLengthY()

double Garfield::SolidRidge::GetHalfLengthY ( ) const
inlineoverridevirtual

Return the half-length along y.

Reimplemented from Garfield::Solid.

Definition at line 39 of file SolidRidge.hh.

39{ return m_lY; }

◆ GetRidgeHeight()

double Garfield::SolidRidge::GetRidgeHeight ( ) const
inlineoverridevirtual

Return the height of a ridge.

Reimplemented from Garfield::Solid.

Definition at line 40 of file SolidRidge.hh.

40{ return m_hz; }

◆ GetRidgeOffset()

double Garfield::SolidRidge::GetRidgeOffset ( ) const
inlineoverridevirtual

Return the x-offset of a ridge.

Reimplemented from Garfield::Solid.

Definition at line 41 of file SolidRidge.hh.

41{ return m_hx; }

◆ IsInside()

bool Garfield::SolidRidge::IsInside ( const double  x,
const double  y,
const double  z 
) const
overridevirtual

Check whether a given point is inside the solid.

Implements Garfield::Solid.

Definition at line 26 of file SolidRidge.cc.

26 {
27 // Transform the point to local coordinates.
28 double u = x, v = y, w = z;
29 ToLocal(x, y, z, u, v, w);
30
31 bool inside = true;
32 if (fabs(u) > m_lX || fabs(v) > m_lY || w < 0. || w > m_hz) {
33 return false;
34 } else if (u >= m_hx && m_hz * u + (m_lX - m_hx) * v > m_hz * m_lX) {
35 inside = false;
36 } else if (u <= m_hx && -m_hz * u + (m_lX + m_hx) * v > m_hz * m_lX) {
37 inside = false;
38 }
39 if (m_debug) {
40 std::cout << "SolidRidge::IsInside: (" << x << ", " << y << ", " << z;
41 if (inside) {
42 std::cout << ") is inside.\n";
43 } else {
44 std::cout << ") is outside.\n";
45 }
46 }
47 return inside;
48}
void ToLocal(const double x, const double y, const double z, double &u, double &v, double &w) const
Definition: Solid.hh:190
DoubleAc fabs(const DoubleAc &f)
Definition: DoubleAc.h:615

◆ IsRidge()

bool Garfield::SolidRidge::IsRidge ( ) const
inlineoverridevirtual

Return true if the solid is a ridge.

Reimplemented from Garfield::Solid.

Definition at line 27 of file SolidRidge.hh.

27{ return true; }

◆ SetHalfLengthX()

void Garfield::SolidRidge::SetHalfLengthX ( const double  lx)

Set the half-length along x.

Definition at line 72 of file SolidRidge.cc.

72 {
73 if (lx <= 0.) {
74 std::cerr << "SolidRidge::SetHalfLengthX: Half-length must be > 0.\n";
75 return;
76 }
77 m_lX = lx;
78}

◆ SetHalfLengthY()

void Garfield::SolidRidge::SetHalfLengthY ( const double  ly)

Set the half-length along y.

Definition at line 80 of file SolidRidge.cc.

80 {
81 if (ly <= 0.) {
82 std::cerr << "SolidRidge::SetHalfLengthY: Half-length must be > 0.\n";
83 return;
84 }
85 m_lY = ly;
86}

◆ SetRidgeHeight()

void Garfield::SolidRidge::SetRidgeHeight ( const double  hz)

Set the height of the ridge.

Definition at line 88 of file SolidRidge.cc.

88 {
89 if (hz <= 0.) {
90 std::cerr << "SolidRidge::SetRidgeHeight: Height must be > 0.\n";
91 return;
92 }
93 m_hz = hz;
94}

◆ SetRidgeOffset()

void Garfield::SolidRidge::SetRidgeOffset ( const double  dx)
inline

Set the x-offset of the ridge.

Definition at line 36 of file SolidRidge.hh.

36{ m_hx = dx; }

◆ SolidPanels()

bool Garfield::SolidRidge::SolidPanels ( std::vector< Panel > &  panels)
overridevirtual

Retrieve the surface panels of the solid.

Implements Garfield::Solid.

Definition at line 96 of file SolidRidge.cc.

96 {
97 const auto id = GetId();
98 const unsigned int nPanels = panels.size();
99 // Direction vector.
100 const double fnorm = sqrt(m_dX * m_dX + m_dY * m_dY + m_dZ * m_dZ);
101 if (fnorm <= 0) {
102 std::cerr << "SolidRidge::SolidPanels:\n"
103 << " Zero norm direction vector; no panels generated.\n";
104 return false;
105 }
106 double xv0, yv0, zv0;
107 double xv1, yv1, zv1;
108 double xv2, yv2, zv2;
109 double xv3, yv3, zv3;
110
111 // Draw the 5 sides of the ridge, start with the floor.
112 ToGlobal(-m_lX, -m_lY, 0, xv0, yv0, zv0);
113 ToGlobal(-m_lX, +m_lY, 0, xv1, yv1, zv1);
114 ToGlobal(+m_lX, +m_lY, 0, xv2, yv2, zv2);
115 ToGlobal(+m_lX, -m_lY, 0, xv3, yv3, zv3);
116
117 Panel base;
118 base.a = -m_cPhi * m_sTheta;
119 base.b = -m_sPhi * m_sTheta;
120 base.c = -m_cTheta;
121 base.xv = {xv0, xv1, xv2, xv3};
122 base.yv = {yv0, yv1, yv2, yv3};
123 base.zv = {zv0, zv1, zv2, zv3};
124 base.colour = 0;
125 base.volume = id;
126 panels.push_back(std::move(base));
127
128 // Side triangles at y=ymin and y=ymax.
129 for (unsigned int i = 0; i < 2; ++i) {
130 const double y = i == 0 ? -m_lY : +m_lY;
131 ToGlobal(-m_lX, y, 0, xv0, yv0, zv0);
132 ToGlobal(+m_lX, y, 0, xv1, yv1, zv1);
133 ToGlobal(m_hx, y, m_hz, xv2, yv2, zv2);
134
135 const double a = i == 0 ? +m_sPhi : -m_sPhi;
136 const double b = i == 0 ? -m_cPhi : +m_cPhi;
137 Panel side;
138 side.a = a;
139 side.b = b;
140 side.c = 0.;
141 side.xv = {xv0, xv1, xv2};
142 side.yv = {yv0, yv1, yv2};
143 side.zv = {zv0, zv1, zv2};
144 side.colour = 0;
145 side.volume = id;
146 panels.push_back(std::move(side));
147 }
148
149 // The roof, parts at +x and -x.
150 for (unsigned int i = 0; i < 2; ++i) {
151 const double x = i == 0 ? +m_lX : -m_lX;
152 ToGlobal(x, -m_lY, 0, xv0, yv0, zv0);
153 ToGlobal(x, +m_lY, 0, xv1, yv1, zv1);
154 ToGlobal(m_hx, +m_lY, m_hz, xv2, yv2, zv2);
155 ToGlobal(m_hx, -m_lY, m_hz, xv3, yv3, zv3);
156 const double dx = i == 0 ? m_lX - m_hx : m_lX + m_hx;
157 const double s = sqrt(m_hz * m_hz + dx * dx);
158 const double xroof = i == 0 ? m_hz / s : -m_hz / s;
159 const double zroof = dx / s;
160
161 Panel roof;
162 roof.a = m_cPhi * m_cTheta * xroof + m_cPhi * m_sTheta * zroof;
163 roof.b = m_sPhi * m_cTheta * xroof + m_sPhi * m_sTheta * zroof;
164 roof.c = -m_sTheta * xroof + m_cTheta * zroof;
165 roof.xv = {xv0, xv1, xv2, xv3};
166 roof.yv = {yv0, yv1, yv2, yv3};
167 roof.zv = {zv0, zv1, zv2, zv3};
168 roof.colour = 0;
169 roof.volume = id;
170 panels.push_back(std::move(roof));
171 }
172 std::cout << "SolidRidge::SolidPanels: " << panels.size() - nPanels
173 << " panels.\n";
174 return true;
175}
double m_dZ
Definition: Solid.hh:167
double m_dX
Direction vector.
Definition: Solid.hh:167
unsigned int GetId() const
Get the ID of the solid.
Definition: Solid.hh:117
double m_sPhi
Definition: Solid.hh:169
void ToGlobal(const double u, const double v, const double w, double &x, double &y, double &z) const
Definition: Solid.hh:202
double m_sTheta
Definition: Solid.hh:171
double m_dY
Definition: Solid.hh:167

The documentation for this class was generated from the following files: