Garfield++ v1r0
A toolkit for the detailed simulation of particle detectors based on ionisation measurement in gases and semiconductors
Loading...
Searching...
No Matches
gparticle.h
Go to the documentation of this file.
1#ifndef GPARTICLE_H
2#define GPARTICLE_H
4
5/*
6"geometrical particle"
7It is particle which does not interact with materials.
8It flyes by polyline line or by circumferences from one volume to another.
9The flying is represented by changing of class members representing
10particle position.
11Interacted particle should be derivated class from this one.
12
13Copyright (c) 2000 Igor B. Smirnov
14
15The file can be used, copied, modified, and distributed
16according to the terms of GNU Lesser General Public License version 2.1
17as published by the Free Software Foundation,
18and provided that the above copyright notice, this permission notice,
19and notices about any modifications of the original text
20appear in all copies and in supporting documentation.
21The file is provided "as is" without express or implied warranty.
22*/
23
24//#define vec_stvpoint_def 10
25//const double PRECISION_OF_SWITCH=1.0e-5;
26//#define PRECISION_OF_SWITCH 1.0e-5
27//#define PRECISION_OF_SWITCH 1.0e-8
28
29// point in space, time and velocity
30class stvpoint {
31 public:
32 // coordinates in the first system from tid system
34 // unit vector, in the first system from tid system
36 // coordinates in the local system, the last system from tid
38 // unit vector, in the local system, the last system from tid
40 // longitudinal velocity
42 //vfloat accel; // longitudinal acceleration
44 //int namvol; // number of currect volumes
45 //manip_absvol* amvol[pqamvol];
46 int sb; // 0 - inside volume, or unknown
47 // 1 - on the border of the volume
48 // 2 - on the border of an embraced volume
49 int s_ent; // 1 - entering new volume, 0 otherwise
50 // embraced volume is also considered new.
51
52 manip_absvol_eid next_eid; // if nextpos.sb==2
53 // range from previous point
56 // vfloat vvel; // value of velocity
57
58 // get least address of manipulator
59 const manip_absvol_eid* G_laeid() const { return tid.G_laeid(); }
60 // get least address of manipulator
61 manip_absvol* G_lamvol() const { return tid.G_lamvol(); }
62 // get least address of volume
63 absvol* G_lavol() const { return tid.G_lavol(); }
64
65 // constructors
67 : pt(),
68 dir(),
69 ptloc(),
70 dirloc(),
71 speed(0.0),
72 tid(),
73 sb(0),
74 s_ent(0),
75 next_eid(),
76 prange(0.0),
77 time(0) {
78 ;
79 }
80 stvpoint(const point& fpt, const vec& fdir, vfloat fspeed,
81 manip_absvol_treeid& ftid, vfloat fprange, vfloat ftime, int fsb,
82 int fs_ent, manip_absvol_eid& faeid)
83 : pt(fpt),
84 dir(unit_vec(fdir)),
85 speed(fspeed),
86 tid(ftid),
87 sb(fsb),
88 s_ent(fs_ent),
89 next_eid(faeid),
90 prange(fprange),
91 time(ftime) {
92 ptloc = pt;
94 dirloc = dir;
96 }
97 stvpoint(const stvpoint& pstv, const trajestep& ts, // in the local system
98 vfloat mrange, // may be less than one in ts
99 //manip_absvol_treeid& ftid,
100 int fsb, int fs_ent, manip_absvol_eid& faeid)
101 : pt(),
102 dir(),
103 ptloc(),
104 dirloc(),
105 speed(pstv.speed),
106 tid(pstv.tid),
107 sb(fsb),
108 s_ent(fs_ent),
109 next_eid(faeid),
110 prange(mrange),
111 time(pstv.time + mrange / pstv.speed) {
112 if (pstv.speed == 0) {
113 time = pstv.time; // just to put anything
114 } else {
115 // If speed is changed, this time is to be corrected in derivative class
116 time = pstv.time + mrange / pstv.speed;
117 }
118 ts.Gnextpoint(mrange, ptloc, dirloc);
119 pt = ptloc;
121 dir = dirloc;
123 }
124
125 stvpoint(const stvpoint& pstv, const trajestep& ts, // in the local system
126 int fsb, int fs_ent, manip_absvol_eid& faeid)
127 : pt(),
128 dir(),
129 ptloc(),
130 dirloc(),
131 speed(pstv.speed),
132 tid(pstv.tid),
133 sb(fsb),
134 s_ent(fs_ent),
135 next_eid(faeid),
136 prange(ts.mrange),
137 time(pstv.time + ts.mrange / pstv.speed) {
138 if (pstv.speed == 0) {
139 time = pstv.time; // just to put anything
140 } else {
141 // If speed is changed, this time is to be corrected in derivative class
142 time = pstv.time + ts.mrange / pstv.speed;
143 }
144 ptloc = ts.mpoint;
145 point temp;
146 ts.Gnextpoint(ts.mrange, temp, dirloc);
147 pt = ptloc;
149 dir = dirloc;
151 }
153 : pt(fp.pt),
154 dir(fp.dir),
155 ptloc(fp.ptloc),
156 dirloc(fp.dirloc),
157 speed(fp.speed),
158 tid(fp.tid),
159 sb(fp.sb),
160 s_ent(fp.s_ent),
161 next_eid(fp.next_eid),
162 prange(fp.prange),
163 time(fp.time) {
164 ;
165 }
166 // destructor
167 virtual ~stvpoint() {}
168 virtual void print(std::ostream& file, int l) const;
169};
170
171class gparticle;
172
173void check_point(gparticle* gp);
174// Seems that this is any function which can be executed after each step.
175
177
178class gparticle : public RegPassivePtr {
179 public:
181 long nstep; // step number
182 double total_range_from_origin; // from origin to currpos
183 long n_zero_step; // number of previous steps with zero range
184 // including this step
185 static long max_q_zero_step;
190 vec curr_relcen; // current relcen computed
191 // at the last call of calc_step_to_bord(), only for debug print
192
193 //static vfloat precision_of_switch;
194 gparticle(void) : s_life(0), nstep(0) { ; }
196 : s_life(1), nstep(0), origin(sp), prevpos(), currpos(sp), nextpos() {
198 physics();
199 }
200
201 gparticle(manip_absvol* primvol, const point& pt, const vec& vel,
202 vfloat time);
203 // As far as I can now understand, PassivePtr< primvol > will be at
204 // origin.tid.eid[0]
205
206 virtual void step(void); // Assigns prevpos=currpos; and currpos=nextpos;
207 // calls change_vol(); if necessary and makes nextpos=calc_step_to_bord();
208 // Derived versions can also recalculate direction of move currpos
209 // right after the call of currpos=nextpos;.
210 // This is especially important in the case when the move is done
211 // by straight steps, but there is a field (magnetic) of any
212 // force which deflects the trajectory slightly. In this case
213 // at the end point of each interval the velocity is corrected (but the
214 // point currpos is not).
215
216 //virtual void check_point( )
217 // {};
218 virtual void change_vol(void) { currpos.tid.G_lavol()->income(this); }
219 virtual void curvature(int& fs_cf, vec& frelcen, vfloat& fmrange,
220 vfloat prec);
221 // Allows to set curvature.
222 // For flying particle it is expected to call another function
223 // so as to obtain value and direction of force.
224 // Can also change currpos.dir.
225 // prec is used to find out if the force is parallel or antiparallel to dir
226 // In the latter case the range is restricted by the stop point.
227 // Thus this prec does not depend on order of geometry sizes.
228 // In calc_step_to_bord() it is set to gtrajlim.max_straight_arange.
229 // vec& frelcen: position of the center of circumf. relatively currpos
230
231 virtual void physics_after_new_speed(void) { ; }
232 // Allows to apply any other processes, to turn the trajectory, kill
233 // the particle and so on.
234 virtual void physics(void) { ; }
235 // Allows to apply any other processes, to turn the trajectory, kill
236 // the particle and so on.
237 virtual void physics_mrange(double& fmrange);
238 // Allows to reduce maxumal possible range due to continious processes.
239 // Called from calc_step_to_bord() after the call of curvature(...)
240 // but before considering the crossing with volumes.
241 // Therefore mrange may be reduced after this.
242
243 virtual stvpoint calc_step_to_bord();
244 // produces nextpos
245
246 //stvpoint switch_new_vol(manip_absvol* famvol[pqamvol], int fnamvol);
248
249 virtual void fly(void) {
250 mfunname("virtual void gparticle::fly(void)");
251 while (s_life == 1) {
252 step();
253 physics();
254 check_point(this);
255 }
256 }
257 virtual void print(std::ostream& file, int l) const;
259 virtual ~gparticle() { ; }
260};
261
262#endif
#define mfunname(string)
Definition: FunNameStack.h:67
Definition: volume.h:91
virtual void income(gparticle *)
Definition: volume.h:142
stvpoint currpos
Definition: gparticle.h:188
vec curr_relcen
Definition: gparticle.h:190
long n_zero_step
Definition: gparticle.h:183
virtual void fly(void)
Definition: gparticle.h:249
virtual void physics_mrange(double &fmrange)
Definition: gparticle.cpp:129
virtual void curvature(int &fs_cf, vec &frelcen, vfloat &fmrange, vfloat prec)
Definition: gparticle.cpp:112
stvpoint switch_new_vol(void)
Definition: gparticle.cpp:231
virtual void print(std::ostream &file, int l) const
Definition: gparticle.cpp:312
virtual stvpoint calc_step_to_bord()
Definition: gparticle.cpp:132
virtual void physics_after_new_speed(void)
Definition: gparticle.h:231
virtual void step(void)
Definition: gparticle.cpp:88
double total_range_from_origin
Definition: gparticle.h:182
macro_copy_total(gparticle)
virtual ~gparticle()
Definition: gparticle.h:259
stvpoint origin
Definition: gparticle.h:186
stvpoint prevpos
Definition: gparticle.h:187
long nstep
Definition: gparticle.h:181
gparticle(const stvpoint &sp)
Definition: gparticle.h:195
int s_life
Definition: gparticle.h:180
virtual void change_vol(void)
Definition: gparticle.h:218
gparticle(void)
Definition: gparticle.h:194
virtual void physics(void)
Definition: gparticle.h:234
static long max_q_zero_step
Definition: gparticle.h:185
stvpoint nextpos
Definition: gparticle.h:189
const manip_absvol_eid * G_laeid() const
Definition: volume.h:54
void down_absref(absref *f)
Definition: volume.cpp:32
manip_absvol * G_lamvol() const
Definition: volume.h:58
void up_absref(absref *f)
Definition: volume.cpp:37
absvol * G_lavol() const
Definition: volume.cpp:28
Definition: vec.h:477
int sb
Definition: gparticle.h:46
point pt
Definition: gparticle.h:33
const manip_absvol_eid * G_laeid() const
Definition: gparticle.h:59
point ptloc
Definition: gparticle.h:37
virtual void print(std::ostream &file, int l) const
Definition: gparticle.cpp:14
absvol * G_lavol() const
Definition: gparticle.h:63
manip_absvol_eid next_eid
Definition: gparticle.h:52
stvpoint(const stvpoint &fp)
Definition: gparticle.h:152
vec dirloc
Definition: gparticle.h:39
int s_ent
Definition: gparticle.h:49
stvpoint(const stvpoint &pstv, const trajestep &ts, int fsb, int fs_ent, manip_absvol_eid &faeid)
Definition: gparticle.h:125
stvpoint(const point &fpt, const vec &fdir, vfloat fspeed, manip_absvol_treeid &ftid, vfloat fprange, vfloat ftime, int fsb, int fs_ent, manip_absvol_eid &faeid)
Definition: gparticle.h:80
manip_absvol * G_lamvol() const
Definition: gparticle.h:61
vfloat prange
Definition: gparticle.h:54
manip_absvol_treeid tid
Definition: gparticle.h:43
stvpoint(void)
Definition: gparticle.h:66
vfloat time
Definition: gparticle.h:55
stvpoint(const stvpoint &pstv, const trajestep &ts, vfloat mrange, int fsb, int fs_ent, manip_absvol_eid &faeid)
Definition: gparticle.h:97
vec dir
Definition: gparticle.h:35
virtual ~stvpoint()
Definition: gparticle.h:167
vfloat speed
Definition: gparticle.h:41
void Gnextpoint(vfloat frange, point &fpos, vec &fdir) const
Definition: trajestep.cpp:78
vfloat mrange
Definition: trajestep.h:91
point mpoint
Definition: trajestep.h:92
Definition: vec.h:248
trajestep_limit gtrajlim
void check_point(gparticle *gp)
Definition: TrackHeed.cc:84
double vfloat
Definition: vfloat.h:15