Garfield++ v1r0
A toolkit for the detailed simulation of particle detectors based on ionisation measurement in gases and semiconductors
Loading...
Searching...
No Matches
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 PointCoorMesh< T, D >

Definition at line 426 of file tline.h.

Constructor & Destructor Documentation

◆ PointCoorMesh() [1/2]

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

Definition at line 457 of file tline.h.

466 : q(0), xmin(0), xmax(0), x_old(0), n_old(-1), amesh(NULL) {
467 ;
468 }

◆ PointCoorMesh() [2/2]

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

Definition at line 498 of file tline.h.

499 : q(fq), x_old(0), n_old(-1) {
500 if (q <= 1) {
501 mcerr << "ERROR in PointCoorMesh<T,D>::PointCoorMesh<T,D>:\n"
502 << "q <= 1\n";
503 Iprintn(mcerr, q);
504 spexit(mcerr);
505 }
506#ifndef TLINE_REDUCE_TO_RAW_ARR
507 //amesh.put( famesh );
508 amesh = famesh;
509 xmin = (*amesh)[0];
510 xmax = (*amesh)[q - 1];
511#else
512 amesh = &((*famesh)[0]);
513 xmin = amesh[0];
514 xmax = amesh[q - 1];
515#endif
516 // check consistence
517 if (xmin > xmax) {
518 mcerr << "ERROR in PointCoorMesh<T,D>::PointCoorMesh<T,D>:\n"
519 << "xmin > xmax\n";
520 Iprint2n(mcerr, xmin, xmax);
521 spexit(mcerr);
522 }
523#ifdef CHECK_POINT_MESH
524 long n;
525 for (n = 0; n < q - 1; n++) {
526#ifndef TLINE_REDUCE_TO_RAW_ARR
527 if ((*amesh)[n] >= (*amesh)[n + 1])
528#else
529 if (amesh[n] >= amesh[n + 1])
530#endif
531 {
532 mcerr << "ERROR in PointCoorMesh<T,D>::PointCoorMesh<T,D>:\n"
533 << "amesh[n] >= amesh[n+1]\n";
534#ifndef TLINE_REDUCE_TO_RAW_ARR
535 Iprint3n(mcerr, n, (*amesh)[n], (*amesh)[n + 1]);
536#else
537 Iprint3n(mcerr, n, amesh[n], amesh[n + 1]);
538#endif
539 spexit(mcerr);
540 }
541 }
542#endif
543
544}
#define spexit(stream)
Definition: FunNameStack.h:536
#define Iprint3n(file, name1, name2, name3)
Definition: prstream.h:249
#define mcerr
Definition: prstream.h:135
#define Iprintn(file, name)
Definition: prstream.h:216
#define Iprint2n(file, name1, name2)
Definition: prstream.h:236

◆ ~PointCoorMesh()

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

Definition at line 457 of file tline.h.

473{}

Member Function Documentation

◆ check()

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

Definition at line 546 of file tline.h.

546 {
547 long n;
548 for (n = 0; n < q - 1; n++) {
549#ifndef TLINE_REDUCE_TO_RAW_ARR
550 if ((*amesh)[n] >= (*amesh)[n + 1])
551#else
552 if (amesh[n] >= amesh[n + 1])
553#endif
554 {
555 mcerr << "ERROR in PointCoorMesh<T,D>::check(void):\n"
556 << "amesh[n] >= amesh[n+1]\n";
557#ifndef TLINE_REDUCE_TO_RAW_ARR
558 Iprint3n(mcerr, n, (*amesh)[n], (*amesh)[n + 1]);
559#else
560 Iprint3n(mcerr, n, amesh[n], amesh[n + 1]);
561#endif
562 spexit(mcerr);
563 }
564 }
565
566}

◆ get_interval() [1/3]

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

Definition at line 439 of file tline.h.

439 {
440 if (n < 0 || n >= q - 1) return 0;
441#ifndef TLINE_REDUCE_TO_RAW_ARR
442 b1 = (*amesh)[n];
443 b2 = (*amesh)[n + 1];
444#else
445 b1 = amesh[n];
446 b2 = amesh[n + 1];
447#endif
448 return 1;
449 }

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

◆ get_interval() [2/3]

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

Definition at line 569 of file tline.h.

569 {
570 if (x < xmin || x >= xmax) {
571 n1 = 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
590 if (n1 < 0) {
591 mcerr << "ERROR in PointCoorMesh<T,D>::get_interval:\n"
592 << "n1 < 0\n";
593 print(mcerr);
594 Iprintn(mcerr, n1);
595 spexit(mcerr);
596 }
597 n_old = n1;
598 x_old = x;
599 return 1;
600}
virtual void print(std::ostream &file) const
Definition: tline.h:715

◆ get_interval() [3/3]

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

Definition at line 603 of file tline.h.

604 {
605 if (x < xmin || x >= xmax) {
606 n1 = 0;
607 n2 = 0;
608 b1 = 0;
609 b2 = 0;
610 return 0;
611 }
612#ifndef TLINE_REDUCE_TO_RAW_ARR
613 if (n_old >= 0 && x_old <= x) {
614 n1 = t_find_interval_end<T, D>(x, q, *amesh, n_old);
615 } else {
616 n1 = t_find_interval<T, D>(x, q, *amesh);
617 }
618//n1 = t_find_interval< T , D >(x, q, amesh);
619#else
620 if (n_old >= 0 && x_old <= x) {
621 n1 = t_find_interval_end<T, T*>(x, q, amesh, n_old);
622 } else {
623 n1 = t_find_interval<T, T*>(x, q, amesh);
624 }
625//n1 = t_find_interval< T , T* >(x, q, &amesh);
626#endif
627 n2 = n1 + 1;
628#ifndef TLINE_REDUCE_TO_RAW_ARR
629 b1 = (*amesh)[n1];
630 b2 = (*amesh)[n2];
631#else
632 b1 = amesh[n1];
633 b2 = amesh[n2];
634#endif
635 if (n1 < 0 || n1 >= q || n2 < 0 || n2 >= q || b1 < xmin || b1 > xmax ||
636 b2 < xmin || b2 > xmax) {
637 mcerr << "ERROR in PointCoorMesh<T,D>::get_interval:\n"
638 << "n1 < 0 || n1 >= q || n2 < 0 || n2 >= q || b1 < xmin || b1 > xmax "
639 "|| b2 < xmin || b2 > xmax\n";
640 print(mcerr);
641 Iprint4n(mcerr, n1, n2, b1, b2);
642 spexit(mcerr);
643 }
644 n_old = n1;
645 x_old = x;
646 return 1;
647}
#define Iprint4n(file, name1, name2, name3, name4)
Definition: prstream.h:260

◆ get_interval_extrap()

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

Definition at line 650 of file tline.h.

651 {
652 int i_ret = 1;
653
654 if (x < xmin) {
655 i_ret = 0;
656 n1 = 0;
657 n2 = 1;
658 b1 = xmin;
659#ifndef TLINE_REDUCE_TO_RAW_ARR
660 b2 = (*amesh)[1];
661#else
662 b2 = amesh[1];
663#endif
664 } else if (x >= xmax) {
665 i_ret = 2;
666 n1 = q - 2;
667 n2 = q - 1;
668#ifndef TLINE_REDUCE_TO_RAW_ARR
669 b1 = (*amesh)[q - 2];
670#else
671 b1 = amesh[q - 2];
672#endif
673 b2 = xmax;
674 } else {
675#ifndef TLINE_REDUCE_TO_RAW_ARR
676 if (n_old >= 0 && x_old <= x) {
677 n1 = t_find_interval_end<T, D>(x, q, *amesh, n_old);
678 } else {
679 n1 = t_find_interval<T, D>(x, q, *amesh);
680 }
681//n1 = t_find_interval< T , D >(x, q, amesh);
682#else
683 if (n_old >= 0 && x_old <= x) {
684 n1 = t_find_interval_end<T, T*>(x, q, amesh, n_old);
685 } else {
686 n1 = t_find_interval<T, T*>(x, q, amesh);
687 }
688//n1 = t_find_interval< T , T* >(x, q, &amesh);
689#endif
690 n2 = n1 + 1;
691#ifndef TLINE_REDUCE_TO_RAW_ARR
692 b1 = (*amesh)[n1];
693 b2 = (*amesh)[n2];
694#else
695 b1 = amesh[n1];
696 b2 = amesh[n2];
697#endif
698 if (n1 < 0 || n1 >= q || n2 < 0 || n2 >= q || b1 < xmin || b1 > xmax ||
699 b2 < xmin || b2 > xmax) {
700 mcerr << "ERROR in PointCoorMesh<T,D>::get_interval:\n"
701 << "n1 < 0 || n1 >= q || n2 < 0 || n2 >= q || b1 < xmin || b1 > "
702 "xmax || b2 < xmin || b2 > xmax\n";
703 print(mcerr);
704 Iprint4n(mcerr, n1, n2, b1, b2);
705 spexit(mcerr);
706 }
707 n_old = n1;
708 x_old = x;
709 }
710 return i_ret;
711
712}

◆ get_qi()

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

Definition at line 428 of file tline.h.

428{ return q - 1; }

◆ get_scoor()

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

Definition at line 431 of file tline.h.

433 {
434 b = (*amesh)[n];
435 }

◆ get_step()

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

Definition at line 457 of file tline.h.

457 {
458 if (n < 0 || n >= q - 1) return 0;
459 T b1, b2;
460 get_interval(n, b1, b2);
461 fstep = b2 - b1;
462 return 1;
463 }
virtual int get_interval(long n, T &b1, T &b2) const
Definition: tline.h:439

◆ get_xmax()

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

Definition at line 430 of file tline.h.

430{ return xmax; }

◆ get_xmin()

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

Definition at line 429 of file tline.h.

429{ return xmin; }

◆ print()

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

Definition at line 715 of file tline.h.

715 {
716 Ifile << "PointCoorMesh<T,D>:\n";
717 indn.n += 2;
718 Ifile << "Type of T is (in internal notations) " << typeid(T).name() << '\n';
719 Ifile << "Type of D is (in internal notations) " << typeid(D).name() << '\n';
720 Iprint3n(file, q, xmin, xmax);
721 Iprint2n(file, n_old, x_old);
722#ifndef TLINE_REDUCE_TO_RAW_ARR
723 Ifile << "(*amesh)=" << (*amesh) << '\n';
724#else
725 Ifile << "amesh:" << '\n';
726 long n;
727 indn.n += 2;
728 for (n = 0; n < q; n++) {
729 Ifile << "n=" << n << " amesh[n]=" << noindent << amesh[n] << yesindent
730 << '\n';
731 }
732 file << yesindent;
733 indn.n -= 2;
734#endif
735 indn.n -= 2;
736}
indentation indn
Definition: prstream.cpp:13
std::ostream & yesindent(std::ostream &f)
Definition: prstream.cpp:19
std::ostream & noindent(std::ostream &f)
Definition: prstream.cpp:15
#define Ifile
Definition: prstream.h:207

Referenced by operator<<().


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