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

#include <SolidBox.hh>

+ Inheritance diagram for Garfield::SolidBox:

Public Member Functions

 SolidBox (const double &cx, const double &cy, const double &cz, const double &lx, const double &ly, const double &lz)
 
 SolidBox (const double &cx, const double &cy, const double &cz, const double &lx, const double &ly, const double &lz, const double &dx, const double &dy, const double &dz)
 
 ~SolidBox ()
 
virtual bool IsInside (const double &x, const double &y, const double &z) const
 
virtual bool GetBoundingBox (double &xmin, double &ymin, double &zmin, double &xmax, double &ymax, double &zmax) const
 
virtual bool IsBox () const
 
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 SetHalfLengthX (const double &lx)
 
void SetHalfLengthY (const double &ly)
 
void SetHalfLengthZ (const double &lz)
 
- Public Member Functions inherited from Garfield::Solid
 Solid ()
 
virtual ~Solid ()
 
virtual bool IsInside (const double &x, const double &y, const double &z) const =0
 
virtual bool GetBoundingBox (double &xmin, double &ymin, double &zmin, double &xmax, double &ymax, double &zmax) const =0
 
virtual bool IsBox () const
 
virtual bool IsTube () const
 
virtual bool IsSphere () const
 
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 ()
 
void DisableDebugging ()
 

Additional Inherited Members

- Protected Attributes inherited from Garfield::Solid
bool m_debug
 

Detailed Description

Definition at line 10 of file SolidBox.hh.

Constructor & Destructor Documentation

◆ SolidBox() [1/2]

Garfield::SolidBox::SolidBox ( const double &  cx,
const double &  cy,
const double &  cz,
const double &  lx,
const double &  ly,
const double &  lz 
)

Definition at line 10 of file SolidBox.cc.

12 : Solid(),
13 m_cX(cx), m_cY(cy), m_cZ(cz),
14 m_lX(lx), m_lY(ly), m_lZ(lz),
15 m_dX(0.), m_dY(0.), m_dZ(1.),
16 m_cPhi(1.), m_sPhi(0.),
17 m_cTheta(1.), m_sTheta(0.) {
18
19 std::cout << "SolidBox:\n";
20 std::cout << " " << cx - lx << " < x [cm] < " << cx + lx << "\n";
21 std::cout << " " << cy - ly << " < y [cm] < " << cy + ly << "\n";
22 std::cout << " " << cz - lz << " < z [cm] < " << cz + lz << "\n";
23}

◆ SolidBox() [2/2]

Garfield::SolidBox::SolidBox ( const double &  cx,
const double &  cy,
const double &  cz,
const double &  lx,
const double &  ly,
const double &  lz,
const double &  dx,
const double &  dy,
const double &  dz 
)

Definition at line 25 of file SolidBox.cc.

28 : Solid(),
29 m_cX(cx), m_cY(cy), m_cZ(cz),
30 m_lX(lx), m_lY(ly), m_lZ(lz),
31 m_dX(0.), m_dY(0.), m_dZ(1.),
32 m_cPhi(1.), m_sPhi(0.),
33 m_cTheta(1.), m_sTheta(0.) {
34
35 const double d = sqrt(dx * dx + dy * dy + dz * dz);
36 if (d < Small) {
37 std::cerr << "SolidBox: Direction vector has zero norm.\n";
38 } else {
39 m_dX = dx / d;
40 m_dY = dy / d;
41 m_dZ = dz / d;
42 double phi, theta;
43 const double dt = sqrt(m_dX * m_dX + m_dY * m_dY);
44 if (dt < Small) {
45 phi = 0.;
46 if (m_dZ > 0.) {
47 theta = 0.;
48 } else {
49 theta = Pi;
50 }
51 } else {
52 phi = atan2(m_dY, m_dX);
53 theta = atan2(dt, m_dZ);
54 }
55 m_cTheta = cos(theta);
56 m_sTheta = sin(theta);
57 m_cPhi = cos(phi);
58 m_sPhi = sin(phi);
59 }
60}
DoubleAc cos(const DoubleAc &f)
Definition: DoubleAc.cpp:431
DoubleAc sqrt(const DoubleAc &f)
Definition: DoubleAc.cpp:313
DoubleAc sin(const DoubleAc &f)
Definition: DoubleAc.cpp:383

◆ ~SolidBox()

Garfield::SolidBox::~SolidBox ( )
inline

Definition at line 20 of file SolidBox.hh.

20{}

Member Function Documentation

◆ GetBoundingBox()

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

Implements Garfield::Solid.

Definition at line 92 of file SolidBox.cc.

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

◆ GetCenter()

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

Implements Garfield::Solid.

Definition at line 115 of file SolidBox.cc.

115 {
116
117 x = m_cX;
118 y = m_cY;
119 z = m_cZ;
120 return true;
121}

◆ GetDimensions()

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

Implements Garfield::Solid.

Definition at line 123 of file SolidBox.cc.

123 {
124
125 l1 = m_lX;
126 l2 = m_lY;
127 l3 = m_lZ;
128 return true;
129}

◆ GetOrientation()

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

Implements Garfield::Solid.

Definition at line 131 of file SolidBox.cc.

132 {
133
134 ctheta = m_cTheta;
135 stheta = m_sTheta;
136 cphi = m_cPhi;
137 sphi = m_sPhi;
138 return true;
139}

◆ IsBox()

virtual bool Garfield::SolidBox::IsBox ( ) const
inlinevirtual

Reimplemented from Garfield::Solid.

Definition at line 25 of file SolidBox.hh.

25{ return true; }

◆ IsInside()

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

Implements Garfield::Solid.

Definition at line 62 of file SolidBox.cc.

63 {
64
65 // Transform the point to local coordinates
66 const double dx = x - m_cX;
67 const double dy = y - m_cY;
68 const double dz = z - m_cZ;
69 const double u = m_cPhi * m_cTheta * dx + m_sPhi * m_cTheta * dy - m_sTheta * dz;
70 const double v = -m_sPhi * dx + m_cPhi * dy;
71 const double w = m_cPhi * m_sTheta * dx + m_sPhi * m_sTheta * dy + m_cTheta * dz;
72
73 // See whether the point is inside
74 if (fabs(u) > m_lX || fabs(v) > m_lY || fabs(w) > m_lZ) {
75 if (m_debug) {
76 std::cout << "SolidBox::IsInside:\n";
77 std::cout << " (" << x << ", " << y << ", " << z << ") "
78 << " is outside.\n";
79 }
80 return false;
81 }
82
83 if (m_debug) {
84 std::cout << "SolidBox::IsInside:\n";
85 std::cout << " (" << x << ", " << y << ", " << z << ") "
86 << " is inside.\n";
87 }
88
89 return true;
90}
DoubleAc fabs(const DoubleAc &f)
Definition: DoubleAc.h:616
bool m_debug
Definition: Solid.hh:35

◆ SetHalfLengthX()

void Garfield::SolidBox::SetHalfLengthX ( const double &  lx)

Definition at line 141 of file SolidBox.cc.

141 {
142
143 if (lx > 0.) {
144 m_lX = lx;
145 } else {
146 std::cerr << "SolidBox::SetHalfLengthX:\n";
147 std::cerr << " Half-length must be > 0.\n";
148 }
149}

◆ SetHalfLengthY()

void Garfield::SolidBox::SetHalfLengthY ( const double &  ly)

Definition at line 151 of file SolidBox.cc.

151 {
152
153 if (ly > 0.) {
154 m_lY = ly;
155 } else {
156 std::cerr << "SolidBox::SetHalfLengthY:\n";
157 std::cerr << " Half-length must be > 0.\n";
158 }
159}

◆ SetHalfLengthZ()

void Garfield::SolidBox::SetHalfLengthZ ( const double &  lz)

Definition at line 161 of file SolidBox.cc.

161 {
162
163 if (lz > 0.) {
164 m_lZ = lz;
165 } else {
166 std::cerr << "SolidBox::SetHalfLengthZ:\n";
167 std::cerr << " Half-length must be > 0.\n";
168 }
169}

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