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

#include <box.h>

+ Inheritance diagram for Heed::box:

Public Member Functions

 box ()
 Default constructor.
 
 box (vfloat fdx, vfloat fdy, vfloat fdz, const std::string &fname)
 
 box (vfloat fdx, vfloat fdy, vfloat fdz, vfloat fprec, const std::string &fname)
 Constructor with user-provided precision.
 
 box (box &fb)
 
 box (const box &fb)
 
virtual ~box ()
 Destructor.
 
void init_prec ()
 
void init_planes ()
 
int check_point_inside (const point &fpt, const vec &dir) const override
 
int range_ext (trajestep &fts, int s_ext) const override
 Range till exit from given volume or to entry only.
 
void income (gparticle *gp) override
 
void chname (char *nm) const override
 
void print (std::ostream &file, int l) const override
 
boxcopy () const override
 
- Public Member Functions inherited from Heed::absvol
virtual ~absvol ()
 Destructor.
 
virtual int check_point_inside (const point &fpt, const vec &dir) const =0
 
virtual int find_embed_vol (const point &fpt, const vec &dir, manip_absvol_treeid *atid) const
 
virtual int range (trajestep &fts, int s_ext, int &sb, manip_absvol *&faeid) const
 
virtual int range_ext (trajestep &fts, int s_ext) const =0
 
virtual void income (gparticle *)
 
virtual void chname (char *nm) const
 
virtual void print (std::ostream &file, int l) const
 
virtual absvolcopy () const
 
virtual std::vector< manip_absvol * > Gamanip_embed () const
 
- 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

vfloat m_dx
 
vfloat m_dy
 
vfloat m_dz
 Lengths of sides.
 
vfloat m_dxh
 
vfloat m_dyh
 
vfloat m_dzh
 Half-lengths of sides.
 
ulsvolume m_ulsv
 
std::string m_name
 
- Public Attributes inherited from Heed::absvol
vfloat prec
 
bool s_sensitive
 

Protected Member Functions

absref_transmit get_components () override
 

Detailed Description

Box (three-dimensional rectangle/rectangular parallelogram). The box is centred with respect to the centre of the coordinate system.

Definition at line 25 of file box.h.

Constructor & Destructor Documentation

◆ box() [1/5]

Heed::box::box ( )

Default constructor.

Definition at line 26 of file box.cpp.

27 : m_dx(0), m_dy(0), m_dz(0), m_dxh(0), m_dyh(0), m_dzh(0), m_name("none") {
28 mfunname("box::box()");
29 init_prec();
31}
#define mfunname(string)
Definition: FunNameStack.h:45
void init_planes()
Definition: box.cpp:91
std::string m_name
Definition: box.h:30
vfloat m_dx
Definition: box.h:27
vfloat m_dy
Definition: box.h:27
vfloat m_dxh
Definition: box.h:28
vfloat m_dz
Lengths of sides.
Definition: box.h:27
vfloat m_dyh
Definition: box.h:28
void init_prec()
Definition: box.cpp:86
vfloat m_dzh
Half-lengths of sides.
Definition: box.h:28

Referenced by copy().

◆ box() [2/5]

Heed::box::box ( vfloat  fdx,
vfloat  fdy,
vfloat  fdz,
const std::string &  fname 
)

Definition at line 33 of file box.cpp.

33 {
34 pvecerror("box(vfloat fdx, vfloat fdy, vfloat fdz, const string &fname)");
35 m_dx = fabs(fdx);
36 m_dy = fabs(fdy);
37 m_dz = fabs(fdz);
38 m_dxh = 0.5 * m_dx;
39 m_dyh = 0.5 * m_dy;
40 m_dzh = 0.5 * m_dz;
41 m_name = fname;
42 init_prec();
44}
DoubleAc fabs(const DoubleAc &f)
Definition: DoubleAc.h:615
#define pvecerror(string)
Definition: vec.h:28

◆ box() [3/5]

Heed::box::box ( vfloat  fdx,
vfloat  fdy,
vfloat  fdz,
vfloat  fprec,
const std::string &  fname 
)

Constructor with user-provided precision.

Definition at line 46 of file box.cpp.

47 {
48 pvecerror("box(vfloat fdx, vfloat fdy, vfloat fdz, vfloat fprec, const string &fname)");
49 m_dx = fabs(fdx);
50 m_dy = fabs(fdy);
51 m_dz = fabs(fdz);
52 m_dxh = 0.5 * m_dx;
53 m_dyh = 0.5 * m_dy;
54 m_dzh = 0.5 * m_dz;
55 m_name = fname;
56 prec = fprec;
58}
vfloat prec
Definition: volume.h:72

◆ box() [4/5]

Heed::box::box ( box fb)

Definition at line 60 of file box.cpp.

60 : absref(fb), absvol(fb) {
61 pvecerror("box(box& fb)");
62 m_dx = fb.m_dx;
63 m_dy = fb.m_dy;
64 m_dz = fb.m_dz;
65 m_dxh = 0.5 * m_dx;
66 m_dyh = 0.5 * m_dy;
67 m_dzh = 0.5 * m_dz;
68 prec = fb.prec;
69 m_name = fb.m_name;
71}

◆ box() [5/5]

Heed::box::box ( const box fb)

Definition at line 73 of file box.cpp.

73 : absref(fb), absvol(fb) {
74 pvecerror("box(const box& fb)");
75 m_dx = fb.m_dx;
76 m_dy = fb.m_dy;
77 m_dz = fb.m_dz;
78 m_dxh = 0.5 * m_dx;
79 m_dyh = 0.5 * m_dy;
80 m_dzh = 0.5 * m_dz;
81 m_name = fb.m_name;
82 prec = fb.prec;
84}

◆ ~box()

virtual Heed::box::~box ( )
inlinevirtual

Destructor.

Definition at line 43 of file box.h.

43{}

Member Function Documentation

◆ check_point_inside()

int Heed::box::check_point_inside ( const point fpt,
const vec dir 
) const
overridevirtual

Check if a point is inside the volume. If two volumes are adjacent, it may happen that a point belongs to both. To avoid this confusion the parameter dir is used. If dir == (0, 0, 0), and the point is exactly on the border, the behaviour is in general not specified. If dir != (0, 0, 0), and the point is on the border with precision prec, the exiting volume is ignored.

Implements Heed::absvol.

Definition at line 109 of file box.cpp.

109 {
110 mfunname("virtual int check_point_inside(const point& fpt, const vec& dir)");
111#ifdef TRACE_find_embed_vol
112 mcout << "box::check_point_inside: \n";
113 print(mcout, 1);
114 mcout << "fpt=" << fpt << "dir=" << dir;
115#endif
116 if (dir == dv0) {
117 if (fabs(fpt.v.x) <= m_dxh && fabs(fpt.v.y) <= m_dyh &&
118 fabs(fpt.v.z) <= m_dzh) {
119 return 1;
120 }
121 return 0;
122 } else {
123 if (fabs(fpt.v.x) <= m_dxh - prec && fabs(fpt.v.y) <= m_dyh - prec &&
124 fabs(fpt.v.z) <= m_dzh - prec) {
125#ifdef TRACE_find_embed_vol
126 mcout << "cond 1, returning 1\n";
127#endif
128 return 1;
129 }
130 if (fabs(fpt.v.x) > m_dxh + prec || fabs(fpt.v.y) > m_dyh + prec ||
131 fabs(fpt.v.z) > m_dzh + prec) {
132#ifdef TRACE_find_embed_vol
133 if (fabs(fpt.v.x) > m_dxh + prec) mcout << "cond 2.1 satisfied\n";
134 if (fabs(fpt.v.y) > m_dyh + prec) mcout << "cond 2.2 satisfied\n";
135 if (fabs(fpt.v.z) > m_dzh + prec) mcout << "cond 2.3 satisfied\n";
136 mcout << "cond 2, returning 0\n";
137#endif
138 return 0;
139 }
140// What remains is point belonging to border
141#ifdef IMPROVED_BOUNDARY
142 // Below we detect cases when particle is exiting, leaving the
143 // case when it is entering
144 if (fabs(fpt.v.x) > m_dxh - prec) {
145 if (dir.x == 0.0) return 0;
146 if ((fpt.v.x > 0 && dir.x > 0) || (fpt.v.x < 0 && dir.x < 0)) {
147#ifdef TRACE_find_embed_vol
148 mcout << "cond 3, returning 0\n";
149#endif
150 return 0;
151 }
152 }
153 if (fabs(fpt.v.y) > m_dyh - prec) {
154 if (dir.y == 0.0) return 0;
155 if ((fpt.v.y > 0 && dir.y > 0) || (fpt.v.y < 0 && dir.y < 0)) {
156#ifdef TRACE_find_embed_vol
157 mcout << "cond 4, returning 0\n";
158#endif
159 return 0;
160 }
161 }
162 if (fabs(fpt.v.z) > m_dzh - prec) {
163 if (dir.z == 0.0) return 0;
164 if ((fpt.v.z > 0 && dir.z > 0) || (fpt.v.z < 0 && dir.z < 0)) {
165#ifdef TRACE_find_embed_vol
166 mcout << "cond 5, returning 0\n";
167#endif
168 return 0;
169 }
170 }
171#ifdef TRACE_find_embed_vol
172 mcout << "finish, returning 1\n";
173#endif
174 return 1;
175
176#else
177 // for IMPROVED_BOUNDARY
178 // In the old version, which is below,
179 // if the track is parallel to a boundary, it was interpreted as
180 // signature of being inside volume.
181 // The general principal, saying that
182 // if particle is located at the boundary and headed
183 // outside the volume,
184 // it is considered in the volume to which it is headed,
185 // cannot help to choose between two versions.
186 // Of course, the box is convex and the particle flying along the border
187 // enters the external space sooner or later and it can be regarded as
188 // already outside. But the same can be said about the particle,
189 // which is completely indise the volume.
190 // So this principle does not work here.
191 // The other principle should be applied.
192 // If we allow the absolutely thing volumes (control surfaces)
193 // we should use the algorithm, which, in particular stops the particle
194 // crossing exactly the corner of volume without entering its inside.
195 // But this does not allow to choose. So now the old (this) variant
196 // is used, untill other arguments appear.
197
198 if (fabs(fpt.v.x) > m_dxh - prec &&
199 ((fpt.v.x > 0 && dir.x > 0) || (fpt.v.x < 0 && dir.x < 0))) {
200#ifdef TRACE_find_embed_vol
201 mcout << "cond 3, returning 0\n";
202#endif
203 return 0; // exiting
204 }
205 if (fabs(fpt.v.y) > m_dyh - prec &&
206 ((fpt.v.y > 0 && dir.y > 0) || (fpt.v.y < 0 && dir.y < 0))) {
207#ifdef TRACE_find_embed_vol
208 mcout << "cond 4, returning 0\n";
209#endif
210 return 0;
211 }
212 if (fabs(fpt.v.z) > m_dzh - prec &&
213 ((fpt.v.z > 0 && dir.z > 0) || (fpt.v.z < 0 && dir.z < 0))) {
214#ifdef TRACE_find_embed_vol
215 mcout << "cond 5, returning 0\n";
216#endif
217 return 0;
218 }
219#ifdef TRACE_find_embed_vol
220 mcout << "finish, returning 1\n";
221#endif
222 return 1;
223#endif
224 }
225}
void print(std::ostream &file, int l) const override
Definition: box.cpp:227
vec dv0(0, 0, 0)
Definition: vec.h:306
#define mcout
Definition: prstream.h:126

◆ chname()

void Heed::box::chname ( char *  nm) const
overridevirtual

Reimplemented from Heed::absvol.

Reimplemented in Heed::manip_box, and Heed::sh_manip_box.

Definition at line 265 of file box.cpp.

265 {
266 strcpy(nm, "box: ");
267 strcat(nm, m_name.c_str());
268}

Referenced by print().

◆ copy()

box * Heed::box::copy ( ) const
overridevirtual

Reimplemented from Heed::absvol.

Reimplemented in Heed::manip_box, and Heed::sh_manip_box.

Definition at line 262 of file box.cpp.

262{ return new box(*this); }
box()
Default constructor.
Definition: box.cpp:26

◆ get_components()

absref_transmit Heed::box::get_components ( )
overrideprotectedvirtual

Reimplemented from Heed::absref.

Reimplemented in Heed::sh_manip_box.

Definition at line 17 of file box.cpp.

17 {
18 mfunnamep("box::get_components(...)");
19 funnw.ehdr(mcerr);
20 mcerr << "one should not call this function, since this object cannot be "
21 "modified\n";
23 return absref_transmit();
24}
#define mfunnamep(string)
Definition: FunNameStack.h:49
#define spexit(stream)
Definition: FunNameStack.h:256
#define mcerr
Definition: prstream.h:128

◆ income()

void Heed::box::income ( gparticle gp)
overridevirtual

Reimplemented from Heed::absvol.

Definition at line 264 of file box.cpp.

264{}

◆ init_planes()

void Heed::box::init_planes ( )

Definition at line 91 of file box.cpp.

91 {
92 mfunname("void box::init_planes()");
93 std::vector<std::shared_ptr<surface> > fsurf(6);
94 fsurf[0] = std::make_shared<splane>(
95 plane(point(m_dxh, 0, 0), vec(-1, 0, 0)), vec(-1, 0, 0));
96 fsurf[1] = std::make_shared<splane>(
97 plane(point(-m_dxh, 0, 0), vec(+1, 0, 0)), vec(+1, 0, 0));
98 fsurf[2] = std::make_shared<splane>(
99 plane(point(0, m_dyh, 0), vec(0, -1, 0)), vec(0, -1, 0));
100 fsurf[3] = std::make_shared<splane>(
101 plane(point(0, -m_dyh, 0), vec(0, +1, 0)), vec(0, +1, 0));
102 fsurf[4] = std::make_shared<splane>(
103 plane(point(0, 0, m_dzh), vec(0, 0, -1)), vec(0, 0, -1));
104 fsurf[5] = std::make_shared<splane>(
105 plane(point(0, 0, -m_dzh), vec(0, 0, +1)), vec(0, 0, +1));
106 m_ulsv.ulsvolume_init(fsurf, "ulsv of box", prec);
107}
ulsvolume m_ulsv
Definition: box.h:29
void ulsvolume_init(const std::vector< std::shared_ptr< surface > > &fsurf, const std::string &fname, vfloat fprec)
Definition: surface.cpp:334

Referenced by box().

◆ init_prec()

void Heed::box::init_prec ( )

Definition at line 86 of file box.cpp.

86 {
87 prec = (m_dxh + m_dyh + m_dzh) / 3.0;
89}
const vfloat vprecision
Definition: vfloat.h:17

Referenced by box().

◆ print()

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

Reimplemented from Heed::absvol.

Reimplemented in Heed::manip_box, and Heed::sh_manip_box.

Definition at line 227 of file box.cpp.

227 {
228 if (l <= 0) return;
229 char s[1000];
230 chname(s);
231 Ifile << "box::print(l=" << l << "): " << s << '\n';
232 indn.n += 2;
233 Ifile << " dx=" << m_dx << " dy=" << m_dy << " dz=" << m_dz
234 << " prec=" << prec << '\n';
235 Ifile << " dxh=" << m_dxh << " dyh=" << m_dyh << " dzh=" << m_dzh << '\n';
236 if (l >= 10) {
237 l--;
238 indn.n += 2;
239 m_ulsv.print(file, l);
240 indn.n -= 2;
241 }
242 absvol::print(file, l);
243 indn.n -= 2;
244}
virtual void print(std::ostream &file, int l) const
Definition: volume.cpp:119
void chname(char *nm) const override
Definition: box.cpp:265
void print(std::ostream &file, int l) const override
Definition: surface.cpp:372
indentation indn
Definition: prstream.cpp:15
#define Ifile
Definition: prstream.h:196

Referenced by check_point_inside(), Heed::manip_box::print(), and Heed::sh_manip_box::print().

◆ range_ext()

int Heed::box::range_ext ( trajestep fts,
int  s_ext 
) const
overridevirtual

Range till exit from given volume or to entry only.

Implements Heed::absvol.

Definition at line 246 of file box.cpp.

246 {
247 mfunname("virtual int box::range_ext(trajestep& fts, int s_ext) const");
248 if (s_ext == 0) {
249 if (fabs(fts.currpos.v.x) > m_dxh + fts.mrange) return 0;
250 if (fabs(fts.currpos.v.y) > m_dyh + fts.mrange) return 0;
251 if (fabs(fts.currpos.v.z) > m_dzh + fts.mrange) return 0;
252 } else {
253 if (fabs(fts.currpos.v.x) < m_dxh - fts.mrange &&
254 fabs(fts.currpos.v.y) < m_dyh - fts.mrange &&
255 fabs(fts.currpos.v.z) < m_dzh - fts.mrange) {
256 return 0;
257 }
258 }
259 return m_ulsv.range_ext(fts, s_ext);
260}
int range_ext(trajestep &fts, int s_ext) const override
Definition: surface.cpp:210

Member Data Documentation

◆ m_dx

vfloat Heed::box::m_dx

Definition at line 27 of file box.h.

Referenced by box(), and print().

◆ m_dxh

vfloat Heed::box::m_dxh

Definition at line 28 of file box.h.

Referenced by box(), check_point_inside(), init_planes(), init_prec(), print(), and range_ext().

◆ m_dy

vfloat Heed::box::m_dy

Definition at line 27 of file box.h.

Referenced by box(), and print().

◆ m_dyh

vfloat Heed::box::m_dyh

Definition at line 28 of file box.h.

Referenced by box(), check_point_inside(), init_planes(), init_prec(), print(), and range_ext().

◆ m_dz

vfloat Heed::box::m_dz

Lengths of sides.

Definition at line 27 of file box.h.

Referenced by box(), and print().

◆ m_dzh

vfloat Heed::box::m_dzh

Half-lengths of sides.

Definition at line 28 of file box.h.

Referenced by box(), check_point_inside(), init_planes(), init_prec(), print(), and range_ext().

◆ m_name

std::string Heed::box::m_name

Definition at line 30 of file box.h.

Referenced by box(), chname(), Heed::manip_box::chname(), and Heed::sh_manip_box::chname().

◆ m_ulsv

ulsvolume Heed::box::m_ulsv

Definition at line 29 of file box.h.

Referenced by init_planes(), print(), and range_ext().


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