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

Energy loss calculation using the Photoabsorption-Ionisation Model. More...

#include <TrackPAI.hh>

+ Inheritance diagram for Garfield::TrackPAI:

Public Member Functions

 TrackPAI ()
 
virtual ~TrackPAI ()
 
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

Energy loss calculation using the Photoabsorption-Ionisation Model.

Definition at line 13 of file TrackPAI.hh.

Constructor & Destructor Documentation

◆ TrackPAI()

Garfield::TrackPAI::TrackPAI ( )

Definition at line 13 of file TrackPAI.cc.

14 : m_ready(false),
15 m_x(0.),
16 m_y(0.),
17 m_z(0.),
18 m_t(0.),
19 m_dx(0.),
20 m_dy(0),
21 m_dz(1.),
22 m_e(0.),
23 m_speed(0.),
24 m_emax(0.),
25 m_imfp(0.),
26 m_dedx(0.),
27 m_nSteps(1000),
28 m_mediumName(""),
29 m_mediumDensity(0.),
30 m_electronDensity(0.) {
31
32 m_className = "TrackPAI";
33
34}
std::string m_className
Definition: Track.hh:80

◆ ~TrackPAI()

virtual Garfield::TrackPAI::~TrackPAI ( )
inlinevirtual

Definition at line 19 of file TrackPAI.hh.

19{}

Member Function Documentation

◆ GetCluster()

bool Garfield::TrackPAI::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 105 of file TrackPAI.cc.

107 {
108
109 ncls = 0;
110 edep = extra = 0.;
111
112 // Clear the stack.
113 m_electrons.clear();
114 m_holes.clear();
115
116 if (!m_ready) {
117 std::cerr << m_className << "::GetCluster:\n";
118 std::cerr << " Track not initialized. Call NewTrack first.\n";
119 return false;
120 }
121
122 if (m_isChanged) {
123 if (SetupCrossSectionTable()) {
124 m_isChanged = false;
125 } else {
126 std::cerr << m_className << "::GetCluster:\n";
127 std::cerr << " Calculation of ionisation cross-section failed.\n";
128 return false;
129 }
130 }
131
132 // Draw a step length and propagate the particle.
133 const double d = -m_imfp * log(RndmUniformPos());
134 m_x += d * m_dx;
135 m_y += d * m_dy;
136 m_z += d * m_dz;
137 m_t += d / m_speed;
138
139 // Check the medium at this location.
140 Medium* medium = NULL;
141 if (!m_sensor->GetMedium(m_x, m_y, m_z, medium)) {
142 m_ready = false;
143 return false;
144 }
145 if (medium->GetName() != m_mediumName ||
146 medium->GetNumberDensity() != m_mediumDensity || !medium->IsIonisable()) {
147 m_ready = false;
148 return false;
149 }
150
151 // Check if the particle is still inside the drift area.
152 if (!m_sensor->IsInArea(m_x, m_y, m_z)) {
153 m_ready = false;
154 return false;
155 }
156
157 xcls = m_x;
158 ycls = m_y;
159 zcls = m_z;
160 tcls = m_t;
161
162 // Sample the energy deposition.
163 double f = 0.;
164 edep = SampleEnergyDeposit(RndmUniform(), f);
165 // Update the particle energy.
166 m_e -= edep;
167
168 // Number of electron/hole (or electron/ion pairs) produced.
169 ncls = 1;
170
171 if (m_debug) {
172 std::cout << m_className << "::GetCluster:\n";
173 std::cout << " Fraction of Rutherford scattering: " << f << "\n";
174 }
175 return true;
176}
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
bool m_debug
Definition: Track.hh:97
bool m_isChanged
Definition: Track.hh:92
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

◆ GetClusterDensity()

double Garfield::TrackPAI::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 300 of file TrackPAI.cc.

300 {
301
302 if (!m_ready) {
303 std::cerr << m_className << "::GetClusterDensity:\n";
304 std::cerr << " Track has not been initialized.\n";
305 return 0.;
306 }
307
308 if (m_isChanged) {
309 if (SetupCrossSectionTable()) {
310 m_isChanged = false;
311 } else {
312 std::cerr << m_className << "::GetClusterDensity:\n";
313 std::cerr << " Ionisation cross-section could not be calculated.\n";
314 return 0.;
315 }
316 }
317
318 return 1. / m_imfp;
319}

◆ GetStoppingPower()

double Garfield::TrackPAI::GetStoppingPower ( )
virtual

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

Reimplemented from Garfield::Track.

Definition at line 321 of file TrackPAI.cc.

321 {
322
323 if (!m_ready) {
324 std::cerr << m_className << "::GetStoppingPower:\n";
325 std::cerr << " Track has not been initialised.\n";
326 return 0.;
327 }
328
329 if (m_isChanged) {
330 if (SetupCrossSectionTable()) {
331 m_isChanged = false;
332 } else {
333 std::cerr << m_className << "::GetStoppingPower:\n";
334 std::cerr << " Ionisation cross-section could not be calculated.\n";
335 return 0.;
336 }
337 }
338
339 return m_dedx;
340}

◆ NewTrack()

bool Garfield::TrackPAI::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 36 of file TrackPAI.cc.

38 {
39
40 m_ready = false;
41
42 // Make sure the sensor has been set.
43 if (!m_sensor) {
44 std::cerr << m_className << "::NewTrack: Sensor is not defined.\n";
45 return false;
46 }
47
48 // Get the medium at this location and check if it is "ionisable".
49 Medium* medium = NULL;
50 if (!m_sensor->GetMedium(x0, y0, z0, medium)) {
51 std::cerr << m_className << "::NewTrack: No medium at initial position.\n";
52 return false;
53 }
54 if (!medium->IsIonisable()) {
55 std::cerr << m_className << "::NewTrack:\n"
56 << " Medium at initial position is not ionisable.\n";
57 return false;
58 }
59
60 if (medium->GetName() != m_mediumName ||
61 medium->GetNumberDensity() != m_mediumDensity) {
62 m_isChanged = true;
63 if (!SetupMedium(medium)) {
64 std::cerr << m_className << "::NewTrack:\n Properties of medium "
65 << medium->GetName() << " are not available.\n";
66 return false;
67 }
68 m_mediumName = medium->GetName();
69 m_mediumDensity = medium->GetNumberDensity();
70 }
71
72 m_ready = true;
73
74 if (m_isChanged) {
75 if (!SetupCrossSectionTable()) {
76 std::cerr << m_className << "::NewTrack:\n"
77 << " Calculation of ionisation cross-section failed.\n";
78 m_ready = false;
79 return false;
80 }
81 m_isChanged = false;
82 }
83
84 m_x = x0;
85 m_y = y0;
86 m_z = z0;
87 m_t = t0;
88 const double d = sqrt(dx0 * dx0 + dy0 * dy0 + dz0 * dz0);
89 if (d < Small) {
90 if (m_debug) {
91 std::cout << m_className << "::NewTrack:\n"
92 << " Direction vector has zero norm.\n"
93 << " Initial direction is randomized.\n";
94 }
95 RndmDirection(m_dx, m_dy, m_dz);
96 } else {
97 // Normalize the direction vector.
98 m_dx = dx0 / d;
99 m_dy = dy0 / d;
100 m_dz = dz0 / d;
101 }
102 return true;
103}
void RndmDirection(double &dx, double &dy, double &dz, const double length=1.)
Draw a random (isotropic) direction vector.
Definition: Random.hh:106
DoubleAc sqrt(const DoubleAc &f)
Definition: DoubleAc.cpp:314

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