Garfield++ 3.0
A toolkit for the detailed simulation of particle detectors based on ionisation measurement in gases and semiconductors
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
EnergyMesh.h
Go to the documentation of this file.
1#ifndef ENERGYMESH_H
2#define ENERGYMESH_H
3
4#include <vector>
5
6namespace Heed {
7
8/// Energy mesh (in MeV, as everywhere in HEED, unless otherwise specified).
9/// Internal calculations in HEED are conveniently performed
10/// with some standard energy mesh. This mesh should be logarithmic or similar,
11/// with dense spacing at small energies and sparse spacing at large energies.
12/// The class below determines such mesh and some standard functions, namely
13/// getting center of energy interval get_ec(long n), left edge of interval
14/// get_e(long n) (right edge is left one for the next bin),
15/// and some other simple functions.
16/// There may be many meshes in program (but currently only one mesh
17/// is used in a single program, different meshes may be used for totally
18/// different matters and cross sections). The pointer
19/// to mesh should be given as parameter of class constructor,
20/// when a class depends on mesh.
21///
22/// The class keeps the left sides of bins and their centers in arrays.
23/// Since the right side of interval is the left of the next one,
24/// the array keeping the left sides should be by one larger then
25/// the dimension of the mesh.
26///
27/// For reasons of speed the internal arrays keep right sides of intervals
28/// and their centers are defined as simple fixed-size arrays.
29///
30/// 2003, I. Smirnov
31
33 public:
34 /// Default constructor.
35 EnergyMesh() = default;
36 /// Constructor from min./max energy and number of bins.
37 EnergyMesh(double femin, double femax, long fq);
38 /// Constructor from a list of energies.
39 EnergyMesh(const std::vector<double>& fec);
40
41 /// Return number of bins.
42 inline long get_q() const { return q; }
43 /// Return left side of the first bin.
44 inline double get_emin() const { return emin; }
45 /// Return right side of the last bin.
46 inline double get_emax() const { return emax; }
47 /// Return left side of a given bin.
48 inline double get_e(long n) const { return e[n]; }
49 /// Return center of a given bin.
50 inline double get_ec(long n) const { return ec[n]; }
51 /// Return all left sides.
52 inline const double* get_ae(void) const { return e; }
53 /// Return all interval centres.
54 inline const double* get_aec(void) const { return ec; }
55
56 long get_interval_number(const double ener) const;
57 long get_interval_number_between_centers(const double ener) const; // left
58 friend std::ostream& operator<<(std::ostream& file, EnergyMesh& f);
59
60 EnergyMesh* copy() const { return new EnergyMesh(*this); }
61 void print(std::ostream& file, int l) const;
62
63 private:
64 /// qener-1 is maximal possible number of bins
65 static const int pqener = 1001;
66 /// Number of intervals
67 long q = 0;
68 /// Left side of the first interval
69 double emin = 0.;
70 /// Right side of the last interval
71 double emax = 0.;
72 /// Left side of interval, q + 1 numbers
73 double e[pqener];
74 /// Center of interval, q numbers
75 double ec[pqener - 1];
76};
77}
78
79#endif
const double * get_ae(void) const
Return all left sides.
Definition: EnergyMesh.h:52
void print(std::ostream &file, int l) const
Definition: EnergyMesh.cpp:95
double get_emin() const
Return left side of the first bin.
Definition: EnergyMesh.h:44
EnergyMesh * copy() const
Definition: EnergyMesh.h:60
long get_q() const
Return number of bins.
Definition: EnergyMesh.h:42
friend std::ostream & operator<<(std::ostream &file, EnergyMesh &f)
Definition: EnergyMesh.cpp:79
double get_emax() const
Return right side of the last bin.
Definition: EnergyMesh.h:46
EnergyMesh()=default
Default constructor.
const double * get_aec(void) const
Return all interval centres.
Definition: EnergyMesh.h:54
double get_ec(long n) const
Return center of a given bin.
Definition: EnergyMesh.h:50
double get_e(long n) const
Return left side of a given bin.
Definition: EnergyMesh.h:48
long get_interval_number_between_centers(const double ener) const
Definition: EnergyMesh.cpp:62
long get_interval_number(const double ener) const
Definition: EnergyMesh.cpp:45
Definition: BGMesh.cpp:6