G4AblaDataFile.cc

Go to the documentation of this file.
00001 //
00002 // ********************************************************************
00003 // * License and Disclaimer                                           *
00004 // *                                                                  *
00005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
00006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
00007 // * conditions of the Geant4 Software License,  included in the file *
00008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
00009 // * include a list of copyright holders.                             *
00010 // *                                                                  *
00011 // * Neither the authors of this software system, nor their employing *
00012 // * institutes,nor the agencies providing financial support for this *
00013 // * work  make  any representation or  warranty, express or implied, *
00014 // * regarding  this  software system or assume any liability for its *
00015 // * use.  Please see the license in the file  LICENSE  and URL above *
00016 // * for the full disclaimer and the limitation of liability.         *
00017 // *                                                                  *
00018 // * This  code  implementation is the result of  the  scientific and *
00019 // * technical work of the GEANT4 collaboration.                      *
00020 // * By using,  copying,  modifying or  distributing the software (or *
00021 // * any work based  on the software)  you  agree  to acknowledge its *
00022 // * use  in  resulting  scientific  publications,  and indicate your *
00023 // * acceptance of all terms of the Geant4 Software license.          *
00024 // ********************************************************************
00025 //
00026 // $Id$ 
00027 // Translation of INCL4.2/ABLA V3 
00028 // Pekka Kaitaniemi, HIP (translation)
00029 // Christelle Schmidt, IPNL (fission code)
00030 // Alain Boudard, CEA (contact person INCL/ABLA)
00031 // Aatos Heikkinen, HIP (project coordination)
00032 
00033 #include "G4AblaDataFile.hh"
00034 //#include "G4HadronicException.hh"
00035 #include "globals.hh" // Needed for G4Exception.
00036 #include <fstream>
00037 
00038 G4AblaDataFile::G4AblaDataFile()
00039 {
00040   verboseLevel = 0;
00041 }
00042 
00046 bool G4AblaDataFile::readData()
00047 {
00048   if(!getenv("G4ABLADATA")) {
00049     //    throw G4HadronicException(__FILE__, __LINE__, "ERROR: Data
00050     //    missing. Set environment variable G4ABLA3.0 to point to the
00051     //    directory containing data files needed by INCL and ABLA
00052     //    models.");
00053     G4String errorMessage1 = "ERROR: Data missing. Set environment variable G4ABLADATA\n";
00054     G4String errorMessage2 = "\t to point to the directory containing data files needed\n";
00055     G4String errorMessage3 = "\t by INCL and ABLA models.\n";
00056     G4String errorMessage = errorMessage1 + errorMessage2 + errorMessage3;
00057     G4Exception(errorMessage);
00058   }
00059   
00060   G4String dataPath(getenv("G4ABLADATA"));
00061   G4String flAlphaFile(dataPath + "/flalpha.dat");
00062   G4String frldmFile(  dataPath + "/frldm.dat");
00063   G4String vgsldFile(  dataPath + "/vgsld.dat");
00064   G4String pace2File(  dataPath + "/pace2.dat");
00065 
00066   if(verboseLevel > 1) {
00067     G4cout <<"Data path   = " << dataPath    << G4endl;
00068     G4cout <<"FlAlphaFile = " << flAlphaFile << G4endl;
00069     G4cout <<"FrldmFile   = " << frldmFile   << G4endl;
00070     G4cout <<"VgsldFile   = " << vgsldFile   << G4endl;
00071     G4cout <<"Pace2File   = " << pace2File   << G4endl;
00072   }
00073   
00074   std::ifstream flalphain(flAlphaFile.c_str());
00075   std::ifstream frldmin(frldmFile.c_str());  
00076   std::ifstream vgsldin(vgsldFile.c_str());  
00077   std::ifstream pace2in(pace2File.c_str());
00078 
00079   std::filebuf *buf1 = flalphain.rdbuf();
00080   std::filebuf *buf2 = frldmin.rdbuf();
00081   std::filebuf *buf3 = vgsldin.rdbuf();
00082   std::filebuf *buf4 = pace2in.rdbuf();  
00083   if (!((buf1->is_open()) && (buf2->is_open()) && (buf3->is_open()) && (buf4->is_open()))) {
00084     G4Exception("ERROR: Data missing. Could not find ABLA data file in " + dataPath +
00085                 " defined by environment variable G4ABLADATA");
00086   }
00087   
00088   G4double flalpha, frldm, vgsld, pace2;
00089   const G4int rows = 98;
00090   const G4int cols = 153;
00091   const G4int massnumbers = 263;
00092   for(int i = 0; i < rows; i++) {
00093     for(int j = 0; j < cols; j++) {
00094       setAlpha(j, i, 0.0);
00095       setEcnz( j, i, 0.0);
00096       setVgsld(j, i, 0.0);      
00097     }
00098   }
00099   
00100   for(int i = 0; i < rows; i++) {
00101     for(int j = 0; j < cols; j++) {
00102       flalphain >> flalpha;
00103       frldmin >> frldm;
00104       vgsldin >> vgsld;      
00105       setAlpha(j, i, flalpha);
00106       setEcnz( j, i, frldm);
00107       setVgsld(j, i, vgsld);      
00108     }
00109   }
00110   flalphain.close();
00111   frldmin.close();  
00112   vgsldin.close();
00113 
00114   int A = 0, Zbegin = 0, Zend = 0;
00115   G4String str1, str2, str3;
00116   for(int i = 0; i < 500; i++) {
00117     for(int j = 0; j < 500; j++) {
00118       setPace2(i, j, 0.0);
00119     }
00120   }
00121   
00122   for(int i = 0; i < massnumbers; i++) {
00123     pace2in >> str1 >> A >> str2 >> Zbegin >> str3 >> Zend;
00124     for(int j = Zbegin; j <= Zend; j++) {
00125       pace2in >> pace2;
00126       setPace2(A, j, pace2);
00127     }
00128   }
00129   pace2in.close();
00130   if(std::fabs(getPace2(A, Zend) - 114516.10) > 1e-6) {
00131     G4cout <<"ERROR: Problem in parsing datafile " + pace2File << G4endl;
00132     return false;
00133   }
00134 
00135   return true;
00136 }
00137 
00138 

Generated on Mon May 27 17:47:36 2013 for Geant4 by  doxygen 1.4.7