Belle II Software  release-05-01-25
niel_fun.cc
1 #include <vxd/background/niel_fun.h>
2 
3 #include <framework/logging/Logger.h>
4 #include <framework/utilities/FileSystem.h>
5 #include <fstream>
6 #include <sstream>
7 
8 
9 // IMPORTANT!!!!! OUTSIDE THE RANGE OF THE DATA, THE VALUE IS SET TO THE CLOSEST KNOWN VALUE
10 //
11 // RANGES:
12 // NEUTRONS: E = 1.025E-10 - 5.525E+03 MeV
13 // PROTONS: E = 1.000E-03 - 9.000E+03 MeV
14 // PIONS: E = 1.500E+01 - 9.005E+03 MeV
15 // ELECTRONS: E = 3.000E-01 - 2.000E+02 MeV
16 
17 // neutrons:
18 // P.J. Griffin et al., SAND92-0094 (Sandia Natl. Lab.93), priv. comm. 1996: E = 1.025E-10 - 1.995E+01 MeV
19 // A. Konobeyev, J. Nucl. Mater. 186 (1992) 117: E = 2.000E+01 - 8.000E+02 MeV
20 // M. Huhtinen and P.A. Aarnio, NIM A 335 (1993) 580 and priv. comm.: E = 8.050E+02 - 8.995E+03 MeV
21 // protons:
22 // G.P. Summers et al., IEEE NS40 (1993) 1372: E = 1.000E-03 - 2.000E+02 MeV
23 // M. Huhtinen and P.A. Aarnio, NIM A 335 (1993) 580 and priv. comm.: E = 1.500E+01 - 9.005E+03 MeV
24 // pions:
25 // M. Huhtinen and P.A. Aarnio, NIM A 335 (1993) 580 and priv. comm.: E = 1.500E+01 - 9.005E+03 MeV
26 // electrons:
27 // G.P. Summers et al., IEEE NS40 (1993) 1372: E = 3.000E-01 - 2.000E+02 MeV
28 
29 // Main Reference
30 // A. Vasilescu (INPE Bucharest) and G. Lindstroem (University of Hamburg),
31 // Displacement damage in silicon, on-line compilation
32 // http://sesam.desy.de/members/gunnar/Si-dfuncs.html
33 
34 using namespace std;
35 using namespace Belle2;
36 
37 TNiel::TNiel(const string& FileName)
38 {
39  string fullName = FileSystem::findFile(FileName);
40  if (fullName == "") {
41  B2FATAL("TNIEL: Can't locate " << FileName);
42  return;
43  }
44  ifstream inputfile;
45  inputfile.open(fullName.c_str(), ifstream::in);
46  if (!inputfile.good()) {
47  B2FATAL("TNIEL: Error opening input file " << FileName);
48  return;
49  }
50 
51  B2INFO("Reading file " << FileName);
52 
53  int i = 0;
54  string line;
55  while (getline(inputfile, line)) {
56  istringstream iss(line);
57  if (!(iss >> E_nielfactor[i] >> nielfactor[i])) {
58  B2FATAL("Error reading NIEL correction data from " << fullName.c_str());
59  break;
60  }
61  i++;
62  }
63  inputfile.close();
64  niel_N = i;
65  B2INFO("INITIALIZED TNIEL FROM " << fullName.c_str());
66  for (int j = 0; j < niel_N; j++)
67  B2DEBUG(100, "E: " << E_nielfactor[j] << " N: " << nielfactor[j]);
68 }
69 
70 double TNiel::getNielFactor(double EMeV)
71 {
72  // input energy in MeV
73  int j = niel_N;
74  for (int i = 0; i < niel_N; i++) {
75  if (EMeV < E_nielfactor[i]) {
76  j = i;
77  break;
78  }
79  }
80  double value;
81  if (j > 0 && j < niel_N)
82  value = nielfactor[j - 1]
83  + (nielfactor[j] - nielfactor[j - 1])
84  / (E_nielfactor[j] - E_nielfactor[j - 1])
85  * (EMeV - E_nielfactor[j - 1]);
86  else if (j == 0)
87  value = nielfactor[0];
88  else
89  value = nielfactor[niel_N - 1];
90  return value;
91 }
92 
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
TNiel::getNielFactor
double getNielFactor(double EMeV)
Get NIEL factor for a given particle energy.
Definition: niel_fun.cc:70
TNiel::TNiel
TNiel(const std::string &FileName)
Constructor takes NIEL table for a particle as input.
Definition: niel_fun.cc:37