Garfield++ v1r0
A toolkit for the detailed simulation of particle detectors based on ionisation measurement in gases and semiconductors
Loading...
Searching...
No Matches
Heed::SimpleTablePhotoAbsCS Class Reference

#include <PhotoAbsCS.h>

+ Inheritance diagram for Heed::SimpleTablePhotoAbsCS:

Public Member Functions

 SimpleTablePhotoAbsCS ()
 
 SimpleTablePhotoAbsCS (const String &fname, int fZ, double fthreshold, const String &ffile_name)
 
 SimpleTablePhotoAbsCS (const String &fname, int fZ, double fthreshold, const DynLinArr< double > &fener, const DynLinArr< double > &fcs)
 
 SimpleTablePhotoAbsCS (const String &fname, int fZ, double fthreshold, int l, double E0, double yw, double ya, double P, double sigma)
 
 SimpleTablePhotoAbsCS (const SimpleTablePhotoAbsCS &total, const SimpleTablePhotoAbsCS &part, double emax_repl)
 
virtual ~SimpleTablePhotoAbsCS ()
 
void remove_leading_zeros (void)
 
void remove_leading_tiny (double level)
 
virtual double get_CS (double energy) const
 
virtual double get_integral_CS (double energy1, double energy2) const
 
const DynLinArr< double > & get_arr_ener () const
 
const DynLinArr< double > & get_arr_CS () const
 
virtual void scale (double fact)
 
virtual void print (std::ostream &file, int l) const
 
 macro_copy_total (SimpleTablePhotoAbsCS)
 

Detailed Description

Definition at line 177 of file PhotoAbsCS.h.

Constructor & Destructor Documentation

◆ SimpleTablePhotoAbsCS() [1/5]

Heed::SimpleTablePhotoAbsCS::SimpleTablePhotoAbsCS ( )

◆ SimpleTablePhotoAbsCS() [2/5]

Heed::SimpleTablePhotoAbsCS::SimpleTablePhotoAbsCS ( const String fname,
int  fZ,
double  fthreshold,
const String ffile_name 
)

Definition at line 413 of file PhotoAbsCS.cpp.

416 : PhotoAbsCS(fname, fZ, fthreshold), file_name(ffile_name) {
417 mfunnamep("SimpleTablePhotoAbsCS::SimpleTablePhotoAbsCS(...)");
418#ifdef USE_STLSTRING
419 std::ifstream file(file_name.c_str());
420#else
421 std::ifstream file(file_name);
422#endif
423 if (!file) {
424 funnw.ehdr(mcerr);
425 mcerr << "cannot open file " << file_name << std::endl;
426 spexit(mcerr);
427 }
428 long q = 0; // number of read values
429 ener = DynLinArr<double>(10, 0.0);
430 cs = DynLinArr<double>(10, 0.0);
431 do {
432 file >> ener[q];
433 //Iprintn(mcout, file.good());
434 //Iprintn(mcout, file.eof());
435 //Iprintn(mcout, file.fail());
436 //Iprintn(mcout, file.bad());
437 //file.clear(); // idiotic thing necessary for the new compiler
438 if (!file.good()) break;
439 check_econd11(ener[q], < 0.0, mcerr);
440 if (q > 0) {
441 check_econd12(ener[q], <, ener[q - 1], mcerr);
442 }
443 ener[q] *= 1.0e-6; // convertion to MeV
444 file >> cs[q];
445 if (!file.good()) break;
446 check_econd11(cs[q], < 0.0, mcerr);
447 q++;
448 if (q == ener.get_qel()) { // increasing the size of arrays
449 long q1 = q * 2;
450 ener.put_qel(q1);
451 cs.put_qel(q1);
452 }
453 } while (1);
454 if (q != ener.get_qel()) { // reducing the size if necessary
455 ener.put_qel(q);
456 cs.put_qel(q);
457 }
458
459}
#define check_econd11(a, signb, stream)
Definition: FunNameStack.h:366
#define mfunnamep(string)
Definition: FunNameStack.h:77
#define spexit(stream)
Definition: FunNameStack.h:536
#define check_econd12(a, sign, b, stream)
Definition: FunNameStack.h:380
#define mcerr
Definition: prstream.h:135

◆ SimpleTablePhotoAbsCS() [3/5]

Heed::SimpleTablePhotoAbsCS::SimpleTablePhotoAbsCS ( const String fname,
int  fZ,
double  fthreshold,
const DynLinArr< double > &  fener,
const DynLinArr< double > &  fcs 
)

Definition at line 460 of file PhotoAbsCS.cpp.

464 : PhotoAbsCS(fname, fZ, fthreshold),
465 file_name("none"),
466 ener(fener),
467 cs(fcs) {
468 mfunname("SimpleTablePhotoAbsCS::SimpleTablePhotoAbsCS(...)");
469 check_econd12(ener.get_qel(), !=, cs.get_qel(), mcerr);
470}
#define mfunname(string)
Definition: FunNameStack.h:67
long get_qel(void) const
Definition: AbsArr.h:420

◆ SimpleTablePhotoAbsCS() [4/5]

Heed::SimpleTablePhotoAbsCS::SimpleTablePhotoAbsCS ( const String fname,
int  fZ,
double  fthreshold,
int  l,
double  E0,
double  yw,
double  ya,
double  P,
double  sigma 
)

Definition at line 472 of file PhotoAbsCS.cpp.

476 : PhotoAbsCS(fname, fZ, fthreshold) {
477 mfunname("SimpleTablePhotoAbsCS::SimpleTablePhotoAbsCS");
478 long q = 1000;
479 ener = make_log_mesh_ec(2.0e-6, 2.0e-1, q);
480 cs.put_qel(q, 0.0);
481 long n;
482 for (n = 0; n < q; n++) {
483 double energy = ener[n];
484 if (energy < threshold)
485 cs[n] = 0.0;
486 else {
487 double Q = 5.5 + l - 0.5 * P;
488 double y = energy / E0;
489 double Fpasc = ((y - 1) * (y - 1) + yw * yw) * pow(y, (-Q)) *
490 pow((1.0 + sqrt(y / ya)), (-P));
491 Fpasc = Fpasc * sigma;
492 cs[n] = Fpasc;
493 //Iprint3n(mcout, energy, E0, threshold);
494 //Iprint4n(mcout, Q, y, sigma, Fpasc);
495 }
496 }
498}
DoubleAc pow(const DoubleAc &f, double p)
Definition: DoubleAc.cpp:336
DoubleAc sqrt(const DoubleAc &f)
Definition: DoubleAc.cpp:313
void put_qel(long fqel)
Definition: AbsArr.h:774
DynLinArr< double > make_log_mesh_ec(double emin, double emax, long q)
Definition: EnergyMesh.cpp:146

◆ SimpleTablePhotoAbsCS() [5/5]

Heed::SimpleTablePhotoAbsCS::SimpleTablePhotoAbsCS ( const SimpleTablePhotoAbsCS total,
const SimpleTablePhotoAbsCS part,
double  emax_repl 
)

Definition at line 500 of file PhotoAbsCS.cpp.

502 {
503 mfunname("SimpleTablePhotoAbsCS::SimpleTablePhotoAbsCS (const "
504 "SimpleTablePhotoAbsCS& total,...)");
505
506 *this = total; // to assure that all is preserved
507
508 long qe_i = total.ener.get_qel();
509
510 const DynLinArr<double>& ener_r = part.get_arr_ener();
511 const DynLinArr<double>& cs_r = part.get_arr_CS();
512 long qe_r = ener_r.get_qel();
513 BlkArr<double> new_ener; // arrays to grow
514 BlkArr<double> new_cs;
515 long qe = 0;
516 long ne;
517 for (ne = 0; ne < qe_r; ne++) // first write replacements
518 {
519 if (ener_r[ne] >= total.get_threshold() && ener_r[ne] <= emax_repl) {
520 qe++;
521 new_ener.put_qel(qe);
522 new_cs.put_qel(qe);
523 new_ener[qe - 1] = ener_r[ne];
524 new_cs[qe - 1] = cs_r[ne];
525 }
526 }
527 for (ne = 0; ne < qe_i; ne++) {
528 if (ener[ne] >= total.get_threshold() && ener[ne] > emax_repl) {
529 qe++;
530 new_ener.put_qel(qe);
531 new_cs.put_qel(qe);
532 new_ener[qe - 1] = total.ener[ne];
533 new_cs[qe - 1] = total.cs[ne];
534 }
535 }
536 ener.put_qel(qe);
537 cs.put_qel(qe);
538 for (ne = 0; ne < qe; ne++) {
539 ener[ne] = new_ener[ne];
540 cs[ne] = new_cs[ne];
541 //Iprint3n(mcout, ne, ener[ne], cs[ne]);
542
543 }
544}
Definition: BlkArr.h:80
void put_qel(long fqel)
Definition: BlkArr.h:354

◆ ~SimpleTablePhotoAbsCS()

virtual Heed::SimpleTablePhotoAbsCS::~SimpleTablePhotoAbsCS ( )
inlinevirtual

Definition at line 194 of file PhotoAbsCS.h.

194{}

Member Function Documentation

◆ get_arr_CS()

const DynLinArr< double > & Heed::SimpleTablePhotoAbsCS::get_arr_CS ( ) const
inline

Definition at line 211 of file PhotoAbsCS.h.

211{ return cs; }

Referenced by Heed::ExAtomPhotoAbsCS::ExAtomPhotoAbsCS(), and SimpleTablePhotoAbsCS().

◆ get_arr_ener()

const DynLinArr< double > & Heed::SimpleTablePhotoAbsCS::get_arr_ener ( ) const
inline

Definition at line 210 of file PhotoAbsCS.h.

210{ return ener; }

Referenced by Heed::ExAtomPhotoAbsCS::ExAtomPhotoAbsCS(), and SimpleTablePhotoAbsCS().

◆ get_CS()

double Heed::SimpleTablePhotoAbsCS::get_CS ( double  energy) const
virtual

Definition at line 585 of file PhotoAbsCS.cpp.

585 {
586 mfunname("double SimpleTablePhotoAbsCS::get_CS(double energy) const");
587 //mcout<<"SimpleTablePhotoAbsCS::get_CS is started\n";
588 //Iprintn(mcout, energy);
589 long q = ener.get_qel();
590 if (q == 0) return 0.0;
591 check_econd11(q, == 1, mcerr);
592 //Iprint3n(mcout, threshold, ener[0], energy);
593 if (energy < threshold)
594 return 0.0;
595 else {
596 if (energy <= ener[q - 1]) {
597 //mcout<<"Create mesh\n";
599 double s;
601 double, DynLinArr<double>,
603 pcmd, cs, &my_val_fun, energy, 1, threshold, 0, DBL_MAX);
604 return s;
605 } else {
606 if (energy == DBL_MAX)
607 return 0.0;
608 else
609 return cs[q - 1] * pow(energy, -2.75) / pow(ener[q - 1], -2.75);
610 }
611
612 /*
613 long i1, i2;
614 long q = ener.get_qel();
615 if(energy < ener[0])
616 {
617 i1 = 0;
618 i2 = 1;
619 return cs[i1] + (energy - ener[i1])*(cs[i2] - cs[i1])/
620 (ener[i2] - ener[i1]);
621 }
622 else
623 {
624 if(energy < ener[q-1])
625 {
626 // now find interval
627 i1 = 0;
628 i2 = q-1;
629 while( i2 - i1 != 1)
630 {
631 long i3 = (i1 + i2)/2;
632 if(energy < ener[i3])
633 i2 = i3;
634 else
635 i1 = i3;
636 }
637 //mcout<<"i12="<<i1<<' '<<i2
638 // <<" ener="<< ener[i1] <<' '<< ener[i2] <<std::endl;
639 // now make interpolation
640 // linear is not always good
641 //return cs[i1] + (energy -
642 // ener[i1])*(cs[i2] - cs[i1])/(ener[i2] - ener[i1]);
643 //if(cs[i2] >= cs[i1] || ener[i2] < 1.2*ener[i1] ||
644 // cs[i1] == 0 || cs[i2] == 0 )
645 if( sign_nonlinear_interpolation(ener[i1], cs[i1],
646 ener[i2], cs[i2], threshold) == 0 )
647 { // linear case
648 //mcout<<"linear\n";
649 //Iprintn(mcout, cs[i1] + (energy - ener[i1])*(cs[i2] -
650 cs[i1])/(ener[i2] - ener[i1]) );
651 return cs[i1] + (energy -
652 ener[i1])*(cs[i2] - cs[i1])/(ener[i2] - ener[i1]);
653 }
654 else
655 {
656 //mcout<<"power\n";
657 //power
658 double pw = log(cs[i1]/cs[i2]) / log(ener[i1]/ener[i2]);
659 //Iprintn(mcout, pw);
660 return cs[i1] * pow( energy , pw ) / pow( ener[i1] , pw );
661 }
662 }
663 else
664 {
665 return cs[q-1] * pow( energy , -2.75 ) / pow( ener[q-1] , -2.75 );
666 }
667 }
668 */
669 }
670}
double my_val_fun(double xp1, double yp1, double xp2, double yp2, double xmin, double, double x)
Definition: PhotoAbsCS.cpp:60
T t_value_generic_point_ar(const M &mesh, const D &y, T(*funval)(T xp1, T yp1, T xp2, T yp2, T xmin, T xmax, T x), T x, int s_extrap_left, T left_bond, int s_extrap_right, T right_bond)
Definition: tline.h:2572

◆ get_integral_CS()

double Heed::SimpleTablePhotoAbsCS::get_integral_CS ( double  energy1,
double  energy2 
) const
virtual

Definition at line 672 of file PhotoAbsCS.cpp.

673 {
674 mfunname("double SimpleTablePhotoAbsCS::get_integral_CS(...)");
675
676 long q = ener.get_qel();
677 if (q == 0) return 0.0;
678 check_econd11(q, == 1, mcerr);
679 //Iprint2n(mcout, energy2, threshold);
680 if (energy2 < threshold) return 0.0;
681 if (energy1 < threshold) energy1 = threshold;
682 double s = 0.0;
683 double energy21 = ener[q - 1];
684 if (energy1 < energy21) {
685 if (energy21 > energy2) energy21 = energy2;
686 check_econd12(energy1, >, energy21, mcerr);
687 s = glin_integ_ar(ener, cs, ener.get_qel(), energy1, energy21, threshold);
688 }
689 //print(mcout, 3);
690 //mcout << "energy1="<<energy1
691 // << " energy21="<<energy21
692 // << " ener[q-1]="<<ener[q-1]
693 // << " threshold="<<threshold
694 // << " s="<<s<<'\n';
695 check_econd11(s, < 0.0, mcout);
696 if (energy2 > ener[q - 1]) {
697 // add tail
698 if (energy2 == DBL_MAX) {
699 if (energy1 < ener[q - 1]) energy1 = ener[q - 1];
700 double c =
701 cs[q - 1] / (1.75 * pow(ener[q - 1], -2.75)) * pow(energy1, -1.75);
702 //check_econd11(c , < 0.0, mcout);
703 s += c;
704 } else {
705 if (energy1 < ener[q - 1]) energy1 = ener[q - 1];
706 double c = cs[q - 1] / (1.75 * pow(ener[q - 1], -2.75)) *
707 (pow(energy1, -1.75) - pow(energy2, -1.75));
708 //check_econd11(c , < 0.0, mcout);
709 s += c;
710 }
711 }
712 return s;
713}
double glin_integ_ar(DynLinArr< double > x, DynLinArr< double > y, long q, double x1, double x2, double threshold)
Definition: PhotoAbsCS.cpp:74
#define mcout
Definition: prstream.h:133

◆ macro_copy_total()

Heed::SimpleTablePhotoAbsCS::macro_copy_total ( SimpleTablePhotoAbsCS  )

◆ print()

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

Definition at line 723 of file PhotoAbsCS.cpp.

723 {
724 if (l > 0) {
725 Ifile << "SimpleTablePhotoAbsCS: name=" << name << " Z = " << Z
726 << std::endl;
727 Ifile << " threshold = " << threshold << " file_name=" << file_name
728 << std::endl;
729 if (l > 1) {
730 indn.n += 2;
731 for (long n = 0; n < ener.get_qel(); ++n) {
732 Ifile << "n=" << n << " ener=" << ener[n] << " cs=" << cs[n]
733 << std::endl;
734 }
735 indn.n -= 2;
736 }
737 }
738}
indentation indn
Definition: prstream.cpp:13
#define Ifile
Definition: prstream.h:207

◆ remove_leading_tiny()

void Heed::SimpleTablePhotoAbsCS::remove_leading_tiny ( double  level)

Definition at line 565 of file PhotoAbsCS.cpp.

565 {
566 long q = ener.get_qel();
567 long ne;
568 long nez;
569 for (ne = 0; ne < q; ne++) {
570 if (cs[ne] > level) break;
571 }
572 if (ne > 0) {
573 long qn = q - ne;
574 DynLinArr<double> enern(qn);
575 DynLinArr<double> csn(qn);
576 for (nez = ne; nez < q; nez++) {
577 enern[nez - ne] = ener[nez];
578 csn[nez - ne] = cs[nez];
579 }
580 ener = enern;
581 cs = csn;
582 }
583}

Referenced by Heed::ExAtomPhotoAbsCS::ExAtomPhotoAbsCS().

◆ remove_leading_zeros()

void Heed::SimpleTablePhotoAbsCS::remove_leading_zeros ( void  )

Definition at line 546 of file PhotoAbsCS.cpp.

546 {
547 long q = ener.get_qel();
548 long ne;
549 long nez;
550 for (ne = 0; ne < q; ne++) {
551 if (cs[ne] > 0.0) break;
552 }
553 if (ne > 0) {
554 long qn = q - ne;
555 DynLinArr<double> enern(qn);
556 DynLinArr<double> csn(qn);
557 for (nez = ne; nez < q; nez++) {
558 enern[nez - ne] = ener[nez];
559 csn[nez - ne] = cs[nez];
560 }
561 ener = enern;
562 cs = csn;
563 }
564}

Referenced by Heed::ExAtomPhotoAbsCS::ExAtomPhotoAbsCS(), and SimpleTablePhotoAbsCS().

◆ scale()

void Heed::SimpleTablePhotoAbsCS::scale ( double  fact)
virtual

Definition at line 715 of file PhotoAbsCS.cpp.

715 {
716 mfunnamep("void SimpleTablePhotoAbsCS::scale(double fact)");
717 long q = ener.get_qel();
718 for (long n = 0; n < q; ++n) {
719 cs[n] *= fact;
720 }
721}

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