1#ifndef G_AVALANCHE_MICROSCOPIC_H
2#define G_AVALANCHE_MICROSCOPIC_H
17class AvalancheMicroscopicGPU;
115 const double sMinStep = 1.e-5) {
211 double& t0,
double& e0,
double& x1,
double& y1,
212 double& z1,
double& t1,
double& e1,
215 double& z0,
double& t0,
double& e0,
double& x1,
216 double& y1,
double& z1,
double& t1,
double& e1,
220 const size_t ip,
const size_t ie = 0)
const;
225 void GetPhoton(
const size_t i,
double& e,
double& x0,
double& y0,
double& z0,
226 double& t0,
double& x1,
double& y1,
double& z1,
double& t1,
237 const double t,
const double e,
const double dx = 0.,
238 const double dy = 0.,
const double dz = 0.,
243 const double t,
const double e,
const double dx = 0.,
244 const double dy = 0.,
const double dz = 0.,
248 const double t,
const double e,
const double dx = 0.,
249 const double dy = 0.,
const double dz = 0.,
256 double e,
double dx,
double dy,
double dz,
262 int type,
int level, Medium* m,
263 double e0,
double e1,
double dx0,
264 double dy0,
double dz0,
double dx1,
265 double dy1,
double dz1));
270 int type,
int level, Medium* m));
275 int type,
int level, Medium* m));
281 int type,
int level, Medium* m));
401 double dx,
double dy,
double dz,
402 bool hole) =
nullptr;
404 int type,
int level, Medium* m,
double e0,
405 double e1,
double dx0,
double dy0,
double dz0,
406 double dx1,
double dy1,
double dz1) =
nullptr;
408 int type,
int level, Medium* m) =
nullptr;
410 int type,
int level, Medium* m) =
nullptr;
412 int type,
int level, Medium* m) =
nullptr;
419 const Seed& seed,
const bool signal,
420 std::vector<double>& ts, std::vector<std::array<double, 3> >& xs,
421 std::vector<Point>& path, std::vector<Seed>& stack);
423 const Seed& seed,
const bool signal,
424 std::vector<double>& ts, std::vector<std::array<double, 3> >& xs,
425 std::vector<Point>& path, std::vector<Seed>& stack);
427 const Seed& seed,
const bool signal,
428 std::vector<double>& ts, std::vector<std::array<double, 3> >& xs,
429 std::vector<Point>& path, std::vector<Seed>& stack);
431 const double t,
const double e,
const size_t w,
432 std::vector<Seed>& stack);
435 const bool aval, std::vector<Seed>& stack,
436 std::vector<Seed>& newParticles,
const bool signal,
437 const bool useBfield,
const bool sc);
438 void Terminate(
double x0,
double y0,
double z0,
double t0,
double& x1,
439 double& y1,
double& z1,
double& t1)
const;
442 const double t,
const size_t w,
443 const double ds,
const double dt,
const double ep,
444 const int level, std::vector<Seed>& stack)
const;
446 const double y,
const double z,
size_t& nCollPlot)
const;
448 const int cstype,
const double x,
const double y,
const double z,
449 const double t,
const int level, Medium* medium,
450 const double en1,
const double en,
451 const double kx,
const double ky,
const double kz,
452 const double kx1,
const double ky1,
const double kz1)
const;
454 const double z,
double& xLast,
double& yLast,
455 double& zLast)
const;
void EnablePlotting(ViewDrift *view, const std::size_t nColl=100)
Switch on drift line plotting.
std::vector< Electron > m_holes
void SetRunModeOptions(MPRunMode mode, int device=-1)
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., const size_t w=1)
Calculate an avalanche initiated by a given electron.
friend class AvalancheMicroscopicGPU
void EnablePathLengthComputation(const bool on=true)
Compute and store the path length of each trajectory (default: off).
void SetMaxNumShowerLoops(int max_loops)
void UnsetUserHandleCollision()
Deactivate the user handle called at every collision.
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., const size_t w=1)
Add an electron to the list of particles to be transported.
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)
Use the weighting potential (as opposed to the weighting field) for calculating the induced current.
void SetDistanceHistogram(TH1 *histo, const char opt='r')
Fill histograms of the distance between successive collisions.
void EnableWeightingFieldIntegration(const bool on=true)
Integrate the weighting field over a drift line step when calculating the induced current (default: o...
void EnableAvalancheSizeLimit(const unsigned int size)
Set a max.
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.
int TransportElectronBfield(const Seed &seed, const bool signal, std::vector< double > &ts, std::vector< std::array< double, 3 > > &xs, std::vector< Point > &path, std::vector< Seed > &stack)
std::vector< Electron > m_electrons_gpu
void EnablePhotonTransport(const bool on=true)
Switch on photon transport.
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 FillDistanceHistogram(const int cstype, const double x, const double y, const double z, double &xLast, double &yLast, double &zLast) const
void CallUserHandles(const int cstype, const double x, const double y, const double z, const double t, const int level, Medium *medium, const double en1, const double en, const double kx, const double ky, const double kz, const double kx1, const double ky1, const double kz1) const
void EnableDriftLines(const bool on=true)
Switch on storage of drift lines (default: off).
TH1 * m_histElectronEnergy
void EnableNullCollisionSteps(const bool on=true, const int nSteps=1)
Switch on update of coordinates for null-collision steps (default: off).
void SetUserHandleIonisation(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 ionising collision or excitation followed by Pen...
void UnsetUserHandleAttachment()
Deactivate the user handle called at every attachment.
void(* m_userHandleCollision)(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)
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., const size_t w=1)
Calculate an electron drift line.
void GetAvalancheSizeGPU(int &ne, int &ni) const
Return the number of electrons and ions in the avalanche.
void GetElectronEndpointGPU(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 DisableHoleEnergyHistogramming()
Stop histogramming the hole energy distribution.
void CreatePenningElectron(const double x, const double y, const double z, const double t, const size_t w, const double ds, const double dt, const double ep, const int level, std::vector< Seed > &stack) const
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 SetDebugShowerIterationAndElectronID(int iter_num, int elec_id)
void SetPhotonTransportCut(const double cut)
Set an energy threshold for photon transport.
const std::vector< Electron > & GetElectrons() const
void(* m_userHandleAttachment)(double x, double y, double z, double t, int type, int level, Medium *m)
size_t GetNumberOfElectronEndpoints() const
Return the number of electron trajectories in the last simulated avalanche (including captured electr...
void EnableIonisationMarkers(const bool on=true)
Draw a marker at every ionising collision or not.
void(* m_userHandleIonisation)(double x, double y, double z, double t, int type, int level, Medium *m)
std::vector< int > m_distanceHistogramType
void UseInducedCharge(const bool on=true)
Switch on calculation of the total induced charge (default: off).
bool m_integrateWeightingField
void Terminate(double x0, double y0, double z0, double t0, double &x1, double &y1, double &z1, double &t1) const
void PlotCollision(const int cstype, const size_t did, const double x, const double y, const double z, size_t &nCollPlot) const
void DisableSecondaryEnergyHistogramming()
Stop histogramming the secondary electron energy distribution.
int m_nIonsGPU
Number of ions produced.
bool m_useNullCollisionSteps
void EnableRKNSteps(const bool on=true)
Switch on Runge-Kutta-Nystrom stepping (default: off).
~AvalancheMicroscopic()
Destructor.
int m_nHolesGPU
Number of holes produced.
AvalancheMicroscopic(Sensor *sensor)
Constructor.
std::vector< Seed > m_stackStoreCPU
void DisableAvalancheSizeLimit()
Do not apply a limit on the avalanche size.
void(* m_userHandleStep)(double x, double y, double z, double t, double e, double dx, double dy, double dz, bool hole)
int TransportElectronSc(const Seed &seed, const bool signal, std::vector< double > &ts, std::vector< std::array< double, 3 > > &xs, std::vector< Point > &path, std::vector< Seed > &stack)
int m_nHoles
Number of holes produced.
unsigned int GetNumberOfElectronEndpointsGPU() const
AvalancheMicroscopic()
Default constructor.
int m_nElectrons
Number of electrons produced.
void EnableBandStructure(const bool on=true)
Switch on stepping according to band structure E(k), for semiconductors.
int m_nElectronsGPU
Number of electrons produced.
double GetPhotonTransportCut() const
Retrieve the energy threshold for transporting photons.
void SetRKNTolerance(const double sTol=1.e-10, const double sMinStep=1.e-5)
Set error tolerance and minimum step size on Runge-Kutta-Nystrom method (default: 1....
void SetCollisionSteps(const unsigned int n)
Set number of collisions to be skipped for storing drift lines.
bool TransportElectrons(std::vector< Seed > &stack, const bool aval)
void GetAvalancheSize(int &ne, int &ni) const
Return the number of electrons and ions in the avalanche.
std::vector< Electron > m_stackStoreGPU
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.
int TransportElectron(const Seed &seed, const bool signal, std::vector< double > &ts, std::vector< std::array< double, 3 > > &xs, std::vector< Point > &path, std::vector< Seed > &stack)
std::vector< Photon > m_photons
Statistics GetStatistics()
void SetSensor(Sensor *sensor)
Set the sensor.
bool m_useWeightingPotential
void(* m_userHandleInelastic)(double x, double y, double z, double t, int type, int level, Medium *m)
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).
std::vector< Seed > GetStackOld()
void DisablePlotting()
Switch off drift line plotting.
void UnsetUserHandleStep()
Deactivate the user handle called at every step.
std::vector< Electron > GetStackOldGPU()
void EnableMagneticField(const bool on=true)
Switch on/off using the magnetic field in the stepping algorithm.
std::vector< Electron > m_electrons
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
Return the coordinates and time of start and end point of a given electron drift line.
AvalancheMicroscopicGPU * m_gpuInterface
void EnableSecondaryEnergyHistogramming(TH1 *histo)
Fill histograms of the energy of electrons emitted in ionising collisions.
void SetElectronTransportCut(const double cut)
Set a (lower) energy threshold for electron transport.
int GetAvalancheSizeLimit() const
Retrieve the currently set size limit.
void DisableElectronEnergyHistogramming()
Stop histogramming the electron energy distribution.
void EnableDebugging()
Switch on debugging messages.
bool transportParticleStack(const bool aval, std::vector< Seed > &stack, std::vector< Seed > &newParticles, const bool signal, const bool useBfield, const bool sc)
void TransportPhoton(const double x, const double y, const double z, const double t, const double e, const size_t w, std::vector< Seed > &stack)
void SetShowProgress(bool show_progress)
const std::vector< Electron > & GetHoles() const
int m_nIons
Number of ions produced.
std::pair< int, int > GetAvalancheSize() const
Return the number of electrons and ions in the avalanche.
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 DisableDistanceHistogramming(const int type)
Stop filling distance distribution histograms for a given collision type.
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).
Visualize drift lines and tracks.
std::vector< Point > path
Drift line.
double pathLength
Path length.
size_t weight
Multiplicity.
double t0
Starting point and time.
double t1
End point and time.
double energy
Kinetic energy.
double kz
Direction/wave vector.
Particle type
Particle type.
std::vector< size_t > stack_old_size
std::vector< double > gpu_stack_transport_time
std::vector< size_t > stack_new_size
std::vector< double > cpu_stack_process_time
std::vector< double > gpu_stack_process_time
std::vector< double > cpu_stack_transport_time