Garfield++ 4.0
A toolkit for the detailed simulation of particle detectors based on ionisation measurement in gases and semiconductors
Loading...
Searching...
No Matches
Garfield::TrackElectron Class Reference

Ionization calculation based on MIP program (S. Biagi). More...

#include <TrackElectron.hh>

+ Inheritance diagram for Garfield::TrackElectron:

Public Member Functions

 TrackElectron ()
 
virtual ~TrackElectron ()
 
virtual void SetParticle (const std::string &particle)
 
virtual bool NewTrack (const double x0, const double y0, const double z0, const double t0, const double dx0, const double dy0, const double dz0)
 
virtual bool GetCluster (double &xcls, double &ycls, double &zcls, double &tcls, int &ncls, double &ecls, double &extra)
 
virtual double GetClusterDensity ()
 
virtual double GetStoppingPower ()
 Get the stopping power (mean energy loss [eV] per cm).
 
- Public Member Functions inherited from Garfield::Track
 Track ()
 Constructor.
 
virtual ~Track ()
 Destructor.
 
virtual void SetParticle (const std::string &part)
 
void SetEnergy (const double e)
 Set the particle energy.
 
void SetBetaGamma (const double bg)
 Set the relative momentum of the particle.
 
void SetBeta (const double beta)
 Set the speed ( $\beta = v/c$) of the particle.
 
void SetGamma (const double gamma)
 Set the Lorentz factor of the particle.
 
void SetMomentum (const double p)
 Set the particle momentum.
 
void SetKineticEnergy (const double ekin)
 Set the kinetic energy of the particle.
 
double GetEnergy () const
 Return the particle energy.
 
double GetBetaGamma () const
 Return the $\beta\gamma$ of the projectile.
 
double GetBeta () const
 Return the speed ( $\beta = v/c$) of the projectile.
 
double GetGamma () const
 Return the Lorentz factor of the projectile.
 
double GetMomentum () const
 Return the particle momentum.
 
double GetKineticEnergy () const
 Return the kinetic energy of the projectile.
 
double GetCharge () const
 Get the charge of the projectile.
 
double GetMass () const
 Get the mass [eV / c2] of the projectile.
 
void SetSensor (Sensor *s)
 Set the sensor through which to transport the particle.
 
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
 
virtual bool GetCluster (double &xcls, double &ycls, double &zcls, double &tcls, int &n, double &e, double &extra)=0
 
virtual double GetClusterDensity ()
 
virtual double GetStoppingPower ()
 Get the stopping power (mean energy loss [eV] per cm).
 
void EnablePlotting (ViewDrift *viewer)
 Switch on plotting.
 
void DisablePlotting ()
 Switch off plotting.
 
void EnableDebugging ()
 Switch on debugging messages.
 
void DisableDebugging ()
 Switch off debugging messages.
 

Additional Inherited Members

- Protected Member Functions inherited from Garfield::Track
void PlotNewTrack (const double x0, const double y0, const double z0)
 
void PlotCluster (const double x0, const double y0, const double z0)
 
- Protected Attributes inherited from Garfield::Track
std::string m_className = "Track"
 
double m_q = -1.
 
int m_spin = 1
 
double m_mass
 
double m_energy = 0.
 
double m_beta2
 
bool m_isElectron = false
 
std::string m_particleName = "mu-"
 
Sensorm_sensor = nullptr
 
bool m_isChanged = true
 
ViewDriftm_viewer = nullptr
 
bool m_debug = false
 
size_t m_plotId = 0
 

Detailed Description

Ionization calculation based on MIP program (S. Biagi).

Definition at line 13 of file TrackElectron.hh.

Constructor & Destructor Documentation

◆ TrackElectron()

Garfield::TrackElectron::TrackElectron ( )

Definition at line 12 of file TrackElectron.cc.

12 : Track() {
13 m_className = "TrackElectron";
14
15 // Setup the particle properties.
16 m_q = -1;
17 m_spin = 1;
18 m_mass = ElectronMass;
19 m_isElectron = true;
20 SetBetaGamma(3.);
21 m_particleName = "electron";
22}
void SetBetaGamma(const double bg)
Set the relative momentum of the particle.
Definition: Track.cc:103
bool m_isElectron
Definition: Track.hh:109
double m_q
Definition: Track.hh:104
std::string m_particleName
Definition: Track.hh:110
std::string m_className
Definition: Track.hh:102
double m_mass
Definition: Track.hh:106
Track()
Constructor.
Definition: Track.cc:13

◆ ~TrackElectron()

virtual Garfield::TrackElectron::~TrackElectron ( )
inlinevirtual

Definition at line 18 of file TrackElectron.hh.

18{}

Member Function Documentation

◆ GetCluster()

bool Garfield::TrackElectron::GetCluster ( double &  xcls,
double &  ycls,
double &  zcls,
double &  tcls,
int &  n,
double &  e,
double &  extra 
)
virtual

Get the next "cluster" (ionising collision of the charged particle).

Parameters
xcls,ycls,zclscoordinates of the collision
tclstime of the collision
nnumber of electrons produced
edeposited energy
extraadditional information (not always implemented)

Implements Garfield::Track.

Definition at line 99 of file TrackElectron.cc.

101 {
102 edep = extra = 0.;
103 ncls = 0;
104
105 m_electrons.clear();
106
107 if (!m_ready) {
108 std::cerr << m_className << "::GetCluster:\n"
109 << " Track not initialized. Call NewTrack first.\n";
110 return false;
111 }
112
113 // Draw a step length and propagate the electron.
114 const double d = -m_mfp * log(RndmUniformPos());
115 m_x += d * m_dx;
116 m_y += d * m_dy;
117 m_z += d * m_dz;
118 m_t += d / (sqrt(m_beta2) * SpeedOfLight);
119
120 if (!m_sensor->IsInArea(m_x, m_y, m_z)) {
121 m_ready = false;
122 return false;
123 }
124
125 Medium* medium = nullptr;
126 if (!m_sensor->GetMedium(m_x, m_y, m_z, medium)) {
127 m_ready = false;
128 return false;
129 }
130
131 if (medium->GetName() != m_mediumName ||
132 medium->GetNumberDensity() != m_mediumDensity || !medium->IsIonisable()) {
133 m_ready = false;
134 return false;
135 }
136
137 xcls = m_x;
138 ycls = m_y;
139 zcls = m_z;
140 tcls = m_t;
141 const double r = RndmUniform();
142 int iComponent = 0;
143 const int nComponents = m_components.size();
144 for (int i = 0; i < nComponents; ++i) {
145 if (r <= RndmUniform()) {
146 iComponent = i;
147 break;
148 }
149 }
150
151 // Sample secondary electron energy according to
152 // Opal-Beaty-Peterson splitting function.
153 const double e0 = ElectronMass * (sqrt(1. / (1. - m_beta2)) - 1.);
154 double esec =
155 m_components[iComponent].wSplit *
156 tan(RndmUniform() * atan((e0 - m_components[iComponent].ethr) /
157 (2. * m_components[iComponent].wSplit)));
158 esec = m_components[iComponent].wSplit *
159 pow(esec / m_components[iComponent].wSplit, 0.9524);
160 m_electrons.resize(1);
161 m_electrons[0].energy = esec;
162 m_electrons[0].x = xcls;
163 m_electrons[0].y = ycls;
164 m_electrons[0].z = zcls;
165
166 ncls = 1;
167 edep = esec;
168
169 return true;
170}
bool IsInArea(const double x, const double y, const double z)
Check if a point is inside the user area.
Definition: Sensor.cc:254
bool GetMedium(const double x, const double y, const double z, Medium *&medium)
Get the medium at (x, y, z).
Definition: Sensor.cc:159
Sensor * m_sensor
Definition: Track.hh:112
double m_beta2
Definition: Track.hh:108
double RndmUniform()
Draw a random number uniformly distributed in the range [0, 1).
Definition: Random.hh:14
double RndmUniformPos()
Draw a random number uniformly distributed in the range (0, 1).
Definition: Random.hh:17
DoubleAc pow(const DoubleAc &f, double p)
Definition: DoubleAc.cpp:337
DoubleAc sqrt(const DoubleAc &f)
Definition: DoubleAc.cpp:314

◆ GetClusterDensity()

double Garfield::TrackElectron::GetClusterDensity ( )
virtual

Get the cluster density (number of ionizing collisions per cm or inverse mean free path for ionization).

Reimplemented from Garfield::Track.

Definition at line 172 of file TrackElectron.cc.

172 {
173 if (!m_ready) {
174 std::cerr << m_className << "::GetClusterDensity:\n";
175 std::cerr << " Track has not been initialized.\n";
176 return 0.;
177 }
178
179 if (m_mfp <= 0.) {
180 std::cerr << m_className << "::GetClusterDensity:\n";
181 std::cerr << " Mean free path is not available.\n";
182 return 0.;
183 }
184
185 return 1. / m_mfp;
186}

◆ GetStoppingPower()

double Garfield::TrackElectron::GetStoppingPower ( )
virtual

Get the stopping power (mean energy loss [eV] per cm).

Reimplemented from Garfield::Track.

Definition at line 188 of file TrackElectron.cc.

188 {
189 if (!m_ready) {
190 std::cerr << m_className << "::GetStoppingPower:\n";
191 std::cerr << " Track has not been initialised.\n";
192 return 0.;
193 }
194
195 constexpr double prefactor =
196 4 * Pi * HbarC * HbarC / (ElectronMass * ElectronMass);
197 const double lnBg2 = log(m_beta2 / (1. - m_beta2));
198
199 double dedx = 0.;
200 // Primary energy
201 const double e0 = ElectronMass * (sqrt(1. / (1. - m_beta2)) - 1.);
202 const int nComponents = m_components.size();
203 for (int i = nComponents; i--;) {
204 // Calculate the mean number of clusters per cm.
205 const double cmean =
206 m_mediumDensity * m_components[i].fraction * (prefactor / m_beta2) *
207 (m_components[i].m2Ion * (lnBg2 - m_beta2) + m_components[i].cIon);
208 const double ew =
209 (e0 - m_components[i].ethr) / (2 * m_components[i].wSplit);
210 // Calculate the mean secondary electron energy.
211 const double emean =
212 (m_components[i].wSplit / (2 * atan(ew))) * log(1. + ew * ew);
213 dedx += cmean * emean;
214 }
215
216 return dedx;
217}

◆ NewTrack()

bool Garfield::TrackElectron::NewTrack ( const double  x0,
const double  y0,
const double  z0,
const double  t0,
const double  dx0,
const double  dy0,
const double  dz0 
)
virtual

Calculate a new track starting from (x0, y0, z0) at time t0 in direction (dx0, dy0, dz0).

Implements Garfield::Track.

Definition at line 30 of file TrackElectron.cc.

32 {
33 m_ready = false;
34
35 // Make sure the sensor has been set.
36 if (!m_sensor) {
37 std::cerr << m_className << "::NewTrack: Sensor is not defined.\n";
38 return false;
39 }
40
41 // Get the medium at this location and check if it is "ionisable".
42 Medium* medium = nullptr;
43 if (!m_sensor->GetMedium(x0, y0, z0, medium)) {
44 std::cerr << m_className << "::NewTrack:\n";
45 std::cerr << " No medium at initial position.\n";
46 return false;
47 }
48 if (!medium->IsIonisable()) {
49 std::cerr << m_className << "::NewTrack:\n";
50 std::cerr << " Medium at initial position is not ionisable.\n";
51 return false;
52 }
53
54 // Check if the medium is a gas.
55 if (!medium->IsGas()) {
56 std::cerr << m_className << "::NewTrack:\n";
57 std::cerr << " Medium at initial position is not a gas.\n";
58 return false;
59 }
60
61 if (!SetupGas(medium)) {
62 std::cerr << m_className << "::NewTrack:\n";
63 std::cerr << " Properties of medium " << medium->GetName()
64 << " are not available.\n";
65 return false;
66 }
67
68 if (!UpdateCrossSection()) {
69 std::cerr << m_className << "::NewTrack:\n";
70 std::cerr << " Cross-sections could not be calculated.\n";
71 return false;
72 }
73
74 m_mediumName = medium->GetName();
75
76 m_x = x0;
77 m_y = y0;
78 m_z = z0;
79 m_t = t0;
80 const double dd = sqrt(dx0 * dx0 + dy0 * dy0 + dz0 * dz0);
81 if (dd < Small) {
82 if (m_debug) {
83 std::cout << m_className << "::NewTrack:\n";
84 std::cout << " Direction vector has zero norm.\n";
85 std::cout << " Initial direction is randomized.\n";
86 }
87 RndmDirection(m_dx, m_dy, m_dz);
88 } else {
89 // Normalize the direction vector.
90 m_dx = dx0 / dd;
91 m_dy = dy0 / dd;
92 m_dz = dz0 / dd;
93 }
94
95 m_ready = true;
96 return true;
97}
bool m_debug
Definition: Track.hh:118
void RndmDirection(double &dx, double &dy, double &dz, const double length=1.)
Draw a random (isotropic) direction vector.
Definition: Random.hh:107

◆ SetParticle()

void Garfield::TrackElectron::SetParticle ( const std::string &  part)
virtual

Set the type of charged particle.

  • electron,e-
  • positron,e+
  • muon,mu-
  • mu+
  • pion,pi-
  • pi+
  • kaon,K-
  • K+
  • proton,p
  • anti-proton,p-bar
  • deuteron,d
  • alpha

Reimplemented from Garfield::Track.

Definition at line 24 of file TrackElectron.cc.

24 {
25 if (particle != "electron" && particle != "e" && particle != "e-") {
26 std::cerr << m_className << "::SetParticle: Only electrons are allowed.\n";
27 }
28}

The documentation for this class was generated from the following files: