Garfield++ v2r0
A toolkit for the detailed simulation of particle detectors based on ionisation measurement in gases and semiconductors
Loading...
Searching...
No Matches
Heed::PointCoorMesh< T, D > Class Template Reference

#include <tline.h>

Public Member Functions

long get_qi (void) const
 
get_xmin (void) const
 
get_xmax (void) const
 
void get_scoor (long n, T &b) const
 
virtual int get_interval (long n, T &b1, T &b2) const
 
int get_interval (T x, long &n1) const
 
int get_interval (T x, long &n1, T &b1, long &n2, T &b2) const
 
int get_interval_extrap (T x, long &n1, T &b1, long &n2, T &b2) const
 
int get_step (long n, T &fstep) const
 
 PointCoorMesh (void)
 
 PointCoorMesh (long fq, D *famesh)
 
virtual ~PointCoorMesh ()
 
void check (void)
 
virtual void print (std::ostream &file) const
 

Detailed Description

template<class T, class D>
class Heed::PointCoorMesh< T, D >

Generic mesh with arbitrary steps. The array determining the step edges is located somewhere outside. In object of this class only the raw pointer is contained with consequences:

Definition at line 390 of file tline.h.

Constructor & Destructor Documentation

◆ PointCoorMesh() [1/2]

template<class T , class D >
Heed::PointCoorMesh< T, D >::PointCoorMesh ( void  )
inline

Definition at line 420 of file tline.h.

429 : q(0), xmin(0), xmax(0), x_old(0), n_old(-1), amesh(NULL) {
430 ;
431 }

◆ PointCoorMesh() [2/2]

template<class T , class D >
Heed::PointCoorMesh< T, D >::PointCoorMesh ( long  fq,
D *  famesh 
)

Definition at line 461 of file tline.h.

462 : q(fq), x_old(0), n_old(-1) {
463 if (q <= 1) {
464 mcerr << "ERROR in PointCoorMesh<T,D>::PointCoorMesh<T,D>:\n"
465 << "q <= 1\n";
466 Iprintn(mcerr, q);
467 spexit(mcerr);
468 }
469#ifndef TLINE_REDUCE_TO_RAW_ARR
470 // amesh.put( famesh );
471 amesh = famesh;
472 xmin = (*amesh)[0];
473 xmax = (*amesh)[q - 1];
474#else
475 amesh = &((*famesh)[0]);
476 xmin = amesh[0];
477 xmax = amesh[q - 1];
478#endif
479 // check consistence
480 if (xmin > xmax) {
481 mcerr << "ERROR in PointCoorMesh<T,D>::PointCoorMesh<T,D>:\n"
482 << "xmin > xmax\n";
483 Iprint2n(mcerr, xmin, xmax);
484 spexit(mcerr);
485 }
486#ifdef CHECK_POINT_MESH
487 long n;
488 for (n = 0; n < q - 1; n++) {
489#ifndef TLINE_REDUCE_TO_RAW_ARR
490 if ((*amesh)[n] >= (*amesh)[n + 1])
491#else
492 if (amesh[n] >= amesh[n + 1])
493#endif
494 {
495 mcerr << "ERROR in PointCoorMesh<T,D>::PointCoorMesh<T,D>:\n"
496 << "amesh[n] >= amesh[n+1]\n";
497#ifndef TLINE_REDUCE_TO_RAW_ARR
498 Iprint3n(mcerr, n, (*amesh)[n], (*amesh)[n + 1]);
499#else
500 Iprint3n(mcerr, n, amesh[n], amesh[n + 1]);
501#endif
502 spexit(mcerr);
503 }
504 }
505#endif
506}
#define spexit(stream)
Definition: FunNameStack.h:256
#define Iprint3n(file, name1, name2, name3)
Definition: prstream.h:233
#define mcerr
Definition: prstream.h:128
#define Iprintn(file, name)
Definition: prstream.h:205
#define Iprint2n(file, name1, name2)
Definition: prstream.h:220

◆ ~PointCoorMesh()

template<class T , class D >
virtual Heed::PointCoorMesh< T, D >::~PointCoorMesh ( )
inlinevirtual

Definition at line 420 of file tline.h.

436{}

Member Function Documentation

◆ check()

template<class T , class D >
void Heed::PointCoorMesh< T, D >::check ( void  )

Definition at line 509 of file tline.h.

509 {
510 long n;
511 for (n = 0; n < q - 1; n++) {
512#ifndef TLINE_REDUCE_TO_RAW_ARR
513 if ((*amesh)[n] >= (*amesh)[n + 1])
514#else
515 if (amesh[n] >= amesh[n + 1])
516#endif
517 {
518 mcerr << "ERROR in PointCoorMesh<T,D>::check(void):\n"
519 << "amesh[n] >= amesh[n+1]\n";
520#ifndef TLINE_REDUCE_TO_RAW_ARR
521 Iprint3n(mcerr, n, (*amesh)[n], (*amesh)[n + 1]);
522#else
523 Iprint3n(mcerr, n, amesh[n], amesh[n + 1]);
524#endif
525 spexit(mcerr);
526 }
527 }
528}

◆ get_interval() [1/3]

template<class T , class D >
virtual int Heed::PointCoorMesh< T, D >::get_interval ( long  n,
T &  b1,
T &  b2 
) const
inlinevirtual

Definition at line 402 of file tline.h.

402 {
403 if (n < 0 || n >= q - 1) return 0;
404#ifndef TLINE_REDUCE_TO_RAW_ARR
405 b1 = (*amesh)[n];
406 b2 = (*amesh)[n + 1];
407#else
408 b1 = amesh[n];
409 b2 = amesh[n + 1];
410#endif
411 return 1;
412 }

Referenced by Heed::PointCoorMesh< T, D >::get_step(), and Heed::HeedParticle_BGM::physics().

◆ get_interval() [2/3]

template<class T , class D >
int Heed::PointCoorMesh< T, D >::get_interval ( x,
long &  n1 
) const

Definition at line 531 of file tline.h.

531 {
532 if (x < xmin || x >= xmax) {
533 n1 = 0;
534 return 0;
535 }
536#ifndef TLINE_REDUCE_TO_RAW_ARR
537 if (n_old >= 0 && x_old <= x) {
538 n1 = t_find_interval_end<T, D>(x, q, *amesh, n_old);
539 } else {
540 n1 = t_find_interval<T, D>(x, q, *amesh);
541 }
542// n1 = t_find_interval< T , D >(x, q, amesh);
543#else
544 if (n_old >= 0 && x_old <= x) {
545 n1 = t_find_interval_end<T, T*>(x, q, amesh, n_old);
546 } else {
547 n1 = t_find_interval<T, T*>(x, q, amesh);
548 }
549// n1 = t_find_interval< T , T* >(x, q, &amesh);
550#endif
551
552 if (n1 < 0) {
553 mcerr << "ERROR in PointCoorMesh<T,D>::get_interval:\n"
554 << "n1 < 0\n";
555 print(mcerr);
556 Iprintn(mcerr, n1);
557 spexit(mcerr);
558 }
559 n_old = n1;
560 x_old = x;
561 return 1;
562}
virtual void print(std::ostream &file) const
Definition: tline.h:676

◆ get_interval() [3/3]

template<class T , class D >
int Heed::PointCoorMesh< T, D >::get_interval ( x,
long &  n1,
T &  b1,
long &  n2,
T &  b2 
) const

Definition at line 565 of file tline.h.

566 {
567 if (x < xmin || x >= xmax) {
568 n1 = 0;
569 n2 = 0;
570 b1 = 0;
571 b2 = 0;
572 return 0;
573 }
574#ifndef TLINE_REDUCE_TO_RAW_ARR
575 if (n_old >= 0 && x_old <= x) {
576 n1 = t_find_interval_end<T, D>(x, q, *amesh, n_old);
577 } else {
578 n1 = t_find_interval<T, D>(x, q, *amesh);
579 }
580// n1 = t_find_interval< T , D >(x, q, amesh);
581#else
582 if (n_old >= 0 && x_old <= x) {
583 n1 = t_find_interval_end<T, T*>(x, q, amesh, n_old);
584 } else {
585 n1 = t_find_interval<T, T*>(x, q, amesh);
586 }
587// n1 = t_find_interval< T , T* >(x, q, &amesh);
588#endif
589 n2 = n1 + 1;
590#ifndef TLINE_REDUCE_TO_RAW_ARR
591 b1 = (*amesh)[n1];
592 b2 = (*amesh)[n2];
593#else
594 b1 = amesh[n1];
595 b2 = amesh[n2];
596#endif
597 if (n1 < 0 || n1 >= q || n2 < 0 || n2 >= q || b1 < xmin || b1 > xmax ||
598 b2 < xmin || b2 > xmax) {
599 mcerr << "ERROR in PointCoorMesh<T,D>::get_interval:\n"
600 << "n1 < 0 || n1 >= q || n2 < 0 || n2 >= q || b1 < xmin || b1 > xmax "
601 "|| b2 < xmin || b2 > xmax\n";
602 print(mcerr);
603 Iprint4n(mcerr, n1, n2, b1, b2);
604 spexit(mcerr);
605 }
606 n_old = n1;
607 x_old = x;
608 return 1;
609}
#define Iprint4n(file, name1, name2, name3, name4)
Definition: prstream.h:244

◆ get_interval_extrap()

template<class T , class D >
int Heed::PointCoorMesh< T, D >::get_interval_extrap ( x,
long &  n1,
T &  b1,
long &  n2,
T &  b2 
) const

Definition at line 612 of file tline.h.

613 {
614 int i_ret = 1;
615
616 if (x < xmin) {
617 i_ret = 0;
618 n1 = 0;
619 n2 = 1;
620 b1 = xmin;
621#ifndef TLINE_REDUCE_TO_RAW_ARR
622 b2 = (*amesh)[1];
623#else
624 b2 = amesh[1];
625#endif
626 } else if (x >= xmax) {
627 i_ret = 2;
628 n1 = q - 2;
629 n2 = q - 1;
630#ifndef TLINE_REDUCE_TO_RAW_ARR
631 b1 = (*amesh)[q - 2];
632#else
633 b1 = amesh[q - 2];
634#endif
635 b2 = xmax;
636 } else {
637#ifndef TLINE_REDUCE_TO_RAW_ARR
638 if (n_old >= 0 && x_old <= x) {
639 n1 = t_find_interval_end<T, D>(x, q, *amesh, n_old);
640 } else {
641 n1 = t_find_interval<T, D>(x, q, *amesh);
642 }
643// n1 = t_find_interval< T , D >(x, q, amesh);
644#else
645 if (n_old >= 0 && x_old <= x) {
646 n1 = t_find_interval_end<T, T*>(x, q, amesh, n_old);
647 } else {
648 n1 = t_find_interval<T, T*>(x, q, amesh);
649 }
650// n1 = t_find_interval< T , T* >(x, q, &amesh);
651#endif
652 n2 = n1 + 1;
653#ifndef TLINE_REDUCE_TO_RAW_ARR
654 b1 = (*amesh)[n1];
655 b2 = (*amesh)[n2];
656#else
657 b1 = amesh[n1];
658 b2 = amesh[n2];
659#endif
660 if (n1 < 0 || n1 >= q || n2 < 0 || n2 >= q || b1 < xmin || b1 > xmax ||
661 b2 < xmin || b2 > xmax) {
662 mcerr << "ERROR in PointCoorMesh<T,D>::get_interval:\n"
663 << "n1 < 0 || n1 >= q || n2 < 0 || n2 >= q || b1 < xmin || b1 > "
664 "xmax || b2 < xmin || b2 > xmax\n";
665 print(mcerr);
666 Iprint4n(mcerr, n1, n2, b1, b2);
667 spexit(mcerr);
668 }
669 n_old = n1;
670 x_old = x;
671 }
672 return i_ret;
673}

◆ get_qi()

template<class T , class D >
long Heed::PointCoorMesh< T, D >::get_qi ( void  ) const
inline

Definition at line 392 of file tline.h.

392{ return q - 1; }

◆ get_scoor()

template<class T , class D >
void Heed::PointCoorMesh< T, D >::get_scoor ( long  n,
T &  b 
) const
inline

Definition at line 395 of file tline.h.

395 {
396#ifndef TLINE_REDUCE_TO_RAW_ARR
397 b = (*amesh)[n];
398#else
399 b = amesh[n];
400#endif
401 }

◆ get_step()

template<class T , class D >
int Heed::PointCoorMesh< T, D >::get_step ( long  n,
T &  fstep 
) const
inline

Definition at line 420 of file tline.h.

420 {
421 if (n < 0 || n >= q - 1) return 0;
422 T b1, b2;
423 get_interval(n, b1, b2);
424 fstep = b2 - b1;
425 return 1;
426 }
virtual int get_interval(long n, T &b1, T &b2) const
Definition: tline.h:402

◆ get_xmax()

template<class T , class D >
T Heed::PointCoorMesh< T, D >::get_xmax ( void  ) const
inline

Definition at line 394 of file tline.h.

394{ return xmax; }

◆ get_xmin()

template<class T , class D >
T Heed::PointCoorMesh< T, D >::get_xmin ( void  ) const
inline

Definition at line 393 of file tline.h.

393{ return xmin; }

◆ print()

template<class T , class D >
void Heed::PointCoorMesh< T, D >::print ( std::ostream &  file) const
virtual

Definition at line 676 of file tline.h.

676 {
677 Ifile << "PointCoorMesh<T,D>:\n";
678 indn.n += 2;
679 Ifile << "Type of T is (in internal notations) " << typeid(T).name() << '\n';
680 Ifile << "Type of D is (in internal notations) " << typeid(D).name() << '\n';
681 Iprint3n(file, q, xmin, xmax);
682 Iprint2n(file, n_old, x_old);
683#ifndef TLINE_REDUCE_TO_RAW_ARR
684 // Ifile << "(*amesh)=" << (*amesh) << '\n';
685 Ifile << "(*amesh)=" << (*amesh)[0] << '\n';
686#else
687 Ifile << "amesh:" << '\n';
688 long n;
689 indn.n += 2;
690 for (n = 0; n < q; n++) {
691 Ifile << "n=" << n << " amesh[n]=" << noindent << amesh[n] << yesindent
692 << '\n';
693 }
694 file << yesindent;
695 indn.n -= 2;
696#endif
697 indn.n -= 2;
698}
std::ostream & noindent(std::ostream &f)
Definition: prstream.cpp:17
indentation indn
Definition: prstream.cpp:15
std::ostream & yesindent(std::ostream &f)
Definition: prstream.cpp:21
#define Ifile
Definition: prstream.h:196

Referenced by Heed::operator<<().


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