Garfield++ 3.0
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 460 of file tline.h.

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

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

◆ 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 530 of file tline.h.

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

◆ 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 564 of file tline.h.

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

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

◆ 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 675 of file tline.h.

675 {
676 Ifile << "PointCoorMesh<T,D>:\n";
677 indn.n += 2;
678 Ifile << "Type of T is (in internal notations) " << typeid(T).name() << '\n';
679 Ifile << "Type of D is (in internal notations) " << typeid(D).name() << '\n';
680 Iprint3n(file, q, xmin, xmax);
681 Iprint2n(file, n_old, x_old);
682#ifndef TLINE_REDUCE_TO_RAW_ARR
683 // Ifile << "(*amesh)=" << (*amesh) << '\n';
684 Ifile << "(*amesh)=" << (*amesh)[0] << '\n';
685#else
686 Ifile << "amesh:" << '\n';
687 long n;
688 indn.n += 2;
689 for (n = 0; n < q; n++) {
690 Ifile << "n=" << n << " amesh[n]=" << noindent << amesh[n] << yesindent
691 << '\n';
692 }
693 file << yesindent;
694 indn.n -= 2;
695#endif
696 indn.n -= 2;
697}
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: