Garfield++ v2r0
A toolkit for the detailed simulation of particle detectors based on ionisation measurement in gases and semiconductors
Loading...
Searching...
No Matches
ComponentBase.hh
Go to the documentation of this file.
1#ifndef G_COMPONENT_BASE_H
2#define G_COMPONENT_BASE_H
3
4#include <vector>
5#include <string>
6
7#include "GeometryBase.hh"
8
9namespace Garfield {
10
11/// Abstract base class for components.
12
14
15 public:
16 /// Constructor
18 /// Destructor
19 virtual ~ComponentBase() {}
20
21 /// Define the geometry.
22 virtual void SetGeometry(GeometryBase* geo);
23 /// Reset.
24 virtual void Clear();
25
26 /// Get the medium at a given location (x, y, z).
27 virtual Medium* GetMedium(const double x, const double y, const double z);
28
29 /** Calculate the drift field at given point.
30 *
31 * \param x,y,z coordinates [cm].
32 * \param ex,ey,ez components of the electric field [V/cm].
33 * \param m pointer to the medium at this location.
34 * \param status status flag
35 *
36 * Status flags:
37 *
38 * 0: Inside an active medium
39 * > 0: Inside a wire of type X
40 * -4 ... -1: On the side of a plane where no wires are
41 * -5: Inside the mesh but not in an active medium
42 * -6: Outside the mesh
43 * -10: Unknown potential type (should not occur)
44 * other: Other cases (should not occur)
45 */
46 virtual void ElectricField(const double x, const double y, const double z,
47 double& ex, double& ey, double& ez, Medium*& m,
48 int& status) = 0;
49 //// Calculate the drift field [V/cm] and potential [V] at (x, y, z).
50 virtual void ElectricField(const double x, const double y, const double z,
51 double& ex, double& ey, double& ez, double& v,
52 Medium*& m, int& status) = 0;
53 /// Calculate the voltage range [V].
54 virtual bool GetVoltageRange(double& vmin, double& vmax) = 0;
55
56 /** Calculate the weighting field at a given point and for a given electrode.
57 * \param x,y,z coordinates [cm].
58 * \param wx,wy,wz components of the weighting field [1/cm].
59 * \param label name of the electrode
60 */
61 virtual void WeightingField(const double x, const double y, const double z,
62 double& wx, double& wy, double& wz,
63 const std::string& label);
64 virtual double WeightingPotential(const double x, const double y,
65 const double z, const std::string& label);
66
67 /** Calculate the magnetic field at a given point.
68 *
69 * \param x,y,z coordinates [cm].
70 * \param bx,by,bz components of the magnetic field [Tesla].
71 * \param status status flag.
72 */
73 virtual void MagneticField(const double x, const double y, const double z,
74 double& bx, double& by, double& bz, int& status);
75 /// Set a constant magnetic field.
76 void SetMagneticField(const double bx, const double by, const double bz);
77
78 /// Ready for use?
79 virtual bool IsReady() { return m_ready; }
80
81 /// Get the bounding box coordinates.
82 virtual bool GetBoundingBox(double& xmin, double& ymin, double& zmin,
83 double& xmax, double& ymax, double& zmax);
84
85 /** Determine whether the line between two points crosses a wire.
86 * \param x0,y0,z0 first point [cm].
87 * \param x1,y1,z1 second point [cm]
88 * \param xc,yc,zc point [cm] where the line crosses the wire.
89 */
90 virtual bool IsWireCrossed(const double x0, const double y0, const double z0,
91 const double x1, const double y1, const double z1,
92 double& xc, double& yc, double& zc);
93 /** Determine whether a particle is inside the trap radius of a wire.
94 * \param q0 charge of the particle [in elementary charges].
95 * \param x0,y0,z0 position [cm] of the particle.
96 * \param xw,yw coordinates of the wire (if applicable).
97 * \param rw radius of the wire (if applicable).
98 */
99 virtual bool IsInTrapRadius(const double q0, const double x0, const double y0,
100 const double z0, double& xw, double& yw,
101 double& rw);
102
103 /// Enable simple periodicity in the \f$x\f$ direction.
104 void EnablePeriodicityX(const bool on = true) {
105 m_xPeriodic = on;
107 }
109 /// Enable simple periodicity in the \f$y\f$ direction.
110 void EnablePeriodicityY(const bool on = true) {
111 m_yPeriodic = on;
113 }
115 /// Enable simple periodicity in the \f$z\f$ direction.
116 void EnablePeriodicityZ(const bool on = true) {
117 m_zPeriodic = on;
119 }
121
122 /// Enable mirror periodicity in the \f$x\f$ direction.
123 void EnableMirrorPeriodicityX(const bool on = true) {
126 }
128 /// Enable mirror periodicity in the \f$y\f$ direction.
129 void EnableMirrorPeriodicityY(const bool on = true) {
132 }
134 /// Enable mirror periodicity in the \f$y\f$ direction.
135 void EnableMirrorPeriodicityZ(const bool on = true) {
138 }
140
141 /// Enable axial periodicity in the \f$x\f$ direction.
142 void EnableAxialPeriodicityX(const bool on = true) {
145 }
147 /// Enable axial periodicity in the \f$y\f$ direction.
148 void EnableAxialPeriodicityY(const bool on = true) {
151 }
153 /// Enable axial periodicity in the \f$z\f$ direction.
154 void EnableAxialPeriodicityZ(const bool on = true) {
157 }
159
160 /// Enable rotation symmetry around the \f$x\f$ axis.
161 void EnableRotationSymmetryX(const bool on = true) {
164 }
166 /// Enable rotation symmetry around the \f$y\f$ axis.
167 void EnableRotationSymmetryY(const bool on = true) {
170 }
172 /// Enable rotation symmetry around the \f$z\f$ axis.
173 void EnableRotationSymmetryZ(const bool on = true) {
176 }
178
179 /// Switch on debugging messages.
180 void EnableDebugging() { m_debug = true; }
181 /// Switch off debugging messages.
182 void DisableDebugging() { m_debug = false; }
183
184 /// Request trapping to be taken care of by the component (for TCAD).
185 void ActivateTraps() { m_activeTraps = true; }
186 void DeactivateTraps() { m_activeTraps = false; }
187 bool IsTrapActive() { return m_activeTraps; }
188
189 /// Request velocity to be taken care of by the component (for TCAD).
193
194 /// Get the electron attachment coefficient.
195 virtual bool ElectronAttachment(const double /*x*/, const double /*y*/,
196 const double /*z*/, double& eta) {
197 eta = 0;
198 return false;
199 }
200 /// Get the hole attachment coefficient.
201 virtual bool HoleAttachment(const double /*x*/, const double /*y*/,
202 const double /*z*/, double& eta) {
203 eta = 0;
204 return false;
205 }
206 /// Get the electron drift velocity.
207 virtual void ElectronVelocity(const double /*x*/, const double /*y*/,
208 const double /*z*/, double& vx, double& vy,
209 double& vz, Medium*& /*m*/, int& status) {
210 vx = vy = vz = 0;
211 status = -100;
212 }
213 /// Get the hole drift velocity.
214 virtual void HoleVelocity(const double /*x*/, const double /*y*/,
215 const double /*z*/, double& vx, double& vy,
216 double& vz, Medium*& /*m*/, int& status) {
217 vx = vy = vz = 0;
218 status = -100;
219 }
220 virtual bool GetElectronLifetime(const double /*x*/, const double /*y*/,
221 const double /*z*/, double& etau) {
222 etau = -1;
223 return false;
224 }
225 virtual bool GetHoleLifetime(const double /*x*/, const double /*y*/,
226 const double /*z*/, double& htau) {
227 htau = -1;
228 return false;
229 }
230
231 protected:
232 /// Class name.
233 std::string m_className;
234
235 /// Pointer to the geometry.
237
238 /// Ready for use?
240
241 /// Does the component have traps?
243 /// Does the component have velocity maps?
245
246 /// Simple periodicity in x.
248 /// Simple periodicity in y.
250 /// Simple periodicity in z.
252 /// Mirror periodicity in x.
254 /// Mirror periodicity in y.
256 /// Mirror periodicity in z.
258 /// Axial periodicity in x.
260 /// Axial periodicity in y.
262 /// Axial periodicity in z.
264 /// Rotation symmetry around x-axis.
266 /// Rotation symmetry around y-axis.
268 /// Rotation symmetry around z-axis.
270
271 double m_bx0, m_by0, m_bz0; //< Constant magnetic field.
272
273 /// Switch on/off debugging messages
275
276 /// Geometry checks
277 virtual void Reset() = 0;
278 /// Verify periodicities
279 virtual void UpdatePeriodicity() = 0;
280};
281}
282
283#endif
Abstract base class for components.
virtual void ElectronVelocity(const double, const double, const double, double &vx, double &vy, double &vz, Medium *&, int &status)
Get the electron drift velocity.
virtual void ElectricField(const double x, const double y, const double z, double &ex, double &ey, double &ez, Medium *&m, int &status)=0
ComponentBase()
Constructor.
Definition: ComponentBase.cc:6
void EnableDebugging()
Switch on debugging messages.
virtual ~ComponentBase()
Destructor.
virtual void HoleVelocity(const double, const double, const double, double &vx, double &vy, double &vz, Medium *&, int &status)
Get the hole drift velocity.
void ActivateVelocityMap()
Request velocity to be taken care of by the component (for TCAD).
void EnableAxialPeriodicityX(const bool on=true)
Enable axial periodicity in the direction.
bool m_zMirrorPeriodic
Mirror periodicity in z.
virtual double WeightingPotential(const double x, const double y, const double z, const std::string &label)
virtual void Clear()
Reset.
bool m_yAxiallyPeriodic
Axial periodicity in y.
GeometryBase * m_geometry
Pointer to the geometry.
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
void EnableRotationSymmetryX(const bool on=true)
Enable rotation symmetry around the axis.
virtual void UpdatePeriodicity()=0
Verify periodicities.
virtual bool IsReady()
Ready for use?
void SetMagneticField(const double bx, const double by, const double bz)
Set a constant magnetic field.
bool m_activeTraps
Does the component have traps?
void ActivateTraps()
Request trapping to be taken care of by the component (for TCAD).
virtual bool GetElectronLifetime(const double, const double, const double, double &etau)
void EnableMirrorPeriodicityZ(const bool on=true)
Enable mirror periodicity in the direction.
virtual void Reset()=0
Geometry checks.
void EnablePeriodicityZ(const bool on=true)
Enable simple periodicity in the direction.
void EnablePeriodicityX(const bool on=true)
Enable simple periodicity in the direction.
virtual void MagneticField(const double x, const double y, const double z, double &bx, double &by, double &bz, int &status)
bool m_zRotationSymmetry
Rotation symmetry around z-axis.
void DisableDebugging()
Switch off debugging messages.
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)
bool m_yRotationSymmetry
Rotation symmetry around y-axis.
bool m_ready
Ready for use?
virtual bool GetBoundingBox(double &xmin, double &ymin, double &zmin, double &xmax, double &ymax, double &zmax)
Get the bounding box coordinates.
bool m_zAxiallyPeriodic
Axial periodicity in z.
bool m_xRotationSymmetry
Rotation symmetry around x-axis.
virtual bool HoleAttachment(const double, const double, const double, double &eta)
Get the hole attachment coefficient.
void EnableMirrorPeriodicityY(const bool on=true)
Enable mirror periodicity in the direction.
virtual bool GetHoleLifetime(const double, const double, const double, double &htau)
bool m_yPeriodic
Simple periodicity in y.
bool m_yMirrorPeriodic
Mirror periodicity in y.
void EnableMirrorPeriodicityX(const bool on=true)
Enable mirror periodicity in the direction.
virtual void WeightingField(const double x, const double y, const double z, double &wx, double &wy, double &wz, const std::string &label)
void EnableRotationSymmetryY(const bool on=true)
Enable rotation symmetry around the axis.
void EnableAxialPeriodicityY(const bool on=true)
Enable axial periodicity in the direction.
void EnablePeriodicityY(const bool on=true)
Enable simple periodicity in the direction.
bool m_xPeriodic
Simple periodicity in x.
bool m_zPeriodic
Simple periodicity in z.
void EnableAxialPeriodicityZ(const bool on=true)
Enable axial periodicity in the direction.
std::string m_className
Class name.
bool m_xAxiallyPeriodic
Axial periodicity in x.
virtual void SetGeometry(GeometryBase *geo)
Define the geometry.
virtual bool IsInTrapRadius(const double q0, const double x0, const double y0, const double z0, double &xw, double &yw, double &rw)
bool m_debug
Switch on/off debugging messages.
bool m_xMirrorPeriodic
Mirror periodicity in x.
virtual bool ElectronAttachment(const double, const double, const double, double &eta)
Get the electron attachment coefficient.
bool m_hasVelocityMap
Does the component have velocity maps?
virtual Medium * GetMedium(const double x, const double y, const double z)
Get the medium at a given location (x, y, z).
void EnableRotationSymmetryZ(const bool on=true)
Enable rotation symmetry around the axis.
virtual bool GetVoltageRange(double &vmin, double &vmax)=0
Calculate the voltage range [V].
Abstract base class for geometry classes.
Definition: GeometryBase.hh:12
Abstract base class for media.
Definition: Medium.hh:11