Garfield++ 4.0
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>
5
9
10// 2003, I. Smirnov
11
12//#define USE_GET_ELOSS_CUT
13
14namespace Heed {
15
16PairProd::PairProd(const std::string& file_name, double fw, double ffano)
17 : m_w(fw), m_f(ffano) {
18 mfunnamep("PairProd::PairProd(const std::string&, double, double)");
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 >> m_wtable >> m_i >> m_j >> m_ftable >> 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, m_i, m_j);
37 m_k = sqrt(m_f * m_w * m_w / (m_ftable * m_wtable * m_wtable));
38 m_s = m_w - m_k * m_wtable;
39 // m_s = m_w - m_w / m_f * (2. * m_f - m_ftable);
40 // m_k = m_w / (m_f * m_wtable) * (2. * m_f - m_ftable);
41}
42
43double PairProd::get_eloss() const {
44 mfunname("double PairProd::get_eloss() const");
45 return m_k * pran.ran(SRANLUX()) + m_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 = m_k * pran.ran(SRANLUX()) + m_s;
53 constexpr double w_cut_ratio = 0.2;
54 return e_cur - e_loss < w_cut_ratio * m_w ? 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 = m_k * pran.ran(SRANLUX()) + m_s;
62 constexpr double V_ratio = 0.5;
63 const double v = V_ratio * m_w / 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 << "W=" << m_w << " Fano factor=" << m_f << '\n';
76 Ifile << "W table=" << m_wtable << " Fano factor table=" << m_ftable << '\n';
77 Ifile << "I=" << m_i << " J=" << m_j << " k=" << m_k << " s=" << m_s << '\n';
78 pran.print(file);
79 indn.n -= 2;
80}
81}
#define mfunnamep(string)
Definition: FunNameStack.h:49
#define spexit(stream)
Definition: FunNameStack.h:256
#define mfunname(string)
Definition: FunNameStack.h:45
void print(std::ostream &file, int l) const
Definition: PairProd.cpp:71
PairProd()=default
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:6
indentation indn
Definition: prstream.cpp:15
DoubleAc sqrt(const DoubleAc &f)
Definition: DoubleAc.cpp:314
#define Ifile
Definition: prstream.h:195
#define mcerr
Definition: prstream.h:128