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::ulsvolume Class Reference

Unlimited surfaces volume. More...

#include <surface.h>

+ Inheritance diagram for Heed::ulsvolume:

Public Member Functions

 ulsvolume ()
 Default constructor.
 
 ulsvolume (const std::vector< std::shared_ptr< surface > > &fsurf, char *fname, vfloat fprec)
 Constructor from surfaces.
 
 ulsvolume (ulsvolume &f)
 
 ulsvolume (const ulsvolume &fv)
 
virtual ~ulsvolume ()
 Destructor.
 
int check_point_inside (const point &fpt, const vec &dir) const override
 
int range_ext (trajestep &fts, int s_ext) const override
 
void ulsvolume_init (const std::vector< std::shared_ptr< surface > > &fsurf, const std::string &fname, vfloat fprec)
 
void income (gparticle *) override
 
void chname (char *nm) const override
 
void print (std::ostream &file, int l) const override
 
ulsvolumecopy () 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

int qsurf = 0
 
std::array< std::shared_ptr< surface >, pqqsurfsurf
 
std::string name = "non-initialized ulsvolume"
 
- Public Attributes inherited from Heed::absvol
vfloat prec
 
bool s_sensitive
 

Static Public Attributes

static constexpr int pqqsurf = 10
 

Protected Member Functions

absref_transmit get_components () override
 

Protected Attributes

surfaceadrsurf [pqqsurf]
 

Detailed Description

Unlimited surfaces volume.

Definition at line 123 of file surface.h.

Constructor & Destructor Documentation

◆ ulsvolume() [1/4]

Heed::ulsvolume::ulsvolume ( )
inline

Default constructor.

Definition at line 156 of file surface.h.

156{}

Referenced by copy().

◆ ulsvolume() [2/4]

Heed::ulsvolume::ulsvolume ( const std::vector< std::shared_ptr< surface > > &  fsurf,
char *  fname,
vfloat  fprec 
)

Constructor from surfaces.

Definition at line 347 of file surface.cpp.

349 : qsurf(fsurf.size()), name(fname) {
350 mfunname("ulsvolume::ulsvolume(...)");
352 prec = fprec;
353 for (int n = 0; n < qsurf; ++n) surf[n] = fsurf[n];
354}
#define check_econd12(a, sign, b, stream)
Definition: FunNameStack.h:163
#define mfunname(string)
Definition: FunNameStack.h:45
vfloat prec
Definition: volume.h:72
static constexpr int pqqsurf
Definition: surface.h:143
std::array< std::shared_ptr< surface >, pqqsurf > surf
Definition: surface.h:145
std::string name
Definition: surface.h:146
#define mcerr
Definition: prstream.h:128

◆ ulsvolume() [3/4]

Heed::ulsvolume::ulsvolume ( ulsvolume f)

Definition at line 356 of file surface.cpp.

357 : absref(f), absvol(f), qsurf(f.qsurf), name(f.name) {
358 mfunname("ulsvolume::ulsvolume(...)");
359 check_econd12(f.qsurf, >, pqqsurf, mcerr);
360 prec = f.prec;
361 for (int n = 0; n < qsurf; ++n) surf[n] = f.surf[n];
362}

◆ ulsvolume() [4/4]

Heed::ulsvolume::ulsvolume ( const ulsvolume fv)

Definition at line 364 of file surface.cpp.

365 : absref(f), absvol(f), qsurf(f.qsurf), name(f.name) {
366 mfunname("ulsvolume::ulsvolume(...)");
367 check_econd12(f.qsurf, >, pqqsurf, mcerr);
368 prec = f.prec;
369 for (int n = 0; n < qsurf; ++n) surf[n] = f.surf[n];
370}

◆ ~ulsvolume()

virtual Heed::ulsvolume::~ulsvolume ( )
inlinevirtual

Destructor.

Definition at line 162 of file surface.h.

162{}

Member Function Documentation

◆ check_point_inside()

int Heed::ulsvolume::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 192 of file surface.cpp.

192 {
193 mfunname("ulsvolume::check_point_inside(const point&, const vec&)");
194 check_econd11(qsurf, <= 0, mcerr);
195 for (int n = 0; n < qsurf; n++) {
196 if (!(surf[n].get()->check_point_inside(fpt, dir, prec))) {
197 return 0;
198 }
199 }
200#ifdef TRACE_find_embed_vol
201 indn.n++;
202 Imcout << "ulsvolume::check_point_inside: the point is in volume\n";
203 Imcout << "point:" << fpt;
204 print(mcout, 0);
205 indn.n--;
206#endif
207 return 1;
208}
#define check_econd11(a, signb, stream)
Definition: FunNameStack.h:155
void print(std::ostream &file, int l) const override
Definition: surface.cpp:372
int check_point_inside(const point &fpt, const vec &dir) const override
Definition: surface.cpp:192
indentation indn
Definition: prstream.cpp:15
#define mcout
Definition: prstream.h:126
#define Imcout
Definition: prstream.h:196

Referenced by check_point_inside(), and range_ext().

◆ chname()

void Heed::ulsvolume::chname ( char *  nm) const
inlineoverridevirtual

Reimplemented from Heed::absvol.

Reimplemented in Heed::manip_ulsvolume.

Definition at line 174 of file surface.h.

174 {
175 strcpy(nm, "ulsvolume: ");
176 strcat(nm, name.c_str());
177 }

Referenced by print().

◆ copy()

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

Reimplemented from Heed::absvol.

Reimplemented in Heed::manip_ulsvolume.

Definition at line 179 of file surface.h.

179{ return new ulsvolume(*this); }
ulsvolume()
Default constructor.
Definition: surface.h:156

◆ get_components()

absref_transmit Heed::ulsvolume::get_components ( )
overrideprotectedvirtual

Reimplemented from Heed::absref.

Definition at line 187 of file surface.cpp.

187 {
188 for (int n = 0; n < qsurf; n++) adrsurf[n] = surf[n].get();
189 return absref_transmit(qsurf, (absref**)adrsurf);
190}
surface * adrsurf[pqqsurf]
Definition: surface.h:150

◆ income()

void Heed::ulsvolume::income ( gparticle )
inlineoverridevirtual

Reimplemented from Heed::absvol.

Definition at line 173 of file surface.h.

173{}

◆ print()

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

Reimplemented from Heed::absvol.

Reimplemented in Heed::manip_ulsvolume.

Definition at line 372 of file surface.cpp.

372 {
373 char s[1000];
374 chname(s);
375 Ifile << "ulsvolume::print(l=" << l << "): " << s << '\n';
376 if (l > 0) {
377 indn.n += 2;
378 Ifile << "qsurf=" << qsurf << " prec=" << prec << '\n';
379 for (int n = 0; n < qsurf; ++n) {
380 Ifile << " nsurf=" << n << '\n';
381 surf[n].get()->print(file, l);
382 }
383 absvol::print(file, l);
384 indn.n -= 2;
385 }
386}
virtual void print(std::ostream &file, int l) const
Definition: volume.cpp:120
void chname(char *nm) const override
Definition: surface.h:174
#define Ifile
Definition: prstream.h:195

Referenced by check_point_inside(), Heed::manip_ulsvolume::print(), Heed::box::print(), and range_ext().

◆ range_ext()

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

Find cross with current volume ignoring embraced ones. s_ext=1 exit, now point is inside, but embraced volumes are ingnored. s_ext=0 enter, now point is outside

Implements Heed::absvol.

Definition at line 210 of file surface.cpp.

210 {
211 mfunnamep("int ulsvolume::range_ext(trajestep& fts, int s_ext) const");
212 check_econd11(qsurf, <= 0, mcerr);
213#ifdef DEBUG_ulsvolume_range_ext
214 mcout << "ulsvolume::range_ext, START, s_ext=" << s_ext << " qsurf=" << qsurf
215 << '\n';
216 mcout << fts;
217#endif
218 constexpr int pqcrossurf = 4;
219 vfloat crange[pqcrossurf];
220 point cpt[pqcrossurf];
221 int fs_ext[pqcrossurf];
222 int n, m, nc;
223 int s = 0; // sign of crossing
224 if (s_ext == 1) {
225 for (n = 0; n < qsurf; n++) {
226 int qc = surf[n].get()->range(fts, crange, cpt, fs_ext);
227 for (m = 0; m < qc; m++) {
228 if (fs_ext[m] == 1) {
229 s = 1;
230 // The last minute change, it was 0 somewhy instead of m
231 fts.mrange = crange[m]; // reduce the range
232 fts.mpoint = cpt[m];
233 break; // take only the first exit point, it should be closest
234 } else if (fs_ext[m] == 0) {
235 if (!(surf[n].get()->check_point_inside(fts.currpos, fts.dir,
236 prec))) {
237 funnw.ehdr(mcerr);
238 mcerr << "\nshould never happen\n"
239 << "It may happen if you call this function with s_ext==1\n"
240 << "for point outside the volume\n";
241 spexit(mcerr);
242 }
243 } else if (fs_ext[m] == 2)
244 break; // don't know what to do, safe to ignore
245 }
246 }
247
248 if (s == 1) {
249 fts.s_prec = 0;
250 }
251 return s;
252 } else { // for if(s_ext==1)
253 int ss = 0; // sign that there is cross with any of the surfaces
254 for (n = 0; n < qsurf; n++) {
255#ifdef DEBUG_ulsvolume_range_ext
256 Iprintn(mcout, n);
257#endif
258 int qc = surf[n].get()->range(fts, crange, cpt, fs_ext);
259#ifdef DEBUG_ulsvolume_range_ext
260 mcout << "ulsvolume::range_ext: qc=" << qc << "\n";
261 surf[n]->print(mcout, 1);
262#endif
263 for (nc = 0; nc < qc; nc++) // loop by crossing points
264 {
265#ifdef DEBUG_ulsvolume_range_ext
266 mcout << "nc=" << nc << " fs_ext[nc]=" << fs_ext[nc] << '\n';
267#endif
268 if (fs_ext[nc] == 0) // thus ignoring exitted surfaces
269 {
270 s = 1;
271 for (m = 0; m < qsurf; m++) // scan other surfaces and verify that
272 { // the crossing point is inside
273 if (m != n) {
274 if (surf[m].get()->check_point_inside1(cpt[nc], fs_ext[nc],
275 prec) == 0) {
276#ifdef DEBUG_ulsvolume_range_ext
277 mcout << "m=" << m << '\n';
278 mcout << "Since the point is outside of the other surface, "
279 << "it can not be border of volume\n";
280#endif
281 s = 0;
282 break;
283 }
284 }
285 }
286#ifdef DEBUG_ulsvolume_range_ext
287 Iprintn(mcout, s);
288#endif
289 if (s == 1) {
290#ifdef DEBUG_ulsvolume_range_ext
291 mcout << "The crossing point is inside all other surfaces, \n"
292 << "so it is good crossing point\n";
293#endif
294 ss = 1;
295 fts.mrange = crange[nc];
296 fts.mpoint = cpt[nc];
297 break; // since points are ordered, go to next surface,
298 // may be there is nearer crossing point
299 }
300 }
301 }
302 }
303 if (ss == 1) {
304 fts.s_prec = 0;
305 }
306#ifdef DEBUG_ulsvolume_range_ext
307 mcout << "ulsvolume::range_ext: at the end\n";
308 print(mcout, 1);
309 mcout << "ss=" << ss << '\n';
310#endif
311 return ss;
312 }
313}
#define mfunnamep(string)
Definition: FunNameStack.h:49
#define spexit(stream)
Definition: FunNameStack.h:256
double vfloat
Definition: vfloat.h:16
#define Iprintn(file, name)
Definition: prstream.h:204

Referenced by Heed::box::range_ext().

◆ ulsvolume_init()

void Heed::ulsvolume::ulsvolume_init ( const std::vector< std::shared_ptr< surface > > &  fsurf,
const std::string &  fname,
vfloat  fprec 
)

Definition at line 334 of file surface.cpp.

335 {
336 prec = fprec;
337 name = fname;
338 if (qsurf > 0) {
339 for (int n = 0; n < qsurf; ++n) surf[n].reset();
340 }
341 qsurf = fsurf.size();
342 for (int n = 0; n < qsurf; ++n) {
343 surf[n] = fsurf[n];
344 }
345}

Referenced by Heed::box::init_planes().

Member Data Documentation

◆ adrsurf

surface* Heed::ulsvolume::adrsurf[pqqsurf]
protected

Definition at line 150 of file surface.h.

Referenced by get_components().

◆ name

std::string Heed::ulsvolume::name = "non-initialized ulsvolume"

Definition at line 146 of file surface.h.

Referenced by Heed::manip_ulsvolume::chname(), chname(), and ulsvolume_init().

◆ pqqsurf

constexpr int Heed::ulsvolume::pqqsurf = 10
staticconstexpr

Definition at line 143 of file surface.h.

Referenced by ulsvolume().

◆ qsurf

int Heed::ulsvolume::qsurf = 0

◆ surf

std::array<std::shared_ptr<surface>, pqqsurf> Heed::ulsvolume::surf

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