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

Protected Attributes

bool m_isReady = false
 
double m_x = 0.
 
double m_y = 0.
 
double m_z = 0.
 
double m_t = 0.
 
double m_dx = 0.
 
double m_dy = 0.
 
double m_dz = 0.
 
double m_mfp = 0.04
 
double m_eloss = 2530.
 
bool m_useEqualSpacing = false
 
- 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
 

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.

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

◆ ~TrackSimple()

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

Destructor.

Definition at line 15 of file TrackSimple.hh.

15{}

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 79 of file TrackSimple.cc.

80 {
81 extra = 0.;
82 if (!m_isReady) return false;
83
85 m_x += m_dx * m_mfp;
86 m_y += m_dy * m_mfp;
87 m_z += m_dz * m_mfp;
88 } else {
89 const double d = -m_mfp * log(RndmUniformPos());
90 m_x += m_dx * d;
91 m_y += m_dy * d;
92 m_z += m_dz * d;
93 }
94
95 xcls = m_x;
96 ycls = m_y;
97 zcls = m_z;
98 tcls = m_t;
99
100 n = 1;
101 e = m_eloss * m_mfp;
102
103 Medium* medium = nullptr;
104 if (!m_sensor->GetMedium(m_x, m_y, m_z, medium)) {
105 m_isReady = false;
106 if (m_debug) {
107 std::cout << m_className << "::GetCluster: Particle left the medium.\n";
108 }
109 return false;
110 }
111
112 return true;
113}
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
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 24 of file TrackSimple.cc.

24{ 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 37 of file TrackSimple.cc.

37{ 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 39 of file TrackSimple.cc.

41 {
42 // Check if a sensor has been defined
43 if (!m_sensor) {
44 std::cerr << m_className << "::NewTrack:\n"
45 << " Sensor is not defined.\n";
46 m_isReady = false;
47 return false;
48 }
49
50 // Make sure we are inside a medium
51 Medium* medium = nullptr;
52 if (!m_sensor->GetMedium(x0, y0, z0, medium)) {
53 std::cerr << m_className << "::NewTrack:\n";
54 std::cerr << " No medium at initial position.\n";
55 m_isReady = false;
56 return false;
57 }
58
59 m_isReady = true;
60
61 m_x = x0;
62 m_y = y0;
63 m_z = z0;
64 m_t = t0;
65
66 // Normalise the direction.
67 const double d = sqrt(dx0 * dx0 + dy0 * dy0 + dz0 * dz0);
68 if (d < Small) {
69 // Choose random direction.
71 } else {
72 m_dx = dx0 / d;
73 m_dy = dy0 / d;
74 m_dz = dz0 / d;
75 }
76 return true;
77}
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

◆ SetClusterDensity()

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

Set the cluster density (inverse mean free path).

Definition at line 13 of file TrackSimple.cc.

13 {
14 if (d < Small) {
15 std::cerr << m_className << "::SetClusterDensity:\n"
16 << " Cluster density (number of clusters per cm)"
17 << " must be positive.\n";
18 return;
19 }
20
21 m_mfp = 1. / d;
22}

◆ SetEqualSpacing()

void Garfield::TrackSimple::SetEqualSpacing ( )
inline

Constant distance between clusters.

Definition at line 18 of file TrackSimple.hh.

18{ m_useEqualSpacing = true; }

◆ SetExponentialSpacing()

void Garfield::TrackSimple::SetExponentialSpacing ( )
inline

Exponentially distributed distance between clusters.

Definition at line 20 of file TrackSimple.hh.

20{ m_useEqualSpacing = false; }

◆ SetStoppingPower()

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

Set the stopping power (dE/dx).

Definition at line 26 of file TrackSimple.cc.

26 {
27 if (dedx < Small) {
28 std::cerr << m_className << "::SetStoppingPower:\n"
29 << " Stopping power (average energy loss [eV] per cm)"
30 << " must be positive.\n";
31 return;
32 }
33
34 m_eloss = dedx;
35}

Member Data Documentation

◆ m_dx

double Garfield::TrackSimple::m_dx = 0.
protected

Definition at line 40 of file TrackSimple.hh.

Referenced by GetCluster(), and NewTrack().

◆ m_dy

double Garfield::TrackSimple::m_dy = 0.
protected

Definition at line 40 of file TrackSimple.hh.

Referenced by GetCluster(), and NewTrack().

◆ m_dz

double Garfield::TrackSimple::m_dz = 0.
protected

Definition at line 40 of file TrackSimple.hh.

Referenced by GetCluster(), and NewTrack().

◆ m_eloss

double Garfield::TrackSimple::m_eloss = 2530.
protected

Definition at line 44 of file TrackSimple.hh.

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

◆ m_isReady

bool Garfield::TrackSimple::m_isReady = false
protected

Definition at line 36 of file TrackSimple.hh.

Referenced by GetCluster(), and NewTrack().

◆ m_mfp

double Garfield::TrackSimple::m_mfp = 0.04
protected

Definition at line 42 of file TrackSimple.hh.

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

◆ m_t

double Garfield::TrackSimple::m_t = 0.
protected

Definition at line 39 of file TrackSimple.hh.

Referenced by GetCluster(), and NewTrack().

◆ m_useEqualSpacing

bool Garfield::TrackSimple::m_useEqualSpacing = false
protected

Definition at line 46 of file TrackSimple.hh.

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

◆ m_x

double Garfield::TrackSimple::m_x = 0.
protected

Definition at line 39 of file TrackSimple.hh.

Referenced by GetCluster(), and NewTrack().

◆ m_y

double Garfield::TrackSimple::m_y = 0.
protected

Definition at line 39 of file TrackSimple.hh.

Referenced by GetCluster(), and NewTrack().

◆ m_z

double Garfield::TrackSimple::m_z = 0.
protected

Definition at line 39 of file TrackSimple.hh.

Referenced by GetCluster(), and NewTrack().


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