Garfield++ 3.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:\n"
142 << "n1 < 0 \n";
143 print(mcerr);
144 Iprintn(mcerr, x);
145 Iprintn(mcerr, n1);
146 spexit(mcerr);
147 }
148 return 1;
149}
#define spexit(stream)
Definition: FunNameStack.h:256
void print(std::ostream &file) const
Definition: tline.h:215
#define Iprintn(file, name)
Definition: prstream.h:205

◆ 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 152 of file tline.h.

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

◆ 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 177 of file tline.h.

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

◆ 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 215 of file tline.h.

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

Referenced by Heed::operator<<().


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