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

#include <surface.h>

+ Inheritance diagram for Heed::splane:

Public Member Functions

 splane ()
 Default constructor.
 
 splane (const splane &fsp)
 
 splane (const plane &fpn, const vec &fdir_ins)
 
virtual ~splane ()
 Destructor.
 
int check_point_inside (const point &fpt, const vec &dir, vfloat fprec) const override
 
int check_point_inside1 (const point &fpt, int s_ext, vfloat fprec) const override
 
int range (const trajestep &fts, vfloat *crange, point *cpt, int *s_ext) const override
 
int cross (const polyline &fpl, point *cntrpt, int &qcntrpt, vfloat prec) const override
 
void print (std::ostream &file, int l) const override
 
splanecopy () const override
 
- Public Member Functions inherited from Heed::surface
virtual surfacecopy () const =0
 
virtual ~surface ()
 
virtual int check_point_inside (const point &fpt, const vec &dir, vfloat fprec) const =0
 
virtual int check_point_inside1 (const point &fpt, int s_ext, vfloat fprec) const =0
 
virtual int range (const trajestep &fts, vfloat *crange, point *cpt, int *s_ext) const =0
 
virtual int cross (const polyline &fpl, point *cntrpt, int &qcntrpt, vfloat prec) const =0
 
virtual void print (std::ostream &file, int l) const =0
 
- Public Member Functions inherited from Heed::absref
virtual ~absref ()
 Destructor.
 
virtual void down (const abssyscoor *fasc)
 Convert numbering representation of object to basical system of fasc.
 
virtual void up (const abssyscoor *fasc)
 Convert numbering representation of objects to new system.
 
virtual void turn (const vec &dir, vfloat angle)
 Turn around axis doing via center of coordinate system along dir.
 
virtual void shift (const vec &dir)
 

Public Attributes

plane pn
 
vec dir_ins
 

Protected Member Functions

absref_transmit get_components () override
 

Static Protected Attributes

static absref absref::* aref_splane [2]
 

Detailed Description

Definition at line 68 of file surface.h.

Constructor & Destructor Documentation

◆ splane() [1/3]

Heed::splane::splane ( )
inline

Default constructor.

Definition at line 78 of file surface.h.

78: pn() {}
plane pn
Definition: surface.h:70

Referenced by copy().

◆ splane() [2/3]

Heed::splane::splane ( const splane fsp)
inline

Definition at line 79 of file surface.h.

79: surface(fsp), pn(fsp.pn), dir_ins(fsp.dir_ins) {}
vec dir_ins
Definition: surface.h:71

◆ splane() [3/3]

Heed::splane::splane ( const plane fpn,
const vec fdir_ins 
)
inline

Definition at line 80 of file surface.h.

81 : pn(fpn), dir_ins(unit_vec(fdir_ins)) {}

◆ ~splane()

virtual Heed::splane::~splane ( )
inlinevirtual

Destructor.

Definition at line 83 of file surface.h.

83{}

Member Function Documentation

◆ check_point_inside()

int Heed::splane::check_point_inside ( const point fpt,
const vec dir,
vfloat  fprec 
) const
overridevirtual

Implements Heed::surface.

Definition at line 25 of file surface.cpp.

26 {
27 mfunname("int splane::check_point_inside(const point&, const vec&, vfloat)");
28 if (dir == dv0) {
29 // this is not useful
30 if (fpt == pn.Gpiv()) return 1;
31 vec v = fpt - pn.Gpiv();
32 if (cos2vec(dir_ins, v) >= -vprecision) return 1;
33 return 0;
34 }
35 if (pn.check_point_in(fpt, fprec) == 1) {
36 vfloat ca = cos2vec(dir, dir_ins);
37 if (ca < 0) return 0;
38 return 1;
39 }
40 vec v = fpt - pn.Gpiv();
41 if (cos2vec(dir_ins, v) >= 0) return 1;
42 return 0;
43}
#define mfunname(string)
Definition: FunNameStack.h:45
point Gpiv() const
Definition: plane.h:32
int check_point_in(const point &fp, vfloat prec) const
Return 1 if a point is in the plane (within precision prec).
Definition: plane.cpp:68
vec dv0(0, 0, 0)
Definition: vec.h:308
vfloat cos2vec(const vec &r1, const vec &r2)
Definition: vec.cpp:66
const vfloat vprecision
Definition: vfloat.h:17
double vfloat
Definition: vfloat.h:16

◆ check_point_inside1()

int Heed::splane::check_point_inside1 ( const point fpt,
int  s_ext,
vfloat  fprec 
) const
overridevirtual

Implements Heed::surface.

Definition at line 45 of file surface.cpp.

46 {
47 if (pn.check_point_in(fpt, fprec) == 1) {
48 if (s_ext == 1) return 0;
49 return 1;
50 }
51 vec v = fpt - pn.Gpiv();
52 if (cos2vec(dir_ins, v) > 0) return 1;
53 return 0;
54}

◆ copy()

splane * Heed::splane::copy ( ) const
inlineoverridevirtual

Implements Heed::surface.

Definition at line 118 of file surface.h.

118{ return new splane(*this); }
splane()
Default constructor.
Definition: surface.h:78

◆ cross()

int Heed::splane::cross ( const polyline fpl,
point cntrpt,
int &  qcntrpt,
vfloat  prec 
) const
inlineoverridevirtual

Implements Heed::surface.

Definition at line 109 of file surface.h.

110 {
111 polyline* plh = new polyline[fpl.Gqsl()];
112 int qplh;
113 int i = pn.cross(fpl, cntrpt, qcntrpt, plh, qplh, prec);
114 delete[] plh;
115 return i;
116 }
point cross(const straight &sl) const
Definition: plane.cpp:75

◆ get_components()

absref_transmit Heed::splane::get_components ( )
overrideprotectedvirtual

Reimplemented from Heed::absref.

Definition at line 21 of file surface.cpp.

21 {
22 return absref_transmit(2, aref_splane);
23}
static absref absref::* aref_splane[2]
Definition: surface.h:74

◆ print()

void Heed::splane::print ( std::ostream &  file,
int  l 
) const
overridevirtual

Implements Heed::surface.

Definition at line 176 of file surface.cpp.

176 {
177 if (l > 0) {
178 Ifile << "splane:\n";
179 indn.n += 2;
180 file << pn;
181 Ifile << "dir_ins: " << noindent << dir_ins << '\n';
182 indn.n -= 2;
183 }
184}
std::ostream & noindent(std::ostream &f)
Definition: prstream.cpp:17
indentation indn
Definition: prstream.cpp:15
#define Ifile
Definition: prstream.h:195

◆ range()

int Heed::splane::range ( const trajestep fts,
vfloat crange,
point cpt,
int *  s_ext 
) const
overridevirtual

Implements Heed::surface.

Definition at line 56 of file surface.cpp.

57 {
58 mfunname("int splane::range(...)");
59 if (fts.s_range_cf == 0) {
60 // straight line
61 point pt = pn.cross(straight(fts.currpos, fts.dir));
62 if (vecerror != 0) {
63 vecerror = 0;
64 return 0;
65 }
66 vfloat rng = (pt - fts.currpos).length();
67 if (pt == fts.currpos || check_par(pt - fts.currpos, fts.dir, 0.01) == 1) {
68 // looks like not matter ^
69 // otherwise the point is behind plane
70 if (fts.mrange >= rng) {
71 // otherwise it can not reach the plane
72 cpt[0] = pt;
73 crange[0] = rng;
74 vfloat t = cos2vec(fts.dir, dir_ins);
75 if (t < 0)
76 s_ext[0] = 1;
77 else if (t > 0)
78 s_ext[0] = 0;
79 else
80 s_ext[0] = 2;
81 return 1;
82 }
83 return 0;
84 } else
85 return 0;
86 } else {
87 point pt[2];
88 circumf cf(fts.currpos + fts.relcen,
89 fts.dir || fts.relcen, // if to us, moving against clock
90 fts.relcen.length());
91 int q = cf.cross(pn, pt, 0.0);
92 if (q == -1) {
93 // total circle lies in the plane
94 cpt[0] = fts.currpos;
95 crange[0] = 0.0;
96 s_ext[0] = 2;
97 return 1;
98 }
99 if (q == 0) return 0;
100 if (q == 1) {
101 vec r1 = -fts.relcen;
102 vec r2 = pt[0] - cf.Gpiv();
103 vfloat angle = ang2projvec(r1, r2, cf.Gdir());
104 vfloat rng = cf.Grad() * angle;
105 if (fts.mrange >= rng) {
106 cpt[0] = pt[0];
107 crange[0] = rng;
108 vfloat c = cos2vec(dir_ins, fts.relcen);
109 if (angle == 0.0) {
110 // cross in the current point
111 if (c > 0)
112 s_ext[0] = 0;
113 else if (c < 0)
114 s_ext[0] = 1;
115 else
116 s_ext[0] = 2;
117 } else {
118 if (c > 0)
119 s_ext[0] = 1;
120 else if (c < 0)
121 s_ext[0] = 0;
122 else
123 s_ext[0] = 2;
124 }
125 return 1;
126 } else
127 return 0;
128 }
129 if (q == 2) {
130 int qq = 0;
131 vec r = -fts.relcen;
132 vec vcr[2];
133 vcr[0] = pt[0] - cf.Gpiv();
134 vcr[1] = pt[1] - cf.Gpiv();
135 vfloat angle[2];
136 angle[0] = ang2projvec(r, vcr[0], cf.Gdir());
137 angle[1] = ang2projvec(r, vcr[1], cf.Gdir());
138 if (angle[0] > angle[1]) { // ordering
139 vfloat a = angle[0];
140 angle[0] = angle[1];
141 angle[1] = a;
142 point p = pt[0];
143 pt[0] = pt[1];
144 pt[1] = p;
145 }
146 vfloat rng;
147 rng = cf.Grad() * angle[0];
148 if (fts.mrange >= rng) {
149 // find out what the first point means
150 int ins = 0; // 1 if the point inside and exits
151 vec td = fts.dir;
152 td.turn(cf.Gdir(), angle[0]); // local dir in the crossing point
153 vfloat t = cos2vec(td, dir_ins);
154 if (t < 0)
155 ins = 1; // means the point was inside and now exiting
156 else
157 ins = 0;
158 cpt[0] = pt[0];
159 crange[0] = rng;
160 s_ext[0] = ins;
161 qq++;
162 rng = cf.Grad() * angle[1];
163 if (fts.mrange >= rng) {
164 cpt[1] = pt[1];
165 crange[1] = rng;
166 s_ext[1] = (ins == 0 ? 1 : 0);
167 qq++;
168 }
169 }
170 return qq;
171 }
172 }
173 return 0;
174}
double cf[nMaxLevels][nEnergySteps]
vfloat ang2projvec(const vec &r1, const vec &r2, const vec &normal)
Definition: vec.cpp:136
int vecerror
Definition: vec.cpp:29

Member Data Documentation

◆ aref_splane

absref absref::* Heed::splane::aref_splane
staticprotected
Initial value:
= {(absref absref::*)&splane::pn,
(absref absref::*)&splane::dir_ins}

Definition at line 74 of file surface.h.

Referenced by get_components().

◆ dir_ins

vec Heed::splane::dir_ins

Definition at line 71 of file surface.h.

Referenced by check_point_inside(), check_point_inside1(), print(), and range().

◆ pn

plane Heed::splane::pn

Definition at line 70 of file surface.h.

Referenced by check_point_inside(), check_point_inside1(), cross(), print(), and range().


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