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

28 : m_dx(0), m_dy(0), m_dz(0), m_dxh(0), m_dyh(0), m_dzh(0), m_name("none") {
29 mfunname("box::box()");
30 init_prec();
32}
#define mfunname(string)
Definition: FunNameStack.h:45
void init_planes()
Definition: box.cpp:92
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:87
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 34 of file box.cpp.

34 {
35 pvecerror("box(vfloat fdx, vfloat fdy, vfloat fdz, const string &fname)");
36 m_dx = fabs(fdx);
37 m_dy = fabs(fdy);
38 m_dz = fabs(fdz);
39 m_dxh = 0.5 * m_dx;
40 m_dyh = 0.5 * m_dy;
41 m_dzh = 0.5 * m_dz;
42 m_name = fname;
43 init_prec();
45}
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 47 of file box.cpp.

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

◆ box() [4/5]

Heed::box::box ( box fb)

Definition at line 61 of file box.cpp.

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

◆ box() [5/5]

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

Definition at line 74 of file box.cpp.

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

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

110 {
111 mfunname("int check_point_inside(const point& fpt, const vec& dir)");
112#ifdef TRACE_find_embed_vol
113 mcout << "box::check_point_inside: \n";
114 print(mcout, 1);
115 mcout << "fpt=" << fpt << "dir=" << dir;
116#endif
117 if (dir == dv0) {
118 if (fabs(fpt.v.x) <= m_dxh && fabs(fpt.v.y) <= m_dyh &&
119 fabs(fpt.v.z) <= m_dzh) {
120 return 1;
121 }
122 return 0;
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 mcout << "cond 1, returning 1\n";
128#endif
129 return 1;
130 }
131 if (fabs(fpt.v.x) > m_dxh + prec || fabs(fpt.v.y) > m_dyh + prec ||
132 fabs(fpt.v.z) > m_dzh + prec) {
133#ifdef TRACE_find_embed_vol
134 if (fabs(fpt.v.x) > m_dxh + prec) mcout << "cond 2.1 satisfied\n";
135 if (fabs(fpt.v.y) > m_dyh + prec) mcout << "cond 2.2 satisfied\n";
136 if (fabs(fpt.v.z) > m_dzh + prec) mcout << "cond 2.3 satisfied\n";
137 mcout << "cond 2, returning 0\n";
138#endif
139 return 0;
140 }
141 // What remains is point belonging to border.
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#ifdef IMPROVED_BOUNDARY
146 if (dir.x == 0.0) return 0;
147#endif
148 if ((fpt.v.x > 0 && dir.x > 0) || (fpt.v.x < 0 && dir.x < 0)) {
149#ifdef TRACE_find_embed_vol
150 mcout << "cond 3, returning 0\n";
151#endif
152 return 0;
153 }
154 }
155 if (fabs(fpt.v.y) > m_dyh - prec) {
156#ifdef IMPROVED_BOUNDARY
157 if (dir.y == 0.0) return 0;
158#endif
159 if ((fpt.v.y > 0 && dir.y > 0) || (fpt.v.y < 0 && dir.y < 0)) {
160#ifdef TRACE_find_embed_vol
161 mcout << "cond 4, returning 0\n";
162#endif
163 return 0;
164 }
165 }
166 if (fabs(fpt.v.z) > m_dzh - prec) {
167#ifdef IMPROVED_BOUNDARY
168 if (dir.z == 0.0) return 0;
169#endif
170 if ((fpt.v.z > 0 && dir.z > 0) || (fpt.v.z < 0 && dir.z < 0)) {
171#ifdef TRACE_find_embed_vol
172 mcout << "cond 5, returning 0\n";
173#endif
174 return 0;
175 }
176 }
177#ifdef TRACE_find_embed_vol
178 mcout << "finish, returning 1\n";
179#endif
180 return 1;
181}
void print(std::ostream &file, int l) const override
Definition: box.cpp:183
vec dv0(0, 0, 0)
Definition: vec.h:308
#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 221 of file box.cpp.

221 {
222 strcpy(nm, "box: ");
223 strcat(nm, m_name.c_str());
224}

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

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

◆ get_components()

absref_transmit Heed::box::get_components ( )
overrideprotectedvirtual

Reimplemented from Heed::absref.

Reimplemented in Heed::sh_manip_box.

Definition at line 18 of file box.cpp.

18 {
19 mfunnamep("box::get_components(...)");
20 funnw.ehdr(mcerr);
21 mcerr << "one should not call this function, since this object cannot be "
22 "modified\n";
24 return absref_transmit();
25}
#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 220 of file box.cpp.

220{}

◆ init_planes()

void Heed::box::init_planes ( )

Definition at line 92 of file box.cpp.

92 {
93 mfunname("void box::init_planes()");
94 std::vector<std::shared_ptr<surface> > fsurf(6);
95 fsurf[0] = std::make_shared<splane>(
96 plane(point(m_dxh, 0, 0), vec(-1, 0, 0)), vec(-1, 0, 0));
97 fsurf[1] = std::make_shared<splane>(
98 plane(point(-m_dxh, 0, 0), vec(+1, 0, 0)), vec(+1, 0, 0));
99 fsurf[2] = std::make_shared<splane>(
100 plane(point(0, m_dyh, 0), vec(0, -1, 0)), vec(0, -1, 0));
101 fsurf[3] = std::make_shared<splane>(
102 plane(point(0, -m_dyh, 0), vec(0, +1, 0)), vec(0, +1, 0));
103 fsurf[4] = std::make_shared<splane>(
104 plane(point(0, 0, m_dzh), vec(0, 0, -1)), vec(0, 0, -1));
105 fsurf[5] = std::make_shared<splane>(
106 plane(point(0, 0, -m_dzh), vec(0, 0, +1)), vec(0, 0, +1));
107 m_ulsv.ulsvolume_init(fsurf, "ulsv of box", prec);
108}
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 87 of file box.cpp.

87 {
88 prec = (m_dxh + m_dyh + m_dzh) / 3.0;
90}
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 183 of file box.cpp.

183 {
184 if (l <= 0) return;
185 char s[1000];
186 chname(s);
187 Ifile << "box::print(l=" << l << "): " << s << '\n';
188 indn.n += 2;
189 Ifile << " dx=" << m_dx << " dy=" << m_dy << " dz=" << m_dz
190 << " prec=" << prec << '\n';
191 Ifile << " dxh=" << m_dxh << " dyh=" << m_dyh << " dzh=" << m_dzh << '\n';
192 if (l >= 10) {
193 l--;
194 indn.n += 2;
195 m_ulsv.print(file, l);
196 indn.n -= 2;
197 }
198 absvol::print(file, l);
199 indn.n -= 2;
200}
virtual void print(std::ostream &file, int l) const
Definition: volume.cpp:120
void chname(char *nm) const override
Definition: box.cpp:221
void print(std::ostream &file, int l) const override
Definition: surface.cpp:372
indentation indn
Definition: prstream.cpp:15
#define Ifile
Definition: prstream.h:195

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

202 {
203 mfunname("virtual int box::range_ext(trajestep& fts, int s_ext) const");
204 if (s_ext == 0) {
205 if (fabs(fts.currpos.v.x) > m_dxh + fts.mrange) return 0;
206 if (fabs(fts.currpos.v.y) > m_dyh + fts.mrange) return 0;
207 if (fabs(fts.currpos.v.z) > m_dzh + fts.mrange) return 0;
208 } else {
209 if (fabs(fts.currpos.v.x) < m_dxh - fts.mrange &&
210 fabs(fts.currpos.v.y) < m_dyh - fts.mrange &&
211 fabs(fts.currpos.v.z) < m_dzh - fts.mrange) {
212 return 0;
213 }
214 }
215 return m_ulsv.range_ext(fts, s_ext);
216}
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: