Garfield++ v1r0
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/*
82003, I. Smirnov
9*/
10//#define USE_GET_ELOSS_CUT
11#ifdef USE_GET_ELOSS_CUT
12const double w_cut_ratio = 0.2;
13#else
14const double V_ratio = 0.5;
15#endif
16
17namespace Heed {
18
19PairProd::PairProd(const String& file_name, double fwa, double ffactorFano)
20 : wa(fwa), factorFano(ffactorFano) {
21 mfunnamep("PairProd::PairProd(const String& file_name, double fwa, double "
22 "ffactorFano)");
23
24#ifdef USE_STLSTRING
25 std::ifstream file(file_name.c_str());
26#else
27 std::ifstream file(file_name);
28#endif
29 if (!file) {
30 funnw.ehdr(mcerr);
31 mcerr << "cannot open file " << file_name << std::endl;
33 }
34 long q;
35 file >> wa_table >> I_table >> J_table >> factorFano_table >> q;
36 if (!file.good()) {
37 funnw.ehdr(mcerr);
38 mcerr << "error at reading file" << std::endl;
40 }
43 for (long n = 0; n < q; n++) {
44 file >> xx[n] >> yy[n];
45 }
46 pran = PointsRan(xx, yy, I_table, J_table);
47 k = sqrt(factorFano * wa * wa / (factorFano_table * wa_table * wa_table));
48 s = wa - k * wa_table;
49 //s = wa - wa / factorFano * ( 2.0 * factorFano - factorFano_table);
50 //k = wa / (factorFano * wa_table) * ( 2.0 * factorFano - factorFano_table);
51}
52
53double PairProd::get_eloss(void) const {
54 mfunname("double PairProd::get_eloss(void) const");
55 const double e_loss = k * pran.ran(SRANLUX()) + s;
56 return e_loss;
57}
58
59#ifdef USE_GET_ELOSS_CUT
60
61double PairProd::get_eloss(const double e_cur) const {
62 mfunname("double PairProd::get_eloss(double ecur) const");
63 double e_loss = k * pran.ran(SRANLUX()) + s;
64 if (e_cur - e_loss < w_cut_ratio * wa) e_loss = 1.0e20; // to stop tracing
65 return e_loss;
66}
67
68#else
69
70double PairProd::get_eloss(const double e_cur) const {
71 mfunname("double PairProd::get_eloss(double ecur) const");
72 double e_loss = k * pran.ran(SRANLUX()) + s;
73 double c;
74 if (e_cur <= V_ratio * wa) {
75 c = DBL_MAX;
76 } else {
77 //c = 1.0 / (1.0 - V_ratio * wa / e_cur);
78 c = 1.0 / (1.0 - pow(V_ratio * wa / e_cur, 2.0));
79 }
80 return e_loss * c;
81}
82
83#endif
84
85void PairProd::print(std::ostream& file, int l) const {
86 if (l <= 0) return;
87 Ifile << "PairProd:\n";
88 indn.n += 2;
89 Ifile << "wa=" << wa << " factorFano=" << factorFano << '\n';
90 Ifile << "wa_table=" << wa_table << " factorFano_table=" << factorFano_table
91 << '\n';
92 Ifile << " I_table=" << I_table << " J_table=" << J_table << " k=" << k
93 << " s=" << s << '\n';
94 pran.print(file);
95 indn.n -= 2;
96}
97
98}
DoubleAc pow(const DoubleAc &f, double p)
Definition: DoubleAc.cpp:336
DoubleAc sqrt(const DoubleAc &f)
Definition: DoubleAc.cpp:313
#define mfunnamep(string)
Definition: FunNameStack.h:77
#define spexit(stream)
Definition: FunNameStack.h:536
#define mfunname(string)
Definition: FunNameStack.h:67
const double V_ratio
Definition: PairProd.cpp:14
std::string String
Definition: String.h:75
virtual void print(std::ostream &file, int l) const
Definition: PairProd.cpp:85
PairProd(void)
Definition: PairProd.h:23
double get_eloss(void) const
Definition: PairProd.cpp:53
double ran(double flat_ran) const
Definition: PointsRan.cpp:114
void print(std::ostream &file) const
Definition: PointsRan.cpp:143
Definition: BGMesh.cpp:3
indentation indn
Definition: prstream.cpp:13
#define Ifile
Definition: prstream.h:207
#define mcerr
Definition: prstream.h:135
ffloat SRANLUX(void)
Definition: ranluxint.h:262