Garfield++ v1r0
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// Abstract base class for components
2
3#ifndef G_COMPONENT_BASE_H
4#define G_COMPONENT_BASE_H
5
6#include <vector>
7#include <string>
8
9#include "GeometryBase.hh"
10
11namespace Garfield {
12
14
15 public:
16 // Constructor
18 // Destructor
19 virtual ~ComponentBase() {}
20
21 virtual void SetGeometry(GeometryBase* geo);
22 virtual void Clear();
23
24 // Get the medium at a given location (x, y, z)
25 virtual Medium* GetMedium(const double& x, const double& y,
26 const double& z);
27
28 // Electric field
29 //
30 // Status flags:
31 //
32 // 0: Inside an active medium
33 // > 0: Inside a wire of type X
34 // -4 ... -1: On the side of a plane where no wires are
35 // -5: Inside the mesh but not in an active medium
36 // -6: Outside the mesh
37 // -10: Unknown potential type (should not occur)
38 // other: Other cases (should not occur)
39 //
40 // Calculate the drift field [V/cm] at (x, y, z)
41 virtual void ElectricField(const double x, const double y, const double z,
42 double& ex, double& ey, double& ez, Medium*& m,
43 int& status) = 0;
44 // Calculate the drift field [V/cm] and potential [V] at (x, y, z)
45 virtual void ElectricField(const double x, const double y, const double z,
46 double& ex, double& ey, double& ez, double& v,
47 Medium*& m, int& status) = 0;
48 // Calculate the voltage range [V]
49 virtual bool GetVoltageRange(double& vmin, double& vmax) = 0;
50
51 // Calculate the weighting field [1/cm] at (x,y,z)
52 // for an electrode (specified by its label)
53 virtual void WeightingField(const double x, const double y, const double z,
54 double& wx, double& wy, double& wz,
55 const std::string label);
56 virtual double WeightingPotential(const double x, const double y,
57 const double z, const std::string label);
58
59 // Magnetic field
60 // Calculate the magnetic field [Tesla] at (x, y, z)
61 virtual void MagneticField(const double x, const double y, const double z,
62 double& bx, double& by, double& bz, int& status);
63 // Set a constant magnetic field
64 void SetMagneticField(const double bx, const double by, const double bz);
65
66 // Ready for use?
67 virtual bool IsReady() { return ready; }
68
69 // Get the bounding box coordinates
70 virtual bool GetBoundingBox(double& xmin, double& ymin, double& zmin,
71 double& xmax, double& ymax, double& zmax);
72
73 virtual bool IsWireCrossed(const double x0, const double y0, const double z0,
74 const double x1, const double y1, const double z1,
75 double& xc, double& yc, double& zc);
76 virtual bool IsInTrapRadius(double x0, double y0, double z0, double& xw,
77 double& yw, double& rw);
78
79 // Enable and disable periodicities
81 xPeriodic = true;
83 }
85 xPeriodic = false;
87 }
89 yPeriodic = true;
91 }
93 yPeriodic = false;
95 }
97 zPeriodic = true;
99 }
101 zPeriodic = false;
103 }
104
106 xMirrorPeriodic = true;
108 }
110 xMirrorPeriodic = false;
112 }
114 yMirrorPeriodic = true;
116 }
118 yMirrorPeriodic = false;
120 }
122 zMirrorPeriodic = true;
124 }
126 zMirrorPeriodic = false;
128 }
129
131 xAxiallyPeriodic = true;
133 }
135 xAxiallyPeriodic = false;
137 }
139 yAxiallyPeriodic = true;
141 }
143 yAxiallyPeriodic = false;
145 }
147 zAxiallyPeriodic = true;
149 }
151 zAxiallyPeriodic = false;
153 }
154
156 xRotationSymmetry = true;
158 }
160 xRotationSymmetry = false;
162 }
164 yRotationSymmetry = true;
166 }
168 yRotationSymmetry = false;
170 }
172 zRotationSymmetry = true;
174 }
176 zRotationSymmetry = false;
178 }
179
180 // Switch on/off debugging messages
181 void EnableDebugging() { debug = true; }
182 void DisableDebugging() { debug = false; }
183
184 protected:
185 std::string m_className;
186
188
189 // Ready for use?
190 bool ready;
191
192 // Simple periodicity in x, y, z
194 // Mirror periodicity in x, y, z
196 // Axial periodicity in x, y, z
198 // Rotation symmetry around x-axis, y-axis, z-axis
200
201 // Constant magnetic field
202 double bx0, by0, bz0;
203
204 // Switch on/off debugging messages
205 bool debug;
206
207 // Geometry checks
208 virtual void Reset() = 0;
209 // Verify periodicities
210 virtual void UpdatePeriodicity() = 0;
211};
212}
213
214#endif
virtual void ElectricField(const double x, const double y, const double z, double &ex, double &ey, double &ez, Medium *&m, int &status)=0
GeometryBase * theGeometry
virtual bool IsInTrapRadius(double x0, double y0, double z0, double &xw, double &yw, double &rw)
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 void UpdatePeriodicity()=0
virtual bool IsReady()
void SetMagneticField(const double bx, const double by, const double bz)
virtual void Reset()=0
virtual void MagneticField(const double x, const double y, const double z, double &bx, double &by, double &bz, int &status)
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 GetBoundingBox(double &xmin, double &ymin, double &zmin, double &xmax, double &ymax, double &zmax)
virtual Medium * GetMedium(const double &x, const double &y, const double &z)
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 SetGeometry(GeometryBase *geo)
virtual bool GetVoltageRange(double &vmin, double &vmax)=0