Garfield++ v2r0
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)
 Set the type of 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)
 Set the type of particle.
 
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
 
double GetBetaGamma () const
 
double GetBeta () const
 
double GetGamma () const
 
double GetMomentum () const
 
double GetKineticEnergy () const
 
double GetCharge () const
 Get the charge of the projectile.
 
double GetMass () const
 Get the mass [eV / c2] of the projectile.
 
void SetSensor (Sensor *s)
 
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)
 
void DisablePlotting ()
 
void EnableDebugging ()
 
void DisableDebugging ()
 

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
 
double m_q
 
int m_spin
 
double m_mass
 
double m_energy
 
double m_beta2
 
bool m_isElectron
 
std::string m_particleName
 
Sensorm_sensor
 
bool m_isChanged
 
bool m_usePlotting
 
ViewDriftm_viewer
 
bool m_debug
 
int m_plotId
 

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.

13 : m_ready(false),
14 m_x(0.),
15 m_y(0.),
16 m_z(0.),
17 m_t(0.),
18 m_dx(0.),
19 m_dy(0),
20 m_dz(1.),
21 m_mediumName(""),
22 m_mediumDensity(0.),
23 m_mfp(0.) {
24
25 m_className = "TrackElectron";
26
27 // Setup the particle properties.
28 m_q = -1;
29 m_spin = 1;
30 m_mass = ElectronMass;
31 m_isElectron = true;
32 SetBetaGamma(3.);
33 m_particleName = "electron";
34
35}
void SetBetaGamma(const double bg)
Set the relative momentum of the particle.
Definition: Track.cc:116
bool m_isElectron
Definition: Track.hh:87
double m_q
Definition: Track.hh:82
std::string m_particleName
Definition: Track.hh:88
std::string m_className
Definition: Track.hh:80
double m_mass
Definition: Track.hh:84

◆ ~TrackElectron()

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

Definition at line 19 of file TrackElectron.hh.

19{}

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 121 of file TrackElectron.cc.

123 {
124
125 edep = extra = 0.;
126 ncls = 0;
127
128 m_electrons.clear();
129
130 if (!m_ready) {
131 std::cerr << m_className << "::GetCluster:\n"
132 << " Track not initialized. Call NewTrack first.\n";
133 return false;
134 }
135
136 // Draw a step length and propagate the electron.
137 const double d = -m_mfp * log(RndmUniformPos());
138 m_x += d * m_dx;
139 m_y += d * m_dy;
140 m_z += d * m_dz;
141 m_t += d / (sqrt(m_beta2) * SpeedOfLight);
142
143 if (!m_sensor->IsInArea(m_x, m_y, m_z)) {
144 m_ready = false;
145 return false;
146 }
147
148 Medium* medium = NULL;
149 if (!m_sensor->GetMedium(m_x, m_y, m_z, medium)) {
150 m_ready = false;
151 return false;
152 }
153
154 if (medium->GetName() != m_mediumName ||
155 medium->GetNumberDensity() != m_mediumDensity || !medium->IsIonisable()) {
156 m_ready = false;
157 return false;
158 }
159
160 xcls = m_x;
161 ycls = m_y;
162 zcls = m_z;
163 tcls = m_t;
164 const double r = RndmUniform();
165 int iComponent = 0;
166 const int nComponents = m_components.size();
167 for (int i = 0; i < nComponents; ++i) {
168 if (r <= RndmUniform()) {
169 iComponent = i;
170 break;
171 }
172 }
173
174 // Sample secondary electron energy according to
175 // Opal-Beaty-Peterson splitting function.
176 const double e0 = ElectronMass * (sqrt(1. / (1. - m_beta2)) - 1.);
177 double esec = m_components[iComponent].wSplit *
178 tan(RndmUniform() * atan((e0 - m_components[iComponent].ethr) /
179 (2. * m_components[iComponent].wSplit)));
180 esec = m_components[iComponent].wSplit *
181 pow(esec / m_components[iComponent].wSplit, 0.9524);
182 m_electrons.resize(1);
183 m_electrons[0].energy = esec;
184 m_electrons[0].x = xcls;
185 m_electrons[0].y = ycls;
186 m_electrons[0].z = zcls;
187
188 ncls = 1;
189 edep = esec;
190
191 return true;
192}
bool IsInArea(const double x, const double y, const double z)
Check if a point is inside the user area.
Definition: Sensor.cc:264
bool GetMedium(const double x, const double y, const double z, Medium *&medium)
Get the medium at (x, y, z).
Definition: Sensor.cc:150
Sensor * m_sensor
Definition: Track.hh:90
double m_beta2
Definition: Track.hh:86
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 194 of file TrackElectron.cc.

194 {
195
196 if (!m_ready) {
197 std::cerr << m_className << "::GetClusterDensity:\n";
198 std::cerr << " Track has not been initialized.\n";
199 return 0.;
200 }
201
202 if (m_mfp <= 0.) {
203 std::cerr << m_className << "::GetClusterDensity:\n";
204 std::cerr << " Mean free path is not available.\n";
205 return 0.;
206 }
207
208 return 1. / m_mfp;
209}

◆ GetStoppingPower()

double Garfield::TrackElectron::GetStoppingPower ( )
virtual

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

Reimplemented from Garfield::Track.

Definition at line 211 of file TrackElectron.cc.

211 {
212
213 if (!m_ready) {
214 std::cerr << m_className << "::GetStoppingPower:\n";
215 std::cerr << " Track has not been initialised.\n";
216 return 0.;
217 }
218
219 const double prefactor = 4 * Pi * pow(HbarC / ElectronMass, 2);
220 const double lnBg2 = log(m_beta2 / (1. - m_beta2));
221
222 double dedx = 0.;
223 // Primary energy
224 const double e0 = ElectronMass * (sqrt(1. / (1. - m_beta2)) - 1.);
225 const int nComponents = m_components.size();
226 for (int i = nComponents; i--;) {
227 // Calculate the mean number of clusters per cm.
228 const double cmean =
229 m_mediumDensity * m_components[i].fraction * (prefactor / m_beta2) *
230 (m_components[i].m2Ion * (lnBg2 - m_beta2) + m_components[i].cIon);
231 const double ew = (e0 - m_components[i].ethr) / (2 * m_components[i].wSplit);
232 // Calculate the mean secondary electron energy.
233 const double emean =
234 (m_components[i].wSplit / (2 * atan(ew))) * log(1. + ew * ew);
235 dedx += cmean * emean;
236 }
237
238 return dedx;
239}

◆ 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 45 of file TrackElectron.cc.

47 {
48
49 m_ready = false;
50
51 // Make sure the sensor has been set.
52 if (!m_sensor) {
53 std::cerr << m_className << "::NewTrack:\n";
54 std::cerr << " Sensor is not defined.\n";
55 return false;
56 }
57
58 // Get the medium at this location and check if it is "ionisable".
59 Medium* medium = NULL;
60 if (!m_sensor->GetMedium(x0, y0, z0, medium)) {
61 std::cerr << m_className << "::NewTrack:\n";
62 std::cerr << " No medium at initial position.\n";
63 return false;
64 }
65 if (!medium->IsIonisable()) {
66 std::cerr << m_className << "::NewTrack:\n";
67 std::cerr << " Medium at initial position is not ionisable.\n";
68 return false;
69 }
70
71 // Check if the medium is a gas.
72 if (!medium->IsGas()) {
73 std::cerr << m_className << "::NewTrack:\n";
74 std::cerr << " Medium at initial position is not a gas.\n";
75 return false;
76 }
77
78 if (!SetupGas(medium)) {
79 std::cerr << m_className << "::NewTrack:\n";
80 std::cerr << " Properties of medium " << medium->GetName()
81 << " are not available.\n";
82 return false;
83 }
84
85 if (!UpdateCrossSection()) {
86 std::cerr << m_className << "::NewTrack:\n";
87 std::cerr << " Cross-sections could not be calculated.\n";
88 return false;
89 }
90
91 m_mediumName = medium->GetName();
92
93 m_x = x0;
94 m_y = y0;
95 m_z = z0;
96 m_t = t0;
97 const double dd = sqrt(dx0 * dx0 + dy0 * dy0 + dz0 * dz0);
98 if (dd < Small) {
99 if (m_debug) {
100 std::cout << m_className << "::NewTrack:\n";
101 std::cout << " Direction vector has zero norm.\n";
102 std::cout << " Initial direction is randomized.\n";
103 }
104 const double ctheta = 1. - 2. * RndmUniform();
105 const double stheta = sqrt(1. - ctheta * ctheta);
106 const double phi = TwoPi * RndmUniform();
107 m_dx = cos(phi) * stheta;
108 m_dy = sin(phi) * stheta;
109 m_dz = ctheta;
110 } else {
111 // Normalize the direction vector.
112 m_dx = dx0 / dd;
113 m_dy = dy0 / dd;
114 m_dz = dz0 / dd;
115 }
116
117 m_ready = true;
118 return true;
119}
bool m_debug
Definition: Track.hh:97
DoubleAc cos(const DoubleAc &f)
Definition: DoubleAc.cpp:432
DoubleAc sin(const DoubleAc &f)
Definition: DoubleAc.cpp:384

◆ SetParticle()

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

Set the type of particle.

Reimplemented from Garfield::Track.

Definition at line 37 of file TrackElectron.cc.

37 {
38
39 if (particle != "electron" && particle != "e" && particle != "e-") {
40 std::cerr << m_className << "::SetParticle:\n";
41 std::cerr << " Only electrons can be transported.\n";
42 }
43}

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