Garfield++ v1r0
A toolkit for the detailed simulation of particle detectors based on ionisation measurement in gases and semiconductors
Loading...
Searching...
No Matches
HeedParticle.cpp
Go to the documentation of this file.
1#include <iomanip>
13/*
142003-2008, I. Smirnov
15*/
16
17namespace Heed {
18
20 const vec& vel, vfloat time, particle_def* fpardef,
21 int fs_loss_only, int fs_print_listing)
22 : eparticle(primvol, pt, vel, time, fpardef),
23 s_print_listing(fs_print_listing),
24 transferred_energy_in_step(0.0),
25 qtransfer(0),
26 s_loss_only(fs_loss_only) {
27
28 mfunname("HeedParticle::HeedParticle(...)");
34
35}
36
38 mfunname("void HeedParticle::physics(void)");
39 if (s_print_listing == 1) {
40 mcout << "HeedParticle::physics is started\n";
42 }
44 qtransfer = 0;
48 if (currpos.prange <= 0.0) return;
49 // Get least address of volume
50 const absvol* av = currpos.G_lavol();
51 const EnTransfCSType* etcst = dynamic_cast<const EnTransfCSType*>(av);
52 // Check if dynamic cast was successful.
53 if (etcst == NULL) return;
54
55 EnTransfCS* aetcs = etcst->etcs.getver();
56 HeedMatterDef* ahmd = aetcs->hmd.getver();
57 MatterDef* amatter = ahmd->matter.getver();
58 EnergyMesh* a_energy_mesh = ahmd->energy_mesh.getver();
59 const double* aetemp = ahmd->energy_mesh->get_ae();
60 PointCoorMesh<double, const double*> pcm_e(a_energy_mesh->get_q() + 1,
61 &(aetemp));
62 long qa = amatter->qatom();
63 if (s_print_listing == 1) Iprintn(mcout, qa);
64 basis tempbas(currpos.dir, "tempbas");
65 for (long na = 0; na < qa; ++na) {
66 if (s_print_listing == 1) Iprintn(mcout, na);
67 long qs = ahmd->apacs[na]->get_qshell();
68 for (long ns = 0; ns < qs; ++ns) {
69 if (s_print_listing == 1) Iprintn(mcout, ns);
70 long qt = 0;
71#ifdef SINGLE_TRANSFER
72 if (aetcs == aetcs_single_transf && na == na_single_transf &&
73 ns == ns_single_transf) {
74 qt = 1;
75 }
76#else
77 if (aetcs->quan[na][ns] > 0.0) {
78 int ierror;
79 qt = pois(aetcs->quan[na][ns] * currpos.prange / cm, ierror);
81 ierror, == 1,
82 " aetcs->quan[na][ns]=" << aetcs->quan[na][ns]
83 << " currpos.prange/cm=" << currpos.prange /
84 cm << '\n',
85 mcerr);
86 }
87#endif
88 if (s_print_listing == 1) Iprintn(mcout, qt);
89 if (qt > 0) {
90 point curpt = prevpos.pt;
91 vec dir = unit_vec(currpos.pt - prevpos.pt);
92 double range = length(currpos.pt - prevpos.pt);
93 if (s_print_listing == 1) {
94 Iprint(mcout, curpt);
95 Iprint(mcout, dir);
96 Iprintn(mcout, range);
97 }
98 for (long nt = 0; nt < qt; ++nt) {
99#ifdef SINGLE_TRANSFER
100 transferred_energy.append(ener_single_transf);
101#else
102 double rn = SRANLUX();
103 if (s_print_listing == 1) {
104 Iprintn(mcout, rn);
105 Iprintn(mcout, aetcs);
106 Iprintn(mcout, aetcs->fadda[na][ns][1]);
107 }
108 double r = t_hisran_step_ar<double, DynLinArr<double>,
110 pcm_e, aetcs->fadda[na][ns], rn);
111
112 // Convert to internal units.
113 transferred_energy.append(r * MeV);
114#endif
115 if (s_print_listing == 1) {
117 }
119 natom.append(na);
120 nshell.append(ns);
121#ifdef SINGLE_TRANSFER
122 double arange = 0.5 * range;
123#else
124 double arange = SRANLUX() * range;
125#endif
126 point pt = curpt + dir * arange;
127 point ptloc = pt;
128 prevpos.tid.up_absref(&ptloc);
129 qtransfer++;
130 if (s_loss_only == 0) {
131 if (s_print_listing == 1) {
132 mcout << "generating new cluster\n";
133 }
135 0, pt, ptloc, prevpos.tid, na, ns));
136
137 double Ep0 = mass * c_squared + curr_kin_energy;
138 double Ep1 = Ep0 - transferred_energy[qtransfer - 1];
139 double Mp = mass;
140 double Mt = electron_def.mass;
141 double theta_p, theta_t;
142 theta_two_part(Ep0, Ep1, Mp, Mt, theta_p, theta_t);
143 vec vel;
144 vel.random_conic_vec(fabs(theta_t));
145 vel.down(&tempbas); // direction is OK
146 vel *= c_light;
147 // HS
148 double speed = length(vel);
149 double time = arange / speed;
150 if (s_print_listing == 1) {
151 mcout << "generating new virtual photon\n";
152 }
153 HeedPhoton hp(currpos.tid.eid[0].amvol.getver(), pt, vel, time,
155 0);
156 hp.s_photon_absorbed = 1;
157 hp.s_delta_generated = 0;
158 hp.na_absorbing = na;
159 hp.ns_absorbing = ns;
160 ActivePtr<gparticle> ac;
161 ac.put(&hp);
162 particle_bank.insert_after(particle_bank.get_last_node(), ac);
163 }
164 }
165 }
166 }
167 }
168 if (s_print_listing == 1) {
170 mcout << "Exiting HeedParticle::physics\n";
171 }
172}
173
174void HeedParticle::print(std::ostream& file, int l) const {
175 if (l >= 0) {
176 Ifile << "HeedParticle (l=" << l << "): particle_number=" << particle_number
177 << " type=";
178 print_notation(file);
179 file << std::endl;
180 if (l == 1) return;
181 mparticle::print(file, l - 1);
184 if (l >= 5) {
185 Ifile << " nt natom nshell transferred_energy\n";
186 for (long nt = 0; nt < qtransfer; nt++) {
187 Ifile << std::setw(3) << nt << ' ' << std::setw(3) << natom[nt] << ' '
188 << std::setw(3) << nshell[nt] << ' ' << std::setw(12)
189 << transferred_energy[nt] << '\n';
190 }
191 }
192 }
193
194}
195
196}
DoubleAc fabs(const DoubleAc &f)
Definition: DoubleAc.h:616
#define check_econd11a(a, signb, add, stream)
Definition: FunNameStack.h:395
#define mfunname(string)
Definition: FunNameStack.h:67
void allocate_block(long fqel)
Definition: BlkArr.h:231
void append(const T &val)
Definition: BlkArr.h:205
long qatom(void) const
Definition: AtomDef.h:142
PassivePtr< EnTransfCS > etcs
Definition: EnTransfCS.h:151
DynLinArr< DynLinArr< double > > quan
Definition: EnTransfCS.h:134
PassivePtr< HeedMatterDef > hmd
Definition: EnTransfCS.h:62
DynLinArr< DynLinArr< DynLinArr< double > > > fadda
Integral, normalised to unity.
Definition: EnTransfCS.h:117
long get_q() const
Definition: EnergyMesh.h:51
PassivePtr< MatterDef > matter
Definition: HeedMatterDef.h:39
PassivePtr< EnergyMesh > energy_mesh
Definition: HeedMatterDef.h:50
DynLinArr< PassivePtr< const AtomPhotoAbsCS > > apacs
Definition: HeedMatterDef.h:40
HeedParticle(void)
Constructors.
Definition: HeedParticle.h:33
BlkArr< long > natom
Definition: HeedParticle.h:54
double transferred_energy_in_step
Definition: HeedParticle.h:50
virtual void physics(void)
BlkArr< long > nshell
Definition: HeedParticle.h:55
BlkArr< double > transferred_energy
Definition: HeedParticle.h:53
virtual void print(std::ostream &file, int l) const
double curr_kin_energy
Definition: mparticle.h:31
double mass
Mass (not mass * speed_of_light^2)
Definition: mparticle.h:25
virtual void print(std::ostream &file, int l) const
Definition: mparticle.cpp:308
void print_notation(std::ostream &file) const
Definition: volume.h:91
Definition: vec.h:397
stvpoint currpos
Definition: gparticle.h:188
stvpoint prevpos
Definition: gparticle.h:187
PassivePtr< manip_absvol > amvol
Definition: volume.h:39
manip_absvol_eid eid[pqamvol]
Definition: volume.h:52
void up_absref(absref *f)
Definition: volume.cpp:37
Definition: vec.h:477
point pt
Definition: gparticle.h:33
absvol * G_lavol() const
Definition: gparticle.h:63
vfloat prange
Definition: gparticle.h:54
manip_absvol_treeid tid
Definition: gparticle.h:43
vec dir
Definition: gparticle.h:35
Definition: vec.h:248
void random_conic_vec(double theta)
Definition: vec.cpp:322
void down(const basis *fabas)
Definition: vec.cpp:247
Definition: BGMesh.cpp:3
BlkArr< HeedCluster > cluster_bank
Definition: TrackHeed.cc:41
long last_particle_number
Definition: HeedParticle.h:26
AbsList< ActivePtr< gparticle > > particle_bank
Definition: TrackHeed.cc:42
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:122
void theta_two_part(double Ep0, double Ep1, double Mp, double Mt, double &theta_p, double &theta_t)
Definition: kinem.cpp:31
long pois(double AMU, int &IERROR)
Definition: pois.cpp:17
#define mcout
Definition: prstream.h:133
#define Ifile
Definition: prstream.h:207
#define Iprint(file, name)
Definition: prstream.h:209
#define mcerr
Definition: prstream.h:135
#define Iprintn(file, name)
Definition: prstream.h:216
#define Iprint2n(file, name1, name2)
Definition: prstream.h:236
ffloat SRANLUX(void)
Definition: ranluxint.h:262
double vfloat
Definition: vfloat.h:15