ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4AblaDataFile.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4AblaDataFile.cc
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, GSI (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 #define ABLAXX_IN_GEANT4_MODE 1
35 
36 #include "globals.hh"
37 
38 #include "G4AblaDataFile.hh"
39 
40 #ifdef ABLAXX_IN_GEANT4_MODE
41 #include "globals.hh"
42 #else
43 #include "G4INCLGeant4Compat.hh"
44 #endif
45 
46 #include <fstream>
47 #include <cmath>
48 #include <iostream>
49 #include <cstdlib>
50 
51 #ifdef ABLAXX_IN_GEANT4_MODE
53 #else
55  : G4AblaVirtualData(config) {
56  theConfig = config;
57 #endif
58  verboseLevel = 0;
59 }
60 
62 {
63 }
64 
69 {
70 #ifdef ABLAXX_IN_GEANT4_MODE
71  if(!std::getenv("G4ABLADATA")) {
72  // throw G4HadronicException(__FILE__, __LINE__, "ERROR: Data
73  // missing. Set environment variable G4ABLA3.0 to point to the
74  // directory containing data files needed by INCL and ABLA
75  // models.");
76  // G4String errorMessage1 = "ERROR: Data missing. Set environment variable G4ABLADATA\n";
77  // G4String errorMessage2 = "\t to point to the directory containing data files needed\n";
78  // G4String errorMessage3 = "\t by INCL and ABLA models.\n";
79  // G4String errorMessage = errorMessage1 + errorMessage2 + errorMessage3;
80  // G4Exception(errorMessage);
82  ed << " Data missing: set environment variable G4ABLADATA\n"
83  << " to point to the directory containing data files needed\n"
84  << " by the ABLA model" << G4endl;
85  G4Exception("G4AblaDataFile::readData()","ABLA_001",
86  FatalException, ed);
87  }
88  G4String dataPath(std::getenv("G4ABLADATA"));
89 #else
90  G4String dataPath(theConfig->getABLAXXDataFilePath().c_str());
91 #endif
92  G4String flAlphaFile(dataPath + "/flalpha.dat");
93  G4String frldmFile( dataPath + "/frldm.dat");
94  G4String vgsldFile( dataPath + "/vgsld.dat");
95  G4String pace2File( dataPath + "/pace2.dat");
96  G4String rmsFile( dataPath + "/rms.dat");
97  G4String defoFile( dataPath + "/defo.dat");
98  G4String massFile( dataPath + "/mass2003.dat");
99 
100  if(verboseLevel > 1) {
101  // G4cout <<"Data path = " << dataPath << G4endl;
102  // G4cout <<"FlAlphaFile = " << flAlphaFile << G4endl;
103  // G4cout <<"FrldmFile = " << frldmFile << G4endl;
104  // G4cout <<"VgsldFile = " << vgsldFile << G4endl;
105  // G4cout <<"Pace2File = " << pace2File << G4endl;
106  }
107 
108  std::ifstream flalphain(flAlphaFile.c_str());
109  std::ifstream frldmin(frldmFile.c_str());
110  std::ifstream vgsldin(vgsldFile.c_str());
111  std::ifstream pace2in(pace2File.c_str());
112  std::ifstream rmsin(rmsFile.c_str());
113  std::ifstream defoin(defoFile.c_str());
114  std::ifstream massin(massFile.c_str());
115 
116  std::filebuf *buf1 = flalphain.rdbuf();
117  std::filebuf *buf2 = frldmin.rdbuf();
118  std::filebuf *buf3 = vgsldin.rdbuf();
119  std::filebuf *buf4 = pace2in.rdbuf();
120  std::filebuf *buf5 = rmsin.rdbuf();
121  std::filebuf *buf6 = defoin.rdbuf();
122  std::filebuf *buf7 = massin.rdbuf();
123  if (!((buf1->is_open()) && (buf2->is_open()) && (buf3->is_open()) && (buf4->is_open()) && (buf5->is_open()) && (buf6->is_open()) && (buf7->is_open()))) {
124 #ifdef ABLAXX_IN_GEANT4_MODE
126  ed << "Data missing: could not find ABLA data file in " << dataPath
127  << "defined by environment variable G4ABLADATA" << G4endl;
128  G4Exception("G4AblaDataFile::readData()", "ABLA", FatalException, ed);
129 #else
130  std::cerr << "Error opening file." << std::endl;
131 #endif
132  }
133 
134  G4double fflalpha, ffrldm, fvgsld, fpace2, frms;
135  int fj,fk,a2,a3,a4;
136  G4double fbeta2,fbeta4;
137  G4double a7;
138  const G4int rows = 99;
139  const G4int cols = 154;
140  const G4int rowsbeta = 137;
141  const G4int colsbeta = 251;
142  const G4int rowsmass = 13;
143  const G4int colsmass = 154;
144  const G4int massnumbers = 263;
145  for(int i = 0; i < rows; i++) {
146  for(int j = 0; j < cols; j++) {
147  setAlpha(j, i, 0.0);
148  setEcnz( j, i, 0.0);
149  setVgsld(j, i, 0.0);
150  setRms(j, i, 0.0);
151  }
152  }
153 
154  for(int i = 0; i < rows; i++) {
155  for(int j = 0; j < cols; j++) {
156  flalphain >> fflalpha;
157  frldmin >> ffrldm;
158  vgsldin >> fvgsld;
159  rmsin >> frms;
160  setAlpha(j, i, fflalpha);
161  setEcnz( j, i, ffrldm);
162  setVgsld(j, i, fvgsld);
163  setRms(j, i, frms);
164  }
165  }
166 
167 
168  for(int i = 0; i < rowsbeta; i++) {
169  for(int j = 0; j < colsbeta; j++) {
170  setBeta2(j, i, 0.0);
171  setBeta4(j, i, 0.0);
172  }
173  }
174 
175  for(int i = 0; i < 8983; i++) {
176  defoin >> fj >> fk >> fbeta2 >> fbeta4;
177  setBeta2(fk, fj, fbeta2);
178  setBeta4(fk, fj, fbeta4);
179  }
180 
181  for(int i = 0; i < rowsmass; i++) {
182  for(int j = 0; j < colsmass; j++) {
183  setMexp(j, i, 0.0);
184  setMexpID(j,i,0);
185  }
186  }
187  massin >> a2 >> a3 >> a4 >> a7 ;
188  while(!massin.eof()){
189  //
190  if(a3<13.){
191  setMexpID(a2,a3,1);
192  setMexp(a2,a3,938.7829835*a3+939.5653301*a2-1.*a4*a7/1000.);
193  }
194  massin >> a2 >> a3 >> a4 >> a7 ;
195  }
196 
197  flalphain.close();
198  frldmin.close();
199  vgsldin.close();
200  rmsin.close();
201  defoin.close();
202  massin.close();
203 
204  G4String str1, str2, str3;
205  for(int i = 0; i < 500; i++) {
206  for(int j = 0; j < 500; j++) {
207  setPace2(i, j, 0.0);
208  }
209  }
210 
211  int A = 0, Zbegin = 0, Zend = 0;
212  for(int i = 0; i < massnumbers; i++) {
213  pace2in >> str1 >> A >> str2 >> Zbegin >> str3 >> Zend;
214  if(Zbegin >= 0 && Zbegin < getPaceCols() &&
215  A >= 0 && A < getPaceRows()) {
216  for(int j = Zbegin; j <= Zend; j++) {
217  pace2in >> fpace2;
218  setPace2(A, j, fpace2);
219  }
220  }
221  }
222  pace2in.close();
223  if(std::abs(getPace2(A, Zend) - 114516.10) > 1e-6) {
224  std::cerr << "ERROR: Problem in parsing datafile " + pace2File << std::endl;
225  return false;
226  }
227 
228  return true;
229 }
230