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::HeedPhoton Class Reference

#include <HeedPhoton.h>

+ Inheritance diagram for Heed::HeedPhoton:

Public Member Functions

 HeedPhoton ()=default
 Default constructor.
 
 HeedPhoton (manip_absvol *primvol, const point &pt, const vec &vel, vfloat time, long fparent_particle_number, double fenergy, HeedFieldMap *fieldmap, const bool fs_print_listing=false)
 Constructor.
 
virtual ~HeedPhoton ()
 Destructor.
 
void print (std::ostream &file, int l) const override
 Print-out.
 
HeedPhotoncopy () 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 Attributes

long m_particle_number
 
long m_parent_particle_number
 
double m_energy
 Photon energy [MeV].
 
bool m_photon_absorbed = false
 
long m_na_absorbing
 Index of absorbing atom.
 
long m_ns_absorbing
 Index of absorbing shell.
 
bool m_delta_generated = false
 Flag that delta-electrons are already generated (or cannot be created).
 

Protected Member Functions

void physics_after_new_speed (std::vector< gparticle * > &secondaries) override
 Apply any other processes (turn the trajectory, kill the particle, ...).
 
void physics (std::vector< gparticle * > &secondaries) override
 Apply any other processes (turn the trajectory, kill the particle, ...).
 
- 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

- 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

Definition of the photon which can be emitted at atomic relaxation cascades and traced through the geometry. 2003, I. Smirnov

Definition at line 18 of file HeedPhoton.h.

Constructor & Destructor Documentation

◆ HeedPhoton() [1/2]

Heed::HeedPhoton::HeedPhoton ( )
default

Default constructor.

Referenced by copy(), and physics_after_new_speed().

◆ HeedPhoton() [2/2]

Heed::HeedPhoton::HeedPhoton ( manip_absvol primvol,
const point pt,
const vec vel,
vfloat  time,
long  fparent_particle_number,
double  fenergy,
HeedFieldMap fieldmap,
const bool  fs_print_listing = false 
)

Constructor.

Definition at line 23 of file HeedPhoton.cpp.

27 : gparticle(primvol, pt, vel, ftime),
29 m_parent_particle_number(fparent_particle_number),
30 m_energy(fenergy),
31#ifdef SFER_PHOTOEL
32 s_sfer_photoel(0),
33#endif
34 m_print_listing(fs_print_listing),
35 m_fieldMap(fieldmap) {
36 mfunname("HeedPhoton::HeedPhoton(...)");
37 double length_vel = vel.length();
38 check_econd11(fabs(length_vel - c_light) / (length_vel + c_light), > 1.0e-10,
39 mcerr);
40}
#define check_econd11(a, signb, stream)
Definition: FunNameStack.h:155
#define mfunname(string)
Definition: FunNameStack.h:45
long m_parent_particle_number
Definition: HeedPhoton.h:33
long m_particle_number
Definition: HeedPhoton.h:32
double m_energy
Photon energy [MeV].
Definition: HeedPhoton.h:36
gparticle()=default
Default constructor.
long last_particle_number
Definition: HeedParticle.h:9
DoubleAc fabs(const DoubleAc &f)
Definition: DoubleAc.h:615
#define mcerr
Definition: prstream.h:128

◆ ~HeedPhoton()

virtual Heed::HeedPhoton::~HeedPhoton ( )
inlinevirtual

Destructor.

Definition at line 27 of file HeedPhoton.h.

27{}

Member Function Documentation

◆ copy()

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

Clone the particle.

Reimplemented from Heed::gparticle.

Definition at line 30 of file HeedPhoton.h.

30{ return new HeedPhoton(*this); }
HeedPhoton()=default
Default constructor.

◆ physics()

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

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

Reimplemented from Heed::gparticle.

Definition at line 42 of file HeedPhoton.cpp.

42 {
43 mfunname("void HeedPhoton::physics()");
44 if (m_print_listing) mcout << "HeedPhoton::physics() starts\n";
45 // Stop here if the photon has already been absorbed.
46 if (m_photon_absorbed) return;
47 if (m_nextpos.prange <= 0.0) return;
48 // Get least address of volume
49 const absvol* av = m_currpos.tid.G_lavol();
50 HeedMatterDef* hmd = nullptr;
51 auto etcs = dynamic_cast<const EnTransfCS*>(av);
52 if (etcs) {
53 hmd = etcs->hmd;
54 } else {
55 auto hdecs = dynamic_cast<const HeedDeltaElectronCS*>(av);
56 if (hdecs) hmd = hdecs->hmd;
57 }
58 // Stop here if we couldn't retrieve the material definition.
59 if (!hmd) return;
60 // Sum up the cross-sections.
61 std::vector<double> cs;
62 std::vector<long> nat;
63 std::vector<long> nsh;
64 double s = 0.0;
65 const long qa = hmd->matter->qatom();
66 for (long na = 0; na < qa; na++) {
67 const long qs = hmd->apacs[na]->get_qshell();
68 const double awq = hmd->matter->weight_quan(na);
69 for (long ns = 0; ns < qs; ns++) {
70 cs.push_back(hmd->apacs[na]->get_ICS(ns, m_energy) * awq);
71 // threshold is taken into account in apacs[na]->get_ACS(ns,..)
72 nat.push_back(na);
73 nsh.push_back(ns);
74 s += cs.back();
75 }
76 }
77 if (m_print_listing) Iprintn(mcout, s);
78 // Multiply with the density and calculate the path length.
79 // s = s * hmd->eldens / hmd->matter->Z_mean() * C1_MEV_CM;
80 s = s * 1.0e-18 * Avogadro / (hmd->matter->A_mean() / (gram / mole)) *
81 hmd->matter->density() / (gram / cm3);
82 if (m_print_listing) Iprintn(mcout, s);
83 const double path_length = 1.0 / s; // cm
84 if (m_print_listing) Iprint2n(mcout, m_energy, path_length);
85 // Draw a random step length.
86 const double xleng = -path_length * log(1.0 - SRANLUX());
87 if (m_print_listing) Iprint2n(mcout, xleng, m_nextpos.prange / cm);
88 if (xleng * cm < m_nextpos.prange) {
89 m_photon_absorbed = true;
90#ifdef SFER_PHOTOEL
91 // Assume that virtual photons are already
92 // absorbed and s_sfer_photoel is 0 for them
93 s_sfer_photoel = 1;
94#endif
95 // Sample the shell.
96 chispre(cs);
97 const double r = chisran(SRANLUX(), cs);
98 const long n = std::min(std::max(long(r), 0L), long(cs.size() - 1));
99 if (m_print_listing) Iprintn(mcout, n);
100 m_na_absorbing = nat[n];
101 m_ns_absorbing = nsh[n];
102 m_nextpos.prange = xleng * cm;
106 }
107}
long m_na_absorbing
Index of absorbing atom.
Definition: HeedPhoton.h:42
long m_ns_absorbing
Index of absorbing shell.
Definition: HeedPhoton.h:44
bool m_photon_absorbed
Definition: HeedPhoton.h:40
stvpoint m_nextpos
Next point.
Definition: gparticle.h:252
stvpoint m_currpos
Current point.
Definition: gparticle.h:250
void up_absref(absref *f)
Definition: volume.cpp:26
absvol * G_lavol() const
Get last address of volume.
Definition: volume.cpp:17
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
point pt
Coordinates in the first system in the tree.
Definition: gparticle.h:23
manip_absvol_treeid tid
Definition: gparticle.h:32
point ptloc
Coordinates in the local system (last system in the tree).
Definition: gparticle.h:27
float chispre(float *x, float *p, float *f, long q)
Definition: chisran.cpp:8
float chisran(float flat_random_number, float *x, float *f, long q)
Definition: chisran.cpp:22
#define mcout
Definition: prstream.h:126
#define Iprintn(file, name)
Definition: prstream.h:205
#define Iprint2n(file, name1, name2)
Definition: prstream.h:220

◆ physics_after_new_speed()

void Heed::HeedPhoton::physics_after_new_speed ( std::vector< gparticle * > &  )
overrideprotectedvirtual

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

Reimplemented from Heed::gparticle.

Definition at line 109 of file HeedPhoton.cpp.

109 {
110 mfunname("void HeedPhoton::physics_after_new_speed()");
111 if (m_print_listing) mcout << "HeedPhoton::physics_after_new_speed starts\n";
112 // Stop if the photon has not been absorbed.
113 if (!m_photon_absorbed) return;
114 // Stop if the delta electrons have already been generated.
115 if (m_delta_generated) return;
116 // Get least address of volume
117 const absvol* av = m_currpos.tid.G_lavol();
118 HeedMatterDef* hmd = nullptr;
119 auto etcs = dynamic_cast<const EnTransfCS*>(av);
120 if (etcs) {
121 hmd = etcs->hmd;
122 } else {
123 auto hdecs = dynamic_cast<const HeedDeltaElectronCS*>(av);
124 if (hdecs) hmd = hdecs->hmd;
125 }
126 // Stop here if we couldn't retrieve the material definition.
127 if (!hmd) return;
128 // Generate delta-electrons.
129 std::vector<double> el_energy;
130 std::vector<double> ph_energy;
131 hmd->apacs[m_na_absorbing]
132 ->get_escape_particles(m_ns_absorbing, m_energy, el_energy, ph_energy);
133 if (m_print_listing) {
134 mcout << "The condition:\n";
136 mcout << "The decay products:\n";
137 for (unsigned int k = 0; k < el_energy.size(); ++k)
138 mcout << el_energy[k] << "\n";
139 for (unsigned int k = 0; k < ph_energy.size(); ++k)
140 mcout << ph_energy[k] << "\n";
141 }
142 const long qel = el_energy.size();
143 for (long nel = 0; nel < qel; nel++) {
144 vec vel = m_currpos.dir;
145 if (nel == 0) {
146 // The first in the list should be the photoelectron.
147#ifdef SFER_PHOTOEL
148 if (s_sfer_photoel == 1) {
149 vel.random_sfer_vec();
150 } else {
151 vel = m_currpos.dir;
152 }
153#else
154 vel = m_currpos.dir; // direction is OK
155#endif
156 } else {
157 vel.random_sfer_vec();
158 }
159 const double gam_1 = el_energy[nel] / electron_mass_c2;
160 const double inv = 1.0 / (gam_1 + 1.0);
161 const double beta = sqrt(1.0 - inv * inv);
162 const double mod_v = beta * c_light;
163 vel = vel * mod_v;
164 if (m_print_listing) {
165 mcout << "Initializing delta electron\n";
166 Iprint4n(mcout, el_energy[nel], gam_1, beta, mod_v);
167 }
168 HeedDeltaElectron* hd =
169 new HeedDeltaElectron(m_currpos.tid.eid[0], m_currpos.pt, vel,
170 m_currpos.time, m_particle_number, m_fieldMap);
171 secondaries.push_back(hd);
172 }
173 const long qph = ph_energy.size();
174 for (long nph = 0; nph < qph; nph++) {
175 vec vel;
176 vel.random_sfer_vec();
177 vel *= c_light;
178 if (m_print_listing) {
179 mcout << "Initializing photon\n";
180 Iprint2n(mcout, el_energy[nph], vel);
181 }
184 ph_energy[nph], m_fieldMap);
185 secondaries.push_back(hp);
186 }
187 m_delta_generated = true;
188 m_alive = false;
189 if (m_print_listing) mcout << "HeedPhoton::physics_after_new_speed exited\n";
190}
bool m_delta_generated
Flag that delta-electrons are already generated (or cannot be created).
Definition: HeedPhoton.h:51
bool m_alive
Status flag whether the particle is active.
Definition: gparticle.h:233
std::vector< manip_absvol * > eid
List of volumes.
Definition: volume.h:37
vfloat time
Definition: gparticle.h:47
void random_sfer_vec()
Definition: vec.cpp:244
DoubleAc sqrt(const DoubleAc &f)
Definition: DoubleAc.cpp:314
#define Iprint4n(file, name1, name2, name3, name4)
Definition: prstream.h:244

◆ print()

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

Print-out.

Reimplemented from Heed::gparticle.

Definition at line 192 of file HeedPhoton.cpp.

192 {
193 if (l < 0) return;
194 Ifile << "HeedPhoton (l=" << l << "): particle_number=" << m_particle_number
195 << " energy=" << m_energy << "MeV\n";
196 if (l == 1) return;
197 indn.n += 2;
198 Ifile << "s_photon_absorbed=" << m_photon_absorbed
199 << " na_absorbing=" << m_na_absorbing
200 << " ns_absorbing=" << m_ns_absorbing
201 << " s_delta_generated=" << m_delta_generated
202#ifdef SFER_PHOTOEL
203 << " s_sfer_photoel=" << s_sfer_photoel
204#endif
205 << " parent_particle_number=" << m_parent_particle_number
206 << " s_print_listing=" << m_print_listing << '\n';
207 gparticle::print(file, l - 1);
208 indn.n -= 2;
209}
virtual void print(std::ostream &file, int l) const
Print-out.
Definition: gparticle.cpp:193
indentation indn
Definition: prstream.cpp:15
#define Ifile
Definition: prstream.h:196

Member Data Documentation

◆ m_delta_generated

bool Heed::HeedPhoton::m_delta_generated = false

Flag that delta-electrons are already generated (or cannot be created).

Definition at line 51 of file HeedPhoton.h.

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

◆ m_energy

double Heed::HeedPhoton::m_energy

Photon energy [MeV].

Definition at line 36 of file HeedPhoton.h.

Referenced by Garfield::TrackHeed::GetCluster(), physics(), physics_after_new_speed(), and print().

◆ m_na_absorbing

long Heed::HeedPhoton::m_na_absorbing

Index of absorbing atom.

Definition at line 42 of file HeedPhoton.h.

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

◆ m_ns_absorbing

long Heed::HeedPhoton::m_ns_absorbing

Index of absorbing shell.

Definition at line 44 of file HeedPhoton.h.

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

◆ m_parent_particle_number

long Heed::HeedPhoton::m_parent_particle_number

Definition at line 33 of file HeedPhoton.h.

Referenced by print().

◆ m_particle_number

long Heed::HeedPhoton::m_particle_number

Definition at line 32 of file HeedPhoton.h.

Referenced by physics_after_new_speed(), and print().

◆ m_photon_absorbed

bool Heed::HeedPhoton::m_photon_absorbed = false

Flag whether the photon has been absorbed. Used in physics_after_new_speed.

Definition at line 40 of file HeedPhoton.h.

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


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