Garfield++ v2r0
A toolkit for the detailed simulation of particle detectors based on ionisation measurement in gases and semiconductors
Loading...
Searching...
No Matches
trajestep.cpp
Go to the documentation of this file.
2/*
3Copyright (c) 2000 Igor B. Smirnov
4
5The file can be used, copied, modified, and distributed
6according to the terms of GNU Lesser General Public License version 2.1
7as published by the Free Software Foundation,
8and provided that the above copyright notice, this permission notice,
9and notices about any modifications of the original text
10appear in all copies and in supporting documentation.
11The file is provided "as is" without express or implied warranty.
12*/
13
14namespace Heed {
15
16void trajestep_limit::range(const int fs_cf0, const vfloat rad, int& fs_cf1,
17 vfloat& mrange) const {
18 if (mrange < 0 || mrange > max_range) mrange = max_range;
19 fs_cf1 = fs_cf0;
20 if (fs_cf1 != 1) return;
21 if (rad >= rad_for_straight) {
22 fs_cf1 = 0;
23 mrange = std::min(mrange, rad * max_straight_arange);
24 } else {
25 mrange = std::min(mrange, rad * max_circumf_arange);
26 }
27}
28
33
35 aref_tran.pass(new absref_transmit(4, aref));
36}
37
39 const vec& fdir, int fs_cf, const vec& frelcen,
40 vfloat fmrange, vfloat prec)
41 : tl(ftl),
42 currpos(fcurrpos),
43 dir(),
44 s_cf(fs_cf),
45 relcen(frelcen),
46 s_prec(1),
47 mrange(fmrange) {
48 pvecerror("trajestep::trajestep(...)");
49 if (fdir == dv0) {
50 dir = dv0;
51 mrange = 0;
52 } else {
53 dir = unit_vec(fdir);
54 if (s_cf == 1) {
55 check_econd11a(check_perp(dir, relcen, prec), != 1,
56 "dir=" << dir << "relcen=" << relcen
57 << "fcurrpos=" << fcurrpos << "fdir=" << fdir,
58 mcerr);
59 }
60 tl->range(s_cf, relcen.length(), s_range_cf, mrange);
61 }
62}
63
65 mfunname("trajestep::trajestep(const trajestep& fts, vfloat fmrange)");
66 // Continue propagation from the end point of the old step.
67 point fpos;
68 vec fdir;
69 vec frelcen;
70 fts.Gnextpoint1(fts.mrange, fpos, fdir, frelcen);
71 vfloat prec = 0.1; // not important here
72 *this =
73 trajestep(fts.tl.getver(), fpos, fdir, fts.s_cf, frelcen, fmrange, prec);
74}
75
76void trajestep::Gnextpoint(vfloat frange, point& fpos, vec& fdir) const {
77 pvecerror("int trajestep::Gnextpoint(vfloat frange, point& fpos, vec& fdir)");
78 check_econd12(frange, >, mrange, mcerr);
79 if (s_range_cf == 0) {
80 // interpolation by straight line
81 fpos = currpos + frange * dir;
82 if (s_cf == 0) {
83 // no curvature
84 fdir = dir;
85 return;
86 } else {
87 vfloat ang = frange / relcen.length();
88 fdir = dir;
89 fdir.turn(dir || relcen, ang);
90 return;
91 }
92 } else {
93 vfloat ang = frange / relcen.length(); // angle to turn
94 fdir = dir;
95 fdir.turn(dir || relcen, ang); // direction at the end
96 vec frelcen = relcen;
97 frelcen.turn(dir || relcen, ang);
98 fpos = currpos + relcen - frelcen;
99 return;
100 }
101}
102
103void trajestep::Gnextpoint1(vfloat frange, point& fpos, vec& fdir,
104 vec& frelcen) const {
105 pvecerror(
106 "int trajestep::Gnextpoint(vfloat frange, point& fpos, vec& fdir, "
107 "vec& frelcen)");
108 check_econd12(frange, >, mrange, mcerr);
109 if (s_range_cf == 0) {
110 // interpolation by straight line
111 fpos = currpos + frange * dir;
112 if (s_cf == 0) {
113 // no curvature
114 fdir = dir;
115 frelcen = relcen; // whatever it is
116 return;
117 } else {
118 vfloat ang = frange / relcen.length();
119 fdir = dir;
120 fdir.turn(dir || relcen, ang);
121 frelcen = relcen;
122 frelcen.turn(dir || relcen, ang);
123 return;
124 }
125 } else {
126 vfloat ang = frange / relcen.length(); // angle to turn
127 fdir = dir;
128 fdir.turn(dir || relcen, ang); // direction at the end
129 frelcen = relcen;
130 frelcen.turn(dir || relcen, ang);
131 fpos = currpos + relcen - frelcen;
132 return;
133 }
134}
135
136std::ostream& operator<<(std::ostream& file, const trajestep& f) {
137 Ifile << "trajestep: s_cf=" << f.s_cf << "\n";
138 indn.n += 2;
139 Ifile << "currpos:" << f.currpos << indn << "dir=" << f.dir << indn
140 << "relcen=" << f.relcen << indn << "s_range_cf=" << f.s_range_cf
141 << " s_prec=" << f.s_prec << " mrange=" << f.mrange << '\n' << indn
142 << "mpoint=" << f.mpoint;
143 indn.n -= 2;
144 return file;
145}
146}
#define check_econd11a(a, signb, add, stream)
Definition: FunNameStack.h:172
#define check_econd12(a, sign, b, stream)
Definition: FunNameStack.h:163
#define mfunname(string)
Definition: FunNameStack.h:45
Active pointer or automatic container or controlling pointer.
Definition: AbsPtr.h:199
void pass(X *fptr)
Definition: AbsPtr.h:247
Point.
Definition: vec.h:374
vfloat max_straight_arange
Angle of range if it goes along straight line, but s_cf == 1.
Definition: trajestep.h:38
vfloat max_circumf_arange
Angle of range if it goes along circle.
Definition: trajestep.h:40
void range(int fs_cf0, vfloat rad, int &fs_cf1, vfloat &mrange) const
Definition: trajestep.cpp:16
vfloat rad_for_straight
Radius beyond which to prefer straight lines to reduce calculation time.
Definition: trajestep.h:35
trajestep()
Default constructor.
Definition: trajestep.h:113
PassivePtr< trajestep_limit > tl
Definition: trajestep.h:67
vfloat mrange
Maximal possible range.
Definition: trajestep.h:90
void Gnextpoint1(vfloat frange, point &fpos, vec &fdir, vec &frelcen) const
Definition: trajestep.cpp:103
virtual void get_components(ActivePtr< absref_transmit > &aref_tran)
Definition: trajestep.cpp:34
static absrefabsref::*[4] aref
Definition: trajestep.h:128
void Gnextpoint(vfloat frange, point &fpos, vec &fdir) const
Definition: trajestep.cpp:76
vec dir
Unit vector.
Definition: trajestep.h:70
Definition: vec.h:186
vfloat length() const
Definition: vec.h:205
void turn(const vec &dir, vfloat angle)
Turn this vector.
Definition: vec.cpp:216
Definition: BGMesh.cpp:5
std::ostream & operator<<(std::ostream &file, const BGMesh &bgm)
Definition: BGMesh.cpp:36
vec dv0(0, 0, 0)
Definition: vec.h:314
indentation indn
Definition: prstream.cpp:15
double vfloat
Definition: vfloat.h:16
#define Ifile
Definition: prstream.h:196
#define mcerr
Definition: prstream.h:128
#define pvecerror(string)
Definition: vec.h:29