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

#include <ComponentConstant.hh>

+ Inheritance diagram for Garfield::ComponentConstant:

Public Member Functions

 ComponentConstant ()
 
 ~ComponentConstant ()
 
void ElectricField (const double x, const double y, const double z, double &ex, double &ey, double &ez, Medium *&m, int &status)
 
void ElectricField (const double x, const double y, const double z, double &ex, double &ey, double &ez, double &v, Medium *&m, int &status)
 
bool GetVoltageRange (double &vmin, double &vmax)
 
void WeightingField (const double x, const double y, const double z, double &wx, double &wy, double &wz, const std::string label)
 
double WeightingPotential (const double x, const double y, const double z, const std::string label)
 
void SetElectricField (const double ex, const double ey, const double ez)
 
void SetPotential (const double x, const double y, const double z, const double v=0.)
 
void SetWeightingField (const double wx, const double wy, const double wz, const std::string label)
 
void SetWeightingPotential (const double x, const double y, const double z, const double v=0.)
 
- Public Member Functions inherited from Garfield::ComponentBase
 ComponentBase ()
 
virtual ~ComponentBase ()
 
virtual void SetGeometry (GeometryBase *geo)
 
virtual void Clear ()
 
virtual MediumGetMedium (const double &x, const double &y, const double &z)
 
virtual void ElectricField (const double x, const double y, const double z, double &ex, double &ey, double &ez, Medium *&m, int &status)=0
 
virtual void ElectricField (const double x, const double y, const double z, double &ex, double &ey, double &ez, double &v, Medium *&m, int &status)=0
 
virtual bool GetVoltageRange (double &vmin, double &vmax)=0
 
virtual void WeightingField (const double x, const double y, const double z, double &wx, double &wy, double &wz, const std::string label)
 
virtual double WeightingPotential (const double x, const double y, const double z, const std::string label)
 
virtual void MagneticField (const double x, const double y, const double z, double &bx, double &by, double &bz, int &status)
 
void SetMagneticField (const double bx, const double by, const double bz)
 
virtual bool IsReady ()
 
virtual bool GetBoundingBox (double &xmin, double &ymin, double &zmin, double &xmax, double &ymax, double &zmax)
 
virtual bool IsWireCrossed (const double x0, const double y0, const double z0, const double x1, const double y1, const double z1, double &xc, double &yc, double &zc)
 
virtual bool IsInTrapRadius (double x0, double y0, double z0, double &xw, double &yw, double &rw)
 
void EnablePeriodicityX ()
 
void DisablePeriodicityX ()
 
void EnablePeriodicityY ()
 
void DisablePeriodicityY ()
 
void EnablePeriodicityZ ()
 
void DisablePeriodicityZ ()
 
void EnableMirrorPeriodicityX ()
 
void DisableMirrorPeriodicityX ()
 
void EnableMirrorPeriodicityY ()
 
void DisableMirrorPeriodicityY ()
 
void EnableMirrorPeriodicityZ ()
 
void DisableMirrorPeriodicityZ ()
 
void EnableAxialPeriodicityX ()
 
void DisableAxialPeriodicityX ()
 
void EnableAxialPeriodicityY ()
 
void DisableAxialPeriodicityY ()
 
void EnableAxialPeriodicityZ ()
 
void DisableAxialPeriodicityZ ()
 
void EnableRotationSymmetryX ()
 
void DisableRotationSymmetryX ()
 
void EnableRotationSymmetryY ()
 
void DisableRotationSymmetryY ()
 
void EnableRotationSymmetryZ ()
 
void DisableRotationSymmetryZ ()
 
void EnableDebugging ()
 
void DisableDebugging ()
 

Additional Inherited Members

virtual void Reset ()=0
 
virtual void UpdatePeriodicity ()=0
 
- Protected Attributes inherited from Garfield::ComponentBase
std::string m_className
 
GeometryBasetheGeometry
 
bool ready
 
bool xPeriodic
 
bool yPeriodic
 
bool zPeriodic
 
bool xMirrorPeriodic
 
bool yMirrorPeriodic
 
bool zMirrorPeriodic
 
bool xAxiallyPeriodic
 
bool yAxiallyPeriodic
 
bool zAxiallyPeriodic
 
bool xRotationSymmetry
 
bool yRotationSymmetry
 
bool zRotationSymmetry
 
double bx0
 
double by0
 
double bz0
 
bool debug
 

Detailed Description

Definition at line 10 of file ComponentConstant.hh.

Constructor & Destructor Documentation

◆ ComponentConstant()

Garfield::ComponentConstant::ComponentConstant ( )

Definition at line 8 of file ComponentConstant.cc.

10 fx(0.),
11 fy(0.),
12 fz(0.),
13 hasPotential(false),
14 x0(0.),
15 y0(0.),
16 z0(0.),
17 v0(0.),
18 hasWeightingField(false),
19 wfield(""),
20 fwx(0.),
21 fwy(0.),
22 fwz(0.),
23 hasWeightingPotential(false),
24 wx0(0.),
25 wy0(0.),
26 wz0(0.),
27 w0(0.) {
28
29 m_className = "ComponentConstant";
30}

◆ ~ComponentConstant()

Garfield::ComponentConstant::~ComponentConstant ( )
inline

Definition at line 16 of file ComponentConstant.hh.

16{}

Member Function Documentation

◆ ElectricField() [1/2]

void Garfield::ComponentConstant::ElectricField ( const double  x,
const double  y,
const double  z,
double &  ex,
double &  ey,
double &  ez,
double &  v,
Medium *&  m,
int &  status 
)
virtual

Implements Garfield::ComponentBase.

Definition at line 57 of file ComponentConstant.cc.

60 {
61
62 ex = fx;
63 ey = fy;
64 ez = fz;
65 if (hasPotential) {
66 v = v0 - (x - x0) * fx - (y - y0) * fy - (z - z0) * fz;
67 } else {
68 v = 0.;
69 if (debug) {
70 std::cerr << m_className << "::ElectricField:\n";
71 std::cerr << " Potential is not defined.\n";
72 }
73 }
74
75 m = GetMedium(x, y, z);
76 if (m == NULL) {
77 if (debug) {
78 std::cerr << m_className << "::ElectricField:\n";
79 std::cerr << " (" << x << ", " << y << ", " << z << ")"
80 << " is not inside a medium.\n";
81 }
82 status = -6;
83 return;
84 }
85
86 if (m->IsDriftable()) {
87 status = 0;
88 } else {
89 status = -5;
90 }
91}
virtual Medium * GetMedium(const double &x, const double &y, const double &z)

◆ ElectricField() [2/2]

void Garfield::ComponentConstant::ElectricField ( const double  x,
const double  y,
const double  z,
double &  ex,
double &  ey,
double &  ez,
Medium *&  m,
int &  status 
)
virtual

Implements Garfield::ComponentBase.

Definition at line 32 of file ComponentConstant.cc.

34 {
35
36 ex = fx;
37 ey = fy;
38 ez = fz;
39 m = GetMedium(x, y, z);
40 if (m == NULL) {
41 if (debug) {
42 std::cerr << m_className << "::ElectricField:\n";
43 std::cerr << " (" << x << ", " << y << ", " << z << ")"
44 << " is not inside a medium.\n";
45 }
46 status = -6;
47 return;
48 }
49
50 if (m->IsDriftable()) {
51 status = 0;
52 } else {
53 status = -5;
54 }
55}

◆ GetVoltageRange()

bool Garfield::ComponentConstant::GetVoltageRange ( double &  vmin,
double &  vmax 
)
virtual

Implements Garfield::ComponentBase.

Definition at line 93 of file ComponentConstant.cc.

93 {
94
95 if (!hasPotential) return false;
96
97 if (theGeometry == 0) {
98 std::cerr << m_className << "::GetVoltageRange:\n";
99 std::cerr << " Geometry pointer is null.\n";
100 return false;
101 }
102 double xmin, ymin, zmin;
103 double xmax, ymax, zmax;
104 if (!GetBoundingBox(xmin, ymin, zmin, xmax, ymax, zmax)) {
105 std::cerr << m_className << "::GetVoltageRange:\n";
106 std::cerr << " Could not determine bounding box.\n";
107 return false;
108 }
109 // Calculate potentials at each corner
110 const double pxmin = v0 - (xmin - x0) * fx;
111 const double pxmax = v0 - (xmax - x0) * fx;
112 const double pymin = -(ymin - y0) * fy;
113 const double pymax = -(ymax - y0) * fy;
114 const double pzmin = -(zmin - z0) * fz;
115 const double pzmax = -(zmax - z0) * fz;
116 double p[8];
117 p[0] = pxmin + pymin + pzmin;
118 p[1] = pxmin + pymin + pzmax;
119 p[2] = pxmin + pymax + pzmin;
120 p[3] = pxmin + pymax + pzmax;
121 p[4] = pxmax + pymin + pzmin;
122 p[5] = pxmax + pymin + pzmax;
123 p[6] = pxmax + pymax + pzmin;
124 p[7] = pxmax + pymax + pzmax;
125 vmin = vmax = p[7];
126 for (int i = 7; i--;) {
127 if (p[i] > vmax) vmax = p[i];
128 if (p[i] < vmin) vmin = p[i];
129 }
130
131 return true;
132}
GeometryBase * theGeometry
virtual bool GetBoundingBox(double &xmin, double &ymin, double &zmin, double &xmax, double &ymax, double &zmax)

◆ SetElectricField()

void Garfield::ComponentConstant::SetElectricField ( const double  ex,
const double  ey,
const double  ez 
)

Definition at line 166 of file ComponentConstant.cc.

167 {
168
169 fx = ex;
170 fy = ey;
171 fz = ez;
172 if (fx * fx + fy * fy + fz * fz > Small) return;
173
174 std::cerr << m_className << "::SetField:\n";
175 std::cerr << " Electric field is set to zero.\n";
176 ready = true;
177}

◆ SetPotential()

void Garfield::ComponentConstant::SetPotential ( const double  x,
const double  y,
const double  z,
const double  v = 0. 
)

Definition at line 179 of file ComponentConstant.cc.

180 {
181
182 x0 = x;
183 y0 = y;
184 z0 = z;
185 v0 = v;
186 hasPotential = true;
187}

◆ SetWeightingField()

void Garfield::ComponentConstant::SetWeightingField ( const double  wx,
const double  wy,
const double  wz,
const std::string  label 
)

Definition at line 189 of file ComponentConstant.cc.

191 {
192
193 wfield = label;
194 fwx = wx;
195 fwy = wy;
196 fwz = wz;
197 hasWeightingField = true;
198}

◆ SetWeightingPotential()

void Garfield::ComponentConstant::SetWeightingPotential ( const double  x,
const double  y,
const double  z,
const double  v = 0. 
)

Definition at line 200 of file ComponentConstant.cc.

201 {
202
203 if (!hasWeightingField) {
204 std::cerr << m_className << "::SetWeightingPotential:\n";
205 std::cerr << " Set the weighting field first!\n";
206 return;
207 }
208 wx0 = x;
209 wy0 = y;
210 wz0 = z;
211 w0 = v;
212 hasWeightingPotential = true;
213}

◆ WeightingField()

void Garfield::ComponentConstant::WeightingField ( const double  x,
const double  y,
const double  z,
double &  wx,
double &  wy,
double &  wz,
const std::string  label 
)
virtual

Reimplemented from Garfield::ComponentBase.

Definition at line 134 of file ComponentConstant.cc.

136 {
137
138 if (!hasWeightingField || label != wfield) return;
139
140 Medium* m = GetMedium(x, y, z);
141 if (m == NULL) {
142 wx = wy = wz = 0.;
143 if (debug) {
144 std::cout << m_className << "::WeightingField:\n";
145 std::cout << " No medium at (" << x << ", " << y << ", " << z << ")\n";
146 }
147 return;
148 }
149 wx = fwx;
150 wy = fwy;
151 wz = fwz;
152}

◆ WeightingPotential()

double Garfield::ComponentConstant::WeightingPotential ( const double  x,
const double  y,
const double  z,
const std::string  label 
)
virtual

Reimplemented from Garfield::ComponentBase.

Definition at line 154 of file ComponentConstant.cc.

156 {
157
158 if (!hasWeightingPotential || label != wfield) return 0.;
159
160 Medium* m = GetMedium(x, y, z);
161 if (m == NULL) return 0.;
162
163 return w0 - (x - wx0) * fwx - (y - wy0) * fwy - (z - wz0) * fwz;
164}

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