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

#include <gparticle.h>

+ Inheritance diagram for Heed::gparticle:

Public Member Functions

 gparticle ()
 Default constructor.
 
 gparticle (manip_absvol *primvol, const point &pt, const vec &vel, vfloat time)
 Constructor.
 
virtual ~gparticle ()
 Destructor.
 
virtual void step (std::vector< gparticle * > &secondaries)
 
virtual void change_vol (void)
 
virtual void curvature (int &fs_cf, vec &frelcen, vfloat &fmrange, vfloat prec)
 
virtual void physics_after_new_speed (std::vector< gparticle * > &)
 
virtual void physics (std::vector< gparticle * > &)
 
virtual void physics_mrange (double &fmrange)
 
virtual stvpoint calc_step_to_bord ()
 Produces nextpos.
 
stvpoint switch_new_vol ()
 
virtual void fly (std::vector< gparticle * > &secondaries)
 Transport the particle.
 
virtual void print (std::ostream &file, int l) const
 
virtual gparticlecopy () const
 
- Public Member Functions inherited from Heed::RegPassivePtr
 RegPassivePtr (void)
 
 RegPassivePtr (char fs_ban_del, char fs_ban_sub, char fs_ban_cop=0)
 
 RegPassivePtr (const RegPassivePtr &f)
 
RegPassivePtroperator= (const RegPassivePtr &f)
 
CountPP_ns::CountPassivePtrbook (void) const
 
void clear_pointers (void) const
 
virtual RegPassivePtrcopy () const
 
virtual ~RegPassivePtr ()
 
virtual void print (std::ostream &file, int l=1) const
 
void set_s_ban_del (char fs_ban_del)
 
char get_s_ban_del (void) const
 
void set_s_ban_sub (char fs_ban_sub)
 
char get_s_ban_sub (void) const
 
void set_s_ban_cop (char fs_ban_cop)
 
char get_s_ban_cop (void) const
 
void set_s_allow_del_at_zero_count (char fs_allow_del_at_zero_count)
 
char get_s_allow_del_at_zero_count (void) const
 
long get_total_number_of_references (void) const
 

Public Attributes

bool s_life
 
long nstep
 Step number.
 
double total_range_from_origin
 Range from origin to currpos.
 
long n_zero_step
 Number of previous steps with zero range (including this step).
 
stvpoint origin
 
stvpoint prevpos
 
stvpoint currpos
 
stvpoint nextpos
 
vec curr_relcen
 

Static Public Attributes

static long max_q_zero_step = 100
 

Additional Inherited Members

- Static Public Member Functions inherited from Heed::RegPassivePtr
static void set_s_ban_del_ignore (char fs_ban_del_ignore)
 
static char get_s_ban_del_ignore (void)
 
static void set_s_print_adr_cpp (char fs_print_adr_cpp)
 
static char get_s_print_adr_cpp (void)
 

Detailed Description

"Geometric particle" (particle which does not interact with materials). It moves along a polyline line or circle from one volume to another. The flying is represented by changing of class members representing particle position. Interacted particle should be derived class from this one.

Definition at line 156 of file gparticle.h.

Constructor & Destructor Documentation

◆ gparticle() [1/2]

Heed::gparticle::gparticle ( )
inline

Default constructor.

Definition at line 159 of file gparticle.h.

159: s_life(false), nstep(0) {}
long nstep
Step number.
Definition: gparticle.h:168

Referenced by copy().

◆ gparticle() [2/2]

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

Constructor.

Definition at line 43 of file gparticle.cpp.

45 : s_life(false),
46 nstep(0),
48 n_zero_step(0),
49 prevpos(),
50 nextpos() {
51 // As far as I can now understand, PassivePtr<primvol> will be at
52 // origin.tid.eid[0]
53 mfunname("gparticle::gparticle(...)");
54 primvol->m_find_embed_vol(pt, vel, &origin.tid);
55 origin.pt = pt;
56 if (vel == dv0) {
57 origin.dir = dv0;
58 origin.speed = 0.0;
59 } else {
60 origin.dir = unit_vec(vel);
61 origin.speed = vel.length();
62 }
67 origin.time = time;
68 origin.sb = 0;
69 origin.s_ent = 1;
70 if (origin.tid.eid.empty()) return;
71 s_life = true;
74 nextpos.s_ent = 0;
75}
#define mfunname(string)
Definition: FunNameStack.h:45
stvpoint prevpos
Definition: gparticle.h:176
stvpoint origin
Definition: gparticle.h:175
double total_range_from_origin
Range from origin to currpos.
Definition: gparticle.h:170
stvpoint currpos
Definition: gparticle.h:177
stvpoint nextpos
Definition: gparticle.h:178
long n_zero_step
Number of previous steps with zero range (including this step).
Definition: gparticle.h:172
void up_absref(absref *f)
Definition: volume.cpp:26
std::vector< PassivePtr< manip_absvol > > eid
List of volumes.
Definition: volume.h:37
vfloat time
Definition: gparticle.h:47
vec dirloc
Unit vector, in the local system (last system in the tree).
Definition: gparticle.h:29
vec dir
Unit vector, in the first system in the tree.
Definition: gparticle.h:25
vfloat speed
Longitudinal velocity.
Definition: gparticle.h:31
point pt
Coordinates in the first system in the tree.
Definition: gparticle.h:23
manip_absvol_treeid tid
Definition: gparticle.h:32
point ptloc
Coordinates in the local system (last system in the tree).
Definition: gparticle.h:27
vec dv0(0, 0, 0)
Definition: vec.h:314

◆ ~gparticle()

virtual Heed::gparticle::~gparticle ( )
inlinevirtual

Destructor.

Definition at line 164 of file gparticle.h.

164{}

Member Function Documentation

◆ calc_step_to_bord()

stvpoint Heed::gparticle::calc_step_to_bord ( )
virtual

Produces nextpos.

Definition at line 119 of file gparticle.cpp.

119 {
120 pvecerror("stvpoint gparticle::calc_step_to_bord()");
122 if (currpos.sb > 0) {
123 // it does not do step, but switch to new volume
124 return switch_new_vol();
125 }
126 int s_cf;
127 vec relcen;
128 vfloat mrange;
129 curvature(s_cf, relcen, mrange, gtrajlim.max_straight_arange);
130 curr_relcen = relcen;
131 if (mrange <= 0) {
132 // preserves currpos for modification by physics
133 stvpoint temp(currpos);
134 temp.s_ent = 0;
135 return temp;
136 }
137 currpos.tid.up_absref(&relcen); // changing to local system
138 physics_mrange(mrange);
139 trajestep ts(&gtrajlim, currpos.ptloc, currpos.dirloc, s_cf, relcen, mrange,
140 currpos.tid.eid.back()->Gavol()->prec);
141 if (ts.mrange <= 0) {
142 stvpoint temp(currpos);
143 temp.s_ent = 0;
144 return temp;
145 }
146 // Here the range is calculated:
147 int sb;
148 // manip_absvol_eid faeid;
149 PassivePtr<manip_absvol> faeid;
150 currpos.tid.G_lavol()->range(ts, 1, sb, faeid);
151 // 1 means inside the volume and makes
152 // the program checking embraced volumes
153 if (ts.s_prec == 0) {
154 // point is crossed
155 return stvpoint(currpos, ts, sb, 0, faeid);
156 }
157 return stvpoint(currpos, ts, ts.mrange, sb, 0, faeid);
158}
virtual int range(trajestep &fts, int s_ext, int &sb, PassivePtr< manip_absvol > &faeid) const
Definition: volume.cpp:98
virtual void physics_mrange(double &fmrange)
Definition: gparticle.cpp:116
virtual void curvature(int &fs_cf, vec &frelcen, vfloat &fmrange, vfloat prec)
Definition: gparticle.cpp:99
stvpoint switch_new_vol()
Definition: gparticle.cpp:160
absvol * G_lavol() const
Get last address of volume.
Definition: volume.cpp:17
vfloat max_straight_arange
Angle of range if it goes along straight line, but s_cf == 1.
Definition: trajestep.h:38
double vfloat
Definition: vfloat.h:16
trajestep_limit gtrajlim
Definition: TrackHeed.cc:50
#define pvecerror(string)
Definition: vec.h:29

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

◆ change_vol()

virtual void Heed::gparticle::change_vol ( void  )
inlinevirtual

Definition at line 194 of file gparticle.h.

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

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

◆ copy()

virtual gparticle * Heed::gparticle::copy ( ) const
inlinevirtual

Reimplemented from Heed::RegPassivePtr.

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

Definition at line 233 of file gparticle.h.

233{ return new gparticle(*this); }
gparticle()
Default constructor.
Definition: gparticle.h:159

◆ curvature()

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

Reimplemented in Heed::mparticle.

Definition at line 99 of file gparticle.cpp.

100 {
101 fs_cf = 0;
102 frelcen = vec(0, 0, 0);
103 fmrange = max_vfloat;
104 /* The following is for debug
105 vec field(0,1,0);
106 vfloat rad = 10;
107 if (length(currpos.dir) > 0 && check_par(currpos.dir, field) == 0) {
108 fs_cf = 1;
109 vfloat coef = sin2vec(currpos.dir, field);
110 rad = rad / coef;
111 frelcen = unit_vec(currpos.dir || field) * rad;
112 }
113 */
114}

Referenced by calc_step_to_bord().

◆ fly()

virtual void Heed::gparticle::fly ( std::vector< gparticle * > &  secondaries)
inlinevirtual

Transport the particle.

Definition at line 225 of file gparticle.h.

225 {
226 mfunname("virtual void gparticle::fly()");
227 while (s_life) {
228 step(secondaries);
229 physics(secondaries);
230 }
231 }
virtual void step(std::vector< gparticle * > &secondaries)
Definition: gparticle.cpp:77
virtual void physics(std::vector< gparticle * > &)
Definition: gparticle.h:210

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

◆ physics()

virtual void Heed::gparticle::physics ( std::vector< gparticle * > &  )
inlinevirtual

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

Definition at line 210 of file gparticle.h.

210{}

Referenced by fly().

◆ physics_after_new_speed()

virtual void Heed::gparticle::physics_after_new_speed ( std::vector< gparticle * > &  )
inlinevirtual

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

Definition at line 207 of file gparticle.h.

207{}

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

◆ physics_mrange()

void Heed::gparticle::physics_mrange ( double &  fmrange)
virtual

Reimplemented in Heed::HeedDeltaElectron.

Definition at line 116 of file gparticle.cpp.

116{}

Referenced by calc_step_to_bord().

◆ print()

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

Reimplemented from Heed::RegPassivePtr.

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

Definition at line 200 of file gparticle.cpp.

200 {
201 if (l < 0) return;
202 Ifile << "gparticle(l=" << l << "): s_life=" << s_life << " nstep=" << nstep
203 << " total_range_from_origin=" << total_range_from_origin
204 << " n_zero_step=" << n_zero_step << '\n';
205 if (l == 1) {
206 file.flush();
207 return;
208 }
209 indn.n += 2;
210 if (l - 5 >= 0) {
211 Ifile << "origin point:\n";
212 indn.n += 2;
213 origin.print(file, l - 2);
214 indn.n -= 2;
215 }
216 if (l - 4 >= 0) {
217 Ifile << "previous point:\n";
218 indn.n += 2;
219 prevpos.print(file, l - 1);
220 indn.n -= 2;
221 }
222 if (l - 2 >= 0) {
223 Ifile << "current point:\n";
224 indn.n += 2;
225 currpos.print(file, l);
226 Iprint(file, curr_relcen);
227 Ifile << " length(curr_relcen)=" << curr_relcen.length() << '\n';
228 indn.n -= 2;
229 }
230 if (l - 3 >= 0) {
231 Ifile << "next point:\n";
232 indn.n += 2;
233 nextpos.print(file, l - 1);
234 indn.n -= 2;
235 }
236 indn.n -= 2;
237 file.flush();
238}
void print(std::ostream &file, int l) const
Definition: gparticle.cpp:16
vfloat length() const
Definition: vec.h:205
indentation indn
Definition: prstream.cpp:15
#define Ifile
Definition: prstream.h:196
#define Iprint(file, name)
Definition: prstream.h:198

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

◆ step()

void Heed::gparticle::step ( std::vector< gparticle * > &  secondaries)
virtual

Assign prevpos = currpos and currpos = nextpos, calls change_vol if necessary and update nextpos =calc_step_to_bord().

Reimplemented in Heed::mparticle.

Definition at line 77 of file gparticle.cpp.

77 {
78 // Make step to nextpos and calculate new step to border
79 mfunname("void gparticle::step()");
84 nstep++;
85 if (currpos.prange == 0) {
88 "too much zero steps, possible infinite loop\n", mcerr);
89 } else {
90 n_zero_step = 0;
91 }
92 physics_after_new_speed(secondaries);
93 if (s_life) {
96 }
97}
#define check_econd12a(a, sign, b, add, stream)
Definition: FunNameStack.h:181
static long max_q_zero_step
Definition: gparticle.h:174
virtual void change_vol(void)
Definition: gparticle.h:194
virtual void physics_after_new_speed(std::vector< gparticle * > &)
Definition: gparticle.h:207
virtual stvpoint calc_step_to_bord()
Produces nextpos.
Definition: gparticle.cpp:119
vfloat prange
Range from previous point.
Definition: gparticle.h:46
#define mcerr
Definition: prstream.h:128

Referenced by fly().

◆ switch_new_vol()

stvpoint Heed::gparticle::switch_new_vol ( void  )

Definition at line 160 of file gparticle.cpp.

160 {
161 // generates next position in new volume
162 mfunname("stvpoint gparticle::switch_new_vol(void)");
163 manip_absvol_treeid tidl;
164 PassivePtr<manip_absvol> eidl;
165 stvpoint nextp = currpos;
166 point pth = nextp.pt;
167 // search from primary
168 // In this case it does not necessary switch to encountered volume
169 // namely nextp.next_eid
170 // Borders of two volumes may coincide. Thus it should look for
171 // the deepest volume at this point.
172 bool ok = false;
173 while (!ok) {
174 nextp.tid.eid[0]->m_find_embed_vol(pth, nextp.dir, &tidl);
175 if (tidl.eid.empty()) {
176 s_life = false;
177 break;
178 }
179 // By default, assume switching to new volume.
180 int s_e = 1;
181 if (tidl == nextp.tid) {
182 // Remains in the same old volume, may be numerical error
183 // Will probably repeat attempt to switch at the same steps until ok.
184 s_e = 0;
185 double curprec = nextp.tid.G_lavol()->prec;
186 if (currpos.prange <= curprec) {
187 // very bad case, to repeat the trial.
188 vec additional_dist = nextp.dir * curprec;
189 pth = pth + additional_dist;
190 tidl = manip_absvol_treeid();
191 continue;
192 }
193 }
194 return stvpoint(pth, nextp.dir, nextp.speed, tidl, 0.0, nextp.time, 0, s_e,
195 eidl);
196 }
197 return stvpoint();
198}

Referenced by calc_step_to_bord().

Member Data Documentation

◆ curr_relcen

vec Heed::gparticle::curr_relcen

Definition at line 181 of file gparticle.h.

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

◆ currpos

◆ max_q_zero_step

long Heed::gparticle::max_q_zero_step = 100
static

Definition at line 174 of file gparticle.h.

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

◆ n_zero_step

long Heed::gparticle::n_zero_step

Number of previous steps with zero range (including this step).

Definition at line 172 of file gparticle.h.

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

◆ nextpos

stvpoint Heed::gparticle::nextpos

Definition at line 178 of file gparticle.h.

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

◆ nstep

long Heed::gparticle::nstep

Step number.

Definition at line 168 of file gparticle.h.

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

◆ origin

stvpoint Heed::gparticle::origin

◆ prevpos

◆ s_life

◆ total_range_from_origin

double Heed::gparticle::total_range_from_origin

Range from origin to currpos.

Definition at line 170 of file gparticle.h.

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


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