1#ifndef G_AVALANCHE_MICROSCOPIC_H
2#define G_AVALANCHE_MICROSCOPIC_H
43 m_useWeightingPotential = on;
48 m_integrateWeightingField = on;
90 m_useBandStructure = on;
95 m_useNullCollisionSteps = on;
142 return m_endpointsElectrons.size();
153 double& z0,
double& t0,
double& e0,
double& x1,
154 double& y1,
double& z1,
double& t1,
double& e1,
157 double& z0,
double& t0,
double& e0,
double& x1,
158 double& y1,
double& z1,
double& t1,
double& e1,
159 double& dx1,
double& dy1,
double& dz1,
162 const unsigned int i = 0)
const;
166 const unsigned int iel = 0)
const;
168 const int ip,
const unsigned int iel = 0)
const;
171 return m_endpointsHoles.size();
173 void GetHoleEndpoint(
const unsigned int i,
double& x0,
double& y0,
double& z0,
174 double& t0,
double& e0,
double& x1,
double& y1,
175 double& z1,
double& t1,
double& e1,
int& status)
const;
180 void GetPhoton(
const unsigned int i,
double& e,
double& x0,
double& y0,
181 double& z0,
double& t0,
double& x1,
double& y1,
double& z1,
182 double& t1,
int& status)
const;
190 bool DriftElectron(
const double x0,
const double y0,
const double z0,
191 const double t0,
const double e0,
const double dx0 = 0.,
192 const double dy0 = 0.,
const double dz0 = 0.);
196 const double t0,
const double e0,
197 const double dx0 = 0.,
const double dy0 = 0.,
198 const double dz0 = 0.);
204 double e,
double dx,
double dy,
double dz,
210 int type,
int level,
Medium* m,
211 double e0,
double e1,
double dx0,
212 double dy0,
double dz0,
double dx1,
213 double dy1,
double dz1));
218 int type,
int level,
Medium* m));
223 int type,
int level,
Medium* m));
229 int type,
int level,
Medium* m));
238 std::string m_className =
"AvalancheMicroscopic";
240 Sensor* m_sensor =
nullptr;
249 double x0, y0, z0, t0;
255 std::vector<point> driftLine;
256 double xLast, yLast, zLast;
258 std::vector<Electron> m_endpointsElectrons;
259 std::vector<Electron> m_endpointsHoles;
264 double x0, y0, z0, t0;
265 double x1, y1, z1, t1;
267 std::vector<photon> m_photons;
270 int m_nElectrons = 0;
276 ViewDrift* m_viewer =
nullptr;
277 bool m_plotExcitations =
true;
278 bool m_plotIonisations =
true;
279 bool m_plotAttachments =
true;
281 TH1* m_histElectronEnergy =
nullptr;
282 TH1* m_histHoleEnergy =
nullptr;
283 TH1* m_histDistance =
nullptr;
284 char m_distanceOption =
'r';
285 std::vector<int> m_distanceHistogramType;
287 TH1* m_histSecondary =
nullptr;
289 bool m_doSignal =
false;
290 bool m_useWeightingPotential =
false;
291 bool m_integrateWeightingField =
false;
292 bool m_doInducedCharge =
false;
293 bool m_storeDriftLines =
false;
294 bool m_usePhotons =
false;
295 bool m_useBandStructure =
true;
296 bool m_useNullCollisionSteps =
false;
297 bool m_useBfield =
false;
300 double m_deltaCut = 0.;
301 double m_gammaCut = 0.;
304 unsigned int m_sizeCut = 0;
306 unsigned int m_nCollSkip = 100;
308 bool m_hasTimeWindow =
false;
313 void (*m_userHandleStep)(
double x,
double y,
double z,
double t,
double e,
314 double dx,
double dy,
double dz,
315 bool hole) =
nullptr;
316 void (*m_userHandleCollision)(
double x,
double y,
double z,
double t,
317 int type,
int level, Medium* m,
double e0,
318 double e1,
double dx0,
double dy0,
double dz0,
319 double dx1,
double dy1,
double dz1) =
nullptr;
320 void (*m_userHandleAttachment)(
double x,
double y,
double z,
double t,
321 int type,
int level, Medium* m) =
nullptr;
322 void (*m_userHandleInelastic)(
double x,
double y,
double z,
double t,
323 int type,
int level, Medium* m) =
nullptr;
324 void (*m_userHandleIonisation)(
double x,
double y,
double z,
double t,
325 int type,
int level, Medium* m) =
nullptr;
328 bool m_debug =
false;
330 bool TransportElectrons(std::vector<Electron>& stack,
const bool aval);
331 void TransportPhoton(
const double x,
const double y,
const double z,
332 const double t,
const double e,
333 std::vector<Electron>& stack);
335 static bool IsInactive(
const Electron& item) {
336 return item.status == StatusLeftDriftMedium ||
337 item.status == StatusBelowTransportCut ||
338 item.status == StatusOutsideTimeWindow ||
339 item.status == StatusLeftDriftArea || item.status == StatusAttached;
341 void Update(std::vector<Electron>::iterator it,
const double x,
342 const double y,
const double z,
const double t,
343 const double energy,
const double kx,
const double ky,
344 const double kz,
const int band);
345 void AddToEndPoints(
const Electron& item,
const bool hole) {
347 m_endpointsHoles.push_back(item);
349 m_endpointsElectrons.push_back(item);
354 void AddToStack(
const double x,
const double y,
const double z,
355 const double t,
const double energy,
const bool hole,
356 std::vector<Electron>& container)
const;
358 void AddToStack(
const double x,
const double y,
const double z,
359 const double t,
const double energy,
const double dx,
360 const double dy,
const double dz,
const int band,
361 const bool hole, std::vector<Electron>& container)
const;
362 void Terminate(
double x0,
double y0,
double z0,
double t0,
double& x1,
363 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 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 UseInducedCharge(const bool on=true)
Switch on calculation of the total induced charge (default: off).
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.