source: trunk/source/processes/hadronic/models/abla/src/G4AblaDataFile.cc @ 1350

Last change on this file since 1350 was 1350, checked in by garnier, 13 years ago

update to last version 4.9.4

File size: 5.0 KB
Line 
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: G4AblaDataFile.cc,v 1.1 2008/02/27 18:31:11 miheikki 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 "G4AblaDataFile.hh"
34//#include "G4HadronicException.hh"
35#include "globals.hh" // Needed for G4Exception.
36#include <fstream>
37
38G4AblaDataFile::G4AblaDataFile()
39{
40  verboseLevel = 0;
41}
42
43/**
44 * Read all data from files.
45 */
46bool G4AblaDataFile::readData()
47{
48  if(!getenv("G4ABLADATA")) {
49    //    throw G4HadronicException(__FILE__, __LINE__, "ERROR: Data
50    //    missing. Set environment variable G4ABLA3.0 to point to the
51    //    directory containing data files needed by INCL and ABLA
52    //    models.");
53    G4String errorMessage1 = "ERROR: Data missing. Set environment variable G4ABLADATA\n";
54    G4String errorMessage2 = "\t to point to the directory containing data files needed\n";
55    G4String errorMessage3 = "\t by INCL and ABLA models.\n";
56    G4String errorMessage = errorMessage1 + errorMessage2 + errorMessage3;
57    G4Exception(errorMessage);
58  }
59 
60  G4String dataPath(getenv("G4ABLADATA"));
61  G4String flAlphaFile(dataPath + "/flalpha.dat");
62  G4String frldmFile(  dataPath + "/frldm.dat");
63  G4String vgsldFile(  dataPath + "/vgsld.dat");
64  G4String pace2File(  dataPath + "/pace2.dat");
65
66  if(verboseLevel > 1) {
67    G4cout <<"Data path   = " << dataPath    << G4endl;
68    G4cout <<"FlAlphaFile = " << flAlphaFile << G4endl;
69    G4cout <<"FrldmFile   = " << frldmFile   << G4endl;
70    G4cout <<"VgsldFile   = " << vgsldFile   << G4endl;
71    G4cout <<"Pace2File   = " << pace2File   << G4endl;
72  }
73 
74  std::ifstream flalphain(flAlphaFile.c_str());
75  std::ifstream frldmin(frldmFile.c_str()); 
76  std::ifstream vgsldin(vgsldFile.c_str()); 
77  std::ifstream pace2in(pace2File.c_str());
78
79  std::filebuf *buf1 = flalphain.rdbuf();
80  std::filebuf *buf2 = frldmin.rdbuf();
81  std::filebuf *buf3 = vgsldin.rdbuf();
82  std::filebuf *buf4 = pace2in.rdbuf(); 
83  if (!((buf1->is_open()) && (buf2->is_open()) && (buf3->is_open()) && (buf4->is_open()))) {
84    G4Exception("ERROR: Data missing. Could not find ABLA data file in " + dataPath +
85                " defined by environment variable G4ABLADATA");
86  }
87 
88  G4double flalpha, frldm, vgsld, pace2;
89  const G4int rows = 98;
90  const G4int cols = 153;
91  const G4int massnumbers = 263;
92  for(int i = 0; i < rows; i++) {
93    for(int j = 0; j < cols; j++) {
94      setAlpha(j, i, 0.0);
95      setEcnz( j, i, 0.0);
96      setVgsld(j, i, 0.0);     
97    }
98  }
99 
100  for(int i = 0; i < rows; i++) {
101    for(int j = 0; j < cols; j++) {
102      flalphain >> flalpha;
103      frldmin >> frldm;
104      vgsldin >> vgsld;     
105      setAlpha(j, i, flalpha);
106      setEcnz( j, i, frldm);
107      setVgsld(j, i, vgsld);     
108    }
109  }
110  flalphain.close();
111  frldmin.close(); 
112  vgsldin.close();
113
114  int A = 0, Zbegin = 0, Zend = 0;
115  G4String str1, str2, str3;
116  for(int i = 0; i < 500; i++) {
117    for(int j = 0; j < 500; j++) {
118      setPace2(i, j, 0.0);
119    }
120  }
121 
122  for(int i = 0; i < massnumbers; i++) {
123    pace2in >> str1 >> A >> str2 >> Zbegin >> str3 >> Zend;
124    for(int j = Zbegin; j <= Zend; j++) {
125      pace2in >> pace2;
126      setPace2(A, j, pace2);
127    }
128  }
129  pace2in.close();
130  if(std::fabs(getPace2(A, Zend) - 114516.10) > 1e-6) {
131    G4cout <<"ERROR: Problem in parsing datafile " + pace2File << G4endl;
132    return false;
133  }
134
135  return true;
136}
137
138
Note: See TracBrowser for help on using the repository browser.