Garfield++ v1r0
A toolkit for the detailed simulation of particle detectors based on ionisation measurement in gases and semiconductors
Loading...
Searching...
No Matches
AvalancheMicroscopic.hh
Go to the documentation of this file.
1// Calculate electron avalanches using microscopic tracking
2
3#ifndef G_AVALANCHE_MICROSCOPIC_H
4#define G_AVALANCHE_MICROSCOPIC_H
5
6#include <vector>
7#include <string>
8
9#include <TH1.h>
10
11#include "Sensor.hh"
12#include "ViewDrift.hh"
13
14namespace Garfield {
15
17
18 public:
19 // Constructor
21 // Destructor
23
24 void SetSensor(Sensor* sensor);
25
26 // Switch on/off drift line plotting
27 void EnablePlotting(ViewDrift* view);
28 void DisablePlotting();
29 void EnableExcitationMarkers() { m_plotExcitations = true; }
30 void DisableExcitationMarkers() { m_plotExcitations = false; }
31 void EnableIonisationMarkers() { m_plotIonisations = true; }
32 void DisableIonisationMarkers() { m_plotIonisations = false; }
33 void EnableAttachmentMarkers() { m_plotAttachments = true; }
34 void DisableAttachmentMarkers() { m_plotAttachments = false; }
35
36 // Switch on/off calculation of induced currents
37 void EnableSignalCalculation() { m_useSignal = true; }
38 void DisableSignalCalculation() { m_useSignal = false; }
39
40 // Switch on/off calculation of total induced charge
41 void EnableInducedChargeCalculation() { m_useInducedCharge = true; }
42 void DisableInducedChargeCalculation() { m_useInducedCharge = false; }
43
44 // Switch on/off filling histograms for energy distribution
45 void EnableElectronEnergyHistogramming(TH1* histo);
47 void EnableHoleEnergyHistogramming(TH1* histo);
49
50 // Switch on/off filling histograms for distance distribution
51 void SetDistanceHistogram(TH1* histo, const char opt = 'r');
52 void EnableDistanceHistogramming(const int type);
53 void DisableDistanceHistogramming(const int type);
55
58
59 // Switch on/off storage of drift lines
60 void EnableDriftLines() { m_useDriftLines = true; }
61 void DisableDriftLines() { m_useDriftLines = false; }
62
63 // Switch on/off photon transport
64 void EnablePhotonTransport() { m_usePhotons = true; }
65 void DisablePhotonTransport() { m_usePhotons = false; }
66
67 // Switch on/off stepping according to band structure E(k)
68 void EnableBandStructure() { m_useBandStructureDefault = true; }
69 void DisableBandStructure() { m_useBandStructureDefault = false; }
70
71 // Switch on/off update of coordinates for null-collision steps
72 void EnableNullCollisionSteps() { m_useNullCollisionSteps = true; }
73 void DisableNullCollisionSteps() { m_useNullCollisionSteps = false; }
74
75 // Set/get energy threshold for electron transport
76 // (useful for delta electrons)
77 void SetElectronTransportCut(const double cut) { m_deltaCut = cut; }
78 double GetElectronTransportCut() const { return m_deltaCut; }
79
80 // Set/get energy threshold for photon transport
81 void SetPhotonTransportCut(const double cut) { m_gammaCut = cut; }
82 double GetPhotonTransportCut() const { return m_gammaCut; }
83
84 // Enable/disable max. avalanche size
85 void EnableAvalancheSizeLimit(const int size) { m_sizeCut = size; }
86 void DisableAvalancheSizeLimit() { m_sizeCut = -1; }
87 int GetAvalancheSizeLimit() const { return m_sizeCut; }
88
89 // Enable/disable magnetic field in stepping algorithm
90 void EnableMagneticField() { m_useBfield = true; }
91 void DisableMagneticField() { m_useBfield = false; }
92
93 // Set number of collisions to be skipped for plotting
94 void SetCollisionSteps(const int n);
95
96 void SetTimeWindow(const double t0, const double t1);
97 void UnsetTimeWindow();
98
99 void GetAvalancheSize(int& ne, int& ni) const {
100 ne = m_nElectrons;
101 ni = m_nIons;
102 }
103 void GetAvalancheSize(int& ne, int& nh, int& ni) const {
104 ne = m_nElectrons;
105 nh = m_nHoles;
106 ni = m_nIons;
107 }
108
109 int GetNumberOfElectronEndpoints() const { return m_nElectronEndpoints; }
110 void GetElectronEndpoint(const unsigned int i, double& x0, double& y0, double& z0,
111 double& t0, double& e0, double& x1, double& y1,
112 double& z1, double& t1, double& e1,
113 int& status) const;
114 void GetElectronEndpoint(const unsigned int i, double& x0, double& y0, double& z0,
115 double& t0, double& e0, double& x1, double& y1,
116 double& z1, double& t1, double& e1, double& dx1,
117 double& dy1, double& dz1, int& status) const;
118 unsigned int GetNumberOfElectronDriftLinePoints(const unsigned int i = 0) const;
119 unsigned int GetNumberOfHoleDriftLinePoints(const unsigned int i = 0) const;
120 void GetElectronDriftLinePoint(double& x, double& y, double& z, double& t,
121 const int ip, const unsigned int iel = 0) const;
122 void GetHoleDriftLinePoint(double& x, double& y, double& z, double& t,
123 const int ip, const unsigned int iel = 0) const;
124
125 int GetNumberOfHoleEndpoints() const { return m_nHoleEndpoints; }
126 void GetHoleEndpoint(const unsigned int i, double& x0, double& y0, double& z0,
127 double& t0, double& e0, double& x1, double& y1,
128 double& z1, double& t1, double& e1, int& status) const;
129
130 int GetNumberOfPhotons() const { return m_usePhotons ? m_nPhotons : 0; }
131 // Status codes:
132 // -2: photon absorbed by gas molecule
133 void GetPhoton(const unsigned int i, double& e, double& x0, double& y0, double& z0,
134 double& t0, double& x1, double& y1, double& z1, double& t1,
135 int& status) const;
136
137 // Calculate an electron drift line for an electron with given
138 // initial coordinates, energy and direction (random if not specified)
139 // Secondary electrons are not transported
140 bool DriftElectron(const double x0, const double y0, const double z0,
141 const double t0, const double e0, const double dx0 = 0.,
142 const double dy0 = 0., const double dz0 = 0.);
143
144 // Calculate an avalanche initiated by an electron with given
145 // initial coordinates, energy and direction (random if not specified)
146 bool AvalancheElectron(const double x0, const double y0, const double z0,
147 const double t0, const double e0,
148 const double dx0 = 0., const double dy0 = 0.,
149 const double dz0 = 0.);
150
151 // Set user handling procedures
152 void SetUserHandleStep(void (*f)(double x, double y, double z, double t,
153 double e, double dx, double dy, double dz,
154 bool hole));
155 void UnsetUserHandleStep();
156 void SetUserHandleAttachment(void (*f)(double x, double y, double z, double t,
157 int type, int level, Medium* m));
159 void SetUserHandleInelastic(void (*f)(double x, double y, double z, double t,
160 int type, int level, Medium* m));
162 void SetUserHandleIonisation(void (*f)(double x, double y, double z, double t,
163 int type, int level, Medium* m));
165
166 // Switch on/off debugging messages
167 void EnableDebugging() { m_debug = true; }
168 void DisableDebugging() { m_debug = false; }
169
170 private:
171 std::string m_className;
172
173 Sensor* m_sensor;
174
175 struct point {
176 double x, y, z, t;
177 };
178
179 struct electron {
180 // Status
181 int status;
182 // Electron or hole
183 bool hole;
184 // Starting point
185 double x0, y0, z0, t0;
186 // Initial energy
187 double e0;
188 // Band
189 int band;
190 // Current position
191 double x, y, z, t;
192 // Current direction/wavevector
193 double kx, ky, kz;
194 // Current energy
195 double energy;
196 // Drift line
197 std::vector<point> driftLine;
198 double xLast, yLast, zLast;
199 };
200 std::vector<electron> m_stack;
201 std::vector<electron> m_endpointsElectrons;
202 std::vector<electron> m_endpointsHoles;
203
204 unsigned int m_nPhotons;
205 struct photon {
206 // Status
207 int status;
208 // Energy
209 double energy;
210 // Starting point
211 double x0, y0, z0, t0;
212 // End point
213 double x1, y1, z1, t1;
214 };
215 std::vector<photon> m_photons;
216
217 // Number of electrons, holes and ions produced
218 int m_nElectrons;
219 int m_nHoles;
220 int m_nIons;
221 // Number of electron/hole trajectories
222 // (including captured electrons)
223 unsigned int m_nElectronEndpoints;
224 unsigned int m_nHoleEndpoints;
225
226 bool m_usePlotting;
227 ViewDrift* m_viewer;
228 bool m_plotExcitations;
229 bool m_plotIonisations;
230 bool m_plotAttachments;
231
232 TH1* m_histElectronEnergy;
233 TH1* m_histHoleEnergy;
234 bool m_hasElectronEnergyHistogram;
235 bool m_hasHoleEnergyHistogram;
236 TH1* m_histDistance;
237 bool m_hasDistanceHistogram;
238 char m_distanceOption;
239 std::vector<int> m_distanceHistogramType;
240
241 TH1* m_histSecondary;
242 bool m_hasSecondaryHistogram;
243
244 bool m_useSignal;
245 bool m_useInducedCharge;
246 bool m_useDriftLines;
247 bool m_usePhotons;
248 bool m_useBandStructureDefault;
249 bool m_useNullCollisionSteps;
250 bool m_useBfield;
251
252 // Rotation matrices
253 double m_rb11, m_rb12, m_rb13;
254 double m_rb21, m_rb22, m_rb23;
255 double m_rb31, m_rb32, m_rb33;
256 double m_rx22, m_rx23, m_rx32, m_rx33;
257
258 // Transport cuts
259 double m_deltaCut;
260 double m_gammaCut;
261
262 // Max. avalanche size
263 int m_sizeCut;
264
265 int m_nCollSkip;
266
267 bool m_hasTimeWindow;
268 double m_tMin, m_tMax;
269
270 // User procedures
271 bool m_hasUserHandleStep;
272 bool m_hasUserHandleAttachment;
273 bool m_hasUserHandleInelastic;
274 bool m_hasUserHandleIonisation;
275 void (*m_userHandleStep)(double x, double y, double z, double t, double e,
276 double dx, double dy, double dz, bool hole);
277 void (*m_userHandleAttachment)(double x, double y, double z, double t, int type,
278 int level, Medium* m);
279 void (*m_userHandleInelastic)(double x, double y, double z, double t, int type,
280 int level, Medium* m);
281 void (*m_userHandleIonisation)(double x, double y, double z, double t, int type,
282 int level, Medium* m);
283
284 // Switch on/off debugging messages
285 bool m_debug;
286
287 // Electron transport
288 bool TransportElectron(const double x0, const double y0, const double z0,
289 const double t0, const double e0, const double dx0,
290 const double dy0, const double dz0, const bool aval,
291 bool hole);
292 // Photon transport
293 void TransportPhoton(const double x, const double y, const double z,
294 const double t, const double e);
295
296 void ComputeRotationMatrix(const double bx, const double by, const double bz,
297 const double bmag, const double ex,
298 const double ey, const double ez);
299
300 void RotateGlobal2Local(double& dx, double& dy, double& dz);
301 void RotateLocal2Global(double& dx, double& dy, double& dz);
302};
303}
304
305#endif
void EnableDistanceHistogramming(const int type)
void SetDistanceHistogram(TH1 *histo, const char opt='r')
void SetUserHandleStep(void(*f)(double x, double y, double z, double t, double e, double dx, double dy, double dz, bool hole))
void EnableAvalancheSizeLimit(const int size)
void EnablePlotting(ViewDrift *view)
void SetUserHandleIonisation(void(*f)(double x, double y, double z, double t, int type, int level, Medium *m))
bool DriftElectron(const double x0, const double y0, const double z0, const double t0, const double e0, const double dx0=0., const double dy0=0., const double dz0=0.)
void SetPhotonTransportCut(const double cut)
unsigned int GetNumberOfElectronDriftLinePoints(const unsigned int i=0) const
void GetAvalancheSize(int &ne, int &ni) const
void SetUserHandleAttachment(void(*f)(double x, double y, double z, double t, int type, int level, Medium *m))
void GetHoleDriftLinePoint(double &x, double &y, double &z, double &t, const int ip, const unsigned int iel=0) const
void GetElectronEndpoint(const unsigned int i, double &x0, double &y0, double &z0, double &t0, double &e0, double &x1, double &y1, double &z1, double &t1, double &e1, int &status) const
void GetHoleEndpoint(const unsigned int i, double &x0, double &y0, double &z0, double &t0, double &e0, double &x1, double &y1, double &z1, double &t1, double &e1, int &status) const
void GetElectronDriftLinePoint(double &x, double &y, double &z, double &t, const int ip, const unsigned int iel=0) const
void EnableElectronEnergyHistogramming(TH1 *histo)
void GetPhoton(const unsigned int i, double &e, double &x0, double &y0, double &z0, double &t0, double &x1, double &y1, double &z1, double &t1, int &status) const
void GetAvalancheSize(int &ne, int &nh, int &ni) const
void EnableSecondaryEnergyHistogramming(TH1 *histo)
bool AvalancheElectron(const double x0, const double y0, const double z0, const double t0, const double e0, const double dx0=0., const double dy0=0., const double dz0=0.)
void SetElectronTransportCut(const double cut)
unsigned int GetNumberOfHoleDriftLinePoints(const unsigned int i=0) const
void SetUserHandleInelastic(void(*f)(double x, double y, double z, double t, int type, int level, Medium *m))
void SetTimeWindow(const double t0, const double t1)
Definition: vec.h:477