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

Abstract base class for track generation. More...

#include <Track.hh>

+ Inheritance diagram for Garfield::Track:

Public Member Functions

 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 Member Functions

void PlotNewTrack (const double x0, const double y0, const double z0)
 
void PlotCluster (const double x0, const double y0, const double z0)
 

Protected Attributes

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

Abstract base class for track generation.

Definition at line 14 of file Track.hh.

Constructor & Destructor Documentation

◆ Track()

Garfield::Track::Track ( )

Constructor.

Definition at line 11 of file Track.cc.

12 : m_className("Track"),
13 m_q(-1.),
14 m_spin(1),
15 m_mass(MuonMass),
16 m_energy(0.),
17 m_isElectron(false),
18 m_particleName("mu-"),
19 m_sensor(NULL),
20 m_isChanged(true),
21 m_usePlotting(false),
22 m_viewer(NULL),
23 m_debug(false),
24 m_plotId(-1) {
25
26 SetBetaGamma(3.);
27}
Sensor * m_sensor
Definition: Track.hh:90
void SetBetaGamma(const double bg)
Set the relative momentum of the particle.
Definition: Track.cc:116
bool m_debug
Definition: Track.hh:97
bool m_isElectron
Definition: Track.hh:87
bool m_isChanged
Definition: Track.hh:92
double m_q
Definition: Track.hh:82
ViewDrift * m_viewer
Definition: Track.hh:95
std::string m_particleName
Definition: Track.hh:88
std::string m_className
Definition: Track.hh:80
int m_plotId
Definition: Track.hh:99
bool m_usePlotting
Definition: Track.hh:94
double m_mass
Definition: Track.hh:84
double m_energy
Definition: Track.hh:85

◆ ~Track()

virtual Garfield::Track::~Track ( )
inlinevirtual

Destructor.

Definition at line 20 of file Track.hh.

20{}

Member Function Documentation

◆ DisableDebugging()

void Garfield::Track::DisableDebugging ( )
inline

Definition at line 77 of file Track.hh.

77{ m_debug = false; }

◆ DisablePlotting()

void Garfield::Track::DisablePlotting ( )

Definition at line 208 of file Track.cc.

208 {
209
210 m_usePlotting = false;
211 m_viewer = NULL;
212}

◆ EnableDebugging()

void Garfield::Track::EnableDebugging ( )
inline

Definition at line 76 of file Track.hh.

76{ m_debug = true; }

Referenced by GarfieldPhysics::InitializePhysics().

◆ EnablePlotting()

void Garfield::Track::EnablePlotting ( ViewDrift viewer)

Definition at line 196 of file Track.cc.

196 {
197
198 if (!view) {
199 std::cerr << m_className << "::EnablePlotting:\n";
200 std::cerr << " Pointer is null.\n";
201 return;
202 }
203
204 m_viewer = view;
205 m_usePlotting = true;
206}

◆ GetBeta()

double Garfield::Track::GetBeta ( ) const
inline

Definition at line 40 of file Track.hh.

40{ return sqrt(m_beta2); }
double m_beta2
Definition: Track.hh:86
DoubleAc sqrt(const DoubleAc &f)
Definition: DoubleAc.cpp:314

Referenced by Garfield::TrackBichsel::NewTrack(), and Garfield::TrackHeed::NewTrack().

◆ GetBetaGamma()

double Garfield::Track::GetBetaGamma ( ) const
inline

◆ GetCharge()

double Garfield::Track::GetCharge ( ) const
inline

Get the charge of the projectile.

Definition at line 46 of file Track.hh.

46{ return m_q; }

◆ GetCluster()

virtual bool Garfield::Track::GetCluster ( double &  xcls,
double &  ycls,
double &  zcls,
double &  tcls,
int &  n,
double &  e,
double &  extra 
)
pure 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)

Implemented in Garfield::TrackBichsel, Garfield::TrackHeed, Garfield::TrackSimple, Garfield::TrackSrim, Garfield::TrackElectron, and Garfield::TrackPAI.

◆ GetClusterDensity()

virtual double Garfield::Track::GetClusterDensity ( )
inlinevirtual

Get the cluster density (number of ionizing collisions per cm or inverse mean free path for ionization).

Reimplemented in Garfield::TrackBichsel, Garfield::TrackElectron, Garfield::TrackHeed, Garfield::TrackPAI, and Garfield::TrackSimple.

Definition at line 69 of file Track.hh.

69{ return 0.; }

◆ GetEnergy()

double Garfield::Track::GetEnergy ( ) const
inline

Definition at line 38 of file Track.hh.

38{ return m_energy; }

◆ GetGamma()

double Garfield::Track::GetGamma ( ) const
inline

Definition at line 41 of file Track.hh.

41{ return sqrt(1. / (1. - m_beta2)); }

◆ GetKineticEnergy()

double Garfield::Track::GetKineticEnergy ( ) const
inline

Definition at line 43 of file Track.hh.

43{ return m_energy - m_mass; }

Referenced by Garfield::TrackSrim::NewTrack().

◆ GetMass()

double Garfield::Track::GetMass ( ) const
inline

Get the mass [eV / c2] of the projectile.

Definition at line 48 of file Track.hh.

48{ return m_mass; }

◆ GetMomentum()

double Garfield::Track::GetMomentum ( ) const
inline

Definition at line 42 of file Track.hh.

42{ return m_mass * sqrt(m_beta2 / (1. - m_beta2)); }

◆ GetStoppingPower()

virtual double Garfield::Track::GetStoppingPower ( )
inlinevirtual

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

Reimplemented in Garfield::TrackBichsel, Garfield::TrackElectron, Garfield::TrackHeed, Garfield::TrackPAI, and Garfield::TrackSimple.

Definition at line 71 of file Track.hh.

71{ return 0.; }

◆ NewTrack()

virtual bool Garfield::Track::NewTrack ( const double  x0,
const double  y0,
const double  z0,
const double  t0,
const double  dx0,
const double  dy0,
const double  dz0 
)
pure virtual

Calculate a new track starting from (x0, y0, z0) at time t0 in direction (dx0, dy0, dz0).

Implemented in Garfield::TrackBichsel, Garfield::TrackElectron, Garfield::TrackHeed, Garfield::TrackPAI, Garfield::TrackSimple, and Garfield::TrackSrim.

◆ PlotCluster()

void Garfield::Track::PlotCluster ( const double  x0,
const double  y0,
const double  z0 
)
protected

Definition at line 221 of file Track.cc.

221 {
222
223 if (m_plotId < 0 || !m_usePlotting || !m_viewer) {
224 std::cerr << m_className << "::PlotCluster:\n";
225 std::cerr << " No track set. Program bug!\n";
226 return;
227 }
228 m_viewer->AddTrackPoint(m_plotId, x0, y0, z0);
229}
void AddTrackPoint(const unsigned int iL, const double x, const double y, const double z)
Definition: ViewDrift.cc:269

Referenced by Garfield::TrackHeed::GetCluster().

◆ PlotNewTrack()

void Garfield::Track::PlotNewTrack ( const double  x0,
const double  y0,
const double  z0 
)
protected

Definition at line 214 of file Track.cc.

214 {
215
216 if (!m_usePlotting || !m_viewer) return;
217
219}
void NewChargedParticleTrack(const unsigned int np, int &id, const double x0, const double y0, const double z0)
Definition: ViewDrift.cc:216

Referenced by Garfield::TrackHeed::NewTrack().

◆ SetBeta()

void Garfield::Track::SetBeta ( const double  beta)

Set the speed ( $\beta = v/c$) of the particle.

Definition at line 130 of file Track.cc.

130 {
131
132 if (beta <= 0. && beta >= 1.) {
133 std::cerr << m_className << "::SetBeta:\n";
134 std::cerr << " Particle speed must be between zero"
135 << " and speed of light.\n";
136 return;
137 }
138
139 m_beta2 = beta * beta;
140 m_energy = m_mass * sqrt(1. / (1. - m_beta2));
141 m_isChanged = true;
142}

◆ SetBetaGamma()

void Garfield::Track::SetBetaGamma ( const double  bg)

Set the relative momentum of the particle.

Definition at line 116 of file Track.cc.

116 {
117
118 if (bg <= 0.) {
119 std::cerr << m_className << "::SetBetaGamma:\n"
120 << " Particle speed must be greater than zero.\n";
121 return;
122 }
123
124 const double bg2 = bg * bg;
125 m_energy = m_mass * sqrt(1. + bg2);
126 m_beta2 = bg2 / (1. + bg2);
127 m_isChanged = true;
128}

Referenced by Track(), and Garfield::TrackElectron::TrackElectron().

◆ SetEnergy()

void Garfield::Track::SetEnergy ( const double  e)

Set the particle energy.

Definition at line 102 of file Track.cc.

102 {
103
104 if (e <= m_mass) {
105 std::cerr << m_className << "::SetEnergy:\n"
106 << " Particle energy must be greater than the mass.\n";
107 return;
108 }
109
110 m_energy = e;
111 const double gamma = m_energy / m_mass;
112 m_beta2 = 1. - 1. / (gamma * gamma);
113 m_isChanged = true;
114}

◆ SetGamma()

void Garfield::Track::SetGamma ( const double  gamma)

Set the Lorentz factor of the particle.

Definition at line 144 of file Track.cc.

144 {
145
146 if (gamma <= 1.) {
147 std::cerr << m_className << "::SetGamma:\n";
148 std::cerr << " Particle speed must be greater than zero.\n";
149 return;
150 }
151
152 m_energy = m_mass * gamma;
153 m_beta2 = 1. - 1. / (gamma * gamma);
154 m_isChanged = true;
155}

◆ SetKineticEnergy()

void Garfield::Track::SetKineticEnergy ( const double  ekin)

Set the kinetic energy of the particle.

Definition at line 171 of file Track.cc.

171 {
172
173 if (ekin <= 0.) {
174 std::cerr << m_className << "::SetKineticEnergy:\n";
175 std::cerr << " Kinetic energy must be greater than zero.\n";
176 return;
177 }
178
179 m_energy = m_mass + ekin;
180 const double gamma = 1. + ekin / m_mass;
181 m_beta2 = 1. - 1. / (gamma * gamma);
182 m_isChanged = true;
183}

Referenced by GarfieldPhysics::DoIt().

◆ SetMomentum()

void Garfield::Track::SetMomentum ( const double  p)

Set the particle momentum.

Definition at line 157 of file Track.cc.

157 {
158
159 if (p <= 0.) {
160 std::cerr << m_className << "::SetMomentum:\n";
161 std::cerr << " Particle momentum must be greater than zero.\n";
162 return;
163 }
164
165 m_energy = sqrt(m_mass * m_mass + p * p);
166 const double bg = p / m_mass;
167 m_beta2 = bg * bg / (1. + bg * bg);
168 m_isChanged = true;
169}

◆ SetParticle()

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

Set the type of particle.

Reimplemented in Garfield::TrackElectron.

Definition at line 29 of file Track.cc.

29 {
30
31 m_isElectron = false;
32 if (part == "electron" || part == "Electron" || part == "e-") {
33 m_q = -1;
34 m_mass = ElectronMass;
35 m_spin = 1;
36 m_isElectron = true;
37 m_particleName = "e-";
38 } else if (part == "positron" || part == "Positron" || part == "e+") {
39 m_q = 1;
40 m_mass = ElectronMass;
41 m_spin = 1;
42 m_particleName = "e+";
43 } else if (part == "muon" || part == "Muon" || part == "mu" ||
44 part == "mu-") {
45 m_q = -1;
46 m_mass = MuonMass;
47 m_spin = 1;
48 m_particleName = "mu-";
49 } else if (part == "mu+") {
50 m_q = 1;
51 m_mass = MuonMass;
52 m_spin = 1;
53 m_particleName = "mu+";
54 } else if (part == "pion" || part == "Pion" || part == "pi" ||
55 part == "pi-") {
56 m_q = -1;
57 m_mass = 139.57018e6;
58 m_spin = 0;
59 m_particleName = "pi-";
60 } else if (part == "pi+") {
61 m_q = 1;
62 m_mass = 139.57018e6;
63 m_spin = 0;
64 m_particleName = "pi+";
65 } else if (part == "kaon" || part == "Kaon" || part == "K" || part == "K-") {
66 m_q = -1;
67 m_mass = 493.677e6;
68 m_spin = 0;
69 m_particleName = "K-";
70 } else if (part == "K+") {
71 m_q = 1;
72 m_mass = 493.677e6;
73 m_spin = 0;
74 m_particleName = "K+";
75 } else if (part == "proton" || part == "Proton" || part == "p") {
76 m_q = 1;
77 m_mass = ProtonMass;
78 m_spin = 1;
79 m_particleName = "p";
80 } else if (part == "anti-proton" || part == "Anti-Proton" ||
81 part == "antiproton" || part == "Antiproton" || part == "p-bar") {
82 m_q = -1;
83 m_mass = ProtonMass;
84 m_spin = 1;
85 m_particleName = "pbar";
86 } else if (part == "deuteron" || part == "Deuteron" || part == "d") {
87 m_q = 1;
88 m_mass = 1875.612793e6;
89 m_spin = 2;
90 m_particleName = "d";
91 } else if (part == "alpha" || part == "Alpha") {
92 m_q = 2;
93 m_mass = 3.727379240e9;
94 m_spin = 0;
95 m_particleName = "alpha";
96 } else {
97 std::cerr << m_className << "::SetParticle:\n"
98 << " Particle " << part << " is not defined.\n";
99 }
100}

Referenced by GarfieldPhysics::DoIt().

◆ SetSensor()

void Garfield::Track::SetSensor ( Sensor s)

Definition at line 185 of file Track.cc.

185 {
186
187 if (!s) {
188 std::cerr << m_className << "::SetSensor:\n";
189 std::cerr << " Sensor pointer is null.\n";
190 return;
191 }
192
193 m_sensor = s;
194}

Referenced by GarfieldPhysics::InitializePhysics().

Member Data Documentation

◆ m_beta2

◆ m_className

std::string Garfield::Track::m_className
protected

Definition at line 80 of file Track.hh.

Referenced by EnablePlotting(), Garfield::TrackSrim::EstimateRange(), Garfield::TrackBichsel::GetCluster(), Garfield::TrackSimple::GetCluster(), Garfield::TrackElectron::GetCluster(), Garfield::TrackPAI::GetCluster(), Garfield::TrackHeed::GetCluster(), Garfield::TrackBichsel::GetClusterDensity(), Garfield::TrackElectron::GetClusterDensity(), Garfield::TrackHeed::GetClusterDensity(), Garfield::TrackPAI::GetClusterDensity(), Garfield::TrackHeed::GetElectron(), Garfield::TrackHeed::GetIon(), Garfield::TrackBichsel::GetStoppingPower(), Garfield::TrackElectron::GetStoppingPower(), Garfield::TrackHeed::GetStoppingPower(), Garfield::TrackPAI::GetStoppingPower(), Garfield::TrackBichsel::NewTrack(), Garfield::TrackElectron::NewTrack(), Garfield::TrackHeed::NewTrack(), Garfield::TrackPAI::NewTrack(), Garfield::TrackSimple::NewTrack(), Garfield::TrackSrim::NewTrack(), PlotCluster(), Garfield::TrackSrim::PreciseLoss(), Garfield::TrackSrim::ReadFile(), SetBeta(), SetBetaGamma(), Garfield::TrackSimple::SetClusterDensity(), SetEnergy(), Garfield::TrackHeed::SetEnergyMesh(), SetGamma(), SetKineticEnergy(), SetMomentum(), SetParticle(), Garfield::TrackElectron::SetParticle(), Garfield::TrackHeed::SetParticleUser(), SetSensor(), Garfield::TrackSimple::SetStoppingPower(), Garfield::TrackSrim::SmallestStep(), Garfield::TrackBichsel::TrackBichsel(), Garfield::TrackElectron::TrackElectron(), Garfield::TrackHeed::TrackHeed(), Garfield::TrackPAI::TrackPAI(), Garfield::TrackSimple::TrackSimple(), Garfield::TrackSrim::TrackSrim(), Garfield::TrackHeed::TransportDeltaElectron(), and Garfield::TrackHeed::TransportPhoton().

◆ m_debug

◆ m_energy

double Garfield::Track::m_energy
protected

◆ m_isChanged

◆ m_isElectron

bool Garfield::Track::m_isElectron
protected

◆ m_mass

◆ m_particleName

std::string Garfield::Track::m_particleName
protected

◆ m_plotId

int Garfield::Track::m_plotId
protected

Definition at line 99 of file Track.hh.

Referenced by PlotCluster(), and PlotNewTrack().

◆ m_q

double Garfield::Track::m_q
protected

◆ m_sensor

◆ m_spin

int Garfield::Track::m_spin
protected

◆ m_usePlotting

bool Garfield::Track::m_usePlotting
protected

◆ m_viewer

ViewDrift* Garfield::Track::m_viewer
protected

Definition at line 95 of file Track.hh.

Referenced by DisablePlotting(), EnablePlotting(), PlotCluster(), and PlotNewTrack().


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