Garfield++ 3.0
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)
 
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 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 = "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
 
bool m_usePlotting = false
 
ViewDriftm_viewer = nullptr
 
bool m_debug = false
 
int m_plotId = -1
 

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 13 of file Track.cc.

13: m_mass(MuonMass) { SetBetaGamma(3.); }
void SetBetaGamma(const double bg)
Set the relative momentum of the particle.
Definition: Track.cc:103
double m_mass
Definition: Track.hh:106

◆ ~Track()

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

Destructor.

Definition at line 19 of file Track.hh.

19{}

Member Function Documentation

◆ DisableDebugging()

void Garfield::Track::DisableDebugging ( )
inline

Switch off debugging messages.

Definition at line 99 of file Track.hh.

99{ m_debug = false; }
bool m_debug
Definition: Track.hh:119

◆ DisablePlotting()

void Garfield::Track::DisablePlotting ( )

Switch off plotting.

Definition at line 188 of file Track.cc.

188 {
189 m_usePlotting = false;
190 m_viewer = NULL;
191}
ViewDrift * m_viewer
Definition: Track.hh:117
bool m_usePlotting
Definition: Track.hh:116

◆ EnableDebugging()

void Garfield::Track::EnableDebugging ( )
inline

Switch on debugging messages.

Definition at line 97 of file Track.hh.

97{ m_debug = true; }

Referenced by GarfieldPhysics::InitializePhysics().

◆ EnablePlotting()

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

Switch on plotting.

Definition at line 177 of file Track.cc.

177 {
178 if (!view) {
179 std::cerr << m_className << "::EnablePlotting:\n";
180 std::cerr << " Pointer is null.\n";
181 return;
182 }
183
184 m_viewer = view;
185 m_usePlotting = true;
186}
std::string m_className
Definition: Track.hh:102

◆ GetBeta()

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

Return the speed ( $\beta = v/c$) of the projectile.

Definition at line 54 of file Track.hh.

54{ return sqrt(m_beta2); }
double m_beta2
Definition: Track.hh:108
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

Return the $\beta\gamma$ of the projectile.

Definition at line 52 of file Track.hh.

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

Referenced by Garfield::TrackBichsel::GetClusterDensity(), Garfield::TrackBichsel::GetStoppingPower(), and Garfield::TrackBichsel::NewTrack().

◆ GetCharge()

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

Get the charge of the projectile.

Definition at line 63 of file Track.hh.

63{ return m_q; }
double m_q
Definition: Track.hh:104

◆ 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::TrackSimple, Garfield::TrackHeed, 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::TrackPAI, Garfield::TrackSimple, and Garfield::TrackHeed.

Definition at line 87 of file Track.hh.

87{ return 0.; }

◆ GetEnergy()

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

Return the particle energy.

Definition at line 50 of file Track.hh.

50{ return m_energy; }
double m_energy
Definition: Track.hh:107

◆ GetGamma()

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

Return the Lorentz factor of the projectile.

Definition at line 56 of file Track.hh.

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

◆ GetKineticEnergy()

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

Return the kinetic energy of the projectile.

Definition at line 60 of file Track.hh.

60{ 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 65 of file Track.hh.

65{ return m_mass; }

◆ GetMomentum()

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

Return the particle momentum.

Definition at line 58 of file Track.hh.

58{ 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::TrackPAI, Garfield::TrackSimple, and Garfield::TrackHeed.

Definition at line 89 of file Track.hh.

89{ 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::TrackPAI, Garfield::TrackSimple, Garfield::TrackHeed, and Garfield::TrackSrim.

◆ PlotCluster()

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

Definition at line 199 of file Track.cc.

199 {
200 if (m_plotId < 0 || !m_usePlotting || !m_viewer) {
201 std::cerr << m_className << "::PlotCluster:\n";
202 std::cerr << " No track set. Program bug!\n";
203 return;
204 }
205 m_viewer->AddTrackPoint(m_plotId, x0, y0, z0);
206}
void AddTrackPoint(const unsigned int iL, const double x, const double y, const double z)
Definition: ViewDrift.cc:198

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

◆ PlotNewTrack()

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

Definition at line 193 of file Track.cc.

193 {
194 if (!m_usePlotting || !m_viewer) return;
195
197}
void NewChargedParticleTrack(const unsigned int np, int &id, const double x0, const double y0, const double z0)
Definition: ViewDrift.cc:149

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 116 of file Track.cc.

116 {
117 if (beta <= 0. && beta >= 1.) {
118 std::cerr << m_className << "::SetBeta:\n";
119 std::cerr << " Particle speed must be between zero"
120 << " and speed of light.\n";
121 return;
122 }
123
124 m_beta2 = beta * beta;
125 m_energy = m_mass * sqrt(1. / (1. - m_beta2));
126 m_isChanged = true;
127}
bool m_isChanged
Definition: Track.hh:114

◆ SetBetaGamma()

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

Set the relative momentum of the particle.

Definition at line 103 of file Track.cc.

103 {
104 if (bg <= 0.) {
105 std::cerr << m_className << "::SetBetaGamma:\n"
106 << " Particle speed must be greater than zero.\n";
107 return;
108 }
109
110 const double bg2 = bg * bg;
111 m_energy = m_mass * sqrt(1. + bg2);
112 m_beta2 = bg2 / (1. + bg2);
113 m_isChanged = true;
114}

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

◆ SetEnergy()

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

Set the particle energy.

Definition at line 90 of file Track.cc.

90 {
91 if (e <= m_mass) {
92 std::cerr << m_className << "::SetEnergy:\n"
93 << " Particle energy must be greater than the mass.\n";
94 return;
95 }
96
97 m_energy = e;
98 const double gamma = m_energy / m_mass;
99 m_beta2 = 1. - 1. / (gamma * gamma);
100 m_isChanged = true;
101}

◆ SetGamma()

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

Set the Lorentz factor of the particle.

Definition at line 129 of file Track.cc.

129 {
130 if (gamma <= 1.) {
131 std::cerr << m_className << "::SetGamma:\n";
132 std::cerr << " Particle speed must be greater than zero.\n";
133 return;
134 }
135
136 m_energy = m_mass * gamma;
137 m_beta2 = 1. - 1. / (gamma * gamma);
138 m_isChanged = true;
139}

◆ SetKineticEnergy()

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

Set the kinetic energy of the particle.

Definition at line 154 of file Track.cc.

154 {
155 if (ekin <= 0.) {
156 std::cerr << m_className << "::SetKineticEnergy:\n";
157 std::cerr << " Kinetic energy must be greater than zero.\n";
158 return;
159 }
160
161 m_energy = m_mass + ekin;
162 const double gamma = 1. + ekin / m_mass;
163 m_beta2 = 1. - 1. / (gamma * gamma);
164 m_isChanged = true;
165}

Referenced by GarfieldPhysics::DoIt().

◆ SetMomentum()

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

Set the particle momentum.

Definition at line 141 of file Track.cc.

141 {
142 if (p <= 0.) {
143 std::cerr << m_className << "::SetMomentum:\n";
144 std::cerr << " Particle momentum must be greater than zero.\n";
145 return;
146 }
147
148 m_energy = sqrt(m_mass * m_mass + p * p);
149 const double bg = p / m_mass;
150 m_beta2 = bg * bg / (1. + bg * bg);
151 m_isChanged = true;
152}

◆ SetParticle()

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

Set the type of charged particle.

  • electron,e-
  • positron,e+
  • muon,mu-
  • mu+
  • pion,pi-
  • pi+
  • kaon,K-
  • K+
  • proton,p
  • anti-proton,p-bar
  • deuteron,d
  • alpha

Reimplemented in Garfield::TrackElectron.

Definition at line 15 of file Track.cc.

15 {
16 std::string id = part;
17 std::transform(id.begin(), id.end(), id.begin(),
18 [](unsigned char c) -> unsigned char {
19 return std::toupper(c);
20 });
21 m_isElectron = false;
22 if (id == "ELECTRON" || id == "E-") {
23 m_q = -1;
24 m_mass = ElectronMass;
25 m_spin = 1;
26 m_isElectron = true;
27 m_particleName = "e-";
28 } else if (id == "POSITRON" || id == "E+") {
29 m_q = 1;
30 m_mass = ElectronMass;
31 m_spin = 1;
32 m_particleName = "e+";
33 } else if (id == "MUON" || id == "MU" || id == "MU-") {
34 m_q = -1;
35 m_mass = MuonMass;
36 m_spin = 1;
37 m_particleName = "mu-";
38 } else if (id == "MU+") {
39 m_q = 1;
40 m_mass = MuonMass;
41 m_spin = 1;
42 m_particleName = "mu+";
43 } else if (id == "PION" || id == "PI" || id == "PI-") {
44 m_q = -1;
45 m_mass = 139.57018e6;
46 m_spin = 0;
47 m_particleName = "pi-";
48 } else if (id == "PI+") {
49 m_q = 1;
50 m_mass = 139.57018e6;
51 m_spin = 0;
52 m_particleName = "pi+";
53 } else if (id == "KAON" || id == "K" || id == "K-") {
54 m_q = -1;
55 m_mass = 493.677e6;
56 m_spin = 0;
57 m_particleName = "K-";
58 } else if (id == "K+") {
59 m_q = 1;
60 m_mass = 493.677e6;
61 m_spin = 0;
62 m_particleName = "K+";
63 } else if (id == "PROTON" || id == "P") {
64 m_q = 1;
65 m_mass = ProtonMass;
66 m_spin = 1;
67 m_particleName = "p";
68 } else if (id == "ANTI-PROTON" || id == "ANTIPROTON" ||
69 id == "P-BAR" || id == "PBAR") {
70 m_q = -1;
71 m_mass = ProtonMass;
72 m_spin = 1;
73 m_particleName = "pbar";
74 } else if (id == "DEUTERON" || id == "D") {
75 m_q = 1;
76 m_mass = 1875.612793e6;
77 m_spin = 2;
78 m_particleName = "d";
79 } else if (id == "ALPHA") {
80 m_q = 2;
81 m_mass = 3.727379240e9;
82 m_spin = 0;
83 m_particleName = "alpha";
84 } else {
85 std::cerr << m_className << "::SetParticle:\n"
86 << " Particle " << part << " is not defined.\n";
87 }
88}
bool m_isElectron
Definition: Track.hh:109
std::string m_particleName
Definition: Track.hh:110

Referenced by GarfieldPhysics::DoIt().

◆ SetSensor()

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

Set the sensor through which to transport the particle.

Definition at line 167 of file Track.cc.

167 {
168 if (!s) {
169 std::cerr << m_className << "::SetSensor:\n";
170 std::cerr << " Sensor pointer is null.\n";
171 return;
172 }
173
174 m_sensor = s;
175}
Sensor * m_sensor
Definition: Track.hh:112

Referenced by GarfieldPhysics::InitializePhysics().

Member Data Documentation

◆ m_beta2

◆ m_className

std::string Garfield::Track::m_className = "Track"
protected

Definition at line 102 of file Track.hh.

Referenced by EnablePlotting(), Garfield::TrackSrim::EstimateRange(), Garfield::TrackBichsel::GetCluster(), Garfield::TrackSimple::GetCluster(), Garfield::TrackSrim::GetCluster(), Garfield::TrackElectron::GetCluster(), Garfield::TrackPAI::GetCluster(), Garfield::TrackHeed::GetCluster(), Garfield::TrackBichsel::GetClusterDensity(), Garfield::TrackElectron::GetClusterDensity(), Garfield::TrackPAI::GetClusterDensity(), Garfield::TrackHeed::GetClusterDensity(), Garfield::TrackHeed::GetElectron(), Garfield::TrackHeed::GetIon(), Garfield::TrackBichsel::GetStoppingPower(), Garfield::TrackElectron::GetStoppingPower(), Garfield::TrackPAI::GetStoppingPower(), Garfield::TrackHeed::GetStoppingPower(), Garfield::TrackBichsel::NewTrack(), Garfield::TrackElectron::NewTrack(), Garfield::TrackPAI::NewTrack(), Garfield::TrackSimple::NewTrack(), Garfield::TrackHeed::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 = 0.
protected

◆ m_isChanged

◆ m_isElectron

bool Garfield::Track::m_isElectron = false
protected

◆ m_mass

◆ m_particleName

std::string Garfield::Track::m_particleName = "mu-"
protected

◆ m_plotId

int Garfield::Track::m_plotId = -1
protected

Definition at line 121 of file Track.hh.

Referenced by PlotCluster(), and PlotNewTrack().

◆ m_q

double Garfield::Track::m_q = -1.
protected

◆ m_sensor

◆ m_spin

int Garfield::Track::m_spin = 1
protected

◆ m_usePlotting

bool Garfield::Track::m_usePlotting = false
protected

◆ m_viewer

ViewDrift* Garfield::Track::m_viewer = nullptr
protected

Definition at line 117 of file Track.hh.

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


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