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::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
 
ViewDriftm_viewer = nullptr
 
bool m_debug = false
 
size_t m_plotId = 0
 

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

◆ DisablePlotting()

void Garfield::Track::DisablePlotting ( )

Switch off plotting.

Definition at line 183 of file Track.cc.

183 {
184 m_viewer = nullptr;
185}
ViewDrift * m_viewer
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; }

◆ EnablePlotting()

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

Switch on plotting.

Definition at line 175 of file Track.cc.

175 {
176 if (!view) {
177 std::cerr << m_className << "::EnablePlotting: Null pointer.\n";
178 return;
179 }
180 m_viewer = view;
181}
std::string m_className
Definition: Track.hh:102

Referenced by main().

◆ 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::TrackTrim, 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)); }

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

◆ 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, Garfield::TrackSrim, and Garfield::TrackTrim.

◆ PlotCluster()

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

Definition at line 192 of file Track.cc.

192 {
193 if (m_viewer) m_viewer->AddTrackPoint(m_plotId, x0, y0, z0);
194}
size_t m_plotId
Definition: Track.hh:120
void AddTrackPoint(const size_t iL, const float x, const float y, const float z)
Definition: ViewDrift.cc:156

Referenced by Garfield::TrackHeed::GetCluster(), Garfield::TrackSrim::NewTrack(), and Garfield::TrackTrim::NewTrack().

◆ PlotNewTrack()

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

Definition at line 187 of file Track.cc.

187 {
188 if (!m_viewer) return;
190}
void NewChargedParticleTrack(const size_t np, size_t &id, const float x0, const float y0, const float z0)
Definition: ViewDrift.cc:111

Referenced by Garfield::TrackHeed::NewTrack(), Garfield::TrackSrim::NewTrack(), and Garfield::TrackTrim::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 << " Beta must be between zero and one.\n";
120 return;
121 }
122
123 m_beta2 = beta * beta;
124 m_energy = m_mass * sqrt(1. / (1. - m_beta2));
125 m_isChanged = true;
126}
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 128 of file Track.cc.

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

◆ SetKineticEnergy()

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

Set the kinetic energy of the particle.

Definition at line 153 of file Track.cc.

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

Referenced by GarfieldPhysics::DoIt().

◆ SetMomentum()

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

Set the particle momentum.

Definition at line 140 of file Track.cc.

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

Referenced by main().

◆ 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(), and main().

◆ SetSensor()

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

Set the sensor through which to transport the particle.

Definition at line 166 of file Track.cc.

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

Referenced by GarfieldPhysics::InitializePhysics(), and main().

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::TrackTrim::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::TrackHeed::Initialise(), Garfield::TrackBichsel::NewTrack(), Garfield::TrackElectron::NewTrack(), Garfield::TrackPAI::NewTrack(), Garfield::TrackSimple::NewTrack(), Garfield::TrackHeed::NewTrack(), Garfield::TrackSrim::NewTrack(), Garfield::TrackTrim::NewTrack(), Garfield::TrackSrim::PreciseLoss(), Garfield::TrackTrim::Print(), Garfield::TrackSrim::ReadFile(), Garfield::TrackTrim::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::TrackTrim::TrackTrim(), 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

◆ m_plotId

size_t Garfield::Track::m_plotId = 0
protected

Definition at line 120 of file Track.hh.

Referenced by PlotCluster(), and PlotNewTrack().

◆ m_q

◆ m_sensor

◆ m_spin

int Garfield::Track::m_spin = 1
protected

◆ m_viewer


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