14using CLHEP::electron_mass_c2;
15using CLHEP::fine_structure_const;
21 long fparticle_charge)
22 : particle_mass(fparticle_mass),
23 particle_charge(fparticle_charge),
26 s_primary_electron(fs_primary_electron),
35 const double beta =
lorbeta(fgamma_1);
36 const double beta2 = beta * beta;
37 const double beta12 = 1.0 - beta2;
38 const double gamma = fgamma_1 + 1.;
47 double rme = electron_mass_c2;
48 if (beta12 > 1.0e-10) {
50 2.0 * rm2 * electron_mass_c2 * beta2 /
51 ((rm2 + rme * rme + 2.0 * rme * gamma *
particle_mass) * beta12);
57 const long qe =
hmd->energy_mesh->get_q();
58 log1C.resize(qe, 0.0);
59 log2C.resize(qe, 0.0);
62 Rruth.resize(qe, 0.0);
63#ifdef DEBUG_EnTransfCS
64 truth.resize(qe, 0.0);
66 addaC.resize(qe, 0.0);
67#ifndef EXCLUDE_A_VALUES
68 addaC_a.resize(qe, 0.0);
71 const long qa =
hmd->matter->qatom();
78#ifndef EXCLUDE_A_VALUES
86#ifndef EXCLUDE_VAL_FADDA
88#ifndef EXCLUDE_A_VALUES
89 val_fadda_a.resize(qa);
93 for (
long na = 0; na < qa; na++) {
94 const long qs =
hmd->apacs[na]->get_qshell();
95 cher[na].resize(qs, std::vector<double>(qe, 0.));
96 fruth[na].resize(qs, std::vector<double>(qe, 0.));
97 adda[na].resize(qs, std::vector<double>(qe, 0.));
98 fadda[na].resize(qs, std::vector<double>(qe, 0.));
101#ifndef EXCLUDE_A_VALUES
102 cher_a[na].resize(qs, std::vector<double>(qe, 0.));
103 adda_a[na].resize(qs, std::vector<double>(qe, 0.));
104 fadda_a[na].resize(qs, std::vector<double>(qe, 0.));
105 quan_a[na].resize(qs);
106 mean_a[na].resize(qs);
108#ifndef EXCLUDE_VAL_FADDA
109 val_fadda[na].resize(qs);
110#ifndef EXCLUDE_A_VALUES
111 val_fadda_a[na].resize(qs);
116 for (
long ne = 0; ne < qe; ne++) {
117 double r = -
hmd->epsi1[ne] + (1.0 +
hmd->epsi1[ne]) * beta12;
118 r = r * r + beta2 * beta2 *
hmd->epsi2[ne] *
hmd->epsi2[ne];
121 for (
long ne = 0; ne < qe; ne++) {
122 double r = 2. * electron_mass_c2 * beta2 /
hmd->energy_mesh->get_ec(ne);
123 log2C[ne] = r > 0. ? log(r) : 0.;
126 double coefpa = fine_structure_const * q2 / (beta2 * CLHEP::pi);
127 for (
long ne = 0; ne < qe; ne++) {
128 const double r0 = 1.0 +
hmd->epsi1[ne];
129 double r = -
hmd->epsi1[ne] + r0 * beta12;
130 const double rr12 = r0 * r0;
131 const double rr22 =
hmd->epsi2[ne] *
hmd->epsi2[ne];
132 const double r1 = (-r0 * r + beta2 * rr22) / (rr12 + rr22);
133 const double r2 =
hmd->epsi2[ne] * beta2 / r;
134 double r3 = atan(r2);
135 if (r < 0) r3 += CLHEP::pi;
137 chereC[ne] = (coefpa /
hmd->eldens) * r1 * r3;
140 for (
long ne = 0; ne < qe; ne++) {
141 const double ec =
hmd->energy_mesh->get_ec(ne);
146 Rruth[ne] = 1. / (ec * ec);
155 const double pg2 = gamma * gamma;
156 const double dgd = delta * (
gamma_1 - delta);
159 (2.0 * pg2 + 2.0 * gamma - 1.0) / dgd + 1.0);
164 double Z_mean =
hmd->matter->Z_mean();
165 for (
long na = 0; na < qa; na++) {
167 const double awq =
hmd->matter->weight_quan(na);
168 const long qs = pacs->get_qshell();
169 for (
long ns = 0; ns < qs; ns++) {
170 std::vector<double>& acher =
cher[na][ns];
171#ifndef EXCLUDE_A_VALUES
172 std::vector<double>& acher_a = cher_a[na][ns];
174 std::vector<double>& afruth =
fruth[na][ns];
176 for (
long ne = 0; ne < qe; ne++) {
177 double e1 =
hmd->energy_mesh->get_e(ne);
178 double e2 =
hmd->energy_mesh->get_e(ne + 1);
180 if (
hmd->s_use_mixture_thresholds == 1) {
181 ics = pacs->get_integral_TICS(ns, e1, e2,
hmd->min_ioniz_pot) /
184 ics = pacs->get_integral_ICS(ns, e1, e2) / (e2 - e1) *
C1_MEV2_MBN;
186#ifndef EXCLUDE_A_VALUES
188 pac->get_integral_ACS(ns, e1, e2) / (e2 - e1) *
C1_MEV2_MBN;
191 "na=" << na <<
" ns=" << ns <<
" ne=" << ne <<
'\n',
193 if (
hmd->ACS[ne] > 0.0) {
195#ifndef EXCLUDE_A_VALUES
200#ifndef EXCLUDE_A_VALUES
207 for (
long ne = 0; ne < qe; ne++) {
208 const double e1 =
hmd->energy_mesh->get_e(ne);
209 const double ec =
hmd->energy_mesh->get_ec(ne);
210 const double e2 =
hmd->energy_mesh->get_e(ne + 1);
211 double r = pacs->get_integral_ACS(ns, e1, e2) *
C1_MEV2_MBN * awq;
213 check_econd11a(r, < 0.0,
"na=" << na <<
" ns=" << ns <<
" na=" << na,
216 afruth[ne] = (s + 0.5 * r) * coefpa *
Rruth[ne] / Z_mean;
218 "na=" << na <<
" ns=" << ns <<
" na=" << na,
mcerr);
223#ifdef DEBUG_EnTransfCS
224 truth[ne] += afruth[ne];
229 for (
long ne = 0; ne < qe; ++ne) {
231#ifndef EXCLUDE_A_VALUES
234 double e1 =
hmd->energy_mesh->get_e(ne);
235 double ec =
hmd->energy_mesh->get_ec(ne);
236 double e2 =
hmd->energy_mesh->get_e(ne + 1);
237 double sqepsi =
pow((1 +
hmd->epsi1[ne]), 2) +
pow(
hmd->epsi2[ne], 2);
238 for (
long na = 0; na < qa; na++) {
239 double awq =
hmd->matter->weight_quan(na);
241 const long qs = pacs->get_qshell();
242 for (
long ns = 0; ns < qs; ns++) {
244 if (
hmd->s_use_mixture_thresholds == 1) {
245 ics = pacs->get_integral_TICS(ns, e1, e2,
hmd->min_ioniz_pot) /
248 ics = pacs->get_integral_ICS(ns, e1, e2) / (e2 - e1) *
C1_MEV2_MBN;
250 double r1 = awq *
log1C[ne] * coefpa * ics / (ec * Z_mean * sqepsi);
251 double r2 = awq *
log2C[ne] * coefpa * ics / (ec * Z_mean * sqepsi);
252 double& r_adda =
adda[na][ns][ne];
253 double& r_fruth =
fruth[na][ns][ne];
254 r_adda = r1 + r2 + r_fruth;
255 if (r_adda < 0.0) r_adda = 0.0;
257#ifndef EXCLUDE_A_VALUES
259 pacs->get_integral_ACS(ns, e1, e2) / (e2 - e1) *
C1_MEV2_MBN;
260 double r1_a = awq *
log1C[ne] * coefpa * acs / (ec * Z_mean * sqepsi);
261 double r2_a = awq *
log2C[ne] * coefpa * acs / (ec * Z_mean * sqepsi);
262 double& r_adda_a = adda_a[na][ns][ne];
263 r_adda_a = r1_a + r2_a +
fruth;
264 if (r_adda_a < 0.0) r_adda_a = 0.0;
266 if (ec >
hmd->min_ioniz_pot) {
267 r_adda +=
cher[na][ns][ne];
270 mcout <<
"negative adda\n";
271 mcout <<
"na=" << na <<
" ns=" << ns <<
" ne=" << ne
272 <<
" adda[na][ns][ne] = " <<
adda[na][ns][ne] <<
'\n';
273 adda[na][ns][ne] = 0.0;
276#ifndef EXCLUDE_A_VALUES
277 adda_a[na][ns][ne] +=
cher[na][ns][ne];
279 "na=" << na <<
" ns=" << ns <<
" na=" << na,
mcerr);
282#ifndef EXCLUDE_A_VALUES
288#ifndef EXCLUDE_A_VALUES
293 const double* aetemp =
hmd->energy_mesh->get_ae();
295 double emin =
hmd->energy_mesh->get_emin();
296 double emax =
hmd->energy_mesh->get_emax();
298 quanC = t_integ_step_ar<double, std::vector<double>,
300 pcm_e,
addaC, emin, emax, 0) *
306 pcm_e, addaC_a, emin, emax, 0) *
310 meanC = t_integ_step_ar<double, std::vector<double>,
312 pcm_e,
addaC, emin, emax, 1) *
318 pcm_e, addaC_a, emin, emax, 1) *
322 const double coef = fine_structure_const * fine_structure_const * q2 * twopi /
323 (electron_mass_c2 * beta2) *
hmd->xeldens;
327 double e1 =
hmd->energy_mesh->get_e(qe);
333 double e1 =
hmd->energy_mesh->get_e(qe);
335 meanC1 += coef * log(e2 / e1);
341 double e1 =
hmd->energy_mesh->get_e(qe);
347#ifndef EXCLUDE_A_VALUES
350 double e1 =
hmd->energy_mesh->get_e(qe);
352 meanC1_a += coef * (log(e2 / e1) - beta2 /
max_etransf * (e2 - e1) +
353 (e2 * e2 - e1 * e1) /
363 for (
long na = 0; na < qa; na++) {
364 long qs =
hmd->apacs[na]->get_qshell();
365 for (
long ns = 0; ns < qs; ns++) {
366 quan[na][ns] = t_integ_step_ar<double, std::vector<double>,
368 pcm_e,
adda[na][ns], emin, emax, 0) *
373 pcm_e, adda_a[na][ns], emin, emax, 0) *
376 mean[na][ns] = t_integ_step_ar<double, std::vector<double>,
378 pcm_e,
adda[na][ns], emin, emax, 1) *
383 pcm_e, adda_a[na][ns], emin, emax, 1) *
389 for (
long na = 0; na < qa; na++) {
390 long qs =
hmd->apacs[na]->get_qshell();
391 for (
long ns = 0; ns < qs; ns++) {
392 if (
quan[na][ns] > 0.0)
393#ifndef EXCLUDE_VAL_FADDA
396 t_hispre_step_ar<double, std::vector<double>,
400#ifndef EXCLUDE_A_VALUES
401 if (quan_a[na][ns] > 0.0)
402#ifndef EXCLUDE_VAL_FADDA
403 val_fadda_a[na][ns] =
405 t_hispre_step_ar<double, std::vector<double>,
407 pcm_e, adda_a[na][ns], fadda_a[na][ns]);
413 for (
long ne = 0; ne < qe; ne++) {
414 const double k0 =
hmd->energy_mesh->get_ec(ne) / (hbarc / cm);
415 const double det_value = 1.0 / (gamma * gamma) -
hmd->epsi1[ne] * beta2;
416 length_y0[ne] = det_value > 0. ? beta / k0 * 1.0 /
sqrt(det_value) : 0.;
424#ifdef DEBUG_EnTransfCS
427 std::ofstream dcsfile;
428 dcsfile.open(
"dcs.txt", std::ios::out);
429 dcsfile <<
"# energy [MeV] vs. diff. cs per electron [Mbarn / MeV]\n";
430 for (
int i = 0; i < qe; ++i) {
437#ifndef EXCLUDE_A_VALUES
441#ifndef EXCLUDE_A_VALUES
446#ifndef EXCLUDE_A_VALUES
449#ifndef EXCLUDE_A_VALUES
452#ifndef EXCLUDE_VAL_FADDA
454#ifndef EXCLUDE_A_VALUES
459#ifndef EXCLUDE_A_VALUES
466 Ifile <<
"EnTransfCS(l=" << l <<
"):\n";
475#ifndef EXCLUDE_A_VALUES
476 Ifile <<
"quanC=" <<
quanC <<
" quanC_a=" << quanC_a <<
'\n';
477 Ifile <<
"meanC=" <<
meanC <<
" meanC_a=" << meanC_a <<
'\n';
479 Ifile <<
"meanC1=" <<
meanC1 <<
" meanC1_a=" << meanC1_a <<
'\n';
488 long qe =
hmd->energy_mesh->get_q();
491#ifdef DEBUG_EnTransfCS
492 Ifile <<
" enerc, log1C, log2C, chereC, addaC, "
493 "chereCangle Rruth truth length_y0\n";
495 Ifile <<
" enerc, log1C, log2C, chereC, addaC, "
496 "chereCangle Rruth length_y0\n";
498 for (ne = 0; ne < qe; ne++) {
499 Ifile << std::setw(12) <<
hmd->energy_mesh->get_ec(ne) << std::setw(12)
500 <<
log1C[ne] << std::setw(12) <<
log2C[ne] << std::setw(12)
501 <<
chereC[ne] << std::setw(12) <<
addaC[ne] << std::setw(12)
503#ifdef DEBUG_EnTransfCS
504 << std::setw(12) << truth[ne]
506 << std::setw(12) <<
length_y0[ne] <<
'\n';
510 long qa =
hmd->matter->qatom();
513 for (na = 0; na < qa; na++) {
515 long qs =
hmd->apacs[na]->get_qshell();
518 for (ns = 0; ns < qs; ns++) {
520 Ifile <<
"quan =" << std::setw(13) <<
quan[na][ns]
521 <<
" mean =" << std::setw(13) <<
mean[na][ns] <<
'\n';
522#ifndef EXCLUDE_A_VALUES
523 Ifile <<
"quan_a =" << std::setw(13) << quan_a[na][ns]
524 <<
" mean_a=" << std::setw(13) << mean_a[na][ns] <<
'\n';
526#ifndef EXCLUDE_VAL_FADDA
527 Ifile <<
"val_fadda=" << std::setw(13) << val_fadda[na][ns]
528#ifndef EXCLUDE_A_VALUES
529 <<
" val_fadda_a=" << std::setw(13) << val_fadda_a[na][ns]
534 Ifile <<
" enerc, cher, cher_a, fruth, adda, "
535 " adda_a, fadda, fadda_a\n";
536 for (ne = 0; ne < qe; ne++) {
537 Ifile << std::setw(12)
538 <<
hmd->energy_mesh->get_ec(ne)
541 << std::setw(12) <<
cher[na][ns][ne]
542#ifndef EXCLUDE_A_VALUES
543 << std::setw(12) << cher_a[na][ns][ne]
546 << std::setw(12) <<
fruth[na][ns][ne] << std::setw(12)
548#ifndef EXCLUDE_A_VALUES
549 << std::setw(12) << adda_a[na][ns][ne]
551 << std::setw(12) <<
fadda[na][ns][ne]
552#ifndef EXCLUDE_A_VALUES
553 << std::setw(12) << fadda_a[na][ns][ne]
#define check_econd11a(a, signb, add, stream)
#define mfunnamep(string)
std::vector< std::vector< double > > quan
long particle_charge
Charge in units of electron charge (used square, sign does not matter).
std::vector< double > Rruth
term called R in my paper
std::vector< double > log2C
common second log without cs
double gamma_1
Lorentz factor - 1 (the best dimensionless measurement of speed).
std::vector< double > chereCangle
angle of Cherenkov's radiation
double particle_ener
Total energy [MeV].
std::vector< std::vector< double > > mean
std::vector< std::vector< std::vector< double > > > fadda
Integral, normalised to unity.
std::vector< double > log1C
common first log without cs
double particle_mass
Particle mass [MeV].
std::vector< std::vector< std::vector< double > > > fruth
Rutherford term.
int s_primary_electron
Flag that the primary particle is the electron.
PassivePtr< HeedMatterDef > hmd
std::vector< std::vector< std::vector< double > > > adda
Sum.
std::vector< double > chereC
Cherenkov's radiation.
std::vector< double > length_y0
std::vector< double > addaC
Sum of (ionization) differential cross-section terms.
std::vector< std::vector< std::vector< double > > > cher
double quanC
Integrated (ionization) cross-section.
virtual void print(std::ostream &file, int l) const
double max_etransf
Max. energy transfer [MeV].
EnTransfCS()
Default constructor.
double lorbeta(const double gamma_1)
as function of .
DoubleAc pow(const DoubleAc &f, double p)
T t_integ_step_ar(const M &mesh, const D &y, T x1, T x2, int xpower)
DoubleAc sqrt(const DoubleAc &f)
#define Iprintn(file, name)