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

#include <HeedParticle.h>

+ Inheritance diagram for Heed::HeedParticle:

Public Member Functions

 HeedParticle ()
 Default constructor.
 
 HeedParticle (manip_absvol *primvol, const point &pt, const vec &vel, vfloat time, particle_def *fpardef, HeedFieldMap *fieldmap, const bool fs_loss_only=false, const bool fs_print_listing=false)
 
virtual ~HeedParticle ()
 Destructor.
 
HeedParticlecopy () const override
 Clone the particle.
 
void print (std::ostream &file, int l) const override
 Print-out.
 
- Public Member Functions inherited from Heed::eparticle
 eparticle ()=default
 Default constructor.
 
 eparticle (manip_absvol *primvol, const point &pt, const vec &vel, vfloat time, particle_def *fpardef, HeedFieldMap *fieldmap)
 Constructor using velocity vector.
 
virtual ~eparticle ()
 Destructor.
 
eparticlecopy () const override
 Clone the particle.
 
void print (std::ostream &file, int l) const override
 Print-out.
 
- Public Member Functions inherited from Heed::mparticle
 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.
 
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.
 
virtual void print (std::ostream &file, int l) const
 Print-out.
 
virtual gparticlecopy () const
 Clone the particle.
 
- Public Member Functions inherited from Heed::particle_type
 particle_type ()=default
 
 particle_type (particle_def *f)
 
 particle_type (const char *name, int s=0)
 
int operator== (const particle_type &f)
 
int operator!= (const particle_type &f)
 
void print_notation (std::ostream &file) const
 

Protected Member Functions

void physics (std::vector< gparticle * > &secondaries) override
 Apply any other processes (turn the trajectory, kill the particle, ...).
 
- Protected Member Functions inherited from Heed::eparticle
int force (const point &pt, vec &f, vec &f_perp, vfloat &mrange) override
 Calculate force components.
 
- Protected Member Functions inherited from Heed::mparticle
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.
 

Additional Inherited Members

- Public Attributes inherited from Heed::particle_type
particle_defpardef = nullptr
 
- Protected Attributes inherited from Heed::eparticle
HeedFieldMapm_fieldMap = nullptr
 Pointer to field map.
 
- Protected Attributes inherited from Heed::mparticle
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.
 
- Static Protected Attributes inherited from Heed::gparticle
static constexpr long m_max_qzero_step = 100
 Max. number of zero-steps allowed.
 

Detailed Description

Charged particle which can be traced through the geometry.

2003, I. Smirnov

Definition at line 15 of file HeedParticle.h.

Constructor & Destructor Documentation

◆ HeedParticle() [1/2]

Heed::HeedParticle::HeedParticle ( )
inline

Default constructor.

Definition at line 18 of file HeedParticle.h.

18: eparticle() {}
eparticle()=default
Default constructor.

Referenced by copy().

◆ HeedParticle() [2/2]

Heed::HeedParticle::HeedParticle ( manip_absvol primvol,
const point pt,
const vec vel,
vfloat  time,
particle_def fpardef,
HeedFieldMap fieldmap,
const bool  fs_loss_only = false,
const bool  fs_print_listing = false 
)

Constructor. If fs_loss_only == false only transferred energy is simulated: no deposition of clusters, no generation of virtual photons.

Definition at line 22 of file HeedParticle.cpp.

26 : eparticle(primvol, pt, vel, ftime, fpardef, fieldmap),
27 m_print_listing(fprint_listing),
28 m_particle_number(last_particle_number++),
29 m_loss_only(floss_only) {
30
31 mfunname("HeedParticle::HeedParticle(...)");
32 m_etransf.reserve(100);
33 m_natom.reserve(100);
34 m_nshell.reserve(100);
35}
#define mfunname(string)
Definition: FunNameStack.h:45
long last_particle_number
Definition: HeedParticle.h:9

◆ ~HeedParticle()

virtual Heed::HeedParticle::~HeedParticle ( )
inlinevirtual

Destructor.

Definition at line 28 of file HeedParticle.h.

28{}

Member Function Documentation

◆ copy()

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

Clone the particle.

Reimplemented from Heed::gparticle.

Definition at line 30 of file HeedParticle.h.

30{ return new HeedParticle(*this); }
HeedParticle()
Default constructor.
Definition: HeedParticle.h:18

◆ physics()

void Heed::HeedParticle::physics ( std::vector< gparticle * > &  )
overrideprotectedvirtual

Apply any other processes (turn the trajectory, kill the particle, ...).

Reimplemented from Heed::gparticle.

Definition at line 37 of file HeedParticle.cpp.

37 {
38 mfunname("void HeedParticle::physics()");
39 if (m_print_listing) {
40 mcout << "HeedParticle::physics is started\n";
42 }
43 m_etransf.clear();
44 m_natom.clear();
45 m_nshell.clear();
46 if (m_currpos.prange <= 0.0) return;
47 // Get local volume.
48 const absvol* av = m_currpos.tid.G_lavol();
49 auto etcs = dynamic_cast<const EnTransfCS*>(av);
50 if (!etcs) return;
51 HeedMatterDef* hmd = etcs->hmd;
52 MatterDef* matter = hmd->matter;
53 EnergyMesh* emesh = hmd->energy_mesh;
54 const double* aetemp = emesh->get_ae();
55 PointCoorMesh<double, const double*> pcm(emesh->get_q() + 1, &(aetemp));
56 const long qa = matter->qatom();
57 if (m_print_listing) Iprintn(mcout, qa);
58 basis tempbas(m_currpos.dir, "tempbas");
59 for (long na = 0; na < qa; ++na) {
60 if (m_print_listing) Iprintn(mcout, na);
61 const long qs = hmd->apacs[na]->get_qshell();
62 for (long ns = 0; ns < qs; ++ns) {
63 if (m_print_listing) Iprintn(mcout, ns);
64 if (etcs->quan[na][ns] <= 0.0) continue;
65 // Sample the number of collisions for this shell.
66 int ierror = 0;
67 const long qt = pois(etcs->quan[na][ns] * m_currpos.prange / cm, ierror);
68 check_econd11a(ierror, == 1,
69 " etcs->quan[na][ns]=" << etcs->quan[na][ns]
70 << " currpos.prange/cm="
71 << m_currpos.prange / cm << '\n',
72 mcerr);
73 if (m_print_listing) Iprintn(mcout, qt);
74 if (qt <= 0) continue;
75 point curpt = m_prevpos.pt;
76 vec dir = unit_vec(m_currpos.pt - m_prevpos.pt);
77 const double range = (m_currpos.pt - m_prevpos.pt).length();
78 if (m_print_listing) Iprint3n(mcout, curpt, dir, range);
79 for (long nt = 0; nt < qt; ++nt) {
80 // Sample the energy transfer in this collision.
81 const double rn = SRANLUX();
82 if (m_print_listing) Iprint3n(mcout, rn, etcs, etcs->fadda[na][ns][1]);
83 const double r = t_hisran_step_ar<
84 double, std::vector<double>, PointCoorMesh<double, const double*> >(
85 pcm, etcs->fadda[na][ns], rn);
86
87 // Convert to internal units.
88 const double et = r * MeV;
89 m_etransf.push_back(et);
90 m_natom.push_back(na);
91 m_nshell.push_back(ns);
92 if (m_print_listing) Iprint2n(mcout, nt, et);
93 // Sample the position of the collision.
94 const double arange = SRANLUX() * range;
95 point pt = curpt + dir * arange;
96 point ptloc = pt;
97 m_prevpos.tid.up_absref(&ptloc);
98 if (m_loss_only) continue;
99 if (m_print_listing) mcout << "generating new cluster\n";
100 if (m_store_clusters) {
101 m_clusterBank.emplace_back(
102 HeedCluster(et, 0, pt, ptloc, m_prevpos.tid, na, ns));
103 }
104 // Generate a virtual photon.
105 const double Ep0 = m_mass * c_squared + m_curr_ekin;
106 const double Ep1 = Ep0 - m_etransf.back();
107 const double Mp = m_mass * c_squared;
108 const double Mt = electron_def.mass * c_squared;
109 double theta_p, theta_t;
110 theta_two_part(Ep0, Ep1, Mp, Mt, theta_p, theta_t);
111 vec vel;
112 vel.random_conic_vec(fabs(theta_t));
113 vel.down(&tempbas); // direction is OK
114 vel *= c_light;
115 const double t = m_prevpos.time + arange / m_prevpos.speed;
116 if (m_print_listing) mcout << "generating new virtual photon\n";
117 HeedPhoton* hp = new HeedPhoton(m_currpos.tid.eid[0], pt, vel, t,
118 m_particle_number, et, m_fieldMap);
119 hp->m_photon_absorbed = true;
120 hp->m_delta_generated = false;
121 hp->m_na_absorbing = na;
122 hp->m_ns_absorbing = ns;
123 secondaries.push_back(hp);
124 }
125 }
126 }
127 if (m_print_listing) {
128 const double sum = std::accumulate(m_etransf.begin(), m_etransf.end(), 0.);
129 Iprint2n(mcout, m_etransf.size(), sum);
130 mcout << "Exiting HeedParticle::physics\n";
131 }
132}
#define check_econd11a(a, signb, add, stream)
Definition: FunNameStack.h:172
HeedFieldMap * m_fieldMap
Pointer to field map.
Definition: eparticle.h:34
stvpoint m_prevpos
Previous point.
Definition: gparticle.h:248
stvpoint m_currpos
Current point.
Definition: gparticle.h:250
void up_absref(absref *f)
Definition: volume.cpp:26
std::vector< manip_absvol * > eid
List of volumes.
Definition: volume.h:37
absvol * G_lavol() const
Get last address of volume.
Definition: volume.cpp:17
double m_curr_ekin
Current kinetic energy.
Definition: mparticle.h:73
double m_mass
Mass (not mass * speed_of_light^2)
Definition: mparticle.h:70
vfloat time
Definition: gparticle.h:47
vec dir
Unit vector, in the first system in the tree.
Definition: gparticle.h:25
vfloat prange
Range from previous point.
Definition: gparticle.h:46
vfloat speed
Longitudinal velocity.
Definition: gparticle.h:31
point pt
Coordinates in the first system in the tree.
Definition: gparticle.h:23
manip_absvol_treeid tid
Definition: gparticle.h:32
long pois(const double amu, int &ierror)
Definition: pois.cpp:9
void theta_two_part(const double Ep0, const double Ep1, const double Mp, const double Mt, double &theta_p, double &theta_t)
Scattering angles as function of incident and final projectile energy.
Definition: kinem.cpp:28
T t_hisran_step_ar(const M &mesh, const D &integ_y, T rannum)
Definition: tline.h:1403
DoubleAc fabs(const DoubleAc &f)
Definition: DoubleAc.h:615
particle_def electron_def("electron", "e-", electron_mass_c2/c_squared, electron_charge, 1, 0, 0.5, spin_def(0.0, 0.0))
Definition: particle_def.h:99
#define mcout
Definition: prstream.h:126
#define Iprint3n(file, name1, name2, name3)
Definition: prstream.h:233
#define mcerr
Definition: prstream.h:128
#define Iprintn(file, name)
Definition: prstream.h:205
#define Iprint2n(file, name1, name2)
Definition: prstream.h:220

◆ print()

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

Print-out.

Reimplemented from Heed::gparticle.

Definition at line 134 of file HeedParticle.cpp.

134 {
135 if (l < 0) return;
136 Ifile << "HeedParticle (l=" << l << "): particle_number=" << m_particle_number
137 << " type=";
138 print_notation(file);
139 file << std::endl;
140 if (l == 1) return;
141 mparticle::print(file, l - 1);
142 const double sum = std::accumulate(m_etransf.begin(), m_etransf.end(), 0.);
143 Iprintn(mcout, sum);
144 Iprintn(mcout, m_etransf.size());
145 if (l >= 5) {
146 Ifile << " nt natom nshell transferred energy\n";
147 const long qt = m_etransf.size();
148 for (long nt = 0; nt < qt; nt++) {
149 Ifile << std::setw(3) << nt << ' ' << std::setw(3) << m_natom[nt] << ' '
150 << std::setw(3) << m_nshell[nt] << ' '
151 << std::setw(12) << m_etransf[nt] << '\n';
152 }
153 }
154}
void print(std::ostream &file, int l) const override
Print-out.
Definition: mparticle.cpp:243
void print_notation(std::ostream &file) const
#define Ifile
Definition: prstream.h:196

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