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::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 389 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 419 of file tline.h.

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

◆ PointCoorMesh() [2/2]

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

Definition at line 459 of file tline.h.

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

◆ ~PointCoorMesh()

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

Definition at line 419 of file tline.h.

435{}

Member Function Documentation

◆ check()

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

Definition at line 507 of file tline.h.

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

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

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

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

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

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

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

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

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

◆ get_qi()

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

Definition at line 391 of file tline.h.

391{ 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 394 of file tline.h.

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

◆ get_step()

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

Definition at line 419 of file tline.h.

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

◆ get_xmax()

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

Definition at line 393 of file tline.h.

393{ return xmax; }

◆ get_xmin()

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

Definition at line 392 of file tline.h.

392{ return xmin; }

◆ print()

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

Definition at line 684 of file tline.h.

684 {
685 Ifile << "PointCoorMesh<T,D>:\n";
686 indn.n += 2;
687 Ifile << "Type of T is (in internal notations) " << typeid(T).name() << '\n';
688 Ifile << "Type of D is (in internal notations) " << typeid(D).name() << '\n';
689 Iprint3n(file, q, xmin, xmax);
690 Iprint2n(file, n_old, x_old);
691#ifndef TLINE_REDUCE_TO_RAW_ARR
692 // Ifile << "(*amesh)=" << (*amesh) << '\n';
693 Ifile << "(*amesh)=" << (*amesh)[0] << '\n';
694#else
695 Ifile << "amesh:" << '\n';
696 long n;
697 indn.n += 2;
698 for (n = 0; n < q; n++) {
699 Ifile << "n=" << n << " amesh[n]=" << noindent << amesh[n] << yesindent
700 << '\n';
701 }
702 file << yesindent;
703 indn.n -= 2;
704#endif
705 indn.n -= 2;
706}
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:195

Referenced by Heed::operator<<().


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