Belle II Software development
TNiel Class Reference

TNiel - the class providing values for NIEL factors. More...

#include <niel_fun.h>

Public Member Functions

 TNiel (const std::string &FileName)
 Constructor takes NIEL table for a particle as input.
 
double getNielFactor (double EMeV)
 Get NIEL factor for a given particle energy.
 

Private Attributes

double nielfactor [1710]
 factor values, enough to acommodate the longest file.
 
double E_nielfactor [1710]
 particle energies at which the NIEL factor is tabulated.
 
int niel_N
 number of rows in NIEL table
 

Detailed Description

TNiel - the class providing values for NIEL factors.

The class constructs a spline from a data table, and evaluates the spline at a desired point.

Definition at line 17 of file niel_fun.h.

Constructor & Destructor Documentation

◆ TNiel()

TNiel ( const std::string &  FileName)
explicit

Constructor takes NIEL table for a particle as input.

Parameters
FileNameString containing the table filename.

Definition at line 44 of file niel_fun.cc.

45{
46 string fullName = FileSystem::findFile(FileName);
47 if (fullName == "") {
48 B2FATAL("TNIEL: Can't locate " << FileName);
49 return;
50 }
51 ifstream inputfile;
52 inputfile.open(fullName.c_str(), ifstream::in);
53 if (!inputfile.good()) {
54 B2FATAL("TNIEL: Error opening input file " << FileName);
55 return;
56 }
57
58 B2INFO("Reading file " << FileName);
59
60 int i = 0;
61 string line;
62 while (getline(inputfile, line)) {
63 istringstream iss(line);
64 if (!(iss >> E_nielfactor[i] >> nielfactor[i])) {
65 B2FATAL("Error reading NIEL correction data from " << fullName.c_str());
66 break;
67 }
68 i++;
69 }
70 inputfile.close();
71 niel_N = i;
72 B2INFO("INITIALIZED TNIEL FROM " << fullName.c_str());
73 for (int j = 0; j < niel_N; j++)
74 B2DEBUG(100, "E: " << E_nielfactor[j] << " N: " << nielfactor[j]);
75}
static std::string findFile(const std::string &path, bool silent=false)
Search for given file or directory in local or central release directory, and return absolute path if...
Definition: FileSystem.cc:151
int niel_N
number of rows in NIEL table
Definition: niel_fun.h:23
double nielfactor[1710]
factor values, enough to acommodate the longest file.
Definition: niel_fun.h:21
double E_nielfactor[1710]
particle energies at which the NIEL factor is tabulated.
Definition: niel_fun.h:22

Member Function Documentation

◆ getNielFactor()

double getNielFactor ( double  EMeV)

Get NIEL factor for a given particle energy.

Parameters
EMeVparticle kinetic energy in MeV.
Returns
NIEL factor for a particle with a given energy.

Definition at line 77 of file niel_fun.cc.

78{
79 // input energy in MeV
80 int j = niel_N;
81 for (int i = 0; i < niel_N; i++) {
82 if (EMeV < E_nielfactor[i]) {
83 j = i;
84 break;
85 }
86 }
87 double value;
88 if (j > 0 && j < niel_N)
89 value = nielfactor[j - 1]
90 + (nielfactor[j] - nielfactor[j - 1])
91 / (E_nielfactor[j] - E_nielfactor[j - 1])
92 * (EMeV - E_nielfactor[j - 1]);
93 else if (j == 0)
94 value = nielfactor[0];
95 else
96 value = nielfactor[niel_N - 1];
97 return value;
98}

Member Data Documentation

◆ E_nielfactor

double E_nielfactor[1710]
private

particle energies at which the NIEL factor is tabulated.

Definition at line 22 of file niel_fun.h.

◆ niel_N

int niel_N
private

number of rows in NIEL table

Definition at line 23 of file niel_fun.h.

◆ nielfactor

double nielfactor[1710]
private

factor values, enough to acommodate the longest file.

Definition at line 21 of file niel_fun.h.


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