Garfield++ v2r0
A toolkit for the detailed simulation of particle detectors based on ionisation measurement in gases and semiconductors
Loading...
Searching...
No Matches
PairProd.cpp
Go to the documentation of this file.
1#include <fstream>
2#include <cmath>
3#include <cfloat>
4#include <climits>
7
8// 2003, I. Smirnov
9
10//#define USE_GET_ELOSS_CUT
11
12namespace Heed {
13
14PairProd::PairProd(const std::string& file_name, double fwa, double ffactorFano)
15 : wa(fwa), factorFano(ffactorFano) {
17 "PairProd::PairProd(const std::string& file_name, double fwa, double "
18 "ffactorFano)");
19
20 std::ifstream file(file_name.c_str());
21 if (!file) {
22 funnw.ehdr(mcerr);
23 mcerr << "cannot open file " << file_name << std::endl;
25 }
26 long q;
27 file >> wa_table >> I_table >> J_table >> factorFano_table >> q;
28 if (!file.good()) {
29 funnw.ehdr(mcerr);
30 mcerr << "error at reading file" << std::endl;
32 }
33 std::vector<double> xx(q);
34 std::vector<double> yy(q);
35 for (long n = 0; n < q; n++) file >> xx[n] >> yy[n];
36 pran = PointsRan(xx, yy, I_table, J_table);
37 k = sqrt(factorFano * wa * wa / (factorFano_table * wa_table * wa_table));
38 s = wa - k * wa_table;
39 // s = wa - wa / factorFano * ( 2.0 * factorFano - factorFano_table);
40 // k = wa / (factorFano * wa_table) * ( 2.0 * factorFano - factorFano_table);
41}
42
43double PairProd::get_eloss() const {
44 mfunname("double PairProd::get_eloss() const");
45 return k * pran.ran(SRANLUX()) + s;
46}
47
48#ifdef USE_GET_ELOSS_CUT
49
50double PairProd::get_eloss(const double e_cur) const {
51 mfunname("double PairProd::get_eloss(const double ecur) const");
52 const double e_loss = k * pran.ran(SRANLUX()) + s;
53 const double w_cut_ratio = 0.2;
54 return e_cur - e_loss < w_cut_ratio * wa ? 1.0e20 : eloss;
55}
56
57#else
58
59double PairProd::get_eloss(const double e_cur) const {
60 mfunname("double PairProd::get_eloss(const double ecur) const");
61 const double e_loss = k * pran.ran(SRANLUX()) + s;
62 const double V_ratio = 0.5;
63 const double v = V_ratio * wa / e_cur;
64 // const double c = 1. / (1. - v);
65 const double c = v < 1. ? 1. / (1. - v * v) : DBL_MAX;
66 return e_loss * c;
67}
68
69#endif
70
71void PairProd::print(std::ostream& file, int l) const {
72 if (l <= 0) return;
73 Ifile << "PairProd:\n";
74 indn.n += 2;
75 Ifile << "wa=" << wa << " factorFano=" << factorFano << '\n';
76 Ifile << "wa_table=" << wa_table << " factorFano_table=" << factorFano_table
77 << '\n';
78 Ifile << " I_table=" << I_table << " J_table=" << J_table << " k=" << k
79 << " s=" << s << '\n';
80 pran.print(file);
81 indn.n -= 2;
82}
83}
#define mfunnamep(string)
Definition: FunNameStack.h:49
#define spexit(stream)
Definition: FunNameStack.h:256
#define mfunname(string)
Definition: FunNameStack.h:45
virtual void print(std::ostream &file, int l) const
Definition: PairProd.cpp:71
double get_eloss() const
Calculate energy loss (in eV).
Definition: PairProd.cpp:43
void print(std::ostream &file) const
Definition: PointsRan.cpp:120
double ran(double flat_ran) const
Definition: PointsRan.cpp:91
Definition: BGMesh.cpp:5
indentation indn
Definition: prstream.cpp:15
DoubleAc sqrt(const DoubleAc &f)
Definition: DoubleAc.cpp:314
#define Ifile
Definition: prstream.h:196
#define mcerr
Definition: prstream.h:128