Garfield++ v1r0
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

#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)
 
 ~SolidSphere ()
 
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 IsSphere () 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 SetInnerRadius (const double &rmin)
 
void SetOuterRadius (const double &rmax)
 
- 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 SolidSphere.hh.

Constructor & Destructor Documentation

◆ SolidSphere()

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

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) {}

◆ ~SolidSphere()

Garfield::SolidSphere::~SolidSphere ( )
inline

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

Implements Garfield::Solid.

Definition at line 50 of file SolidSphere.cc.

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

◆ GetCenter()

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

Implements Garfield::Solid.

Definition at line 62 of file SolidSphere.cc.

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

◆ GetDimensions()

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

Implements Garfield::Solid.

Definition at line 70 of file SolidSphere.cc.

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

◆ GetOrientation()

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

Implements Garfield::Solid.

Definition at line 78 of file SolidSphere.cc.

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

◆ IsInside()

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

Implements Garfield::Solid.

Definition at line 16 of file SolidSphere.cc.

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

◆ IsSphere()

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

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 88 of file SolidSphere.cc.

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

◆ SetOuterRadius()

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

Definition at line 103 of file SolidSphere.cc.

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

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