Geant4 11.4.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4AblaDataFile.cc
Go to the documentation of this file.
1//
2// ********************************************************************
3// * License and Disclaimer *
4// * *
5// * The Geant4 software is copyright of the Copyright Holders of *
6// * the Geant4 Collaboration. It is provided under the terms and *
7// * conditions of the Geant4 Software License, included in the file *
8// * LICENSE and available at http://cern.ch/geant4/license . These *
9// * include a list of copyright holders. *
10// * *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work make any representation or warranty, express or implied, *
14// * regarding this software system or assume any liability for its *
15// * use. Please see the license in the file LICENSE and URL above *
16// * for the full disclaimer and the limitation of liability. *
17// * *
18// * This code implementation is the result of the scientific and *
19// * technical work of the GEANT4 collaboration. *
20// * By using, copying, modifying or distributing the software (or *
21// * any work based on the software) you agree to acknowledge its *
22// * use in resulting scientific publications, and indicate your *
23// * acceptance of all terms of the Geant4 Software license. *
24// ********************************************************************
25//
26// ABLAXX statistical de-excitation model
27// Jose Luis Rodriguez, UDC (translation from ABLA07 and contact person)
28// Pekka Kaitaniemi, HIP (initial translation of ablav3p)
29// Aleksandra Kelic, GSI (ABLA07 code)
30// Davide Mancusi, CEA (contact person INCL)
31// Aatos Heikkinen, HIP (project coordination)
32//
33
34#include "G4AblaDataFile.hh"
35
36#include "G4AblaDataDefs.hh"
37#include "globals.hh"
38
39#include <cmath>
40#include <cstdlib>
41#include <fstream>
42#include <iostream>
43
45{
46 verboseLevel = 0;
47}
48
49/**
50 * Read all data from files.
51 */
53{
54 if (!G4FindDataDir("G4ABLADATA")) {
56 ed << " Data missing: set environment variable G4ABLADATA\n"
57 << " to point to the directory containing data files needed\n"
58 << " by the ABLA model" << G4endl;
59 G4Exception("G4AblaDataFile::readData()", "ABLA_001", FatalException, ed);
60 }
61 G4String dataPath(G4FindDataDir("G4ABLADATA"));
62
63 G4String flAlphaFile(dataPath + "/flalpha.dat");
64 G4String frldmFile(dataPath + "/frldm.dat");
65 G4String vgsldFile(dataPath + "/vgsld.dat");
66 G4String rmsFile(dataPath + "/rms.dat");
67 G4String defoFile(dataPath + "/defo.dat");
68 G4String massFile(dataPath + "/mass2020.dat");
69
70 if (verboseLevel > 1) {
71 // G4cout <<"Data path = " << dataPath << G4endl;
72 // G4cout <<"FlAlphaFile = " << flAlphaFile << G4endl;
73 // G4cout <<"FrldmFile = " << frldmFile << G4endl;
74 // G4cout <<"VgsldFile = " << vgsldFile << G4endl;
75 }
76
77 std::ifstream flalphain(flAlphaFile.c_str());
78 std::ifstream frldmin(frldmFile.c_str());
79 std::ifstream vgsldin(vgsldFile.c_str());
80 std::ifstream rmsin(rmsFile.c_str());
81 std::ifstream defoin(defoFile.c_str());
82 std::ifstream massin(massFile.c_str());
83
84 if (!massin.is_open()) {
85 massFile = dataPath + "/mass2016.dat";
86 massin.close();
87 massin.open(massFile.c_str());
88 std::cout << "Mass evaluation file mass2020.dat not found, current file: " << massFile.c_str()
89 << std::endl;
90
91 if (!massin.is_open()) {
92 massFile = dataPath + "/mass2003.dat";
93 massin.close();
94 massin.open(massFile.c_str());
95 std::cout << "Mass evaluation file mass2016.dat not found, current file: " << massFile.c_str()
96 << std::endl;
97 }
98 }
99
100 std::filebuf* buf1 = flalphain.rdbuf();
101 std::filebuf* buf2 = frldmin.rdbuf();
102 std::filebuf* buf3 = vgsldin.rdbuf();
103 std::filebuf* buf4 = rmsin.rdbuf();
104 std::filebuf* buf5 = defoin.rdbuf();
105 std::filebuf* buf6 = massin.rdbuf();
106 if (!((buf1->is_open()) && (buf2->is_open()) && (buf3->is_open()) && (buf4->is_open())
107 && (buf5->is_open()) && (buf6->is_open())))
108 {
110 ed << "Data missing: could not find ABLA data file in " << dataPath
111 << "defined by environment variable G4ABLADATA" << G4endl;
112 G4Exception("G4AblaDataFile::readData()", "ABLA", FatalException, ed);
113 }
114
115 G4double fflalpha, ffrldm, fvgsld, frms;
116 G4int fj = 0, fk = 0, a2, a3, a4;
117 G4double fbeta2, fbeta4;
118 G4double a7;
119 const G4int rows = 99;
120 const G4int cols = 154;
121 const G4int rowsbeta = 137;
122 const G4int colsbeta = 251;
123
124 for (G4int i = 0; i < zcols; i++) {
125 for (G4int j = 0; j < nrows; j++) {
126 setAlpha(j, i, 0.0);
127 setEcnz(j, i, 0.0);
128 setVgsld(j, i, 0.0);
129 setRms(j, i, 0.0);
130 }
131 }
132
133 for (G4int i = 0; i < rows; i++) {
134 for (G4int j = 0; j < cols; j++) {
135 flalphain >> fflalpha;
136 frldmin >> ffrldm;
137 vgsldin >> fvgsld;
138 rmsin >> frms;
139 setAlpha(j, i, fflalpha);
140 setEcnz(j, i, ffrldm);
141 setVgsld(j, i, fvgsld);
142 setRms(j, i, frms);
143 }
144 }
145
146 for (G4int i = 0; i < rowsbeta; i++) {
147 for (G4int j = 0; j < colsbeta; j++) {
148 setBeta2(j, i, 0.0);
149 setBeta4(j, i, 0.0);
150 }
151 }
152
153 defoin >> fj >> fk >> fbeta2 >> fbeta4;
154 while (!defoin.eof()) {
155 setBeta2(fk, fj, fbeta2);
156 setBeta4(fk, fj, fbeta4);
157 defoin >> fj >> fk >> fbeta2 >> fbeta4;
158 }
159
160 for (G4int i = 0; i < zcols; i++) {
161 for (G4int j = 0; j < nrows; j++) {
162 setMexp(j, i, 0.0);
163 setMexpID(j, i, 0);
164 }
165 }
166 massin >> a2 >> a3 >> a4 >> a7;
167 while (!massin.eof()) {
168 //
169 if (a3 < lpcols) {
170 setMexpID(a2, a3, 1);
171 setMexp(a2, a3, 938.7829835 * a3 + 939.5653301 * a2 - 1. * a4 * a7 / 1000.);
172 }
173 massin >> a2 >> a3 >> a4 >> a7;
174 }
175
176 flalphain.close();
177 frldmin.close();
178 vgsldin.close();
179 rmsin.close();
180 defoin.close();
181 massin.close();
182
183 return true;
184}
constexpr const G4int zcols
constexpr const G4int nrows
constexpr const G4int lpcols
const char * G4FindDataDir(const char *)
@ FatalException
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
std::ostringstream G4ExceptionDescription
double G4double
Definition G4Types.hh:83
bool G4bool
Definition G4Types.hh:86
int G4int
Definition G4Types.hh:85
#define G4endl
Definition G4ios.hh:67
G4bool setEcnz(G4int A, G4int Z, G4double value)
G4bool setBeta4(G4int A, G4int Z, G4double value)
G4bool setVgsld(G4int A, G4int Z, G4double value)
G4bool setAlpha(G4int A, G4int Z, G4double value)
G4bool setMexp(G4int A, G4int Z, G4double value)
G4bool setBeta2(G4int A, G4int Z, G4double value)
G4bool setMexpID(G4int A, G4int Z, G4int value)
G4bool setRms(G4int A, G4int Z, G4double value)