Garfield++ 4.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 /// Constructor
17 Track();
18 /// Destructor
19 virtual ~Track() {}
20
21 /// Set the type of charged particle.
22 /// - electron,e-
23 /// - positron,e+
24 /// - muon,mu-
25 /// - mu+
26 /// - pion,pi-
27 /// - pi+
28 /// - kaon,K-
29 /// - K+
30 /// - proton,p
31 /// - anti-proton,p-bar
32 /// - deuteron,d
33 /// - alpha
34 virtual void SetParticle(const std::string& part);
35
36 /// Set the particle energy.
37 void SetEnergy(const double e);
38 /// Set the relative momentum of the particle.
39 void SetBetaGamma(const double bg);
40 /// Set the speed (\f$\beta = v/c\f$) of the particle.
41 void SetBeta(const double beta);
42 /// Set the Lorentz factor of the particle.
43 void SetGamma(const double gamma);
44 /// Set the particle momentum.
45 void SetMomentum(const double p);
46 /// Set the kinetic energy of the particle.
47 void SetKineticEnergy(const double ekin);
48
49 /// Return the particle energy.
50 double GetEnergy() const { return m_energy; }
51 /// Return the \f$\beta\gamma\f$ of the projectile.
52 double GetBetaGamma() const { return sqrt(m_beta2 / (1. - m_beta2)); }
53 /// Return the speed (\f$\beta = v/c\f$) of the projectile.
54 double GetBeta() const { return sqrt(m_beta2); }
55 /// Return the Lorentz factor of the projectile.
56 double GetGamma() const { return sqrt(1. / (1. - m_beta2)); }
57 /// Return the particle momentum.
58 double GetMomentum() const { return m_mass * sqrt(m_beta2 / (1. - m_beta2)); }
59 /// Return the kinetic energy of the projectile.
60 double GetKineticEnergy() const { return m_energy - m_mass; }
61
62 /// Get the charge of the projectile.
63 double GetCharge() const { return m_q; }
64 /// Get the mass [eV / c2] of the projectile.
65 double GetMass() const { return m_mass; }
66
67 /// Set the sensor through which to transport the particle.
68 void SetSensor(Sensor* s);
69
70 /// Calculate a new track starting from (x0, y0, z0) at time t0
71 /// in direction (dx0, dy0, dz0).
72 virtual bool NewTrack(const double x0, const double y0, const double z0,
73 const double t0, const double dx0, const double dy0,
74 const double dz0) = 0;
75 /** Get the next "cluster" (ionising collision of the charged particle).
76 * \param xcls,ycls,zcls coordinates of the collision
77 * \param tcls time of the collision
78 * \param n number of electrons produced
79 * \param e deposited energy
80 * \param extra additional information (not always implemented)
81 */
82 virtual bool GetCluster(double& xcls, double& ycls, double& zcls,
83 double& tcls, int& n, double& e, double& extra) = 0;
84
85 /// Get the cluster density (number of ionizing collisions per cm or
86 /// inverse mean free path for ionization).
87 virtual double GetClusterDensity() { return 0.; }
88 /// Get the stopping power (mean energy loss [eV] per cm).
89 virtual double GetStoppingPower() { return 0.; }
90
91 /// Switch on plotting.
92 void EnablePlotting(ViewDrift* viewer);
93 /// Switch off plotting.
94 void DisablePlotting();
95
96 /// Switch on debugging messages.
97 void EnableDebugging() { m_debug = true; }
98 /// Switch off debugging messages.
99 void DisableDebugging() { m_debug = false; }
100
101 protected:
102 std::string m_className = "Track";
103
104 double m_q = -1.;
105 int m_spin = 1;
106 double m_mass;
107 double m_energy = 0.;
108 double m_beta2;
109 bool m_isElectron = false;
110 std::string m_particleName = "mu-";
111
112 Sensor* m_sensor = nullptr;
113
114 bool m_isChanged = true;
115
116 ViewDrift* m_viewer = nullptr;
117
118 bool m_debug = false;
119
120 size_t m_plotId = 0;
121 void PlotNewTrack(const double x0, const double y0, const double z0);
122 void PlotCluster(const double x0, const double y0, const double z0);
123};
124}
125
126#endif
Abstract base class for track generation.
Definition: Track.hh:14
double GetMass() const
Get the mass [eV / c2] of the projectile.
Definition: Track.hh:65
double GetKineticEnergy() const
Return the kinetic energy of the projectile.
Definition: Track.hh:60
size_t m_plotId
Definition: Track.hh:120
void DisablePlotting()
Switch off plotting.
Definition: Track.cc:183
double GetEnergy() const
Return the particle energy.
Definition: Track.hh:50
double GetBetaGamma() const
Return the of the projectile.
Definition: Track.hh:52
void EnablePlotting(ViewDrift *viewer)
Switch on plotting.
Definition: Track.cc:175
Sensor * m_sensor
Definition: Track.hh:112
void SetBetaGamma(const double bg)
Set the relative momentum of the particle.
Definition: Track.cc:103
bool m_debug
Definition: Track.hh:118
double GetBeta() const
Return the speed ( ) of the projectile.
Definition: Track.hh:54
double GetGamma() const
Return the Lorentz factor of the projectile.
Definition: Track.hh:56
double GetCharge() const
Get the charge of the projectile.
Definition: Track.hh:63
virtual double GetClusterDensity()
Definition: Track.hh:87
void SetSensor(Sensor *s)
Set the sensor through which to transport the particle.
Definition: Track.cc:166
bool m_isElectron
Definition: Track.hh:109
bool m_isChanged
Definition: Track.hh:114
void SetKineticEnergy(const double ekin)
Set the kinetic energy of the particle.
Definition: Track.cc:153
virtual ~Track()
Destructor.
Definition: Track.hh:19
void SetMomentum(const double p)
Set the particle momentum.
Definition: Track.cc:140
virtual void SetParticle(const std::string &part)
Definition: Track.cc:15
void EnableDebugging()
Switch on debugging messages.
Definition: Track.hh:97
double m_q
Definition: Track.hh:104
ViewDrift * m_viewer
Definition: Track.hh:116
std::string m_particleName
Definition: Track.hh:110
void PlotCluster(const double x0, const double y0, const double z0)
Definition: Track.cc:192
double m_beta2
Definition: Track.hh:108
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:102
void SetEnergy(const double e)
Set the particle energy.
Definition: Track.cc:90
void SetGamma(const double gamma)
Set the Lorentz factor of the particle.
Definition: Track.cc:128
double m_mass
Definition: Track.hh:106
void SetBeta(const double beta)
Set the speed ( ) of the particle.
Definition: Track.cc:116
double GetMomentum() const
Return the particle momentum.
Definition: Track.hh:58
Track()
Constructor.
Definition: Track.cc:13
virtual double GetStoppingPower()
Get the stopping power (mean energy loss [eV] per cm).
Definition: Track.hh:89
void DisableDebugging()
Switch off debugging messages.
Definition: Track.hh:99
double m_energy
Definition: Track.hh:107
void PlotNewTrack(const double x0, const double y0, const double z0)
Definition: Track.cc:187
virtual bool GetCluster(double &xcls, double &ycls, double &zcls, double &tcls, int &n, double &e, double &extra)=0
Visualize drift lines and tracks.
Definition: ViewDrift.hh:18