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

Cylindrical tube. More...

#include <SolidTube.hh>

+ Inheritance diagram for Garfield::SolidTube:

Public Member Functions

 SolidTube (const double cx, const double cy, const double cz, const double rmin, const double rmax, const double lz)
 Constructor from centre, inner/outer radii, and length.
 
 SolidTube (const double cx, const double cy, const double cz, const double rmin, const double rmax, const double lz, const double dx, const double dy, const double dz)
 Constructor from centre, inner/outer radii, length and orientation.
 
 ~SolidTube ()
 Destructor.
 
virtual bool IsInside (const double x, const double y, const double z) const
 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
 Return the bounding box of the solid.
 
virtual bool IsTube () const
 Return true if the solid is a tube.
 
virtual bool GetCenter (double &x, double &y, double &z) const
 
virtual bool GetDimensions (double &l1, double &l2, double &l3) const
 
virtual bool GetOrientation (double &ctheta, double &stheta, double &cphi, double &sphi) const
 
void SetInnerRadius (const double rmin)
 
void SetOuterRadius (const double rmax)
 
void SetHalfLengthZ (const double lz)
 
- Public Member Functions inherited from Garfield::Solid
 Solid ()
 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 GetCenter (double &x, double &y, double &z) const =0
 
virtual bool GetDimensions (double &l1, double &l2, double &l3) const =0
 
virtual bool GetOrientation (double &ctheta, double &stheta, double &cphi, double &shpi) const =0
 
void EnableDebugging ()
 Switch on debugging messages.
 
void DisableDebugging ()
 

Additional Inherited Members

- Protected Attributes inherited from Garfield::Solid
bool m_debug
 

Detailed Description

Cylindrical tube.

Definition at line 10 of file SolidTube.hh.

Constructor & Destructor Documentation

◆ SolidTube() [1/2]

Garfield::SolidTube::SolidTube ( const double  cx,
const double  cy,
const double  cz,
const double  rmin,
const double  rmax,
const double  lz 
)

Constructor from centre, inner/outer radii, and length.

Definition at line 10 of file SolidTube.cc.

12 : Solid(),
13 m_cX(cx), m_cY(cy), m_cZ(cz),
14 m_rMin(rmin), m_rMax(rmax),
15 m_lZ(lz),
16 m_dX(0.), m_dY(0.), m_dZ(1.),
17 m_cPhi(1.), m_sPhi(0.),
18 m_cTheta(1.), m_sTheta(0.) {}
Solid()
Constructor.
Definition: Solid.hh:12

◆ SolidTube() [2/2]

Garfield::SolidTube::SolidTube ( const double  cx,
const double  cy,
const double  cz,
const double  rmin,
const double  rmax,
const double  lz,
const double  dx,
const double  dy,
const double  dz 
)

Constructor from centre, inner/outer radii, length and orientation.

Definition at line 20 of file SolidTube.cc.

23 : Solid(),
24 m_cX(cx), m_cY(cy), m_cZ(cz),
25 m_rMin(rmin), m_rMax(rmax),
26 m_lZ(lz),
27 m_dX(0.), m_dY(0.), m_dZ(1.),
28 m_cPhi(1.), m_sPhi(0.),
29 m_cTheta(1.), m_sTheta(0.) {
30
31 const double d = sqrt(dx * dx + dy * dy + dz * dz);
32 if (d < Small) {
33 std::cerr << "SolidTube: Direction vector has zero norm.\n";
34 } else {
35 m_dX = dx / d;
36 m_dY = dy / d;
37 m_dZ = dz / d;
38 double phi, theta;
39 const double dt = sqrt(m_dX * m_dX + m_dY * m_dY);
40 if (dt < Small) {
41 phi = 0.;
42 if (m_dZ > 0.) {
43 theta = 0.;
44 } else {
45 theta = Pi;
46 }
47 } else {
48 phi = atan2(m_dY, m_dX);
49 theta = atan2(dt, m_dZ);
50 }
51 m_cTheta = cos(theta);
52 m_sTheta = sin(theta);
53 m_cPhi = cos(phi);
54 m_sPhi = sin(phi);
55 }
56}
DoubleAc cos(const DoubleAc &f)
Definition: DoubleAc.cpp:432
DoubleAc sin(const DoubleAc &f)
Definition: DoubleAc.cpp:384
DoubleAc sqrt(const DoubleAc &f)
Definition: DoubleAc.cpp:314

◆ ~SolidTube()

Garfield::SolidTube::~SolidTube ( )
inline

Destructor.

Definition at line 21 of file SolidTube.hh.

21{}

Member Function Documentation

◆ GetBoundingBox()

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

Return the bounding box of the solid.

Implements Garfield::Solid.

Definition at line 95 of file SolidTube.cc.

96 {
97
98 if (m_cTheta == 1. && m_cPhi == 1.) {
99 xmin = m_cX - m_rMax;
100 xmax = m_cX + m_rMax;
101 ymin = m_cY - m_rMax;
102 ymax = m_cY + m_rMax;
103 zmin = m_cZ - m_lZ;
104 zmax = m_cZ + m_lZ;
105 return true;
106 }
107
108 const double dd = sqrt(m_rMax * m_rMax + m_lZ * m_lZ);
109 xmin = m_cX - dd;
110 xmax = m_cX + dd;
111 ymin = m_cY - dd;
112 ymax = m_cY + dd;
113 zmin = m_cZ - dd;
114 zmax = m_cZ + dd;
115 return true;
116}

◆ GetCenter()

bool Garfield::SolidTube::GetCenter ( double &  x,
double &  y,
double &  z 
) const
virtual

Implements Garfield::Solid.

Definition at line 118 of file SolidTube.cc.

118 {
119
120 x = m_cX;
121 y = m_cY;
122 z = m_cZ;
123 return true;
124}

◆ GetDimensions()

bool Garfield::SolidTube::GetDimensions ( double &  l1,
double &  l2,
double &  l3 
) const
virtual

Implements Garfield::Solid.

Definition at line 126 of file SolidTube.cc.

126 {
127
128 l1 = m_rMin;
129 l2 = m_rMax;
130 l3 = m_lZ;
131 return true;
132}

◆ GetOrientation()

bool Garfield::SolidTube::GetOrientation ( double &  ctheta,
double &  stheta,
double &  cphi,
double &  sphi 
) const
virtual

Implements Garfield::Solid.

Definition at line 134 of file SolidTube.cc.

135 {
136
137 ctheta = m_cTheta;
138 stheta = m_sTheta;
139 cphi = m_cPhi;
140 sphi = m_sPhi;
141 return true;
142}

◆ IsInside()

bool Garfield::SolidTube::IsInside ( const double  x,
const double  y,
const double  z 
) const
virtual

Check whether a given point is inside the solid.

Implements Garfield::Solid.

Definition at line 58 of file SolidTube.cc.

58 {
59
60 // Transform the point to local coordinates
61 const double dx = x - m_cX;
62 const double dy = y - m_cY;
63 const double dz = z - m_cZ;
64 const double u = m_cPhi * m_cTheta * dx + m_sPhi * m_cTheta * dy - m_sTheta * dz;
65 const double v = -m_sPhi * dx + m_cPhi * dy;
66 const double w = m_cPhi * m_sTheta * dx + m_sPhi * m_sTheta * dy + m_cTheta * dz;
67
68 if (fabs(w) > m_lZ) {
69 if (m_debug) {
70 std::cout << "SolidTube::IsInside:\n";
71 std::cout << " (" << x << ", " << y << ", " << z << ")"
72 << " is outside.\n";
73 }
74 return false;
75 }
76
77 const double r = sqrt(u * u + v * v);
78 if (r >= m_rMin && r <= m_rMax) {
79 if (m_debug) {
80 std::cout << "SolidTube::IsInside:\n";
81 std::cout << " (" << x << ", " << y << ", " << z << ")"
82 << " is inside.\n";
83 }
84 return true;
85 }
86
87 if (m_debug) {
88 std::cout << "SolidTube::IsInside:\n";
89 std::cout << " (" << x << ", " << y << ", " << z << ") "
90 << " is outside.\n";
91 }
92 return false;
93}
bool m_debug
Definition: Solid.hh:39
DoubleAc fabs(const DoubleAc &f)
Definition: DoubleAc.h:615

◆ IsTube()

virtual bool Garfield::SolidTube::IsTube ( ) const
inlinevirtual

Return true if the solid is a tube.

Reimplemented from Garfield::Solid.

Definition at line 26 of file SolidTube.hh.

26{ return true; }

◆ SetHalfLengthZ()

void Garfield::SolidTube::SetHalfLengthZ ( const double  lz)

Definition at line 174 of file SolidTube.cc.

174 {
175
176 if (lz <= 0.) {
177 std::cerr << "SolidTube::SetHalfLengthZ:\n";
178 std::cerr << " Half-length must be > 0.\n";
179 return;
180 }
181 m_lZ = lz;
182}

◆ SetInnerRadius()

void Garfield::SolidTube::SetInnerRadius ( const double  rmin)

Definition at line 144 of file SolidTube.cc.

144 {
145
146 if (rmin <= 0.) {
147 std::cerr << "SolidTube::SetInnerRadius:\n";
148 std::cerr << " Radius must be > 0.\n";
149 return;
150 }
151 if (rmin >= m_rMax) {
152 std::cerr << "SolidTube::SetInnerRadius:\n";
153 std::cerr << " Inner radius must be smaller than outer radius.\n";
154 return;
155 }
156 m_rMin = rmin;
157}

◆ SetOuterRadius()

void Garfield::SolidTube::SetOuterRadius ( const double  rmax)

Definition at line 159 of file SolidTube.cc.

159 {
160
161 if (rmax <= 0.) {
162 std::cerr << "SolidTube::SetOuterRadius:\n";
163 std::cerr << " Radius must be > 0.\n";
164 return;
165 }
166 if (rmax <= m_rMin) {
167 std::cerr << "SolidTube::SetOuterRadius:\n";
168 std::cerr << " Outer radius must be greater than inner radius.\n";
169 return;
170 }
171 m_rMax = rmax;
172}

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