Geant4  10.03
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 // Pekka Kaitaniemi, HIP (translation)
28 // Christelle Schmidt, IPNL (fission code)
29 // Davide Mancusi, CEA (contact person INCL/ABLA)
30 // Aatos Heikkinen, HIP (project coordination)
31 //
32 #define ABLAXX_IN_GEANT4_MODE 1
33 
34 #include "globals.hh"
35 
36 #include "G4AblaDataFile.hh"
37 //#include "G4HadronicException.hh"
38 #ifdef ABLAXX_IN_GEANT4_MODE
39 #include "globals.hh"
40 #else
41 #include "G4INCLGeant4Compat.hh"
42 #endif
43 #include <fstream>
44 #include <cmath>
45 #include <iostream>
46 #include <cstdlib>
47 
48 #ifdef ABLAXX_IN_GEANT4_MODE
50 #else
52  : G4AblaVirtualData(config) {
53  theConfig = config;
54 #endif
55  verboseLevel = 0;
56 }
57 
59 {
60 }
61 
66 {
67 #ifdef ABLAXX_IN_GEANT4_MODE
68  if(!getenv("G4ABLADATA")) {
69  // throw G4HadronicException(__FILE__, __LINE__, "ERROR: Data
70  // missing. Set environment variable G4ABLA3.0 to point to the
71  // directory containing data files needed by INCL and ABLA
72  // models.");
73  // G4String errorMessage1 = "ERROR: Data missing. Set environment variable G4ABLADATA\n";
74  // G4String errorMessage2 = "\t to point to the directory containing data files needed\n";
75  // G4String errorMessage3 = "\t by INCL and ABLA models.\n";
76  // G4String errorMessage = errorMessage1 + errorMessage2 + errorMessage3;
77  // G4Exception(errorMessage);
79  ed << " Data missing: set environment variable G4ABLADATA\n"
80  << " to point to the directory containing data files needed\n"
81  << " by the ABLA model" << G4endl;
82  G4Exception("G4AblaDataFile::readData()","ABLA_001",
83  FatalException, ed);
84  }
85 
86  G4String dataPath(getenv("G4ABLADATA"));
87 #else
88  G4String dataPath(theConfig->getABLAv3pCxxDataFilePath().c_str());
89 #endif
90  G4String flAlphaFile(dataPath + "/flalpha.dat");
91  G4String frldmFile( dataPath + "/frldm.dat");
92  G4String vgsldFile( dataPath + "/vgsld.dat");
93  G4String pace2File( dataPath + "/pace2.dat");
94 
95  if(verboseLevel > 1) {
96  // G4cout <<"Data path = " << dataPath << G4endl;
97  // G4cout <<"FlAlphaFile = " << flAlphaFile << G4endl;
98  // G4cout <<"FrldmFile = " << frldmFile << G4endl;
99  // G4cout <<"VgsldFile = " << vgsldFile << G4endl;
100  // G4cout <<"Pace2File = " << pace2File << G4endl;
101  }
102 
103  std::ifstream flalphain(flAlphaFile.c_str());
104  std::ifstream frldmin(frldmFile.c_str());
105  std::ifstream vgsldin(vgsldFile.c_str());
106  std::ifstream pace2in(pace2File.c_str());
107 
108  std::filebuf *buf1 = flalphain.rdbuf();
109  std::filebuf *buf2 = frldmin.rdbuf();
110  std::filebuf *buf3 = vgsldin.rdbuf();
111  std::filebuf *buf4 = pace2in.rdbuf();
112  if (!((buf1->is_open()) && (buf2->is_open()) && (buf3->is_open()) && (buf4->is_open()))) {
113 #ifdef ABLAXX_IN_GEANT4_MODE
115  ed << " Data missing: could not find ABLA data file in " << dataPath
116  << "defined by environment variable G4ABLADATA" << G4endl;
117  G4Exception("G4AblaDataFile::readData()", "ABLA002", FatalException, ed);
118 #else
119  std::cerr << "Error opening file." << std::endl;
120 #endif
121  }
122 
123  G4double fflalpha, ffrldm, fvgsld, fpace2;
124  const G4int rows = 99;
125  const G4int cols = 154;
126  const G4int massnumbers = 263;
127  for(int i = 0; i < rows; i++) {
128  for(int j = 0; j < cols; j++) {
129  setAlpha(j, i, 0.0);
130  setEcnz( j, i, 0.0);
131  setVgsld(j, i, 0.0);
132  }
133  }
134 
135  for(int i = 0; i < rows; i++) {
136  for(int j = 0; j < cols; j++) {
137  flalphain >> fflalpha;
138  frldmin >> ffrldm;
139  vgsldin >> fvgsld;
140  setAlpha(j, i, fflalpha);
141  setEcnz( j, i, ffrldm);
142  setVgsld(j, i, fvgsld);
143  }
144  }
145  flalphain.close();
146  frldmin.close();
147  vgsldin.close();
148 
149  G4String str1, str2, str3;
150  for(int i = 0; i < 500; i++) {
151  for(int j = 0; j < 500; j++) {
152  setPace2(i, j, 0.0);
153  }
154  }
155 
156  int A = 0, Zbegin = 0, Zend = 0;
157  for(int i = 0; i < massnumbers; i++) {
158  pace2in >> str1 >> A >> str2 >> Zbegin >> str3 >> Zend;
159  if(Zbegin >= 0 && Zbegin < getPaceCols() &&
160  A >= 0 && A < getPaceRows()) {
161  for(int j = Zbegin; j <= Zend; j++) {
162  pace2in >> fpace2;
163  setPace2(A, j, fpace2);
164  }
165  }
166  }
167  pace2in.close();
168  if(std::abs(getPace2(A, Zend) - 114516.10) > 1e-6) {
169  std::cerr << "ERROR: Problem in parsing datafile " + pace2File << std::endl;
170  return false;
171  }
172 
173  return true;
174 }
175 
The INCL configuration object.
Definition: G4INCLConfig.hh:60
G4bool setVgsld(G4int A, G4int Z, G4double value)
Set the value of Vgsld.
G4AblaVirtualData()
Constructor, destructor.
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
G4bool setPace2(G4int A, G4int Z, G4double value)
Set the value of Pace2.
int G4int
Definition: G4Types.hh:78
double A(double temperature)
struct config_s config
G4bool setEcnz(G4int A, G4int Z, G4double value)
Set the value of Ecnz.
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
G4bool setAlpha(G4int A, G4int Z, G4double value)
Set the value of Alpha.
bool readData()
Read all data from files.
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76
G4double getPace2(G4int A, G4int Z)
Get the value of Pace2.