Garfield++ v1r0
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

#include <TrackSimple.hh>

+ Inheritance diagram for Garfield::TrackSimple:

Public Member Functions

 TrackSimple ()
 
 ~TrackSimple ()
 
void SetEqualSpacing ()
 
void SetExponentialSpacing ()
 
void SetClusterDensity (const double d)
 
double GetClusterDensity ()
 
void SetStoppingPower (const double dedx)
 
double GetStoppingPower ()
 
bool NewTrack (const double x0, const double y0, const double z0, const double t0, const double dx0, const double dy0, const double dz0)
 
bool GetCluster (double &xcls, double &ycls, double &zcls, double &tcls, int &n, double &e, double &extra)
 
- Public Member Functions inherited from Garfield::Track
 Track ()
 
virtual ~Track ()
 
virtual void SetParticle (std::string part)
 
void SetEnergy (const double e)
 
void SetBetaGamma (const double bg)
 
void SetBeta (const double beta)
 
void SetGamma (const double gamma)
 
void SetMomentum (const double p)
 
void SetKineticEnergy (const double ekin)
 
double GetEnergy () const
 
double GetBetaGamma () const
 
double GetBeta () const
 
double GetGamma () const
 
double GetMomentum () const
 
double GetKineticEnergy () const
 
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 ()
 
void EnablePlotting (ViewDrift *viewer)
 
void DisablePlotting ()
 
void EnableDebugging ()
 
void DisableDebugging ()
 

Protected Attributes

bool isReady
 
double x
 
double y
 
double z
 
double t
 
double dx
 
double dy
 
double dz
 
double mfp
 
double eloss
 
bool useEqualSpacing
 
- Protected Attributes inherited from Garfield::Track
std::string className
 
double q
 
int spin
 
double mass
 
double energy
 
double beta2
 
bool isElectron
 
std::string particleName
 
Sensorsensor
 
bool isChanged
 
bool usePlotting
 
ViewDriftviewer
 
bool debug
 
int 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

Definition at line 9 of file TrackSimple.hh.

Constructor & Destructor Documentation

◆ TrackSimple()

Garfield::TrackSimple::TrackSimple ( )

Definition at line 11 of file TrackSimple.cc.

12 : isReady(false),
13 x(0.),
14 y(0.),
15 z(0.),
16 t(0.),
17 dx(0.),
18 dy(0.),
19 dz(1.),
20 mfp(0.04),
21 eloss(2530.),
22 useEqualSpacing(false) {
23
24 className = "TrackSimple";
25}
std::string className
Definition: Track.hh:61

◆ ~TrackSimple()

Garfield::TrackSimple::~TrackSimple ( )
inline

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

Implements Garfield::Track.

Definition at line 101 of file TrackSimple.cc.

102 {
103
104 extra = 0.;
105 if (!isReady) return false;
106
107 if (useEqualSpacing) {
108 x += dx * mfp;
109 y += dy * mfp;
110 z += dz * mfp;
111 } else {
112 const double d = -mfp * log(RndmUniformPos());
113 x += dx * d;
114 y += dy * d;
115 z += dz * d;
116 }
117
118 xcls = x;
119 ycls = y;
120 zcls = z;
121 tcls = t;
122
123 n = 1;
124 e = eloss * mfp;
125
126 Medium* medium;
127 if (!sensor->GetMedium(x, y, z, medium)) {
128 isReady = false;
129 if (debug) {
130 std::cout << className << "::GetCluster:\n";
131 std::cout << " Particle left the medium.\n";
132 }
133 return false;
134 }
135
136 return true;
137}
bool GetMedium(const double x, const double y, const double z, Medium *&medium)
Definition: Sensor.cc:141
bool debug
Definition: Track.hh:78
Sensor * sensor
Definition: Track.hh:71
double RndmUniformPos()
Definition: Random.hh:19

◆ GetClusterDensity()

double Garfield::TrackSimple::GetClusterDensity ( )
virtual

Reimplemented from Garfield::Track.

Definition at line 39 of file TrackSimple.cc.

39{ return 1. / mfp; }

◆ GetStoppingPower()

double Garfield::TrackSimple::GetStoppingPower ( )
virtual

Reimplemented from Garfield::Track.

Definition at line 53 of file TrackSimple.cc.

53{ return 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

Implements Garfield::Track.

Definition at line 55 of file TrackSimple.cc.

57 {
58
59 // Check if a sensor has been defined
60 if (sensor == 0) {
61 std::cerr << className << "::NewTrack:\n";
62 std::cerr << " Sensor is not defined.\n";
63 isReady = false;
64 return false;
65 }
66
67 // Make sure we are inside a medium
68 Medium* medium;
69 if (!sensor->GetMedium(x0, y0, z0, medium)) {
70 std::cerr << className << "::NewTrack:\n";
71 std::cerr << " No medium at initial position.\n";
72 isReady = false;
73 return false;
74 }
75
76 isReady = true;
77
78 x = x0;
79 y = y0;
80 z = z0;
81 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
87 double phi = TwoPi * RndmUniform();
88 double ctheta = 1. - 2. * RndmUniform();
89 double stheta = sqrt(1. - ctheta * ctheta);
90 dx = cos(phi) * stheta;
91 dy = sin(phi) * stheta;
92 dz = ctheta;
93 } else {
94 dx = dx0 / d;
95 dy = dy0 / d;
96 dz = dz0 / d;
97 }
98 return true;
99}
DoubleAc cos(const DoubleAc &f)
Definition: DoubleAc.cpp:431
DoubleAc sqrt(const DoubleAc &f)
Definition: DoubleAc.cpp:313
DoubleAc sin(const DoubleAc &f)
Definition: DoubleAc.cpp:383
double RndmUniform()
Definition: Random.hh:16

◆ SetClusterDensity()

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

Definition at line 27 of file TrackSimple.cc.

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

◆ SetEqualSpacing()

void Garfield::TrackSimple::SetEqualSpacing ( )
inline

Definition at line 17 of file TrackSimple.hh.

17{ useEqualSpacing = true; }

◆ SetExponentialSpacing()

void Garfield::TrackSimple::SetExponentialSpacing ( )
inline

Definition at line 18 of file TrackSimple.hh.

18{ useEqualSpacing = false; }

◆ SetStoppingPower()

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

Definition at line 41 of file TrackSimple.cc.

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

Member Data Documentation

◆ dx

double Garfield::TrackSimple::dx
protected

Definition at line 36 of file TrackSimple.hh.

Referenced by GetCluster(), and NewTrack().

◆ dy

double Garfield::TrackSimple::dy
protected

Definition at line 36 of file TrackSimple.hh.

Referenced by GetCluster(), and NewTrack().

◆ dz

double Garfield::TrackSimple::dz
protected

Definition at line 36 of file TrackSimple.hh.

Referenced by GetCluster(), and NewTrack().

◆ eloss

double Garfield::TrackSimple::eloss
protected

Definition at line 40 of file TrackSimple.hh.

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

◆ isReady

bool Garfield::TrackSimple::isReady
protected

Definition at line 32 of file TrackSimple.hh.

Referenced by GetCluster(), and NewTrack().

◆ mfp

double Garfield::TrackSimple::mfp
protected

Definition at line 38 of file TrackSimple.hh.

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

◆ t

double Garfield::TrackSimple::t
protected

Definition at line 35 of file TrackSimple.hh.

Referenced by GetCluster(), and NewTrack().

◆ useEqualSpacing

bool Garfield::TrackSimple::useEqualSpacing
protected

Definition at line 42 of file TrackSimple.hh.

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

◆ x

double Garfield::TrackSimple::x
protected

Definition at line 35 of file TrackSimple.hh.

Referenced by GetCluster(), and NewTrack().

◆ y

double Garfield::TrackSimple::y
protected

Definition at line 35 of file TrackSimple.hh.

Referenced by GetCluster(), and NewTrack().

◆ z

double Garfield::TrackSimple::z
protected

Definition at line 35 of file TrackSimple.hh.

Referenced by GetCluster(), and NewTrack().


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