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