Belle II Software  release-08-01-10
niel_fun.cc
1 /**************************************************************************
2  * basf2 (Belle II Analysis Software Framework) *
3  * Author: The Belle II Collaboration *
4  * *
5  * See git log for contributors and copyright holders. *
6  * This file is licensed under LGPL-3.0, see LICENSE.md. *
7  **************************************************************************/
8 #include <vxd/background/niel_fun.h>
9 
10 #include <framework/logging/Logger.h>
11 #include <framework/utilities/FileSystem.h>
12 #include <fstream>
13 #include <sstream>
14 
15 
16 // IMPORTANT!!!!! OUTSIDE THE RANGE OF THE DATA, THE VALUE IS SET TO THE CLOSEST KNOWN VALUE
17 //
18 // RANGES:
19 // NEUTRONS: E = 1.025E-10 - 5.525E+03 MeV
20 // PROTONS: E = 1.000E-03 - 9.000E+03 MeV
21 // PIONS: E = 1.500E+01 - 9.005E+03 MeV
22 // ELECTRONS: E = 3.000E-01 - 2.000E+02 MeV
23 
24 // neutrons:
25 // P.J. Griffin et al., SAND92-0094 (Sandia Natl. Lab.93), priv. comm. 1996: E = 1.025E-10 - 1.995E+01 MeV
26 // A. Konobeyev, J. Nucl. Mater. 186 (1992) 117: E = 2.000E+01 - 8.000E+02 MeV
27 // M. Huhtinen and P.A. Aarnio, NIM A 335 (1993) 580 and priv. comm.: E = 8.050E+02 - 8.995E+03 MeV
28 // protons:
29 // G.P. Summers et al., IEEE NS40 (1993) 1372: E = 1.000E-03 - 2.000E+02 MeV
30 // M. Huhtinen and P.A. Aarnio, NIM A 335 (1993) 580 and priv. comm.: E = 1.500E+01 - 9.005E+03 MeV
31 // pions:
32 // M. Huhtinen and P.A. Aarnio, NIM A 335 (1993) 580 and priv. comm.: E = 1.500E+01 - 9.005E+03 MeV
33 // electrons:
34 // G.P. Summers et al., IEEE NS40 (1993) 1372: E = 3.000E-01 - 2.000E+02 MeV
35 
36 // Main Reference
37 // A. Vasilescu (INPE Bucharest) and G. Lindstroem (University of Hamburg),
38 // Displacement damage in silicon, on-line compilation
39 // http://sesam.desy.de/members/gunnar/Si-dfuncs.html
40 
41 using namespace std;
42 using namespace Belle2;
43 
44 TNiel::TNiel(const string& FileName)
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 }
76 
77 double TNiel::getNielFactor(double EMeV)
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 }
99 
TNiel(const std::string &FileName)
Constructor takes NIEL table for a particle as input.
Definition: niel_fun.cc:44
double getNielFactor(double EMeV)
Get NIEL factor for a given particle energy.
Definition: niel_fun.cc:77
Abstract base class for different kinds of events.