Garfield++ v1r0
A toolkit for the detailed simulation of particle detectors based on ionisation measurement in gases and semiconductors
Loading...
Searching...
No Matches
gparticle Class Reference

#include <gparticle.h>

+ Inheritance diagram for gparticle:

Public Member Functions

 gparticle (void)
 
 gparticle (const stvpoint &sp)
 
 gparticle (manip_absvol *primvol, const point &pt, const vec &vel, vfloat time)
 
virtual void step (void)
 
virtual void change_vol (void)
 
virtual void curvature (int &fs_cf, vec &frelcen, vfloat &fmrange, vfloat prec)
 
virtual void physics_after_new_speed (void)
 
virtual void physics (void)
 
virtual void physics_mrange (double &fmrange)
 
virtual stvpoint calc_step_to_bord ()
 
stvpoint switch_new_vol (void)
 
virtual void fly (void)
 
virtual void print (std::ostream &file, int l) const
 
 macro_copy_total (gparticle)
 
virtual ~gparticle ()
 

Public Attributes

int s_life
 
long nstep
 
double total_range_from_origin
 
long n_zero_step
 
stvpoint origin
 
stvpoint prevpos
 
stvpoint currpos
 
stvpoint nextpos
 
vec curr_relcen
 

Static Public Attributes

static long max_q_zero_step = 100
 

Detailed Description

Definition at line 178 of file gparticle.h.

Constructor & Destructor Documentation

◆ gparticle() [1/3]

gparticle::gparticle ( void  )
inline

Definition at line 194 of file gparticle.h.

194: s_life(0), nstep(0) { ; }
long nstep
Definition: gparticle.h:181
int s_life
Definition: gparticle.h:180

◆ gparticle() [2/3]

gparticle::gparticle ( const stvpoint sp)
inline

Definition at line 195 of file gparticle.h.

196 : s_life(1), nstep(0), origin(sp), prevpos(), currpos(sp), nextpos() {
198 physics();
199 }
stvpoint currpos
Definition: gparticle.h:188
virtual stvpoint calc_step_to_bord()
Definition: gparticle.cpp:132
stvpoint origin
Definition: gparticle.h:186
stvpoint prevpos
Definition: gparticle.h:187
virtual void physics(void)
Definition: gparticle.h:234
stvpoint nextpos
Definition: gparticle.h:189

◆ gparticle() [3/3]

gparticle::gparticle ( manip_absvol primvol,
const point pt,
const vec vel,
vfloat  time 
)

Definition at line 50 of file gparticle.cpp.

52 : s_life(0),
53 nstep(0),
55 n_zero_step(0),
56 prevpos(),
57 nextpos() {
58 mfunname("gparticle::gparticle(...)");
59 //mcout<<"origin.namvol="<<origin.namvol<<'\n';
60 origin.tid.eid[0].nembed = 0; // just to clear
61 primvol->m_find_embed_vol(pt, vel, &origin.tid);
62 origin.pt = pt;
63 if (vel == dv0) {
64 origin.dir = dv0;
65 origin.speed = 0.0;
66 } else {
67 origin.dir = unit_vec(vel);
68 origin.speed = length(vel);
69 }
74 origin.time = time;
75 origin.sb = 0;
76 origin.s_ent = 1; //origin.next_eid=NULL;
77 if (origin.tid.qeid == 0) return;
78 s_life = 1;
81 nextpos.s_ent = 0;
82 //mcout<<"origin.namvol="<<origin.namvol<<'\n';
83 //mcout<<"origin=\n"; origin.print(mcout,1);
84 //mcout<<"currpos=\n"; currpos.print(mcout,1);
85 //nextpos=calc_step_to_bord();
86}
#define mfunname(string)
Definition: FunNameStack.h:67
long n_zero_step
Definition: gparticle.h:183
double total_range_from_origin
Definition: gparticle.h:182
manip_absvol_eid eid[pqamvol]
Definition: volume.h:52
void up_absref(absref *f)
Definition: volume.cpp:37
virtual int m_find_embed_vol(const point &fpt, const vec &fdir, manip_absvol_treeid *atid) const
int sb
Definition: gparticle.h:46
point pt
Definition: gparticle.h:33
point ptloc
Definition: gparticle.h:37
vec dirloc
Definition: gparticle.h:39
int s_ent
Definition: gparticle.h:49
manip_absvol_treeid tid
Definition: gparticle.h:43
vfloat time
Definition: gparticle.h:55
vec dir
Definition: gparticle.h:35
vfloat speed
Definition: gparticle.h:41
vec dv0(0, 0, 0)

◆ ~gparticle()

virtual gparticle::~gparticle ( )
inlinevirtual

Definition at line 259 of file gparticle.h.

259{ ; }

Member Function Documentation

◆ calc_step_to_bord()

stvpoint gparticle::calc_step_to_bord ( )
virtual

Definition at line 132 of file gparticle.cpp.

132 {
133 pvecerror("stvpoint gparticle::calc_step_to_bord()");
135 if (currpos.sb > 0) {
136 // it does not do step, but switch to new volume
137 //return switch_new_vol(currpos.amvol, currpos.namvol);
138 return switch_new_vol();
139 } else {
140 manip_absvol_eid faeid; //manip_absvol* famvol;
141 /*
142 if(currpos.s_ent > 0 && currpos.tid.G_lavol()->mandatory()==1) {
143 // to find volume again, borders can be common for many volumes,
144 // or mandatory volume can be thin.
145 // manip_absvol* ffamvol[pqamvol];
146 manip_absvol_treeid tidl;
147 //int ffnamvol=0;
148 currpos.tid.eid[0].amvol->find_embed_vol(currpos.pt, currpos.dir, &tidl);
149 if(currpos.tid != tidl)
150 //currpos.namvol != ffnamvol ||
151 //currpos.amvol[currpos.namvol-1] != ffamvol[ffnamvol-1])
152 {
153 //Imcout<<"calc_step_to_bord: volume is changed again\n";
154 return stvpoint(currpos.pt, currpos.dir, currpos.speed,
155 currpos.tid,
156 //currpos.amvol, currpos.namvol, // till end of this
157 0.0,
158 currpos.time ,
159 1, 0, *(tidl.G_laeid()) );
160 }
161 }
162 */
163 int s_cf;
164 vec relcen;
165 vfloat mrange;
166 //mcout<<"gparticle::calc_step_to_bord(): now running the curvature()\n";
167 curvature(s_cf, relcen, mrange, gtrajlim.max_straight_arange);
168 curr_relcen = relcen;
169 if (mrange <= 0) {
170 // preserves currpos for modification by physics
171 stvpoint temp(currpos);
172 temp.s_ent = 0;
173 return temp;
174 }
175 //mcout<<"s_cf="<<s_cf<<" relcen="<<relcen
176 // <<"mrange="<<mrange<<'\n';
177
178 //mcout<<"gparticle::calc_step_to_bord(): now running the trajestep\n";
179 currpos.tid.up_absref(&relcen); // changing to local system
180 physics_mrange(mrange);
181 trajestep ts(&gtrajlim, currpos.ptloc, currpos.dirloc, s_cf, relcen, mrange,
182 currpos.tid.G_laeid()->amvol->Gavol()->prec);
183 //s_cf, relcen, mrange, currpos.next_eid.amvol->Gavol()->prec );
184 if (ts.mrange <= 0) {
185 stvpoint temp(currpos);
186 temp.s_ent = 0;
187 return temp;
188 /*
189 return stvpoint(currpos.pt, currpos.dir, currpos.speed,
190 currpos.tid,
191 //currpos.amvol, currpos.namvol, // till end of this
192 ts.mrange,
193 currpos.time,
194 0, 0, currpos.next_eid );
195 */
196 }
197 //mcout<<"calc_step_to_bord: ts="<<ts;
198 //currpos.tid.G_lavol()->print(mcout, 1);
199
200 // Here the range is calculated:
201 int sb;
202 currpos.tid.G_lavol()->range(ts, 1, sb, &faeid);
203 // 1 means inside the volume and makes
204 // the program checking embraced volumes
205 // point pte;
206 // range(currpos.pt, currpos.dir,
207 // 1, sb, rng, pte, &faeid);
208 //mcout<<"calc_step_to_bord: sb="<<sb<<" ts="<<ts;
209 if (ts.s_prec == 0) {
210 // point is crossed
211 return stvpoint(currpos, ts, sb, 0, faeid);
212 } else {
213 return stvpoint(currpos, ts, ts.mrange, sb, 0, faeid);
214 }
215 /*
216 vec dir;
217 ts.Gnextpoint(ts.mrange, pte, dir);
218 return stvpoint(pte, dir, currpos.speed,
219 currpos.tid,
220 //currpos.amvol, currpos.namvol, // till end of this
221 ts.mrange,
222 currpos.time + ts.mrange / currpos.speed,
223 sb, 0, faeid );
224 */
225 }
226}
virtual int range(trajestep &fts, int s_ext, int &sb, manip_absvol_eid *faeid) const
Definition: volume.cpp:118
vec curr_relcen
Definition: gparticle.h:190
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
PassivePtr< manip_absvol > amvol
Definition: volume.h:39
const manip_absvol_eid * G_laeid() const
Definition: volume.h:54
absvol * G_lavol() const
Definition: volume.cpp:28
vfloat max_straight_arange
Definition: trajestep.h:48
Definition: vec.h:248
trajestep_limit gtrajlim
#define pvecerror(string)
Definition: vec.h:52
double vfloat
Definition: vfloat.h:15

Referenced by gparticle(), step(), and Heed::mparticle::step().

◆ change_vol()

virtual void gparticle::change_vol ( void  )
inlinevirtual

Definition at line 218 of file gparticle.h.

218{ currpos.tid.G_lavol()->income(this); }
virtual void income(gparticle *)
Definition: volume.h:142

Referenced by step(), and Heed::mparticle::step().

◆ curvature()

void gparticle::curvature ( int &  fs_cf,
vec frelcen,
vfloat fmrange,
vfloat  prec 
)
virtual

Reimplemented in Heed::mparticle.

Definition at line 112 of file gparticle.cpp.

113 {
114 fs_cf = 0;
115 frelcen = vec(0, 0, 0);
116 fmrange = max_vfloat;
117 /* The following is for debug
118 vec field(0,1,0);
119 vfloat rad = 10;
120 if (length(currpos.dir) > 0 && check_par(currpos.dir, field) == 0) {
121 fs_cf = 1;
122 vfloat coef = sin2vec(currpos.dir, field);
123 rad = rad / coef;
124 frelcen = unit_vec(currpos.dir || field) * rad;
125 }
126 */
127}
#define max_vfloat
Definition: vfloat.h:14

Referenced by calc_step_to_bord().

◆ fly()

virtual void gparticle::fly ( void  )
inlinevirtual

Definition at line 249 of file gparticle.h.

249 {
250 mfunname("virtual void gparticle::fly(void)");
251 while (s_life == 1) {
252 step();
253 physics();
254 check_point(this);
255 }
256 }
virtual void step(void)
Definition: gparticle.cpp:88
void check_point(gparticle *gp)
Definition: TrackHeed.cc:84

Referenced by Garfield::TrackHeed::GetCluster(), Garfield::TrackHeed::NewTrack(), Garfield::TrackHeed::TransportDeltaElectron(), and Garfield::TrackHeed::TransportPhoton().

◆ macro_copy_total()

gparticle::macro_copy_total ( gparticle  )

◆ physics()

virtual void gparticle::physics ( void  )
inlinevirtual

Reimplemented in Heed::HeedParticle, Heed::HeedParticle_BGM, Heed::HeedPhoton, and Heed::mparticle.

Definition at line 234 of file gparticle.h.

234{ ; }

Referenced by fly(), and gparticle().

◆ physics_after_new_speed()

virtual void gparticle::physics_after_new_speed ( void  )
inlinevirtual

Reimplemented in Heed::HeedDeltaElectron, Heed::HeedPhoton, Heed::mparticle, and Heed::eiparticle.

Definition at line 231 of file gparticle.h.

231{ ; }

Referenced by step().

◆ physics_mrange()

void gparticle::physics_mrange ( double &  fmrange)
virtual

Reimplemented in Heed::HeedDeltaElectron.

Definition at line 129 of file gparticle.cpp.

129{}

Referenced by calc_step_to_bord().

◆ print()

void gparticle::print ( std::ostream &  file,
int  l 
) const
virtual

Reimplemented in Heed::HeedDeltaElectron, Heed::HeedParticle, Heed::HeedParticle_BGM, Heed::HeedPhoton, Heed::mparticle, Heed::eiparticle, and Heed::eparticle.

Definition at line 312 of file gparticle.cpp.

312 {
313 if (l >= 0) {
314 Ifile << "gparticle(l=" << l << "): s_life=" << s_life << " nstep=" << nstep
315 << " total_range_from_origin=" << total_range_from_origin
316 << " n_zero_step=" << n_zero_step << '\n';
317 if (l == 1) {
318 file.flush();
319 return;
320 }
321 indn.n += 2;
322 if (l - 5 >= 0) {
323 Ifile << "origin point:\n";
324 indn.n += 2;
325 origin.print(file, l - 2);
326 indn.n -= 2;
327 }
328 if (l - 4 >= 0) {
329 Ifile << "previous point:\n";
330 indn.n += 2;
331 prevpos.print(file, l - 1);
332 indn.n -= 2;
333 }
334 if (l - 2 >= 0) {
335 Ifile << "current point:\n";
336 indn.n += 2;
337 currpos.print(file, l);
338 Iprint(file, curr_relcen);
339 Ifile << " length(curr_relcen)=" << length(curr_relcen) << '\n';
340 indn.n -= 2;
341 }
342 if (l - 3 >= 0) {
343 Ifile << "next point:\n";
344 indn.n += 2;
345 nextpos.print(file, l - 1);
346 indn.n -= 2;
347 }
348 indn.n -= 2;
349 file.flush();
350 }
351}
virtual void print(std::ostream &file, int l) const
Definition: gparticle.cpp:14
indentation indn
Definition: prstream.cpp:13
#define Ifile
Definition: prstream.h:207
#define Iprint(file, name)
Definition: prstream.h:209

Referenced by Heed::HeedPhoton::print(), and Heed::mparticle::print().

◆ step()

void gparticle::step ( void  )
virtual

Reimplemented in Heed::mparticle.

Definition at line 88 of file gparticle.cpp.

89 { // make step to nextpos and calculate new step to border
90 mfunname("void gparticle::step(void)");
95 nstep++;
96 if (currpos.prange == 0) {
99 "too much zero steps, possible infinite loop\n", mcerr);
100 } else
101 n_zero_step = 0;
103 if (s_life == 1) {
104 if (prevpos.tid != currpos.tid)
105 //prevpos.namvol != currpos.namvol ||
106 //prevpos.amvol[prevpos.namvol-1] != currpos.amvol[currpos.namvol-1])
107 change_vol(); // possible correction ( reflection..)
109 }
110}
#define check_econd12a(a, sign, b, add, stream)
Definition: FunNameStack.h:411
virtual void physics_after_new_speed(void)
Definition: gparticle.h:231
virtual void change_vol(void)
Definition: gparticle.h:218
static long max_q_zero_step
Definition: gparticle.h:185
vfloat prange
Definition: gparticle.h:54
#define mcerr
Definition: prstream.h:135

Referenced by fly().

◆ switch_new_vol()

stvpoint gparticle::switch_new_vol ( void  )

Definition at line 231 of file gparticle.cpp.

231 {
232 // generates next position in new volume
233 mfunname("stvpoint gparticle::switch_new_vol(void)");
234 /*
235 mcout<<"gparticle::switch_new_vol:\n";
236 if(currpos.next_eid.amvol==NULL)
237 {
238 mcout<<"currpos.next_eid.amvol="<<currpos.next_eid.amvol<<'\n';
239 }
240 else
241 {
242 currpos.next_eid.amvol->print(mcout,3);
243 int i=currpos.next_eid.amvol->check_point_inside(currpos.ptloc,
244 currpos.dirloc);
245 mcout<<"i="<<i<<'\n';
246 }
247 */
249 manip_absvol_eid eidl;
250 //int namvoll=0;
251 //manip_absvol* amvoll[pqamvol];
252 stvpoint nextp = currpos;
253 //vec additional_dist=currpos.dir * nextp.next_eid.amvol->Gavol()->prec;
254 //vec additional_dist=currpos.dir * precision_of_switch;
255 //nextp.pt.shift(additional_dist);
256 //nextp.time=nextp.time+length(additional_dist)/nextp.speed;
257 point pth = nextp.pt;
258//if(famvol[fnamvol]->Gavol()->mandatory()==1)
259/*
260if(nextp.sb==2 && nextp.next_eid.amvol->Gavol()->mandatory()==1)
261{
262 // Going to embraced volume even if it is too thin
263 //for( namvoll=0; namvoll<nextp.namvol; namvoll++)
264 // amvoll[namvoll]=nextp.amvol[namvoll];
265 //amvoll[namvoll++]=nextp.next_mvol;
266 tidl = nextp.tid;
267 tidl.eid[tidl.qeid++] = nextp.next_eid;
268 return stvpoint(pth, nextp.dir, nextp.speed, tidl,
269 0.0, nextp.time, 0 , 1, eidl);
270}
271else
272{
273*/
274// search from primary
275// In this case it does not necessary switch to encountered volume
276// namely nextp.next_eid
277// Borders of two volumes may coincide. Thus it should look for
278// the deepest volume at this point.
279mark1:
280 nextp.tid.eid[0].amvol->m_find_embed_vol(pth, nextp.dir, &tidl);
281 //tidl.print(mcout, 2);
282 //mcout<<"namvoll="<<namvoll<<'\n';
283 if (tidl.qeid > 0) {
284 int s_e;
285 if (tidl == nextp.tid) {
286 //namvoll==nextp.namvol && amvoll[namvoll-1]==nextp.amvol[namvoll-1] )
287 s_e = 0; // remains in the same old volume, may be numerical error
288 // Will probably repeat attempt to switch at the same steps
289 // untill success.
290 //mcout<<"stvpoint gparticle::switch_new_vol(void): remains in the same
291 //volume\n";
292 double curprec = nextp.tid.G_lavol()->prec;
293 if (currpos.prange <= curprec) { // very bad case, to repeat the trial.
294 //mcout<<"trial is repeated\n";
295 vec additional_dist = nextp.dir * curprec;
296 //Iprint(mcout, additional_dist);
297 pth = pth + additional_dist;
298 //Iprint(mcout, pth);
299 tidl = manip_absvol_treeid();
300 goto mark1;
301 }
302 } else
303 s_e = 1; // switch to new volume
304 return stvpoint(pth, nextp.dir, nextp.speed, tidl, 0.0, nextp.time, 0, s_e,
305 eidl);
306 } else {
307 s_life = 0;
308 return stvpoint();
309 }
310 //}
311}
vfloat prec
Definition: volume.h:95
Definition: vec.h:477

Referenced by calc_step_to_bord().

Member Data Documentation

◆ curr_relcen

vec gparticle::curr_relcen

Definition at line 190 of file gparticle.h.

Referenced by calc_step_to_bord(), print(), step(), and Heed::mparticle::step().

◆ currpos

◆ max_q_zero_step

long gparticle::max_q_zero_step = 100
static

Definition at line 185 of file gparticle.h.

Referenced by step(), and Heed::mparticle::step().

◆ n_zero_step

long gparticle::n_zero_step

Definition at line 183 of file gparticle.h.

Referenced by print(), step(), and Heed::mparticle::step().

◆ nextpos

◆ nstep

long gparticle::nstep

Definition at line 181 of file gparticle.h.

Referenced by print(), step(), and Heed::mparticle::step().

◆ origin

stvpoint gparticle::origin

◆ prevpos

◆ s_life

◆ total_range_from_origin

double gparticle::total_range_from_origin

Definition at line 182 of file gparticle.h.

Referenced by print(), step(), and Heed::mparticle::step().


The documentation for this class was generated from the following files: