1#ifndef G_AVALANCHE_MICROSCOPIC_H
2#define G_AVALANCHE_MICROSCOPIC_H
45 m_useWeightingPotential = on;
50 m_integrateWeightingField = on;
58 m_computePathLength = on;
96 m_useBandStructure = on;
101 m_useNullCollisionSteps = on;
125 m_useBfieldAuto =
false;
162 const std::vector<Electron>&
GetElectrons()
const {
return m_electrons; }
163 const std::vector<Electron>&
GetHoles()
const {
return m_holes; }
167 return m_electrons.size();
178 double& z0,
double& t0,
double& e0,
double& x1,
179 double& y1,
double& z1,
double& t1,
double& e1,
182 double& z0,
double& t0,
double& e0,
double& x1,
183 double& y1,
double& z1,
double& t1,
double& e1,
184 double& dx1,
double& dy1,
double& dz1,
189 const size_t ip,
const size_t ie = 0)
const;
191 const size_t ip,
const size_t ih = 0)
const;
194 void GetHoleEndpoint(
const size_t i,
double& x0,
double& y0,
double& z0,
195 double& t0,
double& e0,
double& x1,
double& y1,
196 double& z1,
double& t1,
double& e1,
int& status)
const;
201 void GetPhoton(
const size_t i,
double& e,
double& x0,
double& y0,
202 double& z0,
double& t0,
double& x1,
double& y1,
double& z1,
203 double& t1,
int& status)
const;
211 bool DriftElectron(
const double x,
const double y,
const double z,
212 const double t,
const double e,
const double dx = 0.,
213 const double dy = 0.,
const double dz = 0.);
217 const double t,
const double e,
218 const double dx = 0.,
const double dy = 0.,
219 const double dz = 0.);
221 void AddElectron(
const double x,
const double y,
const double z,
222 const double t,
const double e,
223 const double dx = 0.,
const double dy = 0.,
224 const double dz = 0.);
230 double e,
double dx,
double dy,
double dz,
236 int type,
int level,
Medium* m,
237 double e0,
double e1,
double dx0,
238 double dy0,
double dz0,
double dx1,
239 double dy1,
double dz1));
244 int type,
int level,
Medium* m));
249 int type,
int level,
Medium* m));
255 int type,
int level,
Medium* m));
264 std::string m_className =
"AvalancheMicroscopic";
266 Sensor* m_sensor =
nullptr;
268 std::vector<Electron> m_electrons;
269 std::vector<Electron> m_holes;
274 double x0, y0, z0, t0;
275 double x1, y1, z1, t1;
277 std::vector<photon> m_photons;
280 int m_nElectrons = 0;
286 ViewDrift* m_viewer =
nullptr;
287 bool m_plotExcitations =
true;
288 bool m_plotIonisations =
true;
289 bool m_plotAttachments =
true;
291 TH1* m_histElectronEnergy =
nullptr;
292 TH1* m_histHoleEnergy =
nullptr;
293 TH1* m_histDistance =
nullptr;
294 char m_distanceOption =
'r';
295 std::vector<int> m_distanceHistogramType;
297 TH1* m_histSecondary =
nullptr;
299 bool m_doSignal =
true;
300 bool m_useWeightingPotential =
false;
301 bool m_integrateWeightingField =
false;
302 bool m_doInducedCharge =
false;
304 bool m_computePathLength =
false;
305 bool m_storeDriftLines =
false;
306 bool m_usePhotons =
false;
307 bool m_useBandStructure =
true;
308 bool m_useNullCollisionSteps =
false;
309 bool m_useBfieldAuto =
true;
310 bool m_useBfield =
false;
313 double m_deltaCut = 0.;
314 double m_gammaCut = 0.;
317 unsigned int m_sizeCut = 0;
319 size_t m_nCollSkip = 100;
320 size_t m_nCollPlot = 100;
322 bool m_hasTimeWindow =
false;
327 void (*m_userHandleStep)(
double x,
double y,
double z,
double t,
double e,
328 double dx,
double dy,
double dz,
329 bool hole) =
nullptr;
330 void (*m_userHandleCollision)(
double x,
double y,
double z,
double t,
331 int type,
int level, Medium* m,
double e0,
332 double e1,
double dx0,
double dy0,
double dz0,
333 double dx1,
double dy1,
double dz1) =
nullptr;
334 void (*m_userHandleAttachment)(
double x,
double y,
double z,
double t,
335 int type,
int level, Medium* m) =
nullptr;
336 void (*m_userHandleInelastic)(
double x,
double y,
double z,
double t,
337 int type,
int level, Medium* m) =
nullptr;
338 void (*m_userHandleIonisation)(
double x,
double y,
double z,
double t,
339 int type,
int level, Medium* m) =
nullptr;
342 bool m_debug =
false;
344 bool TransportElectrons(std::vector<std::pair<Point, bool> >& stack,
346 int TransportElectron(
const Point& p0,
const bool hole,
347 const bool aval,
const bool signal,
348 std::vector<Point>& path,
349 std::vector<std::pair<Point, bool> >& newParticles,
351 int TransportElectronBfield(
const Point& p0,
const bool hole,
354 std::vector<Point>& path,
355 std::vector<std::pair<Point, bool> >& newParticles,
357 int TransportElectronSc(
const Point& p0,
const bool hole,
360 std::vector<Point>& path,
361 std::vector<std::pair<Point, bool> >& newParticles,
363 void TransportPhoton(
const double x,
const double y,
const double z,
364 const double t,
const double e,
365 std::vector<std::pair<Point, bool> >& stack);
367 void AddSignal(
const double x0,
const double y0,
const double z0,
369 const double x1,
const double y1,
const double z1,
370 const double t1,
const bool hole)
const;
372 void Terminate(
double x0,
double y0,
double z0,
double t0,
double& x1,
373 double& y1,
double& z1,
double& t1);
375 void PlotCollision(
const int cstype,
const size_t did,
376 const double x,
const double y,
const double z,
377 size_t& nCollPlot)
const;
378 void FillDistanceHistogram(
const int cstype,
379 const double x,
const double y,
const double z,
380 double& xLast,
double& yLast,
double& zLast);
void EnablePathLengthComputation(const bool on=true)
Compute and store the path length of each trajectory (default: off).
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 GetHoleDriftLinePoint(double &x, double &y, double &z, double &t, const size_t ip, const size_t ih=0) const
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 callback function to be 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).
size_t GetNumberOfHoleEndpoints() const
void EnablePhotonTransport(const bool on=true)
void AddElectron(const double x, const double y, const double z, const double t, const double e, const double dx=0., const double dy=0., const double dz=0.)
Add an electron to the list of particles to be transported.
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 callback function to be called at every (real) collision.
void GetHoleEndpoint(const size_t 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 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.
size_t GetNumberOfElectronDriftLinePoints(const size_t i=0) const
void GetPhoton(const size_t i, double &e, double &x0, double &y0, double &z0, double &t0, double &x1, double &y1, double &z1, double &t1, int &status) const
void SetPhotonTransportCut(const double cut)
Set an energy threshold for photon transport.
const std::vector< Electron > & GetElectrons() const
size_t GetNumberOfElectronEndpoints() const
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).
bool DriftElectron(const double x, const double y, const double z, const double t, const double e, const double dx=0., const double dy=0., const double dz=0.)
void DisableSecondaryEnergyHistogramming()
Stop histogramming the secondary electron energy distribution.
~AvalancheMicroscopic()
Destructor.
void DisableAvalancheSizeLimit()
Do not apply a limit on the avalanche size.
AvalancheMicroscopic()
Default constructor.
void EnableBandStructure(const bool on=true)
Switch on stepping according to band structure E(k), for semiconductors.
double GetPhotonTransportCut() const
Retrieve the energy threshold for transporting photons.
void SetCollisionSteps(const unsigned int n)
Set number of collisions to be skipped for storing drift lines.
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 EnableExcitationMarkers(const bool on=true)
Draw a marker at every excitation or not.
void EnableSignalCalculation(const bool on=true)
Switch calculation of induced currents on or off (default: enabled).
void DisablePlotting()
Switch off drift line plotting.
void UnsetUserHandleStep()
Deactivate the user handle called at every step.
bool AvalancheElectron(const double x, const double y, const double z, const double t, const double e, const double dx=0., const double dy=0., const double dz=0.)
Calculate an avalanche initiated by a given electron.
void EnableMagneticField(const bool on=true)
Switch on/off using the magnetic field in the stepping algorithm.
double GetElectronTransportCut() const
Retrieve the value of the energy threshold.
void EnableElectronEnergyHistogramming(TH1 *histo)
Fill a histogram with the electron energy distribution.
bool ResumeAvalanche()
Continue the avalanche simulation from the current set of electrons.
void UnsetUserHandleIonisation()
Deactivate the user handle called at every ionisation.
void EnableAttachmentMarkers(const bool on=true)
Draw a marker at every attachment or not.
size_t GetNumberOfPhotons() const
void DisableDistanceHistogramming()
Stop filling distance distribution histograms.
void GetAvalancheSize(int &ne, int &nh, int &ni) const
void GetElectronEndpoint(const size_t 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 EnableSecondaryEnergyHistogramming(TH1 *histo)
Fill histograms of the energy of electrons emitted in ionising collisions.
void EnablePlotting(ViewDrift *view, const size_t nColl=100)
Switch on drift line plotting.
void GetElectronEndpoint(const size_t i, double &x0, double &y0, double &z0, double &t0, double &e0, double &x1, double &y1, double &z1, double &t1, double &e1, double &dx1, double &dy1, double &dz1, int &status) const
void SetElectronTransportCut(const double cut)
int GetAvalancheSizeLimit() const
Retrieve the currently set size limit.
void DisableElectronEnergyHistogramming()
Stop histogramming the electron energy distribution.
void EnableDebugging()
Switch on debugging messages.
size_t GetNumberOfHoleDriftLinePoints(const size_t i=0) const
const std::vector< Electron > & GetHoles() 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 GetElectronDriftLinePoint(double &x, double &y, double &z, double &t, const size_t ip, const size_t ie=0) const
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.
std::vector< Point > path
Drift line.
double pathLength
Path length.
double energy
Kinetic energy.
double kz
Direction/wave vector.