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 | // $Id: G4InclAblaDataFile.cc,v 1.10 2010/11/17 20:19:09 kaitanie Exp $ |
---|
27 | // Translation of INCL4.2/ABLA V3 |
---|
28 | // Pekka Kaitaniemi, HIP (translation) |
---|
29 | // Christelle Schmidt, IPNL (fission code) |
---|
30 | // Alain Boudard, CEA (contact person INCL/ABLA) |
---|
31 | // Aatos Heikkinen, HIP (project coordination) |
---|
32 | |
---|
33 | #include "G4InclAblaDataFile.hh" |
---|
34 | //#include "G4HadronicException.hh" |
---|
35 | #include "globals.hh" // Needed for G4Exception. |
---|
36 | #include <fstream> |
---|
37 | |
---|
38 | G4InclAblaDataFile::G4InclAblaDataFile() : G4InclAblaVirtualData() |
---|
39 | { |
---|
40 | verboseLevel = 0; |
---|
41 | } |
---|
42 | |
---|
43 | G4InclAblaDataFile::~G4InclAblaDataFile() |
---|
44 | { |
---|
45 | } |
---|
46 | |
---|
47 | /** |
---|
48 | * Read all data from files. |
---|
49 | */ |
---|
50 | bool G4InclAblaDataFile::readData() |
---|
51 | { |
---|
52 | if(!getenv("G4ABLADATA")) { |
---|
53 | // throw G4HadronicException(__FILE__, __LINE__, "ERROR: Data |
---|
54 | // missing. Set environment variable G4ABLA3.0 to point to the |
---|
55 | // directory containing data files needed by INCL and ABLA |
---|
56 | // models."); |
---|
57 | G4String errorMessage1 = "ERROR: Data missing. Set environment variable G4ABLADATA\n"; |
---|
58 | G4String errorMessage2 = "\t to point to the directory containing data files needed\n"; |
---|
59 | G4String errorMessage3 = "\t by INCL and ABLA models.\n"; |
---|
60 | G4String errorMessage = errorMessage1 + errorMessage2 + errorMessage3; |
---|
61 | G4Exception(errorMessage); |
---|
62 | } |
---|
63 | |
---|
64 | G4String dataPath(getenv("G4ABLADATA")); |
---|
65 | G4String flAlphaFile(dataPath + "/flalpha.dat"); |
---|
66 | G4String frldmFile( dataPath + "/frldm.dat"); |
---|
67 | G4String vgsldFile( dataPath + "/vgsld.dat"); |
---|
68 | G4String pace2File( dataPath + "/pace2.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 | G4cout <<"Pace2File = " << pace2File << G4endl; |
---|
76 | } |
---|
77 | |
---|
78 | std::ifstream flalphain(flAlphaFile.c_str()); |
---|
79 | std::ifstream frldmin(frldmFile.c_str()); |
---|
80 | std::ifstream vgsldin(vgsldFile.c_str()); |
---|
81 | std::ifstream pace2in(pace2File.c_str()); |
---|
82 | |
---|
83 | std::filebuf *buf1 = flalphain.rdbuf(); |
---|
84 | std::filebuf *buf2 = frldmin.rdbuf(); |
---|
85 | std::filebuf *buf3 = vgsldin.rdbuf(); |
---|
86 | std::filebuf *buf4 = pace2in.rdbuf(); |
---|
87 | if (!((buf1->is_open()) && (buf2->is_open()) && (buf3->is_open()) && (buf4->is_open()))) { |
---|
88 | G4Exception("ERROR: Data missing. Could not find ABLA data file in " + dataPath + |
---|
89 | " defined by environment variable G4ABLADATA"); |
---|
90 | } |
---|
91 | |
---|
92 | G4double flalpha, frldm, vgsld, pace2; |
---|
93 | const G4int rows = 99; |
---|
94 | const G4int cols = 154; |
---|
95 | const G4int massnumbers = 263; |
---|
96 | for(int i = 0; i < rows; i++) { |
---|
97 | for(int j = 0; j < cols; j++) { |
---|
98 | setAlpha(j, i, 0.0); |
---|
99 | setEcnz( j, i, 0.0); |
---|
100 | setVgsld(j, i, 0.0); |
---|
101 | } |
---|
102 | } |
---|
103 | |
---|
104 | for(int i = 0; i < rows; i++) { |
---|
105 | for(int j = 0; j < cols; j++) { |
---|
106 | flalphain >> flalpha; |
---|
107 | frldmin >> frldm; |
---|
108 | vgsldin >> vgsld; |
---|
109 | setAlpha(j, i, flalpha); |
---|
110 | setEcnz( j, i, frldm); |
---|
111 | setVgsld(j, i, vgsld); |
---|
112 | } |
---|
113 | } |
---|
114 | flalphain.close(); |
---|
115 | frldmin.close(); |
---|
116 | vgsldin.close(); |
---|
117 | |
---|
118 | G4String str1, str2, str3; |
---|
119 | for(int i = 0; i < 500; i++) { |
---|
120 | for(int j = 0; j < 500; j++) { |
---|
121 | setPace2(i, j, 0.0); |
---|
122 | } |
---|
123 | } |
---|
124 | |
---|
125 | int A = 0, Zbegin = 0, Zend = 0; |
---|
126 | for(int i = 0; i < massnumbers; i++) { |
---|
127 | pace2in >> str1 >> A >> str2 >> Zbegin >> str3 >> Zend; |
---|
128 | if(Zbegin >= 0 && Zbegin < getPaceCols() && |
---|
129 | A >= 0 && A < getPaceRows()) { |
---|
130 | for(int j = Zbegin; j <= Zend; j++) { |
---|
131 | pace2in >> pace2; |
---|
132 | setPace2(A, j, pace2); |
---|
133 | } |
---|
134 | } |
---|
135 | } |
---|
136 | pace2in.close(); |
---|
137 | if(std::fabs(getPace2(A, Zend) - 114516.10) > 1e-6) { |
---|
138 | G4cout <<"ERROR: Problem in parsing datafile " + pace2File << G4endl; |
---|
139 | return false; |
---|
140 | } |
---|
141 | |
---|
142 | return true; |
---|
143 | } |
---|
144 | |
---|
145 | |
---|