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

#include <EnergyMesh.h>

+ Inheritance diagram for Heed::EnergyMesh:

Public Member Functions

 EnergyMesh ()
 Default constructor.
 
 EnergyMesh (double femin, double femax, long fq)
 Constructor from min./max energy and number of bins.
 
 EnergyMesh (const std::vector< double > &fec)
 Constructor from a list of energies.
 
virtual ~EnergyMesh ()
 Destructor.
 
long get_q () const
 Return number of bins.
 
double get_emin () const
 Return left side of the first bin.
 
double get_emax () const
 Return right side of the last bin.
 
double get_e (long n) const
 Return left side of a given bin.
 
double get_ec (long n) const
 Return center of a given bin.
 
const double * get_ae (void) const
 Return all left sides.
 
const double * get_aec (void) const
 Return all interval centres.
 
long get_interval_number (const double ener) const
 
long get_interval_number_between_centers (const double ener) const
 
virtual EnergyMeshcopy () const
 
virtual void print (std::ostream &file, int l) const
 
- Public Member Functions inherited from Heed::RegPassivePtr
 RegPassivePtr (void)
 
 RegPassivePtr (char fs_ban_del, char fs_ban_sub, char fs_ban_cop=0)
 
 RegPassivePtr (const RegPassivePtr &f)
 
RegPassivePtroperator= (const RegPassivePtr &f)
 
CountPP_ns::CountPassivePtrbook (void) const
 
void clear_pointers (void) const
 
virtual RegPassivePtrcopy () const
 
virtual ~RegPassivePtr ()
 
virtual void print (std::ostream &file, int l=1) const
 
void set_s_ban_del (char fs_ban_del)
 
char get_s_ban_del (void) const
 
void set_s_ban_sub (char fs_ban_sub)
 
char get_s_ban_sub (void) const
 
void set_s_ban_cop (char fs_ban_cop)
 
char get_s_ban_cop (void) const
 
void set_s_allow_del_at_zero_count (char fs_allow_del_at_zero_count)
 
char get_s_allow_del_at_zero_count (void) const
 
long get_total_number_of_references (void) const
 

Friends

std::ostream & operator<< (std::ostream &file, EnergyMesh &f)
 

Additional Inherited Members

- Static Public Member Functions inherited from Heed::RegPassivePtr
static void set_s_ban_del_ignore (char fs_ban_del_ignore)
 
static char get_s_ban_del_ignore (void)
 
static void set_s_print_adr_cpp (char fs_print_adr_cpp)
 
static char get_s_print_adr_cpp (void)
 

Detailed Description

Energy mesh (in MeV, as everywhere in HEED, unless otherwise specified). Internal calculations in HEED are conveniently performed with some standard energy mesh. This mesh should be logarithmic or similar, with dense spacing at small energies and sparse spacing at large energies. The class below determines such mesh and some standard functions, namely getting center of energy interval get_ec(long n), left edge of interval get_e(long n) (right edge is left one for the next bin), and some other simple functions. There may be many meshes in program (but currently only one mesh is used in a single program, different meshes may be used for totally different matters and cross sections). The pointer to mesh should be given as parameter of class constructor, when a class depends on mesh.

The class keeps the left sides of bins and their centers in arrays. Since the right side of interval is the left of the next one, the array keeping the left sides should be by one larger then the dimension of the mesh.

For reasons of speed the internal arrays keep right sides of intervals and their centers are defined as simple fixed-size arrays.

2003, I. Smirnov

Definition at line 33 of file EnergyMesh.h.

Constructor & Destructor Documentation

◆ EnergyMesh() [1/3]

Heed::EnergyMesh::EnergyMesh ( )
inline

Default constructor.

Definition at line 36 of file EnergyMesh.h.

36: q(0), emin(0.0), emax(0.0) {}

Referenced by copy().

◆ EnergyMesh() [2/3]

Heed::EnergyMesh::EnergyMesh ( double  femin,
double  femax,
long  fq 
)

Constructor from min./max energy and number of bins.

Definition at line 8 of file EnergyMesh.cpp.

9 : q(fq), emin(femin), emax(femax) {
10 mfunname("EnergyMesh::EnergyMesh(double femin, double femax, long fq)");
11 check_econd21(q, < 0 ||, > pqener - 1, mcerr);
12
13 const double rk = pow(emax / emin, (1.0 / double(q)));
14 double er = emin;
15 e[0] = er;
16 for (long n = 1; n < q + 1; n++) {
17 e[n] = er * rk;
18 ec[n - 1] = (e[n - 1] + e[n]) * 0.5;
19 er = e[n];
20 }
21}
#define check_econd21(a, sign1_b1_sign0, sign2_b2, stream)
Definition: FunNameStack.h:191
#define mfunname(string)
Definition: FunNameStack.h:45
DoubleAc pow(const DoubleAc &f, double p)
Definition: DoubleAc.cpp:337
#define mcerr
Definition: prstream.h:128

◆ EnergyMesh() [3/3]

Heed::EnergyMesh::EnergyMesh ( const std::vector< double > &  fec)

Constructor from a list of energies.

Definition at line 23 of file EnergyMesh.cpp.

23 : q(fec.size()) {
24 mfunname("std::vector< double > fec");
25 check_econd21(q, < 0 ||, > pqener - 1, mcerr);
26 check_econd11(q, != 1, mcerr); // otherwise problems with emin/emax
27 if (q <= 0) {
28 emin = 0.0;
29 emax = 0.0;
30 return;
31 }
32 emin = fec[0] - (fec[1] - fec[0]) / 2.0;
33 emax = fec[q - 1] + (fec[q - 1] - fec[q - 2]) / 2.0;
34 e[0] = emin;
35 e[q] = emax;
36
37 for (long n = 0; n < q; n++) {
38 ec[n] = fec[n];
39 }
40 for (long n = 1; n < q; n++) {
41 e[n] = 0.5 * (fec[n - 1] + fec[n]);
42 }
43}
#define check_econd11(a, signb, stream)
Definition: FunNameStack.h:155

◆ ~EnergyMesh()

virtual Heed::EnergyMesh::~EnergyMesh ( )
inlinevirtual

Destructor.

Definition at line 42 of file EnergyMesh.h.

42{}

Member Function Documentation

◆ copy()

virtual EnergyMesh * Heed::EnergyMesh::copy ( ) const
inlinevirtual

Reimplemented from Heed::RegPassivePtr.

Definition at line 63 of file EnergyMesh.h.

63{ return new EnergyMesh(*this); }
EnergyMesh()
Default constructor.
Definition: EnergyMesh.h:36

◆ get_ae()

const double * Heed::EnergyMesh::get_ae ( void  ) const
inline

Return all left sides.

Definition at line 55 of file EnergyMesh.h.

55{ return e; }

◆ get_aec()

const double * Heed::EnergyMesh::get_aec ( void  ) const
inline

Return all interval centres.

Definition at line 57 of file EnergyMesh.h.

57{ return ec; }

◆ get_e()

double Heed::EnergyMesh::get_e ( long  n) const
inline

Return left side of a given bin.

Definition at line 51 of file EnergyMesh.h.

51{ return e[n]; }

◆ get_ec()

double Heed::EnergyMesh::get_ec ( long  n) const
inline

Return center of a given bin.

Definition at line 53 of file EnergyMesh.h.

53{ return ec[n]; }

Referenced by Heed::HeedDeltaElectron::physics_after_new_speed(), and Heed::HeedDeltaElectron::physics_mrange().

◆ get_emax()

double Heed::EnergyMesh::get_emax ( ) const
inline

Return right side of the last bin.

Definition at line 49 of file EnergyMesh.h.

49{ return emax; }

◆ get_emin()

double Heed::EnergyMesh::get_emin ( ) const
inline

Return left side of the first bin.

Definition at line 47 of file EnergyMesh.h.

47{ return emin; }

◆ get_interval_number()

long Heed::EnergyMesh::get_interval_number ( const double  ener) const

Definition at line 45 of file EnergyMesh.cpp.

45 {
46 if (ener < emin) return -1;
47 if (ener > emax) return q;
48
49 long n1 = 0;
50 long n2 = q; // right side of last
51 while (n2 - n1 > 1) {
52 const long n3 = n1 + ((n2 - n1) >> 1);
53 if (ener < e[n3]) {
54 n2 = n3;
55 } else {
56 n1 = n3;
57 }
58 }
59 return n1;
60}

◆ get_interval_number_between_centers()

long Heed::EnergyMesh::get_interval_number_between_centers ( const double  ener) const

Definition at line 62 of file EnergyMesh.cpp.

62 {
63 if (ener < ec[0]) return -1;
64 if (ener > ec[q - 1]) return q;
65
66 long n1 = 0;
67 long n2 = q - 1; // right side of last
68 while (n2 - n1 > 1) {
69 const long n3 = n1 + ((n2 - n1) >> 1);
70 if (ener < ec[n3]) {
71 n2 = n3;
72 } else {
73 n1 = n3;
74 }
75 }
76 return n1;
77}

◆ get_q()

long Heed::EnergyMesh::get_q ( ) const
inline

Return number of bins.

Definition at line 45 of file EnergyMesh.h.

45{ return q; }

Referenced by Heed::HeedParticle::physics(), and Heed::HeedParticle_BGM::physics().

◆ print()

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

Reimplemented from Heed::RegPassivePtr.

Definition at line 95 of file EnergyMesh.cpp.

95 {
96 if (l <= 0) return;
97 Ifile << "EnergyMesh (l=" << l << "): \n";
98 indn.n += 2;
99 Ifile << "emin=" << emin << " emax=" << emax << " quantity of intervals=" << q
100 << '\n' << " maximal possible quantity of intervals=" << pqener << '\n';
101 if (l > 1) {
102 Ifile << " number left side center right side widht\n";
103 for (int n = 0; n < q; n++) {
104 Ifile << std::setw(5) << n << std::setw(15) << e[n] << std::setw(15)
105 << ec[n] << std::setw(15) << e[n + 1] << std::setw(15)
106 << (e[n + 1] - e[n]) << '\n';
107 }
108 }
109 indn.n -= 2;
110}
indentation indn
Definition: prstream.cpp:15
#define Ifile
Definition: prstream.h:196

Friends And Related Function Documentation

◆ operator<<

std::ostream & operator<< ( std::ostream &  file,
EnergyMesh f 
)
friend

Definition at line 79 of file EnergyMesh.cpp.

79 {
80 Ifile << "EnergyMesh: \n";
81 indn.n += 2;
82 Ifile << "emin=" << f.emin << " emax=" << f.emax
83 << " number of intervals=" << f.q << '\n'
84 << " maximal number of intervals=" << EnergyMesh::pqener << '\n';
85 Ifile << " bin left side center right side width\n";
86 for (int n = 0; n < f.q; n++) {
87 Ifile << std::setw(5) << n << std::setw(15) << f.e[n] << std::setw(15)
88 << f.ec[n] << std::setw(15) << f.e[n + 1] << std::setw(15)
89 << (f.e[n + 1] - f.e[n]) << '\n';
90 }
91 indn.n -= 2;
92 return file;
93}

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