Garfield++ 5.0
A toolkit for the detailed simulation of particle detectors based on ionisation measurement in gases and semiconductors
Loading...
Searching...
No Matches
Track.hh
Go to the documentation of this file.
1#ifndef G_TRACK_H
2#define G_TRACK_H
3
4#include <cmath>
5#include <string>
6
7namespace Garfield {
8
9class Sensor;
10class ViewDrift;
11
12/// Abstract base class for track generation.
13
14class Track {
15 public:
16 /// Default constructor.
17 Track() = delete;
18 /// Constructor
19 Track(const std::string& name);
20 /// Destructor
21 virtual ~Track() {}
22
23 /// Set the type of charged particle.
24 /// - electron,e-
25 /// - positron,e+
26 /// - muon,mu-
27 /// - mu+
28 /// - pion,pi-
29 /// - pi+
30 /// - kaon,K-
31 /// - K+
32 /// - proton,p
33 /// - anti-proton,p-bar
34 /// - deuteron,d
35 /// - alpha
36 virtual void SetParticle(const std::string& part);
37
38 /// Set the particle energy.
39 void SetEnergy(const double e);
40 /// Set the relative momentum of the particle.
41 void SetBetaGamma(const double bg);
42 /// Set the speed (\f$\beta = v/c\f$) of the particle.
43 void SetBeta(const double beta);
44 /// Set the Lorentz factor of the particle.
45 void SetGamma(const double gamma);
46 /// Set the particle momentum.
47 void SetMomentum(const double p);
48 /// Set the kinetic energy of the particle.
49 void SetKineticEnergy(const double ekin);
50
51 /// Return the particle energy.
52 double GetEnergy() const { return m_energy; }
53 /// Return the \f$\beta\gamma\f$ of the projectile.
54 double GetBetaGamma() const { return sqrt(m_beta2 / (1. - m_beta2)); }
55 /// Return the speed (\f$\beta = v/c\f$) of the projectile.
56 double GetBeta() const { return sqrt(m_beta2); }
57 /// Return the Lorentz factor of the projectile.
58 double GetGamma() const { return sqrt(1. / (1. - m_beta2)); }
59 /// Return the particle momentum.
60 double GetMomentum() const { return m_mass * sqrt(m_beta2 / (1. - m_beta2)); }
61 /// Return the kinetic energy of the projectile.
62 double GetKineticEnergy() const { return m_energy - m_mass; }
63
64 /// Get the charge of the projectile.
65 double GetCharge() const { return m_q; }
66 /// Get the mass [eV / c2] of the projectile.
67 double GetMass() const { return m_mass; }
68
69 /// Set the sensor through which to transport the particle.
70 void SetSensor(Sensor* s);
71
72 /// Calculate a new track starting from (x0, y0, z0) at time t0
73 /// in direction (dx0, dy0, dz0).
74 virtual bool NewTrack(const double x0, const double y0, const double z0,
75 const double t0, const double dx0, const double dy0,
76 const double dz0) = 0;
77 /** Get the next "cluster" (ionising collision of the charged particle).
78 * \param xc,yc,zc coordinates of the collision
79 * \param tc time of the collision
80 * \param nc number of electrons produced
81 * \param ec deposited energy
82 * \param extra additional information (not always implemented)
83 */
84 virtual bool GetCluster(double& xc, double& yc, double& zc, double& tc,
85 int& nc, double& ec, double& extra) = 0;
86
87 /// Get the cluster density (number of ionizing collisions per cm or
88 /// inverse mean free path for ionization).
89 virtual double GetClusterDensity() { return 0.; }
90 /// Get the stopping power (mean energy loss [eV] per cm).
91 virtual double GetStoppingPower() { return 0.; }
92
93 /// Switch on plotting.
94 void EnablePlotting(ViewDrift* viewer);
95 /// Switch off plotting.
96 void DisablePlotting();
97
98 /// Switch on debugging messages.
99 void EnableDebugging() { m_debug = true; }
100 /// Switch off debugging messages.
101 void DisableDebugging() { m_debug = false; }
102
103 protected:
104 std::string m_className = "Track";
105
106 double m_q = -1.;
107 int m_spin = 1;
108 double m_mass;
109 double m_energy = 0.;
110 double m_beta2 = 1.;
111 bool m_isElectron = false;
112 std::string m_particleName = "mu-";
113
114 Sensor* m_sensor = nullptr;
115
116 bool m_isChanged = true;
117
118 ViewDrift* m_viewer = nullptr;
119
120 bool m_debug = false;
121
122 size_t m_plotId = 0;
123 void PlotNewTrack(const double x0, const double y0, const double z0);
124 void PlotCluster(const double x0, const double y0, const double z0);
125
126 static std::array<double, 3> StepBfield(const double dt, const double qoverm,
127 const double vmag, double bx, double by, double bz,
128 std::array<double, 3>& dir);
129
130};
131}
132
133#endif
double GetMass() const
Get the mass [eV / c2] of the projectile.
Definition Track.hh:67
double GetKineticEnergy() const
Return the kinetic energy of the projectile.
Definition Track.hh:62
size_t m_plotId
Definition Track.hh:122
void DisablePlotting()
Switch off plotting.
Definition Track.cc:186
double GetEnergy() const
Return the particle energy.
Definition Track.hh:52
double GetBetaGamma() const
Return the of the projectile.
Definition Track.hh:54
void EnablePlotting(ViewDrift *viewer)
Switch on plotting.
Definition Track.cc:178
Sensor * m_sensor
Definition Track.hh:114
void SetBetaGamma(const double bg)
Set the relative momentum of the particle.
Definition Track.cc:106
double GetBeta() const
Return the speed ( ) of the projectile.
Definition Track.hh:56
double GetGamma() const
Return the Lorentz factor of the projectile.
Definition Track.hh:58
double GetCharge() const
Get the charge of the projectile.
Definition Track.hh:65
virtual double GetClusterDensity()
Definition Track.hh:89
void SetSensor(Sensor *s)
Set the sensor through which to transport the particle.
Definition Track.cc:169
bool m_isElectron
Definition Track.hh:111
bool m_isChanged
Definition Track.hh:116
void SetKineticEnergy(const double ekin)
Set the kinetic energy of the particle.
Definition Track.cc:156
virtual ~Track()
Destructor.
Definition Track.hh:21
static std::array< double, 3 > StepBfield(const double dt, const double qoverm, const double vmag, double bx, double by, double bz, std::array< double, 3 > &dir)
Definition Track.cc:199
void SetMomentum(const double p)
Set the particle momentum.
Definition Track.cc:143
virtual void SetParticle(const std::string &part)
Definition Track.cc:18
void EnableDebugging()
Switch on debugging messages.
Definition Track.hh:99
ViewDrift * m_viewer
Definition Track.hh:118
std::string m_particleName
Definition Track.hh:112
void PlotCluster(const double x0, const double y0, const double z0)
Definition Track.cc:195
double m_beta2
Definition Track.hh:110
virtual bool NewTrack(const double x0, const double y0, const double z0, const double t0, const double dx0, const double dy0, const double dz0)=0
std::string m_className
Definition Track.hh:104
void SetEnergy(const double e)
Set the particle energy.
Definition Track.cc:93
void SetGamma(const double gamma)
Set the Lorentz factor of the particle.
Definition Track.cc:131
virtual bool GetCluster(double &xc, double &yc, double &zc, double &tc, int &nc, double &ec, double &extra)=0
double m_mass
Definition Track.hh:108
Track()=delete
Default constructor.
void SetBeta(const double beta)
Set the speed ( ) of the particle.
Definition Track.cc:119
double GetMomentum() const
Return the particle momentum.
Definition Track.hh:60
virtual double GetStoppingPower()
Get the stopping power (mean energy loss [eV] per cm).
Definition Track.hh:91
void DisableDebugging()
Switch off debugging messages.
Definition Track.hh:101
double m_energy
Definition Track.hh:109
void PlotNewTrack(const double x0, const double y0, const double z0)
Definition Track.cc:190
Visualize drift lines and tracks.
Definition ViewDrift.hh:19