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::EqualStepCoorMesh< T > Class Template Reference

#include <tline.h>

Public Member Functions

long get_qi (void) const
 Get number of intervals.
 
get_xmin (void) const
 
get_xmax (void) const
 
void get_scoor (long n, T &b) const
 
int get_interval (long n, T &b1, T &b2) const
 Get interval. Return 1 if interval is found.
 
virtual int get_interval (T x, long &n1) const
 
virtual int get_interval (T x, long &n1, T &b1, long &n2, T &b2) const
 
virtual int get_interval_extrap (T x, long &n1, T &b1, long &n2, T &b2) const
 
int get_step (long n, T &fstep) const
 
 EqualStepCoorMesh ()
 
 EqualStepCoorMesh (long fq, T fxmin, T fxmax)
 
void print (std::ostream &file) const
 

Detailed Description

template<class T>
class Heed::EqualStepCoorMesh< T >

Mesh with equal steps. Determined by the number of "bins", minimum and maximum. The object of this class keeps all ingredients in it. It can be therefore copied and deleted freely. T is the type of returned value. T cannot be const. At construction q has meaning of number of intervals.

Definition at line 63 of file tline.h.

Constructor & Destructor Documentation

◆ EqualStepCoorMesh() [1/2]

template<class T >
Heed::EqualStepCoorMesh< T >::EqualStepCoorMesh ( )
inline

Definition at line 100 of file tline.h.

106: q(0), xmin(0), xmax(0), step(0) {}

◆ EqualStepCoorMesh() [2/2]

template<class T >
Heed::EqualStepCoorMesh< T >::EqualStepCoorMesh ( long  fq,
fxmin,
fxmax 
)

Definition at line 121 of file tline.h.

122 : q(fq), xmin(fxmin), xmax(fxmax) {
123 mfunname(
124 "template<class T> EqualStepCoorMesh<T>::EqualStepCoorMesh<T>(long "
125 "fq, T fxmin, T fxmax)");
126 check_econd11(q, < 0, mcerr);
127 check_econd24(q, ==, 0, &&, xmin, <, xmax, mcerr);
128 check_econd12(xmin, >, xmax, mcerr);
129 step = (fxmax - fxmin) / q;
130 check_econd11(step, == 0, mcerr);
131}
#define check_econd11(a, signb, stream)
Definition: FunNameStack.h:155
#define check_econd24(a1, sign1, b1, sign0, a2, sign2, b2, stream)
Definition: FunNameStack.h:211
#define check_econd12(a, sign, b, stream)
Definition: FunNameStack.h:163
#define mfunname(string)
Definition: FunNameStack.h:45
#define mcerr
Definition: prstream.h:128

Member Function Documentation

◆ get_interval() [1/3]

template<class T >
int Heed::EqualStepCoorMesh< T >::get_interval ( long  n,
T &  b1,
T &  b2 
) const
inline

Get interval. Return 1 if interval is found.

Definition at line 75 of file tline.h.

75 {
76 if (n < 0 || n >= q) return 0;
77 b1 = xmin + n * step;
78 b2 = b1 + step;
79 return 1;
80 }

◆ get_interval() [2/3]

template<class T >
int Heed::EqualStepCoorMesh< T >::get_interval ( x,
long &  n1 
) const
virtual

Get interval.

Parameters
xcoordinate
n1bin number

Definition at line 134 of file tline.h.

134 {
135 if (x < xmin || x >= xmax) {
136 n1 = 0;
137 return 0;
138 }
139 n1 = long((x - xmin) / step);
140 if (n1 < 0) {
141 mcerr << "ERROR in EqualStepCoorMesh<T>::get_interval: n1 < 0\n";
142 print(mcerr);
143 Iprintn(mcerr, x);
144 Iprintn(mcerr, n1);
145 spexit(mcerr);
146 }
147 return 1;
148}
#define spexit(stream)
Definition: FunNameStack.h:256
void print(std::ostream &file) const
Definition: tline.h:214
#define Iprintn(file, name)
Definition: prstream.h:204

◆ get_interval() [3/3]

template<class T >
int Heed::EqualStepCoorMesh< T >::get_interval ( x,
long &  n1,
T &  b1,
long &  n2,
T &  b2 
) const
virtual

Definition at line 151 of file tline.h.

152 {
153 if (x < xmin || x >= xmax) {
154 n1 = 0;
155 n2 = 0;
156 b1 = 0;
157 b2 = 0;
158 return 0;
159 }
160 n1 = long((x - xmin) / step);
161 n2 = n1 + 1;
162 b1 = xmin + step * n1;
163 b2 = b1 + step;
164 if (n1 < 0 || n2 > q || b2 > xmax) {
165 mcerr << "ERROR in EqualStepCoorMesh<T>::get_interval:\n"
166 << "n1 < 0 || n2 > q || b2 > xmax\n";
167 print(mcerr);
168 Iprintn(mcerr, x);
169 Iprint4n(mcerr, n1, n2, b1, b2);
170 spexit(mcerr);
171 }
172 return 1;
173}
#define Iprint4n(file, name1, name2, name3, name4)
Definition: prstream.h:243

◆ get_interval_extrap()

template<class T >
int Heed::EqualStepCoorMesh< T >::get_interval_extrap ( x,
long &  n1,
T &  b1,
long &  n2,
T &  b2 
) const
virtual

Definition at line 176 of file tline.h.

177 {
178 int i_ret = 1;
179
180 if (x < xmin) {
181 i_ret = 0;
182 n1 = 0;
183 n2 = 1;
184 b1 = xmin;
185 b2 = xmin + step;
186 } else if (x >= xmax) {
187 i_ret = 2;
188 n1 = q - 1;
189 n2 = q;
190 b1 = xmax - step;
191 b2 = xmax;
192 } else {
193 n1 = long((x - xmin) / step);
194 n2 = n1 + 1;
195 if (n2 == q) {
196 b2 = xmax;
197 b1 = b2 - step;
198 } else {
199 b1 = xmin + step * n1;
200 b2 = b1 + step;
201 if (n1 < 0 || n2 > q || b2 > xmax) {
202 mcerr << "ERROR in EqualStepCoorMesh<T>::get_interval_extrap:\n"
203 << "n1 < 0 || n2 > q || b2 > xmax\n";
204 print(mcerr);
205 Iprint4n(mcerr, n1, n2, b1, b2);
206 spexit(mcerr);
207 }
208 }
209 }
210 return i_ret;
211}

◆ get_qi()

template<class T >
long Heed::EqualStepCoorMesh< T >::get_qi ( void  ) const
inline

Get number of intervals.

Definition at line 66 of file tline.h.

66{ return q; }

Referenced by Heed::apeq_mant(), Heed::operator!=(), and Heed::operator==().

◆ get_scoor()

template<class T >
void Heed::EqualStepCoorMesh< T >::get_scoor ( long  n,
T &  b 
) const
inline

Get single coordinate of the point in the mesh. It can be last point of the last interval.

Definition at line 73 of file tline.h.

73{ b = xmin + n * step; }

◆ get_step()

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

Definition at line 100 of file tline.h.

100 {
101 if (n < 0 || n >= q) return 0;
102 fstep = step;
103 return 1;
104 }

◆ get_xmax()

template<class T >
T Heed::EqualStepCoorMesh< T >::get_xmax ( void  ) const
inline

Definition at line 69 of file tline.h.

69{ return xmax; }

Referenced by Heed::apeq_mant(), Heed::operator!=(), and Heed::operator==().

◆ get_xmin()

template<class T >
T Heed::EqualStepCoorMesh< T >::get_xmin ( void  ) const
inline

Definition at line 68 of file tline.h.

68{ return xmin; }

Referenced by Heed::apeq_mant(), Heed::operator!=(), and Heed::operator==().

◆ print()

template<class T >
void Heed::EqualStepCoorMesh< T >::print ( std::ostream &  file) const

Definition at line 214 of file tline.h.

214 {
215 Ifile << "EqualStepCoorMesh<T>:\n";
216 indn.n += 2;
217 Ifile << "Type of T is (in internal notations) " << typeid(T).name() << '\n';
218 Iprint4n(file, q, xmin, xmax, step);
219 indn.n -= 2;
220}
indentation indn
Definition: prstream.cpp:15
#define Ifile
Definition: prstream.h:195

Referenced by Heed::operator<<().


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