Garfield++ v1r0
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 (void)
 Constructors.
 
 box (vfloat fdx, vfloat fdy, vfloat fdz, const String &fname)
 
 box (vfloat fdx, vfloat fdy, vfloat fdz, vfloat fprec, const String &fname)
 
 box (box &fb)
 
 box (const box &fb)
 
 macro_copy_header (box)
 
virtual ~box ()
 Destructor.
 
void init_prec (void)
 
void init_planes (void)
 
virtual int check_point_inside (const point &fpt, const vec &dir) const
 
virtual int range_ext (trajestep &fts, int s_ext) const
 
virtual void income (gparticle *gp)
 
virtual void chname (char *nm) const
 
virtual void print (std::ostream &file, int l) const
 
- Public Member Functions inherited from absvol
virtual ~absvol ()
 
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_eid *faeid) const
 
virtual int range_ext (trajestep &fts, int s_ext) const =0
 
 macro_copy_header (absvol)
 
virtual void income (gparticle *)
 
virtual void chname (char *nm) const
 
virtual void print (std::ostream &file, int l) const
 
virtual DynLinArr< manip_absvol * > Gamanip_embed (void) const
 
- Public Member Functions inherited from absref
virtual ~absref ()
 
virtual void down (const abssyscoor *fasc)
 
virtual void up (const abssyscoor *fasc)
 
virtual void turn (const vec &dir, vfloat angle)
 
virtual void shift (const vec &dir)
 

Public Attributes

vfloat dx
 
vfloat dy
 
vfloat dz
 
vfloat dxh
 
vfloat dyh
 
vfloat dzh
 
ulsvolume ulsv
 
String name
 
- Public Attributes inherited from absvol
vfloat prec
 

Protected Member Functions

virtual void get_components (ActivePtr< absref_transmit > &aref_tran)
 

Detailed Description

Definition at line 24 of file box.h.

Constructor & Destructor Documentation

◆ box() [1/5]

Heed::box::box ( void  )

Constructors.

Definition at line 26 of file box.cpp.

26 : dx(0), dy(0), dz(0), dxh(0), dyh(0), dzh(0), name("none") {
27 mfunname("box::box(void)");
28 init_prec();
30}
#define mfunname(string)
Definition: FunNameStack.h:67
String name
Definition: box.h:29
vfloat dx
Definition: box.h:26
vfloat dzh
Definition: box.h:27
vfloat dz
Definition: box.h:26
vfloat dy
Definition: box.h:26
void init_planes(void)
Definition: box.cpp:90
vfloat dyh
Definition: box.h:27
vfloat dxh
Definition: box.h:27
void init_prec(void)
Definition: box.cpp:85

◆ box() [2/5]

Heed::box::box ( vfloat  fdx,
vfloat  fdy,
vfloat  fdz,
const String fname 
)

Definition at line 32 of file box.cpp.

32 {
33 pvecerror("box(vfloat fdx, vfloat fdy, vfloat fdz, const String &fname)");
34 dx = abslt(fdx);
35 dy = abslt(fdy);
36 dz = abslt(fdz);
37 dxh = 0.5 * dx;
38 dyh = 0.5 * dy;
39 dzh = 0.5 * dz;
40 name = fname;
41 init_prec();
43}
#define pvecerror(string)
Definition: vec.h:52
vfloat abslt(vfloat f)
Definition: vfloat.h:19

◆ box() [3/5]

Heed::box::box ( vfloat  fdx,
vfloat  fdy,
vfloat  fdz,
vfloat  fprec,
const String fname 
)

Definition at line 45 of file box.cpp.

46 {
47 pvecerror("box(vfloat fdx, vfloat fdy, vfloat fdz, const String &fname)");
48 dx = abslt(fdx);
49 dy = abslt(fdy);
50 dz = abslt(fdz);
51 dxh = 0.5 * dx;
52 dyh = 0.5 * dy;
53 dzh = 0.5 * dz;
54 name = fname;
55 prec = fprec;
57}
vfloat prec
Definition: volume.h:95

◆ box() [4/5]

Heed::box::box ( box fb)

Definition at line 59 of file box.cpp.

59 : absref(fb), absvol(fb) {
60 pvecerror("box(const box& fb)");
61 dx = fb.dx;
62 dy = fb.dy;
63 dz = fb.dz;
64 dxh = 0.5 * dx;
65 dyh = 0.5 * dy;
66 dzh = 0.5 * dz;
67 prec = fb.prec;
68 name = fb.name;
70}
Definition: vec.h:134
Definition: volume.h:91

◆ box() [5/5]

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

Definition at line 72 of file box.cpp.

72 : absref(fb), absvol(fb) {
73 pvecerror("box(const box& fb)");
74 dx = fb.dx;
75 dy = fb.dy;
76 dz = fb.dz;
77 dxh = 0.5 * dx;
78 dyh = 0.5 * dy;
79 dzh = 0.5 * dz;
80 name = fb.name;
81 prec = fb.prec;
83}

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

Implements absvol.

Definition at line 105 of file box.cpp.

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

◆ chname()

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

Reimplemented from absvol.

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

Definition at line 260 of file box.cpp.

260 {
261#ifdef USE_STLSTRING
262 strcpy(nm, "box: ");
263 strcat(nm, name.c_str());
264#else
265 strcpy(nm, "box: ");
266 strcat(nm, name);
267#endif
268}

Referenced by print().

◆ get_components()

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

Reimplemented from absref.

Reimplemented in Garfield::HeedChamber, and 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}
#define mfunnamep(string)
Definition: FunNameStack.h:77
#define spexit(stream)
Definition: FunNameStack.h:536
#define mcerr
Definition: prstream.h:135

◆ income()

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

Reimplemented from absvol.

◆ init_planes()

void Heed::box::init_planes ( void  )

Definition at line 90 of file box.cpp.

90 {
91 mfunname("void box::init_planes(void)");
92 splane spl[6];
93 spl[0] = splane(plane(point(dxh, 0, 0), vec(-1, 0, 0)), vec(-1, 0, 0));
94 spl[1] = splane(plane(point(-dxh, 0, 0), vec(1, 0, 0)), vec(1, 0, 0));
95 spl[2] = splane(plane(point(0, dyh, 0), vec(0, -1, 0)), vec(0, -1, 0));
96 spl[3] = splane(plane(point(0, -dyh, 0), vec(0, 1, 0)), vec(0, 1, 0));
97 spl[4] = splane(plane(point(0, 0, dzh), vec(0, 0, -1)), vec(0, 0, -1));
98 spl[5] = splane(plane(point(0, 0, -dzh), vec(0, 0, 1)), vec(0, 0, 1));
99 surface* fsurf[6];
100 for (int n = 0; n < 6; ++n)
101 fsurf[n] = &spl[n];
102 ulsv.ulsvolume_init(fsurf, 6, "ulsv of box", prec);
103}
ulsvolume ulsv
Definition: box.h:28
void ulsvolume_init(surface *fsurf[pqqsurf], int fqsurf, const String &fname, vfloat fprec)
Definition: surface.cpp:339
Definition: vec.h:477
Definition: vec.h:248

Referenced by box().

◆ init_prec()

void Heed::box::init_prec ( void  )

Definition at line 85 of file box.cpp.

85 {
86 prec = (dxh + dyh + dzh) / 3.0;
88}
const vfloat vprecision
Definition: vfloat.h:17

Referenced by box().

◆ macro_copy_header()

Heed::box::macro_copy_header ( box  )

◆ print()

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

Reimplemented from absvol.

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

Definition at line 223 of file box.cpp.

223 {
224 if (l <= 0) return;
225 char s[1000];
226 chname(s);
227 Ifile << "box::print(l=" << l << "): " << s << '\n';
228 indn.n += 2;
229 Ifile << " dx=" << dx << " dy=" << dy << " dz=" << dz << " prec=" << prec
230 << '\n';
231 Ifile << " dxh=" << dxh << " dyh=" << dyh << " dzh=" << dzh << '\n';
232 if (l >= 10) {
233 l--;
234 indn.n += 2;
235 ulsv.print(file, l);
236 indn.n -= 2;
237 }
238 absvol::print(file, l);
239 indn.n -= 2;
240}
virtual void chname(char *nm) const
Definition: box.cpp:260
virtual void print(std::ostream &file, int l) const
virtual void print(std::ostream &file, int l) const
Definition: volume.cpp:144
indentation indn
Definition: prstream.cpp:13
#define Ifile
Definition: prstream.h:207

Referenced by check_point_inside().

◆ range_ext()

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

Implements absvol.

Definition at line 242 of file box.cpp.

242 {
243 mfunname("virtual int box::range_ext(trajestep& fts, int s_ext) const");
244 if (s_ext == 0) {
245 if (abslt(fts.currpos.v.x) > dxh + fts.mrange) return 0;
246 if (abslt(fts.currpos.v.y) > dyh + fts.mrange) return 0;
247 if (abslt(fts.currpos.v.z) > dzh + fts.mrange) return 0;
248 } else {
249 if (abslt(fts.currpos.v.x) < dxh - fts.mrange &&
250 abslt(fts.currpos.v.y) < dyh - fts.mrange &&
251 abslt(fts.currpos.v.z) < dzh - fts.mrange) {
252 return 0;
253 }
254 }
255 return ulsv.range_ext(fts, s_ext);
256}
int range_ext(trajestep &fts, int s_ext) const
Definition: surface.cpp:214
point currpos
Definition: trajestep.h:74
vfloat mrange
Definition: trajestep.h:91

Member Data Documentation

◆ dx

vfloat Heed::box::dx

Definition at line 26 of file box.h.

Referenced by box(), and print().

◆ dxh

vfloat Heed::box::dxh

Definition at line 27 of file box.h.

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

◆ dy

vfloat Heed::box::dy

Definition at line 26 of file box.h.

Referenced by box(), and print().

◆ dyh

vfloat Heed::box::dyh

Definition at line 27 of file box.h.

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

◆ dz

vfloat Heed::box::dz

Definition at line 26 of file box.h.

Referenced by box(), and print().

◆ dzh

vfloat Heed::box::dzh

Definition at line 27 of file box.h.

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

◆ name

String Heed::box::name

Definition at line 29 of file box.h.

Referenced by box(), chname(), and Heed::macro_copy_body().

◆ ulsv

ulsvolume Heed::box::ulsv

Definition at line 28 of file box.h.

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


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