Garfield++ 4.0
A toolkit for the detailed simulation of particle detectors based on ionisation measurement in gases and semiconductors
Loading...
Searching...
No Matches
Heed::mparticle Class Reference

Massive particle. A force can be applied. More...

#include <mparticle.h>

+ Inheritance diagram for Heed::mparticle:

Public Member Functions

 mparticle ()=default
 Default constructor.
 
 mparticle (manip_absvol *primvol, const point &pt, const vec &vel, vfloat ftime, double fmass)
 Constructor, $\gamma - 1$ calculated from the from velocity vector.
 
virtual ~mparticle ()
 Destructor.
 
double kinetic_energy () const
 Get the current kinetic energy.
 
void print (std::ostream &file, int l) const override
 Print-out.
 
mparticlecopy () const override
 Clone the particle.
 
- Public Member Functions inherited from Heed::gparticle
 gparticle ()=default
 Default constructor.
 
 gparticle (manip_absvol *primvol, const point &pt, const vec &vel, vfloat time)
 Constructor.
 
virtual ~gparticle ()
 Destructor.
 
virtual void fly (std::vector< gparticle * > &secondaries)
 Transport the particle.
 
virtual void fly (std::vector< gparticle * > &secondaries, const bool one_step)
 
void set_step_limits (const vfloat fmax_range, const vfloat frad_for_straight, const vfloat fmax_straight_arange, const vfloat fmax_circ_arange)
 Set limits/parameters for trajectory steps.
 
const vecposition () const
 Get the current position of the particle.
 
vfloat time () const
 Get the current time of the particle.
 
const vecdirection () const
 Get the current direction of the particle.
 
bool alive () const
 
virtual void print (std::ostream &file, int l) const
 Print-out.
 
virtual gparticlecopy () const
 Clone the particle.
 

Protected Member Functions

void step (std::vector< gparticle * > &secondaries) override
 
void curvature (bool &curved, vec &frelcen, vfloat &fmrange, vfloat prec) override
 
virtual int force (const point &pt, vec &f, vec &f_perp, vfloat &mrange)
 
- Protected Member Functions inherited from Heed::gparticle
virtual void step (std::vector< gparticle * > &secondaries)
 
virtual void change_vol ()
 Move from one volume to another.
 
virtual void curvature (bool &curved, vec &frelcen, vfloat &fmrange, vfloat prec)
 
virtual void physics_after_new_speed (std::vector< gparticle * > &)
 Apply any other processes (turn the trajectory, kill the particle, ...).
 
virtual void physics (std::vector< gparticle * > &)
 Apply any other processes (turn the trajectory, kill the particle, ...).
 
virtual void physics_mrange (double &fmrange)
 
virtual stvpoint calc_step_to_bord ()
 Determine next position.
 
stvpoint switch_new_vol ()
 Generate next position in new volume.
 

Protected Attributes

double m_mass = 0.
 Mass (not mass * speed_of_light^2)
 
double m_curr_ekin = 0.
 Current kinetic energy.
 
double m_orig_ekin = 0.
 Original kinetic energy.
 
double m_prev_ekin = 0.
 Previous kinetic energy.
 
double m_curr_gamma_1 = 0.
 Current $\gamma - 1$.
 
double m_orig_gamma_1 = 0.
 Original $\gamma - 1$.
 
double m_prev_gamma_1 = 0.
 Previous $\gamma - 1$.
 
- Protected Attributes inherited from Heed::gparticle
bool m_alive = false
 Status flag whether the particle is active.
 
long m_nstep = 0
 Step number.
 
long m_nzero_step = 0
 Number of previous steps with zero range (including this step).
 
stvpoint m_origin
 Original point.
 
double m_total_range_from_origin = 0.
 Range from origin to current position.
 
stvpoint m_prevpos
 Previous point.
 
stvpoint m_currpos
 Current point.
 
stvpoint m_nextpos
 Next point.
 

Additional Inherited Members

- Static Protected Attributes inherited from Heed::gparticle
static constexpr long m_max_qzero_step = 100
 Max. number of zero-steps allowed.
 

Detailed Description

Massive particle. A force can be applied.

Definition at line 23 of file mparticle.h.

Constructor & Destructor Documentation

◆ mparticle() [1/2]

Heed::mparticle::mparticle ( )
default

Default constructor.

Referenced by copy().

◆ mparticle() [2/2]

Heed::mparticle::mparticle ( manip_absvol primvol,
const point pt,
const vec vel,
vfloat  ftime,
double  fmass 
)

Constructor, $\gamma - 1$ calculated from the from velocity vector.

Definition at line 20 of file mparticle.cpp.

22 : gparticle(primvol, pt, vel, ftime),
23 m_mass(fmass) {
24
25 mfunname("mparticle::mparticle(...)");
26
27 const double mc2 = m_mass * c_squared;
34 check_consistency();
35}
#define mfunname(string)
Definition: FunNameStack.h:45
stvpoint m_prevpos
Previous point.
Definition: gparticle.h:262
gparticle()=default
Default constructor.
stvpoint m_currpos
Current point.
Definition: gparticle.h:264
stvpoint m_origin
Original point.
Definition: gparticle.h:257
double m_prev_ekin
Previous kinetic energy.
Definition: mparticle.h:77
double m_curr_ekin
Current kinetic energy.
Definition: mparticle.h:73
double m_curr_gamma_1
Current .
Definition: mparticle.h:80
double m_orig_ekin
Original kinetic energy.
Definition: mparticle.h:75
double m_prev_gamma_1
Previous .
Definition: mparticle.h:84
double m_orig_gamma_1
Original .
Definition: mparticle.h:82
double m_mass
Mass (not mass * speed_of_light^2)
Definition: mparticle.h:70
vfloat speed
Longitudinal velocity.
Definition: gparticle.h:31
double lorgamma_1(double beta)
as function of .
Definition: lorgamma.cpp:10

◆ ~mparticle()

virtual Heed::mparticle::~mparticle ( )
inlinevirtual

Destructor.

Definition at line 31 of file mparticle.h.

31{}

Member Function Documentation

◆ copy()

mparticle * Heed::mparticle::copy ( ) const
inlineoverridevirtual

Clone the particle.

Reimplemented from Heed::gparticle.

Reimplemented in Heed::eparticle.

Definition at line 37 of file mparticle.h.

37{ return new mparticle(*this); }
mparticle()=default
Default constructor.

◆ curvature()

void Heed::mparticle::curvature ( bool &  curved,
vec frelcen,
vfloat fmrange,
vfloat  prec 
)
overrideprotectedvirtual

Set curvature. Calls force().

  • If force is zero, set curved = false, frelcen = (0, 0, 0).
    • If, in addition, currpos.dir == (0, 0, 0), set fmrange = 0.
  • If currpos.dir == (0, 0, 0), set currpos.dir = unit_vec(f).
  • If force is parallel or anti-parallel to dir, set curved = false, frelcen = (0, 0, 0).
  • If force is anti-parallel to dir, restrict range till exceeding kinetic energy.

Reimplemented from Heed::gparticle.

Definition at line 98 of file mparticle.cpp.

99 {
100
101 pvecerror("void mparticle::curvature(...)");
102 vec f;
103 vec f_perp_fl;
104 int i = force(m_currpos.pt, f, f_perp_fl, fmrange);
105 vec f_perp = m_currpos.speed * (m_currpos.dir || f_perp_fl);
106 f += f_perp;
107 if (i == 0 || f == dv0) {
108 curved = false;
109 frelcen = dv0;
110 if (m_currpos.dir == dv0) fmrange = 0; // to stay in the place
111 return;
112 }
113 if (m_currpos.dir == dv0) {
114 // starting to move in the direction of force
115 m_currpos.dir = unit_vec(f);
116 }
117 const int j = check_par(m_currpos.dir, f, prec);
118 if (j != 0) {
119 curved = false;
120 frelcen = dv0;
121 if (j == -1) {
122 // decelerate, search for stop point
123 const double ran = m_curr_ekin / f.length();
124 if (fmrange > ran) fmrange = ran;
125 }
126 } else {
127 curved = true;
128 vec fn = project_to_plane(f, m_currpos.dir); // normal component
129 frelcen = unit_vec(fn);
130 double len = fn.length();
131 vfloat rad =
133 frelcen *= rad;
134 }
137}
void up_absref(absref *f)
Definition: volume.cpp:27
virtual int force(const point &pt, vec &f, vec &f_perp, vfloat &mrange)
Definition: mparticle.cpp:139
vec dirloc
Unit vector, in the local system (last system in the tree).
Definition: gparticle.h:29
vec dir
Unit vector, in the first system in the tree.
Definition: gparticle.h:25
point pt
Coordinates in the first system in the tree.
Definition: gparticle.h:23
manip_absvol_treeid tid
Definition: gparticle.h:32
vec project_to_plane(const vec &r, const vec &normal)
Definition: vec.cpp:124
vec dv0(0, 0, 0)
Definition: vec.h:308
double vfloat
Definition: vfloat.h:16
#define pvecerror(string)
Definition: vec.h:28

◆ force()

int Heed::mparticle::force ( const point pt,
vec f,
vec f_perp,
vfloat mrange 
)
protectedvirtual

The force is considered to be split in two components. One component, f, can be in any direction and is capable of doing work. The other one is always normal to dir and cannot do work. The latter can represent the magnetic component of the Lorentz force. This splitting improve precision of calculation of kinetic energy. But the latter component is not the true force. To derive the force one should do vector multiplication of speed by f_perp, f_perp2 = currpos.speed * (currpos.dir || f_perp_fl2); Return 0 if there is no force, f is initialised to zero anyway. mrange is the distance at which the force should not change much. The dimension of f is [weight] * [lenght] / [time]^2 The dimension of f_perp is [weight] / [time];

Reimplemented in Heed::eparticle.

Definition at line 139 of file mparticle.cpp.

139 {
140 f.x = f_perp.x = 0.;
141 f.y = f_perp.y = 0.;
142 f.z = f_perp.z = 0.;
143 mrange = max_vfloat;
144 return 0;
145}

Referenced by curvature().

◆ kinetic_energy()

double Heed::mparticle::kinetic_energy ( ) const
inline

Get the current kinetic energy.

Definition at line 34 of file mparticle.h.

34{ return m_curr_ekin; }

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

◆ print()

void Heed::mparticle::print ( std::ostream &  file,
int  l 
) const
overridevirtual

Print-out.

Reimplemented from Heed::gparticle.

Reimplemented in Heed::eparticle.

Definition at line 243 of file mparticle.cpp.

243 {
244 if (l < 0) return;
245 Ifile << "mparticle: mass=" << m_mass << " (" << m_mass / CLHEP::kg << " kg, "
246 << m_mass * c_squared / CLHEP::GeV << " GeV)\n";
247 Ifile << "orig_ekin=" << m_orig_ekin << " ("
248 << m_orig_ekin / CLHEP::GeV << " GeV)"
249 << " orig_gamma_1=" << m_orig_gamma_1 << '\n';
250 Ifile << "prev_ekin=" << m_prev_ekin << " ("
251 << m_prev_ekin / CLHEP::GeV << " GeV)"
252 << " prev_gamma_1=" << m_prev_gamma_1 << '\n';
253 Ifile << "curr_kin_energy=" << m_curr_ekin << " ("
254 << m_curr_ekin / CLHEP::GeV << " GeV)"
255 << " curr_gamma_1=" << m_curr_gamma_1 << '\n';
256 gparticle::print(file, l);
257}
virtual void print(std::ostream &file, int l) const
Print-out.
Definition: gparticle.cpp:192
#define Ifile
Definition: prstream.h:195

Referenced by Heed::HeedDeltaElectron::print(), Heed::HeedParticle::print(), Heed::HeedParticle_BGM::print(), Heed::eparticle::print(), and step().

◆ step()

void Heed::mparticle::step ( std::vector< gparticle * > &  secondaries)
overrideprotectedvirtual

Assign prevpos = currpos and currpos = nextpos, call change_vol if necessary and update nextpos = calc_step_to_bord(). Derived versions can also recalculate the direction at currpos right after updating currpos = nextpos. This is especially important in the case when the motion is approximated by straight-line steps, but there is a (magnetic) field which slightly
deflects the trajectory. In this case, the velocity is corrected at the end point of each interval, but the position is not.

Reimplemented from Heed::gparticle.

Definition at line 71 of file mparticle.cpp.

71 {
72 // Make step to nextpos and calculate new step to border
73 mfunname("void mparticle::step(...)");
79 m_nstep++;
80 if (m_currpos.prange == 0) {
83 "too many zero steps, possible infinite loop\n";
84 print(mcout, 10);, mcerr);
85 } else {
86 m_nzero_step = 0;
87 }
88 // Calculate new current speed, direction and time.
89 new_speed();
90 physics_after_new_speed(secondaries);
91
92 if (m_alive) {
95 }
96}
#define check_econd12a(a, sign, b, add, stream)
Definition: FunNameStack.h:181
virtual void physics_after_new_speed(std::vector< gparticle * > &)
Apply any other processes (turn the trajectory, kill the particle, ...).
Definition: gparticle.h:229
stvpoint m_nextpos
Next point.
Definition: gparticle.h:266
double m_total_range_from_origin
Range from origin to current position.
Definition: gparticle.h:259
virtual stvpoint calc_step_to_bord()
Determine next position.
Definition: gparticle.cpp:110
static constexpr long m_max_qzero_step
Max. number of zero-steps allowed.
Definition: gparticle.h:252
virtual void change_vol()
Move from one volume to another.
Definition: gparticle.h:211
long m_nzero_step
Number of previous steps with zero range (including this step).
Definition: gparticle.h:254
bool m_alive
Status flag whether the particle is active.
Definition: gparticle.h:247
long m_nstep
Step number.
Definition: gparticle.h:250
void print(std::ostream &file, int l) const override
Print-out.
Definition: mparticle.cpp:243
vfloat prange
Range from previous point.
Definition: gparticle.h:46
#define mcout
Definition: prstream.h:126
#define mcerr
Definition: prstream.h:128

Referenced by Heed::HeedParticle::physics(), and Heed::HeedParticle_BGM::physics().

Member Data Documentation

◆ m_curr_ekin

◆ m_curr_gamma_1

double Heed::mparticle::m_curr_gamma_1 = 0.
protected

◆ m_mass

double Heed::mparticle::m_mass = 0.
protected

◆ m_orig_ekin

double Heed::mparticle::m_orig_ekin = 0.
protected

Original kinetic energy.

Definition at line 75 of file mparticle.h.

Referenced by mparticle(), and print().

◆ m_orig_gamma_1

double Heed::mparticle::m_orig_gamma_1 = 0.
protected

Original $\gamma - 1$.

Definition at line 82 of file mparticle.h.

Referenced by mparticle(), and print().

◆ m_prev_ekin

double Heed::mparticle::m_prev_ekin = 0.
protected

Previous kinetic energy.

Definition at line 77 of file mparticle.h.

Referenced by mparticle(), Heed::HeedDeltaElectron::physics_after_new_speed(), print(), and step().

◆ m_prev_gamma_1

double Heed::mparticle::m_prev_gamma_1 = 0.
protected

Previous $\gamma - 1$.

Definition at line 84 of file mparticle.h.

Referenced by mparticle(), print(), and step().


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