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

Sphere. More...

#include <SolidSphere.hh>

+ Inheritance diagram for Garfield::SolidSphere:

Public Member Functions

 SolidSphere (const double cx, const double cy, const double cz, const double rmin, const double rmax)
 Constructor.
 
 ~SolidSphere ()
 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 IsSphere () const
 Return true if the solid is a sphere.
 
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)
 
- 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

Sphere.

Definition at line 10 of file SolidSphere.hh.

Constructor & Destructor Documentation

◆ SolidSphere()

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

Constructor.

Definition at line 10 of file SolidSphere.cc.

12 : Solid(),
13 m_cX(cx), m_cY(cy), m_cZ(cz),
14 m_rMin(rmin), m_rMax(rmax) {}
Solid()
Constructor.
Definition: Solid.hh:12

◆ ~SolidSphere()

Garfield::SolidSphere::~SolidSphere ( )
inline

Destructor.

Definition at line 17 of file SolidSphere.hh.

17{}

Member Function Documentation

◆ GetBoundingBox()

bool Garfield::SolidSphere::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 51 of file SolidSphere.cc.

52 {
53
54 xmin = m_cX - m_rMax;
55 xmax = m_cX + m_rMax;
56 ymin = m_cY - m_rMax;
57 ymax = m_cY + m_rMax;
58 zmin = m_cZ - m_rMax;
59 zmax = m_cZ + m_rMax;
60 return true;
61}

◆ GetCenter()

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

Implements Garfield::Solid.

Definition at line 63 of file SolidSphere.cc.

63 {
64
65 x = m_cX;
66 y = m_cY;
67 z = m_cZ;
68 return true;
69}

◆ GetDimensions()

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

Implements Garfield::Solid.

Definition at line 71 of file SolidSphere.cc.

71 {
72
73 l1 = m_rMin;
74 l2 = m_rMax;
75 l3 = 0.;
76 return true;
77}

◆ GetOrientation()

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

Implements Garfield::Solid.

Definition at line 79 of file SolidSphere.cc.

80 {
81
82 ctheta = 1.;
83 stheta = 0.;
84 cphi = 1.;
85 sphi = 0.;
86 return true;
87}

◆ IsInside()

bool Garfield::SolidSphere::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 16 of file SolidSphere.cc.

17 {
18
19 // Transform the point to local coordinates
20 const double dx = x - m_cX;
21 const double dy = y - m_cY;
22 const double dz = z - m_cZ;
23
24 if (fabs(dx) > m_rMax || fabs(dy) > m_rMax || fabs(dz) > m_rMax) {
25 if (m_debug) {
26 std::cout << "SolidSphere::IsInside:\n";
27 std::cout << " (" << x << ", " << y << ", " << z << ")"
28 << " is outside.\n";
29 }
30 return false;
31 }
32
33 const double r = sqrt(dx * dx + dy * dy + dz * dz);
34 if (r >= m_rMin && r <= m_rMax) {
35 if (m_debug) {
36 std::cout << "SolidSphere::IsInside:\n";
37 std::cout << " (" << x << ", " << y << ", " << z << ")"
38 << " is inside.\n";
39 }
40 return true;
41 }
42
43 if (m_debug) {
44 std::cout << "SolidSphere::IsInside:\n";
45 std::cout << " (" << x << ", " << y << ", " << z << ") "
46 << " is outside.\n";
47 }
48 return false;
49}
bool m_debug
Definition: Solid.hh:39
DoubleAc fabs(const DoubleAc &f)
Definition: DoubleAc.h:615
DoubleAc sqrt(const DoubleAc &f)
Definition: DoubleAc.cpp:314

◆ IsSphere()

virtual bool Garfield::SolidSphere::IsSphere ( ) const
inlinevirtual

Return true if the solid is a sphere.

Reimplemented from Garfield::Solid.

Definition at line 22 of file SolidSphere.hh.

22{ return true; }

◆ SetInnerRadius()

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

Definition at line 89 of file SolidSphere.cc.

89 {
90
91 if (rmin <= 0.) {
92 std::cerr << "SolidSphere::SetInnerRadius:\n";
93 std::cerr << " Radius must be > 0.\n";
94 return;
95 }
96 if (rmin >= m_rMax) {
97 std::cerr << "SolidSphere::SetInnerRadius:\n";
98 std::cerr << " Inner radius must be smaller than outer radius.\n";
99 return;
100 }
101 m_rMin = rmin;
102}

◆ SetOuterRadius()

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

Definition at line 104 of file SolidSphere.cc.

104 {
105
106 if (rmax <= 0.) {
107 std::cerr << "SolidSphere::SetOuterRadius:\n";
108 std::cerr << " Radius must be > 0.\n";
109 return;
110 }
111 if (rmax <= m_rMin) {
112 std::cerr << "SolidSphere::SetOuterRadius:\n";
113 std::cerr << " Outer radius must be greater than inner radius.\n";
114 return;
115 }
116 m_rMax = rmax;
117}

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