1#ifndef G_AVALANCHE_MICROSCOPIC_H
2#define G_AVALANCHE_MICROSCOPIC_H
33 m_plotExcitations = on;
37 m_plotIonisations = on;
41 m_plotAttachments = on;
49 m_useWeightingPotential = on;
54 m_integrateWeightingField = on;
59 m_doInducedCharge = on;
98 m_useBandStructureDefault = on;
103 m_useNullCollisionSteps = on;
150 return m_endpointsElectrons.size();
161 double& z0,
double& t0,
double& e0,
double& x1,
162 double& y1,
double& z1,
double& t1,
double& e1,
165 double& z0,
double& t0,
double& e0,
double& x1,
166 double& y1,
double& z1,
double& t1,
double& e1,
167 double& dx1,
double& dy1,
double& dz1,
170 const unsigned int i = 0)
const;
174 const unsigned int iel = 0)
const;
176 const int ip,
const unsigned int iel = 0)
const;
179 return m_endpointsHoles.size();
181 void GetHoleEndpoint(
const unsigned int i,
double& x0,
double& y0,
double& z0,
182 double& t0,
double& e0,
double& x1,
double& y1,
183 double& z1,
double& t1,
double& e1,
int& status)
const;
188 void GetPhoton(
const unsigned int i,
double& e,
double& x0,
double& y0,
189 double& z0,
double& t0,
double& x1,
double& y1,
double& z1,
190 double& t1,
int& status)
const;
198 bool DriftElectron(
const double x0,
const double y0,
const double z0,
199 const double t0,
const double e0,
const double dx0 = 0.,
200 const double dy0 = 0.,
const double dz0 = 0.);
204 const double t0,
const double e0,
205 const double dx0 = 0.,
const double dy0 = 0.,
206 const double dz0 = 0.);
210 double e,
double dx,
double dy,
double dz,
216 int type,
int level,
Medium* m,
217 double e0,
double e1,
218 double dx0,
double dy0,
double dz0,
219 double dx1,
double dy1,
double dz1));
224 int type,
int level,
Medium* m));
229 int type,
int level,
Medium* m));
235 int type,
int level,
Medium* m));
244 std::string m_className =
"AvalancheMicroscopic";
246 Sensor* m_sensor =
nullptr;
255 double x0, y0, z0, t0;
261 std::vector<point> driftLine;
262 double xLast, yLast, zLast;
264 std::vector<Electron> m_endpointsElectrons;
265 std::vector<Electron> m_endpointsHoles;
270 double x0, y0, z0, t0;
271 double x1, y1, z1, t1;
273 std::vector<photon> m_photons;
276 int m_nElectrons = 0;
282 ViewDrift* m_viewer =
nullptr;
283 bool m_plotExcitations =
true;
284 bool m_plotIonisations =
true;
285 bool m_plotAttachments =
true;
287 TH1* m_histElectronEnergy =
nullptr;
288 TH1* m_histHoleEnergy =
nullptr;
289 TH1* m_histDistance =
nullptr;
290 char m_distanceOption =
'r';
291 std::vector<int> m_distanceHistogramType;
293 TH1* m_histSecondary =
nullptr;
295 bool m_doSignal =
false;
296 bool m_useWeightingPotential =
false;
297 bool m_integrateWeightingField =
false;
298 bool m_doInducedCharge =
false;
299 bool m_useDriftLines =
false;
300 bool m_usePhotons =
false;
301 bool m_useBandStructureDefault =
true;
302 bool m_useNullCollisionSteps =
false;
303 bool m_useBfield =
false;
306 double m_deltaCut = 0.;
307 double m_gammaCut = 0.;
310 unsigned int m_sizeCut = 0;
312 unsigned int m_nCollSkip = 100;
314 bool m_hasTimeWindow =
false;
319 void (*m_userHandleStep)(
double x,
double y,
double z,
double t,
double e,
320 double dx,
double dy,
double dz,
321 bool hole) =
nullptr;
322 void (*m_userHandleCollision)(
double x,
double y,
double z,
double t,
323 int type,
int level, Medium* m,
324 double e0,
double e1,
325 double dx0,
double dy0,
double dz0,
326 double dx1,
double dy1,
double dz1) =
nullptr;
327 void (*m_userHandleAttachment)(
double x,
double y,
double z,
double t,
328 int type,
int level, Medium* m) =
nullptr;
329 void (*m_userHandleInelastic)(
double x,
double y,
double z,
double t,
330 int type,
int level, Medium* m) =
nullptr;
331 void (*m_userHandleIonisation)(
double x,
double y,
double z,
double t,
332 int type,
int level, Medium* m) =
nullptr;
335 bool m_debug =
false;
338 bool TransportElectron(
const double x0,
const double y0,
const double z0,
339 const double t0,
double e0,
const double dx0,
340 const double dy0,
const double dz0,
const bool aval,
343 void TransportPhoton(
const double x,
const double y,
const double z,
344 const double t,
const double e,
345 std::vector<Electron>& stack);
347 static bool IsInactive(
const Electron& item) {
348 return item.status == StatusLeftDriftMedium ||
349 item.status == StatusBelowTransportCut ||
350 item.status == StatusOutsideTimeWindow ||
351 item.status == StatusLeftDriftArea || item.status == StatusAttached;
353 void Update(std::vector<Electron>::iterator it,
const double x,
354 const double y,
const double z,
const double t,
355 const double energy,
const double kx,
const double ky,
356 const double kz,
const int band);
357 void AddToEndPoints(
const Electron& item,
const bool hole) {
359 m_endpointsHoles.push_back(item);
361 m_endpointsElectrons.push_back(item);
366 void AddToStack(
const double x,
const double y,
const double z,
367 const double t,
const double energy,
const bool hole,
368 std::vector<Electron>& container)
const;
370 void AddToStack(
const double x,
const double y,
const double z,
371 const double t,
const double energy,
const double dx,
372 const double dy,
const double dz,
const int band,
373 const bool hole, std::vector<Electron>& container)
const;
374 void Terminate(
double x0,
double y0,
double z0,
double t0,
double& x1,
375 double& y1,
double& z1,
double& t1);
Calculate electron drift lines and avalanches using microscopic tracking.
void UnsetUserHandleCollision()
Deactivate the user handle called at every collision.
void EnableDistanceHistogramming(const int type)
Fill distance distribution histograms for a given collision type.
void UnsetTimeWindow()
Do not restrict the time interval within which carriers are simulated.
void EnableInducedChargeCalculation(const bool on=true)
Switch on calculation of the total induced charge (default: off).
void UseWeightingPotential(const bool on=true)
void SetDistanceHistogram(TH1 *histo, const char opt='r')
void EnableWeightingFieldIntegration(const bool on=true)
void EnableAvalancheSizeLimit(const unsigned int size)
void SetUserHandleStep(void(*f)(double x, double y, double z, double t, double e, double dx, double dy, double dz, bool hole))
Set a user handling procedure. This function is called at every step.
void EnableHoleEnergyHistogramming(TH1 *histo)
Fill a histogram with the hole energy distribution.
void EnableNullCollisionSteps(const bool on=true)
Switch on update of coordinates for null-collision steps (default: off).
void EnablePhotonTransport(const bool on=true)
void SetUserHandleCollision(void(*f)(double x, double y, double z, double t, int type, int level, Medium *m, double e0, double e1, double dx0, double dy0, double dz0, double dx1, double dy1, double dz1))
Set a user handling procedure, to be called at every (real) collision.
void EnablePlotting(ViewDrift *view)
Switch on drift line plotting.
void EnableDriftLines(const bool on=true)
Switch on storage of drift lines (default: off).
void SetUserHandleIonisation(void(*f)(double x, double y, double z, double t, int type, int level, Medium *m))
void UnsetUserHandleAttachment()
Deactivate the user handle called at every attachment.
void DisableHoleEnergyHistogramming()
Stop histogramming the hole energy distribution.
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)
Set an energy threshold for photon transport.
void EnableIonisationMarkers(const bool on=true)
Draw a marker at every ionising collision or not.
void DisableSecondaryEnergyHistogramming()
Stop histogramming the secondary electron energy distribution.
unsigned int GetNumberOfElectronDriftLinePoints(const unsigned int i=0) const
unsigned int GetNumberOfHoleEndpoints() const
~AvalancheMicroscopic()
Destructor.
void DisableAvalancheSizeLimit()
Do not apply a limit on the avalanche size.
AvalancheMicroscopic()
Constructor.
void EnableBandStructure(const bool on=true)
Switch on stepping according to band structure E(k), for semiconductors.
unsigned int GetNumberOfPhotons() const
double GetPhotonTransportCut() const
Retrieve the energy threshold for transporting photons.
void SetCollisionSteps(const unsigned int n)
Set number of collisions to be skipped for plotting.
void GetAvalancheSize(int &ne, int &ni) const
Return the number of electrons and ions in the avalanche.
void SetUserHandleAttachment(void(*f)(double x, double y, double z, double t, int type, int level, Medium *m))
Set a user handling procedure, to be called at every attachment.
void SetSensor(Sensor *sensor)
Set the sensor.
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 EnableExcitationMarkers(const bool on=true)
Draw a marker at every excitation or not.
void EnableSignalCalculation(const bool on=true)
Switch on calculation of induced currents (default: off).
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 DisablePlotting()
Switch off drift line plotting.
void GetElectronDriftLinePoint(double &x, double &y, double &z, double &t, const int ip, const unsigned int iel=0) const
void UnsetUserHandleStep()
Deactivate the user handle called at every step.
void EnableMagneticField(const bool on=true)
Enable magnetic field in stepping algorithm (default: off).
double GetElectronTransportCut() const
Retrieve the value of the energy threshold.
void EnableElectronEnergyHistogramming(TH1 *histo)
Fill a histogram with the electron energy distribution.
void UnsetUserHandleIonisation()
Deactivate the user handle called at every ionisation.
void EnableAttachmentMarkers(const bool on=true)
Draw a marker at every attachment or not.
void DisableDistanceHistogramming()
Stop filling distance distribution histograms.
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)
Fill histograms of the energy of electrons emitted in ionising collisions.
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.)
Calculate an avalanche initiated by a given electron.
void SetElectronTransportCut(const double cut)
int GetAvalancheSizeLimit() const
Retrieve the currently set size limit.
unsigned int GetNumberOfElectronEndpoints() const
void DisableElectronEnergyHistogramming()
Stop histogramming the electron energy distribution.
void EnableDebugging()
Switch on debugging messages.
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))
Set a user handling procedure, to be called at every inelastic collision.
void UnsetUserHandleInelastic()
Deactivate the user handle called at every inelastic collision.
void SetTimeWindow(const double t0, const double t1)
Define a time interval (only carriers inside the interval are simulated).
Abstract base class for media.
Visualize drift lines and tracks.