Garfield++ v2r0
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 ()
 
virtual int check_point_inside (const point &fpt, const vec &dir) const
 
virtual int range_ext (trajestep &fts, int s_ext) const
 Range till exit from given volume or to entry only.
 
virtual void income (gparticle *gp)
 
virtual void chname (char *nm) const
 
virtual void print (std::ostream &file, int l) const
 
virtual boxcopy () const
 
- 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, PassivePtr< 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 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

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

virtual void get_components (ActivePtr< absref_transmit > &aref_tran)
 

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

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 24 of file box.cpp.

25 : m_dx(0), m_dy(0), m_dz(0), m_dxh(0), m_dyh(0), m_dzh(0), m_name("none") {
26 mfunname("box::box()");
27 init_prec();
29}
#define mfunname(string)
Definition: FunNameStack.h:45
void init_planes()
Definition: box.cpp:89
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:84
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 31 of file box.cpp.

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

◆ 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 44 of file box.cpp.

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

◆ box() [4/5]

Heed::box::box ( box fb)

Definition at line 58 of file box.cpp.

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

◆ box() [5/5]

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

Definition at line 71 of file box.cpp.

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

◆ ~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
virtual

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 103 of file box.cpp.

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

◆ chname()

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

Reimplemented from Heed::absvol.

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

Definition at line 259 of file box.cpp.

259 {
260 strcpy(nm, "box: ");
261 strcat(nm, m_name.c_str());
262}

Referenced by print().

◆ copy()

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

Reimplemented from Heed::absvol.

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

Definition at line 256 of file box.cpp.

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

◆ get_components()

void Heed::box::get_components ( ActivePtr< absref_transmit > &  aref_tran)
protectedvirtual

Reimplemented from Heed::absref.

Reimplemented in Heed::sh_manip_box, and Garfield::HeedChamber.

Definition at line 16 of file box.cpp.

16 {
17 mfunnamep("box::get_components(...)");
18 funnw.ehdr(mcerr);
19 mcerr << "one should not call this function, since this object cannot be "
20 "modified\n";
22}
#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)
virtual

Reimplemented from Heed::absvol.

Definition at line 258 of file box.cpp.

258{}

◆ init_planes()

void Heed::box::init_planes ( )

Definition at line 89 of file box.cpp.

89 {
90 mfunname("void box::init_planes()");
91 splane spl[6];
92 spl[0] = splane(plane(point(m_dxh, 0, 0), vec(-1, 0, 0)), vec(-1, 0, 0));
93 spl[1] = splane(plane(point(-m_dxh, 0, 0), vec(+1, 0, 0)), vec(+1, 0, 0));
94 spl[2] = splane(plane(point(0, m_dyh, 0), vec(0, -1, 0)), vec(0, -1, 0));
95 spl[3] = splane(plane(point(0, -m_dyh, 0), vec(0, +1, 0)), vec(0, +1, 0));
96 spl[4] = splane(plane(point(0, 0, m_dzh), vec(0, 0, -1)), vec(0, 0, -1));
97 spl[5] = splane(plane(point(0, 0, -m_dzh), vec(0, 0, +1)), vec(0, 0, +1));
98 surface* fsurf[6];
99 for (int n = 0; n < 6; ++n) fsurf[n] = &spl[n];
100 m_ulsv.ulsvolume_init(fsurf, 6, "ulsv of box", prec);
101}
ulsvolume m_ulsv
Definition: box.h:29
void ulsvolume_init(surface *fsurf[pqqsurf], int fqsurf, const std::string &fname, vfloat fprec)
Definition: surface.cpp:339

Referenced by box().

◆ init_prec()

void Heed::box::init_prec ( )

Definition at line 84 of file box.cpp.

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

Referenced by box().

◆ print()

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

Reimplemented from Heed::absvol.

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

Definition at line 221 of file box.cpp.

221 {
222 if (l <= 0) return;
223 char s[1000];
224 chname(s);
225 Ifile << "box::print(l=" << l << "): " << s << '\n';
226 indn.n += 2;
227 Ifile << " dx=" << m_dx << " dy=" << m_dy << " dz=" << m_dz
228 << " prec=" << prec << '\n';
229 Ifile << " dxh=" << m_dxh << " dyh=" << m_dyh << " dzh=" << m_dzh << '\n';
230 if (l >= 10) {
231 l--;
232 indn.n += 2;
233 m_ulsv.print(file, l);
234 indn.n -= 2;
235 }
236 absvol::print(file, l);
237 indn.n -= 2;
238}
virtual void print(std::ostream &file, int l) const
Definition: volume.cpp:118
virtual void chname(char *nm) const
Definition: box.cpp:259
virtual void print(std::ostream &file, int l) const
Definition: surface.cpp:377
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
virtual

Range till exit from given volume or to entry only.

Implements Heed::absvol.

Definition at line 240 of file box.cpp.

240 {
241 mfunname("virtual int box::range_ext(trajestep& fts, int s_ext) const");
242 if (s_ext == 0) {
243 if (fabs(fts.currpos.v.x) > m_dxh + fts.mrange) return 0;
244 if (fabs(fts.currpos.v.y) > m_dyh + fts.mrange) return 0;
245 if (fabs(fts.currpos.v.z) > m_dzh + fts.mrange) return 0;
246 } else {
247 if (fabs(fts.currpos.v.x) < m_dxh - fts.mrange &&
248 fabs(fts.currpos.v.y) < m_dyh - fts.mrange &&
249 fabs(fts.currpos.v.z) < m_dzh - fts.mrange) {
250 return 0;
251 }
252 }
253 return m_ulsv.range_ext(fts, s_ext);
254}
int range_ext(trajestep &fts, int s_ext) const
Definition: surface.cpp:212

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: