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

Basis. More...

#include <vec.h>

+ Inheritance diagram for Heed::basis:

Public Member Functions

vec Gex () const
 
vec Gey () const
 
vec Gez () const
 
basis switch_xyz () const
 Change ex=ez; ey=ex; ez=ey.
 
 basis ()
 Nominal basis.
 
 basis (const std::string &pname)
 Nominal basis.
 
 basis (const vec &p, const std::string &fname)
 
 basis (const vec &p, const vec &c, const std::string &pname)
 
 basis (const basis &pb, const std::string &pname)
 Same basis with other name, useful for later turning.
 
 basis (const vec &pex, const vec &pey, const vec &pez, const std::string &pname)
 Direct definitions of basis by three perpendicular unit-length vectors.
 
virtual basiscopy () const
 
virtual void print (std::ostream &file, int l) const
 
virtual ~basis ()
 
- 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

std::string name
 

Protected Member Functions

virtual absref_transmit get_components () override
 

Protected Attributes

vec ex
 
vec ey
 
vec ez
 

Static Protected Attributes

static absref absref::* aref [3]
 

Friends

std::ostream & operator<< (std::ostream &file, const basis &b)
 

Detailed Description

Basis.

Definition at line 313 of file vec.h.

Constructor & Destructor Documentation

◆ basis() [1/6]

Heed::basis::basis ( )

Nominal basis.

Definition at line 281 of file vec.cpp.

281 : ex(1, 0, 0), ey(0, 1, 0), ez(0, 0, 1) {
282 name = "primary_bas";
283}
vec ez
Definition: vec.h:317
std::string name
Definition: vec.h:324
vec ex
Definition: vec.h:317
vec ey
Definition: vec.h:317

Referenced by copy(), and switch_xyz().

◆ basis() [2/6]

Heed::basis::basis ( const std::string &  pname)

Nominal basis.

Definition at line 285 of file vec.cpp.

285 : ex(1, 0, 0), ey(0, 1, 0), ez(0, 0, 1) {
286 name = pname;
287}

◆ basis() [3/6]

Heed::basis::basis ( const vec p,
const std::string &  fname 
)

Longitudinal basis. z-axis is parallel to p. y-axis is vector product of z_new and z_old x-axis is vector product of y_new and z_new If p is parallel to z_old, the copy of old basis is created. If p is anti-parallel to z_old, the inverted copy of old basis is created.

Definition at line 289 of file vec.cpp.

289 {
290 pvecerror("basis::basis(vec &p)");
291 name = pname;
292 // vec dex(1, 0, 0);
293 // vec dey(0, 1, 0);
294 // vec dez(0, 0, 1);
295 if (p.length() == 0) {
296 vecerror = 1;
297 ex = dex;
298 ey = dey;
299 ez = dez;
300 }
301 vfloat ca = cos2vec(p, dez);
302 if (ca == 1) {
303 ex = dex;
304 ey = dey;
305 ez = dez;
306 } else if (ca == -1) {
307 ex = -dex;
308 ey = -dey;
309 ez = -dez;
310 } else {
311 ez = unit_vec(p);
312 ey = unit_vec(ez || dez);
313 ex = ey || ez;
314 }
315}
int vecerror
Definition: vec.cpp:29
vec dex(1, 0, 0)
Definition: vec.h:305
vfloat cos2vec(const vec &r1, const vec &r2)
Definition: vec.cpp:66
vec dez(0, 0, 1)
Definition: vec.h:307
vec dey(0, 1, 0)
Definition: vec.h:306
double vfloat
Definition: vfloat.h:16
#define pvecerror(string)
Definition: vec.h:28

◆ basis() [4/6]

Heed::basis::basis ( const vec p,
const vec c,
const std::string &  pname 
)

More sophisticated basis. ez is parallel to p, ez=unit_vec(p) ey is perpendicular to plane which have p and c, ey=unit_vec(ez||c) ex is vector product of y and z, ex=ey||ez If p is parallel to c, or p is anti-parallel to c, vecerror=1 if(length(p)==0||length(c)==0)) vecerror=1;

Definition at line 317 of file vec.cpp.

317 {
318 pvecerror("basis::basis(vec &p, vec &c, char pname[12])");
319 name = pname;
320
321 if (p.length() == 0 || c.length() == 0) {
322 vecerror = 1;
323 ex = dex;
324 ey = dey;
325 ez = dez;
326 }
327 vfloat ca = cos2vec(p, c);
328 if (ca == 1) {
329 vecerror = 1;
330 ex = dex;
331 ey = dey;
332 ez = dez;
333 } else if (ca == -1) {
334 vecerror = 1;
335 ex = dex;
336 ey = dey;
337 ez = dez;
338 } else {
339 ez = unit_vec(p);
340 ey = unit_vec(ez || c);
341 ex = ey || ez;
342 }
343}

◆ basis() [5/6]

Heed::basis::basis ( const basis pb,
const std::string &  pname 
)

Same basis with other name, useful for later turning.

Definition at line 346 of file vec.cpp.

347 : ex(pb.ex), ey(pb.ey), ez(pb.ez) {
348 name = pname;
349}

◆ basis() [6/6]

Heed::basis::basis ( const vec pex,
const vec pey,
const vec pez,
const std::string &  pname 
)

Direct definitions of basis by three perpendicular unit-length vectors.

Definition at line 351 of file vec.cpp.

352 {
353 pvecerror("basis::basis(vec &pex, vec &pey, vec &pez, char pname[12])");
354 if (!check_perp(pex, pey, vprecision) || !check_perp(pex, pez, vprecision) ||
355 !check_perp(pey, pez, vprecision)) {
356 mcerr << "ERROR in basis::basis(vec &pex, vec &pey, vec &pez) : \n"
357 << "the vectors are not perpendicular\n";
358 mcerr << " pex,pey,pez:\n";
359 mcerr << pex << pey << pez;
360 mcerr << "name=" << pname << '\n';
361 spexit(mcerr);
362 }
363 if (!apeq(pex.length(), vfloat(1.0)) ||
364 !apeq(pey.length(), vfloat(1.0)) ||
365 !apeq(pez.length(), vfloat(1.0))) {
366 mcerr << "ERROR in basis::basis(vec &pex, vec &pey, vec &pez) : \n"
367 << "the vectors are not of unit length\n";
368 mcerr << " pex,pey,pez:\n";
369 mcerr << pex << pey << pez;
370 mcerr << "name=" << pname << '\n';
371 spexit(mcerr);
372 }
373 if (!apeq(pex || pey, pez, vprecision)) {
374 mcerr << "ERROR in basis::basis(vec &pex, vec &pey, vec &pez) : \n";
375 mcerr << "wrong direction of pez\n";
376 mcerr << " pex,pey,pez:\n";
377 mcerr << pex << pey << pez;
378 mcerr << "name=" << pname << '\n';
379 spexit(mcerr);
380 }
381 name = pname;
382 ex = pex;
383 ey = pey;
384 ez = pez;
385}
#define spexit(stream)
Definition: FunNameStack.h:256
bool apeq(const circumf &f1, const circumf &f2, vfloat prec)
Definition: circumf.cpp:44
const vfloat vprecision
Definition: vfloat.h:17
#define mcerr
Definition: prstream.h:128

◆ ~basis()

virtual Heed::basis::~basis ( )
inlinevirtual

Definition at line 362 of file vec.h.

362{}

Member Function Documentation

◆ copy()

virtual basis * Heed::basis::copy ( ) const
inlinevirtual

Definition at line 360 of file vec.h.

360{ return new basis(*this); }
basis()
Nominal basis.
Definition: vec.cpp:281

◆ get_components()

absref_transmit Heed::basis::get_components ( )
overrideprotectedvirtual

Reimplemented from Heed::absref.

Definition at line 272 of file vec.cpp.

272 {
273 return absref_transmit(3, aref);
274}
static absref absref::* aref[3]
Definition: vec.h:321

◆ Gex()

vec Heed::basis::Gex ( ) const
inline

Definition at line 327 of file vec.h.

327{ return ex; }

Referenced by Heed::vec::down_new(), and Heed::vec::up_new().

◆ Gey()

vec Heed::basis::Gey ( ) const
inline

Definition at line 328 of file vec.h.

328{ return ey; }

Referenced by Heed::vec::down_new(), and Heed::vec::up_new().

◆ Gez()

vec Heed::basis::Gez ( ) const
inline

Definition at line 329 of file vec.h.

329{ return ez; }

Referenced by Heed::vec::down_new(), and Heed::vec::up_new().

◆ print()

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

Definition at line 387 of file vec.cpp.

387{ file << (*this); }

◆ switch_xyz()

basis Heed::basis::switch_xyz ( ) const

Change ex=ez; ey=ex; ez=ey.

Definition at line 276 of file vec.cpp.

276 {
277 pvecerror("basis basis::switch_xyz(void)");
278 return basis(ez, ex, ey, name);
279}

Friends And Related Function Documentation

◆ operator<<

std::ostream & operator<< ( std::ostream &  file,
const basis b 
)
friend

Definition at line 389 of file vec.cpp.

389 {
390 Ifile << "basis: name=" << b.name << '\n';
391 indn.n += 2;
392 int indnsave = indn.n;
393 Ifile << "ex: ";
394 indn.n = 0;
395 file << b.ex;
396 indn.n = indnsave;
397 Ifile << "ey: ";
398 indn.n = 0;
399 file << b.ey;
400 indn.n = indnsave;
401 Ifile << "ez: ";
402 indn.n = 0;
403 file << b.ez;
404 indn.n = indnsave;
405 indn.n -= 2;
406 return file;
407}
indentation indn
Definition: prstream.cpp:15
#define Ifile
Definition: prstream.h:195

Member Data Documentation

◆ aref

absref absref::* Heed::basis::aref
staticprotected
Initial value:
= {
reinterpret_cast<absref absref::*>(static_cast<vec absref::*>(&basis::ex)),
reinterpret_cast<absref absref::*>(static_cast<vec absref::*>(&basis::ey)),
reinterpret_cast<absref absref::*>(static_cast<vec absref::*>(&basis::ez))}

Definition at line 321 of file vec.h.

Referenced by get_components().

◆ ex

vec Heed::basis::ex
protected

Unit vectors giving directions of Cartesian axes. Supposed to be perpendicular, therefore not public.

Definition at line 317 of file vec.h.

Referenced by basis(), Gex(), and switch_xyz().

◆ ey

vec Heed::basis::ey
protected

Definition at line 317 of file vec.h.

Referenced by basis(), Gey(), and switch_xyz().

◆ ez

vec Heed::basis::ez
protected

Definition at line 317 of file vec.h.

Referenced by basis(), Gez(), and switch_xyz().

◆ name

std::string Heed::basis::name

Definition at line 324 of file vec.h.

Referenced by basis(), and switch_xyz().


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