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::SimpleTablePhotoAbsCS Class Reference

#include <PhotoAbsCS.h>

+ Inheritance diagram for Heed::SimpleTablePhotoAbsCS:

Public Member Functions

 SimpleTablePhotoAbsCS ()=default
 Default constructor.
 
 SimpleTablePhotoAbsCS (const std::string &fname, int fZ, double fthreshold, const std::string &ffile_name)
 Constructor for reading table from file.
 
 SimpleTablePhotoAbsCS (const std::string &fname, int fZ, double fthreshold, const std::vector< double > &fener, const std::vector< double > &fcs)
 Constructor from given energy and cross-section tables.
 
 SimpleTablePhotoAbsCS (const std::string &fname, int fZ, double fthreshold, int l, double E0, double yw, double ya, double P, double sigma)
 
 SimpleTablePhotoAbsCS (const SimpleTablePhotoAbsCS &total, const SimpleTablePhotoAbsCS &part, double emax_repl)
 Replace part of the cross-section table.
 
virtual ~SimpleTablePhotoAbsCS ()
 Destructor.
 
void remove_leading_zeros ()
 Remove points with zero cross-section from the table.
 
void remove_leading_tiny (double level)
 
double get_CS (double energy) const override
 Retrieve cross-section [Mb] at a given energy [MeV].
 
double get_integral_CS (double energy1, double energy2) const override
 Retrieve integral cross-section [Mb * MeV] in a given interval [MeV].
 
const std::vector< double > & get_arr_ener () const
 
const std::vector< double > & get_arr_CS () const
 
void scale (double fact) override
 Multiply by some factor. Can be useful for debugging and other purposes.
 
void print (std::ostream &file, int l) const override
 
SimpleTablePhotoAbsCScopy () const override
 
- Public Member Functions inherited from Heed::PhotoAbsCS
 PhotoAbsCS ()
 Default constructor.
 
 PhotoAbsCS (const std::string &fname, int fZ, double fthreshold)
 Constructor.
 
virtual ~PhotoAbsCS ()
 Destructor.
 
const std::string & get_name () const
 Name of this shell or atom.
 
int get_number () const
 Number of this shell.
 
int get_Z () const
 
double get_threshold () const
 Return the threshold energy.
 
virtual double get_CS (double energy) const =0
 Retrieve cross-section [Mb] at a given energy [MeV].
 
virtual double get_integral_CS (double energy1, double energy2) const =0
 Retrieve integral cross-section [Mb * MeV] in a given interval [MeV].
 
virtual void scale (double fact)=0
 Multiply by some factor. Can be useful for debugging and other purposes.
 
virtual void print (std::ostream &file, int l) const
 
virtual PhotoAbsCScopy () const =0
 

Additional Inherited Members

- Protected Attributes inherited from Heed::PhotoAbsCS
std::string name
 
int number = 0
 
int Z
 
double threshold
 

Detailed Description

Typically this is for reading Experimental CS, for example of argon, as if there is one shell. File is two-column table, the first row is energy in eV, the second one is CS in Mbarn. The points are understood as local points. The interpolation between them are either straight or by power function. the choice is determined by function sign_nonlinear_interpolation (see above). If the first point is not zero cross section, and the threshold is to the left, the straight extrapolation is performed from the two edge points. The extrapolation to the right is performed to the end of the energy mesh by power function with power -2.75. The minimal number of points is 2, as in PointCoorMesh from tline.h The zero number of points is allowed as well. Then the cross section is assumed to be zero.

Definition at line 160 of file PhotoAbsCS.h.

Constructor & Destructor Documentation

◆ SimpleTablePhotoAbsCS() [1/5]

Heed::SimpleTablePhotoAbsCS::SimpleTablePhotoAbsCS ( )
default

Default constructor.

Referenced by copy().

◆ SimpleTablePhotoAbsCS() [2/5]

Heed::SimpleTablePhotoAbsCS::SimpleTablePhotoAbsCS ( const std::string &  fname,
int  fZ,
double  fthreshold,
const std::string &  ffile_name 
)

Constructor for reading table from file.

Definition at line 194 of file PhotoAbsCS.cpp.

197 : PhotoAbsCS(fname, fZ, fthreshold), file_name(ffile_name) {
198 mfunnamep("SimpleTablePhotoAbsCS::SimpleTablePhotoAbsCS(...)");
199 std::ifstream file(file_name.c_str());
200 if (!file) {
201 funnw.ehdr(mcerr);
202 mcerr << "cannot open file " << file_name << std::endl;
203 spexit(mcerr);
204 }
205 ener.reserve(20);
206 cs.reserve(20);
207 do {
208 // Read the energy.
209 double x = 0.;
210 file >> x;
211 if (!file.good()) break;
212 // Make sure it is non-negative and in ascending order.
213 check_econd11(x, < 0.0, mcerr);
214 if (!ener.empty()) check_econd12(x, <, ener.back(), mcerr);
215 // Read the cross-section.
216 double y = 0.;
217 file >> y;
218 if (!file.good()) break;
219 check_econd11(y, < 0.0, mcerr);
220 // Add the point to the table.
221 ener.push_back(x * 1.e-6);
222 cs.push_back(y);
223 } while (1);
224}
#define check_econd11(a, signb, stream)
Definition: FunNameStack.h:155
#define mfunnamep(string)
Definition: FunNameStack.h:49
#define spexit(stream)
Definition: FunNameStack.h:256
#define check_econd12(a, sign, b, stream)
Definition: FunNameStack.h:163
PhotoAbsCS()
Default constructor.
Definition: PhotoAbsCS.cpp:79
#define mcerr
Definition: prstream.h:128

◆ SimpleTablePhotoAbsCS() [3/5]

Heed::SimpleTablePhotoAbsCS::SimpleTablePhotoAbsCS ( const std::string &  fname,
int  fZ,
double  fthreshold,
const std::vector< double > &  fener,
const std::vector< double > &  fcs 
)

Constructor from given energy and cross-section tables.

Definition at line 226 of file PhotoAbsCS.cpp.

230 : PhotoAbsCS(fname, fZ, fthreshold),
231 file_name("none"),
232 ener(fener),
233 cs(fcs) {
234 mfunname("SimpleTablePhotoAbsCS::SimpleTablePhotoAbsCS(...)");
235 check_econd12(ener.size(), !=, cs.size(), mcerr);
236}
#define mfunname(string)
Definition: FunNameStack.h:45

◆ SimpleTablePhotoAbsCS() [4/5]

Heed::SimpleTablePhotoAbsCS::SimpleTablePhotoAbsCS ( const std::string &  fname,
int  fZ,
double  fthreshold,
int  l,
double  E0,
double  yw,
double  ya,
double  P,
double  sigma 
)

Constructor from fit parameters. Fit formula from Band-Band-Trzaskovskaya et al. It is difficult to integrate those formulas analytically, so I create numerical array and treat it as input data.

Definition at line 238 of file PhotoAbsCS.cpp.

242 : PhotoAbsCS(fname, fZ, fthreshold) {
243 mfunname("SimpleTablePhotoAbsCS::SimpleTablePhotoAbsCS(...)");
244 const long q = 1000;
245 // Make a logarithmic energy mesh.
246 ener.resize(q, 0.);
247 const double emin = 2.e-6;
248 const double emax = 2.e-1;
249 const double rk = pow(emax / emin, (1.0 / double(q)));
250 double e2 = emin;
251 for (long n = 0; n < q; n++) {
252 const double e1 = e2;
253 e2 = e2 * rk;
254 ener[n] = (e1 + e2) * 0.5;
255 }
256 cs.assign(q, 0.);
257 for (long n = 0; n < q; n++) {
258 double energy = ener[n];
259 if (energy < threshold) continue;
260 const double Q = 5.5 + l - 0.5 * P;
261 const double y = energy / E0;
262 const double Fpasc = ((y - 1) * (y - 1) + yw * yw) * pow(y, (-Q)) *
263 pow((1.0 + sqrt(y / ya)), (-P));
264 cs[n] = Fpasc * sigma;
265 }
267}
double threshold
Definition: PhotoAbsCS.h:79
void remove_leading_zeros()
Remove points with zero cross-section from the table.
Definition: PhotoAbsCS.cpp:302
DoubleAc pow(const DoubleAc &f, double p)
Definition: DoubleAc.cpp:337
DoubleAc sqrt(const DoubleAc &f)
Definition: DoubleAc.cpp:314

◆ SimpleTablePhotoAbsCS() [5/5]

Heed::SimpleTablePhotoAbsCS::SimpleTablePhotoAbsCS ( const SimpleTablePhotoAbsCS total,
const SimpleTablePhotoAbsCS part,
double  emax_repl 
)

Replace part of the cross-section table.

Definition at line 269 of file PhotoAbsCS.cpp.

271 {
272 mfunname(
273 "SimpleTablePhotoAbsCS::SimpleTablePhotoAbsCS(const "
274 "SimpleTablePhotoAbsCS& total,...)");
275
276 *this = total; // to assure that all is preserved
277
278 long qe_i = total.ener.size();
279
280 const std::vector<double>& ener_r = part.get_arr_ener();
281 const std::vector<double>& cs_r = part.get_arr_CS();
282 long qe_r = ener_r.size();
283 std::vector<double> new_ener;
284 std::vector<double> new_cs;
285 // first write replacements
286 for (long ne = 0; ne < qe_r; ne++) {
287 if (ener_r[ne] >= total.get_threshold() && ener_r[ne] <= emax_repl) {
288 new_ener.push_back(ener_r[ne]);
289 new_cs.push_back(cs_r[ne]);
290 }
291 }
292 for (long ne = 0; ne < qe_i; ne++) {
293 if (ener[ne] >= total.get_threshold() && ener[ne] > emax_repl) {
294 new_ener.push_back(total.ener[ne]);
295 new_cs.push_back(total.cs[ne]);
296 }
297 }
298 ener.swap(new_ener);
299 cs.swap(new_cs);
300}

◆ ~SimpleTablePhotoAbsCS()

virtual Heed::SimpleTablePhotoAbsCS::~SimpleTablePhotoAbsCS ( )
inlinevirtual

Destructor.

Definition at line 182 of file PhotoAbsCS.h.

182{}

Member Function Documentation

◆ copy()

SimpleTablePhotoAbsCS * Heed::SimpleTablePhotoAbsCS::copy ( ) const
inlineoverridevirtual

Implements Heed::PhotoAbsCS.

Definition at line 197 of file PhotoAbsCS.h.

197 {
198 return new SimpleTablePhotoAbsCS(*this);
199 }
SimpleTablePhotoAbsCS()=default
Default constructor.

◆ get_arr_CS()

const std::vector< double > & Heed::SimpleTablePhotoAbsCS::get_arr_CS ( ) const
inline

Definition at line 194 of file PhotoAbsCS.h.

194{ return cs; }

Referenced by Heed::ExAtomPhotoAbsCS::ExAtomPhotoAbsCS(), and SimpleTablePhotoAbsCS().

◆ get_arr_ener()

const std::vector< double > & Heed::SimpleTablePhotoAbsCS::get_arr_ener ( ) const
inline

Definition at line 193 of file PhotoAbsCS.h.

193{ return ener; }

Referenced by Heed::ExAtomPhotoAbsCS::ExAtomPhotoAbsCS(), and SimpleTablePhotoAbsCS().

◆ get_CS()

double Heed::SimpleTablePhotoAbsCS::get_CS ( double  energy) const
overridevirtual

Retrieve cross-section [Mb] at a given energy [MeV].

Implements Heed::PhotoAbsCS.

Definition at line 337 of file PhotoAbsCS.cpp.

337 {
338 mfunname("double SimpleTablePhotoAbsCS::get_CS(double energy) const");
339 long q = ener.size();
340 if (q == 0) return 0.0;
341 check_econd11(q, == 1, mcerr);
342 if (energy < threshold) return 0.;
343 if (energy <= ener[q - 1]) {
344 PointCoorMesh<double, const std::vector<double> > pcm(q, &ener);
346 double, std::vector<double>,
347 PointCoorMesh<double, const std::vector<double> > >(
348 pcm, cs, &my_val_fun, energy, 1, threshold, 0, DBL_MAX);
349 } else {
350 if (energy == DBL_MAX)
351 return 0.0;
352 else
353 return cs[q - 1] * pow(energy, -2.75) / pow(ener[q - 1], -2.75);
354 }
355}
T t_value_generic_point_ar(const M &mesh, const D &y, T(*funval)(T xp1, T yp1, T xp2, T yp2, T xmin, T xmax, T x), T x, int s_extrap_left, T left_bond, int s_extrap_right, T right_bond)
Definition: tline.h:1615

◆ get_integral_CS()

double Heed::SimpleTablePhotoAbsCS::get_integral_CS ( double  energy1,
double  energy2 
) const
overridevirtual

Retrieve integral cross-section [Mb * MeV] in a given interval [MeV].

Implements Heed::PhotoAbsCS.

Definition at line 357 of file PhotoAbsCS.cpp.

358 {
359 mfunname("double SimpleTablePhotoAbsCS::get_integral_CS(...)");
360
361 const long q = ener.size();
362 if (q == 0) return 0.0;
363 check_econd11(q, == 1, mcerr);
364 if (energy2 < threshold) return 0.0;
365 if (energy1 < threshold) energy1 = threshold;
366 double s = 0.0;
367 double energy21 = ener[q - 1];
368 if (energy1 < energy21) {
369 if (energy21 > energy2) energy21 = energy2;
370 check_econd12(energy1, >, energy21, mcerr);
371 PointCoorMesh<double, const std::vector<double> > pcm(q, &ener);
373 double, std::vector<double>,
374 PointCoorMesh<double, const std::vector<double> > >(
375 pcm, cs, &my_integr_fun, energy1, energy21, 1, threshold, 0, DBL_MAX);
376 }
377 // print(mcout, 3);
378 // mcout << "energy1="<<energy1
379 // << " energy21="<<energy21
380 // << " ener[q-1]="<<ener[q-1]
381 // << " threshold="<<threshold
382 // << " s="<<s<<'\n';
383 check_econd11(s, < 0.0, mcout);
384 if (energy2 > ener[q - 1]) {
385 // add tail
386 if (energy2 == DBL_MAX) {
387 if (energy1 < ener[q - 1]) energy1 = ener[q - 1];
388 double c =
389 cs[q - 1] / (1.75 * pow(ener[q - 1], -2.75)) * pow(energy1, -1.75);
390 // check_econd11(c , < 0.0, mcout);
391 s += c;
392 } else {
393 if (energy1 < ener[q - 1]) energy1 = ener[q - 1];
394 double c = cs[q - 1] / (1.75 * pow(ener[q - 1], -2.75)) *
395 (pow(energy1, -1.75) - pow(energy2, -1.75));
396 // check_econd11(c , < 0.0, mcout);
397 s += c;
398 }
399 }
400 return s;
401}
T t_integ_generic_point_ar(const M &mesh, const D &y, T(*fun)(T xp1, T yp1, T xp2, T yp2, T xmin, T xmax, T x1, T x2), T x1, T x2, int s_extrap_left, T left_bond, int s_extrap_right, T right_bond)
Definition: tline.h:1832
#define mcout
Definition: prstream.h:126

◆ print()

void Heed::SimpleTablePhotoAbsCS::print ( std::ostream &  file,
int  l 
) const
overridevirtual

Reimplemented from Heed::PhotoAbsCS.

Definition at line 409 of file PhotoAbsCS.cpp.

409 {
410 if (l <= 0) return;
411 Ifile << "SimpleTablePhotoAbsCS: name=" << name << " Z = " << Z << "\n";
412 Ifile << " threshold = " << threshold << " file_name=" << file_name << "\n";
413 if (l > 1) {
414 indn.n += 2;
415 const long q = ener.size();
416 for (long n = 0; n < q; ++n) {
417 Ifile << "n=" << n << " ener=" << ener[n] << " cs=" << cs[n] << "\n";
418 }
419 indn.n -= 2;
420 }
421}
std::string name
Definition: PhotoAbsCS.h:76
indentation indn
Definition: prstream.cpp:15
#define Ifile
Definition: prstream.h:195

◆ remove_leading_tiny()

void Heed::SimpleTablePhotoAbsCS::remove_leading_tiny ( double  level)

Remove points with cross section below a given level from the table. The function is designed for Henke tables, which are prepared for database with leading values like 1.0e-15 . Both functions allow to use the straight interpolation to threshold

Definition at line 319 of file PhotoAbsCS.cpp.

319 {
320 const long q = ener.size();
321 long ne = 0;
322 for (ne = 0; ne < q; ne++) {
323 if (cs[ne] > level) break;
324 }
325 if (ne <= 0) return;
326 const long qn = q - ne;
327 std::vector<double> enern(qn);
328 std::vector<double> csn(qn);
329 for (long nez = ne; nez < q; nez++) {
330 enern[nez - ne] = ener[nez];
331 csn[nez - ne] = cs[nez];
332 }
333 ener = enern;
334 cs = csn;
335}

Referenced by Heed::ExAtomPhotoAbsCS::ExAtomPhotoAbsCS().

◆ remove_leading_zeros()

void Heed::SimpleTablePhotoAbsCS::remove_leading_zeros ( )

Remove points with zero cross-section from the table.

Definition at line 302 of file PhotoAbsCS.cpp.

302 {
303 const long q = ener.size();
304 long ne = 0;
305 for (ne = 0; ne < q; ne++) {
306 if (cs[ne] > 0.0) break;
307 }
308 if (ne <= 0) return;
309 const long qn = q - ne;
310 std::vector<double> enern(qn);
311 std::vector<double> csn(qn);
312 for (long nez = ne; nez < q; nez++) {
313 enern[nez - ne] = ener[nez];
314 csn[nez - ne] = cs[nez];
315 }
316 ener = enern;
317 cs = csn;
318}

Referenced by SimpleTablePhotoAbsCS().

◆ scale()

void Heed::SimpleTablePhotoAbsCS::scale ( double  fact)
overridevirtual

Multiply by some factor. Can be useful for debugging and other purposes.

Implements Heed::PhotoAbsCS.

Definition at line 403 of file PhotoAbsCS.cpp.

403 {
404 mfunnamep("void SimpleTablePhotoAbsCS::scale(double fact)");
405 const long q = ener.size();
406 for (long n = 0; n < q; ++n) cs[n] *= fact;
407}

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