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

Generate tracks based on a cluster density given by the user. More...

#include <TrackSimple.hh>

+ Inheritance diagram for Garfield::TrackSimple:

Public Member Functions

 TrackSimple ()
 Constructor.
 
virtual ~TrackSimple ()
 Destructor.
 
void SetEqualSpacing ()
 Constant distance between clusters.
 
void SetExponentialSpacing ()
 Exponentially distributed distance between clusters.
 
void SetClusterDensity (const double d)
 Set the cluster density (inverse mean free path).
 
virtual double GetClusterDensity ()
 
void SetStoppingPower (const double dedx)
 Set the stopping power (dE/dx).
 
virtual double GetStoppingPower ()
 Get the stopping power (mean energy loss [eV] per cm).
 
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 &n, double &e, double &extra)
 
- 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 ()
 

Protected Attributes

bool m_isReady
 
double m_x
 
double m_y
 
double m_z
 
double m_t
 
double m_dx
 
double m_dy
 
double m_dz
 
double m_mfp
 
double m_eloss
 
bool m_useEqualSpacing
 
- 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
 

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)
 

Detailed Description

Generate tracks based on a cluster density given by the user.

Definition at line 10 of file TrackSimple.hh.

Constructor & Destructor Documentation

◆ TrackSimple()

Garfield::TrackSimple::TrackSimple ( )

Constructor.

Definition at line 11 of file TrackSimple.cc.

12 : m_isReady(false),
13 m_x(0.),
14 m_y(0.),
15 m_z(0.),
16 m_t(0.),
17 m_dx(0.),
18 m_dy(0.),
19 m_dz(1.),
20 m_mfp(0.04),
21 m_eloss(2530.),
22 m_useEqualSpacing(false) {
23
24 m_className = "TrackSimple";
25}
std::string m_className
Definition: Track.hh:80

◆ ~TrackSimple()

virtual Garfield::TrackSimple::~TrackSimple ( )
inlinevirtual

Destructor.

Definition at line 16 of file TrackSimple.hh.

16{}

Member Function Documentation

◆ GetCluster()

bool Garfield::TrackSimple::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 96 of file TrackSimple.cc.

97 {
98
99 extra = 0.;
100 if (!m_isReady) return false;
101
102 if (m_useEqualSpacing) {
103 m_x += m_dx * m_mfp;
104 m_y += m_dy * m_mfp;
105 m_z += m_dz * m_mfp;
106 } else {
107 const double d = -m_mfp * log(RndmUniformPos());
108 m_x += m_dx * d;
109 m_y += m_dy * d;
110 m_z += m_dz * d;
111 }
112
113 xcls = m_x;
114 ycls = m_y;
115 zcls = m_z;
116 tcls = m_t;
117
118 n = 1;
119 e = m_eloss * m_mfp;
120
121 Medium* medium = NULL;
122 if (!m_sensor->GetMedium(m_x, m_y, m_z, medium)) {
123 m_isReady = false;
124 if (m_debug) {
125 std::cout << m_className << "::GetCluster: Particle left the medium.\n";
126 }
127 return false;
128 }
129
130 return true;
131}
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
double RndmUniformPos()
Draw a random number uniformly distributed in the range (0, 1).
Definition: Random.hh:17

◆ GetClusterDensity()

double Garfield::TrackSimple::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 39 of file TrackSimple.cc.

39{ return 1. / m_mfp; }

◆ GetStoppingPower()

double Garfield::TrackSimple::GetStoppingPower ( )
virtual

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

Reimplemented from Garfield::Track.

Definition at line 53 of file TrackSimple.cc.

53{ return m_eloss; }

◆ NewTrack()

bool Garfield::TrackSimple::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 55 of file TrackSimple.cc.

57 {
58
59 // Check if a sensor has been defined
60 if (!m_sensor) {
61 std::cerr << m_className << "::NewTrack:\n"
62 << " Sensor is not defined.\n";
63 m_isReady = false;
64 return false;
65 }
66
67 // Make sure we are inside a medium
68 Medium* medium = NULL;
69 if (!m_sensor->GetMedium(x0, y0, z0, medium)) {
70 std::cerr << m_className << "::NewTrack:\n";
71 std::cerr << " No medium at initial position.\n";
72 m_isReady = false;
73 return false;
74 }
75
76 m_isReady = true;
77
78 m_x = x0;
79 m_y = y0;
80 m_z = z0;
81 m_t = t0;
82
83 // Normalise the direction.
84 const double d = sqrt(dx0 * dx0 + dy0 * dy0 + dz0 * dz0);
85 if (d < Small) {
86 // Choose random direction.
88 } else {
89 m_dx = dx0 / d;
90 m_dy = dy0 / d;
91 m_dz = dz0 / d;
92 }
93 return true;
94}
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

◆ SetClusterDensity()

void Garfield::TrackSimple::SetClusterDensity ( const double  d)

Set the cluster density (inverse mean free path).

Definition at line 27 of file TrackSimple.cc.

27 {
28
29 if (d < Small) {
30 std::cerr << m_className << "::SetClusterDensity:\n"
31 << " Cluster density (number of clusters per cm)"
32 << " must be positive.\n";
33 return;
34 }
35
36 m_mfp = 1. / d;
37}

◆ SetEqualSpacing()

void Garfield::TrackSimple::SetEqualSpacing ( )
inline

Constant distance between clusters.

Definition at line 19 of file TrackSimple.hh.

19{ m_useEqualSpacing = true; }

◆ SetExponentialSpacing()

void Garfield::TrackSimple::SetExponentialSpacing ( )
inline

Exponentially distributed distance between clusters.

Definition at line 21 of file TrackSimple.hh.

21{ m_useEqualSpacing = false; }

◆ SetStoppingPower()

void Garfield::TrackSimple::SetStoppingPower ( const double  dedx)

Set the stopping power (dE/dx).

Definition at line 41 of file TrackSimple.cc.

41 {
42
43 if (dedx < Small) {
44 std::cerr << m_className << "::SetStoppingPower:\n"
45 << " Stopping power (average energy loss [eV] per cm)"
46 << " must be positive.\n";
47 return;
48 }
49
50 m_eloss = dedx;
51}

Member Data Documentation

◆ m_dx

double Garfield::TrackSimple::m_dx
protected

Definition at line 41 of file TrackSimple.hh.

Referenced by GetCluster(), and NewTrack().

◆ m_dy

double Garfield::TrackSimple::m_dy
protected

Definition at line 41 of file TrackSimple.hh.

Referenced by GetCluster(), and NewTrack().

◆ m_dz

double Garfield::TrackSimple::m_dz
protected

Definition at line 41 of file TrackSimple.hh.

Referenced by GetCluster(), and NewTrack().

◆ m_eloss

double Garfield::TrackSimple::m_eloss
protected

Definition at line 45 of file TrackSimple.hh.

Referenced by GetCluster(), GetStoppingPower(), and SetStoppingPower().

◆ m_isReady

bool Garfield::TrackSimple::m_isReady
protected

Definition at line 37 of file TrackSimple.hh.

Referenced by GetCluster(), and NewTrack().

◆ m_mfp

double Garfield::TrackSimple::m_mfp
protected

Definition at line 43 of file TrackSimple.hh.

Referenced by GetCluster(), GetClusterDensity(), and SetClusterDensity().

◆ m_t

double Garfield::TrackSimple::m_t
protected

Definition at line 40 of file TrackSimple.hh.

Referenced by GetCluster(), and NewTrack().

◆ m_useEqualSpacing

bool Garfield::TrackSimple::m_useEqualSpacing
protected

Definition at line 47 of file TrackSimple.hh.

Referenced by GetCluster(), SetEqualSpacing(), and SetExponentialSpacing().

◆ m_x

double Garfield::TrackSimple::m_x
protected

Definition at line 40 of file TrackSimple.hh.

Referenced by GetCluster(), and NewTrack().

◆ m_y

double Garfield::TrackSimple::m_y
protected

Definition at line 40 of file TrackSimple.hh.

Referenced by GetCluster(), and NewTrack().

◆ m_z

double Garfield::TrackSimple::m_z
protected

Definition at line 40 of file TrackSimple.hh.

Referenced by GetCluster(), and NewTrack().


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