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::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)
 
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

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 14 of file TrackPAI.cc.

14: Track() { m_className = "TrackPAI"; }
std::string m_className
Definition: Track.hh:102
Track()
Constructor.
Definition: Track.cc:13

◆ ~TrackPAI()

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

Definition at line 18 of file TrackPAI.hh.

18{}

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 84 of file TrackPAI.cc.

86 {
87 ncls = 0;
88 edep = extra = 0.;
89
90 // Clear the stack.
91 m_electrons.clear();
92 m_holes.clear();
93
94 if (!m_ready) {
95 std::cerr << m_className << "::GetCluster:\n";
96 std::cerr << " Track not initialized. Call NewTrack first.\n";
97 return false;
98 }
99
100 if (m_isChanged) {
101 if (SetupCrossSectionTable()) {
102 m_isChanged = false;
103 } else {
104 std::cerr << m_className << "::GetCluster:\n";
105 std::cerr << " Calculation of ionisation cross-section failed.\n";
106 return false;
107 }
108 }
109
110 // Draw a step length and propagate the particle.
111 const double d = -m_imfp * log(RndmUniformPos());
112 m_x += d * m_dx;
113 m_y += d * m_dy;
114 m_z += d * m_dz;
115 m_t += d / m_speed;
116
117 // Check the medium at this location.
118 Medium* medium = nullptr;
119 if (!m_sensor->GetMedium(m_x, m_y, m_z, medium)) {
120 m_ready = false;
121 return false;
122 }
123 if (medium->GetName() != m_mediumName ||
124 medium->GetNumberDensity() != m_mediumDensity || !medium->IsIonisable()) {
125 m_ready = false;
126 return false;
127 }
128
129 // Check if the particle is still inside the drift area.
130 if (!m_sensor->IsInArea(m_x, m_y, m_z)) {
131 m_ready = false;
132 return false;
133 }
134
135 xcls = m_x;
136 ycls = m_y;
137 zcls = m_z;
138 tcls = m_t;
139
140 // Sample the energy deposition.
141 double f = 0.;
142 edep = SampleEnergyDeposit(RndmUniform(), f);
143 // Update the particle energy.
144 m_e -= edep;
145
146 // Number of electron/hole (or electron/ion pairs) produced.
147 ncls = 1;
148
149 if (m_debug) {
150 std::cout << m_className << "::GetCluster:\n";
151 std::cout << " Fraction of Rutherford scattering: " << f << "\n";
152 }
153 return true;
154}
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
bool m_debug
Definition: Track.hh:118
bool m_isChanged
Definition: Track.hh:114
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 270 of file TrackPAI.cc.

270 {
271 if (!m_ready) {
272 std::cerr << m_className << "::GetClusterDensity:\n";
273 std::cerr << " Track has not been initialized.\n";
274 return 0.;
275 }
276
277 if (m_isChanged) {
278 if (SetupCrossSectionTable()) {
279 m_isChanged = false;
280 } else {
281 std::cerr << m_className << "::GetClusterDensity:\n";
282 std::cerr << " Ionisation cross-section could not be calculated.\n";
283 return 0.;
284 }
285 }
286
287 return 1. / m_imfp;
288}

◆ GetStoppingPower()

double Garfield::TrackPAI::GetStoppingPower ( )
virtual

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

Reimplemented from Garfield::Track.

Definition at line 290 of file TrackPAI.cc.

290 {
291 if (!m_ready) {
292 std::cerr << m_className << "::GetStoppingPower:\n";
293 std::cerr << " Track has not been initialised.\n";
294 return 0.;
295 }
296
297 if (m_isChanged) {
298 if (SetupCrossSectionTable()) {
299 m_isChanged = false;
300 } else {
301 std::cerr << m_className << "::GetStoppingPower:\n";
302 std::cerr << " Ionisation cross-section could not be calculated.\n";
303 return 0.;
304 }
305 }
306
307 return m_dedx;
308}

◆ 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 16 of file TrackPAI.cc.

18 {
19 m_ready = false;
20
21 // Make sure the sensor has been set.
22 if (!m_sensor) {
23 std::cerr << m_className << "::NewTrack: Sensor is not defined.\n";
24 return false;
25 }
26
27 // Get the medium at this location and check if it is "ionisable".
28 Medium* medium = nullptr;
29 if (!m_sensor->GetMedium(x0, y0, z0, medium)) {
30 std::cerr << m_className << "::NewTrack: No medium at initial position.\n";
31 return false;
32 }
33 if (!medium->IsIonisable()) {
34 std::cerr << m_className << "::NewTrack:\n"
35 << " Medium at initial position is not ionisable.\n";
36 return false;
37 }
38
39 if (medium->GetName() != m_mediumName ||
40 medium->GetNumberDensity() != m_mediumDensity) {
41 m_isChanged = true;
42 if (!SetupMedium(medium)) {
43 std::cerr << m_className << "::NewTrack:\n Properties of medium "
44 << medium->GetName() << " are not available.\n";
45 return false;
46 }
47 m_mediumName = medium->GetName();
48 m_mediumDensity = medium->GetNumberDensity();
49 }
50
51 m_ready = true;
52
53 if (m_isChanged) {
54 if (!SetupCrossSectionTable()) {
55 std::cerr << m_className << "::NewTrack:\n"
56 << " Calculation of ionisation cross-section failed.\n";
57 m_ready = false;
58 return false;
59 }
60 m_isChanged = false;
61 }
62
63 m_x = x0;
64 m_y = y0;
65 m_z = z0;
66 m_t = t0;
67 const double d = sqrt(dx0 * dx0 + dy0 * dy0 + dz0 * dz0);
68 if (d < Small) {
69 if (m_debug) {
70 std::cout << m_className << "::NewTrack:\n"
71 << " Direction vector has zero norm.\n"
72 << " Initial direction is randomized.\n";
73 }
74 RndmDirection(m_dx, m_dy, m_dz);
75 } else {
76 // Normalize the direction vector.
77 m_dx = dx0 / d;
78 m_dy = dy0 / d;
79 m_dz = dz0 / d;
80 }
81 return true;
82}
void RndmDirection(double &dx, double &dy, double &dz, const double length=1.)
Draw a random (isotropic) direction vector.
Definition: Random.hh:107
DoubleAc sqrt(const DoubleAc &f)
Definition: DoubleAc.cpp:314

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