// ******************************************************************** // * License and Disclaimer * // * * // * The Geant4 software is copyright of the Copyright Holders of * // * the Geant4 Collaboration. It is provided under the terms and * // * conditions of the Geant4 Software License, included in the file * // * LICENSE and available at http://cern.ch/geant4/license . These * // * include a list of copyright holders. * // * * // * Neither the authors of this software system, nor their employing * // * institutes,nor the agencies providing financial support for this * // * work make any representation or warranty, express or implied, * // * regarding this software system or assume any liability for its * // * use. Please see the license in the file LICENSE and URL above * // * for the full disclaimer and the limitation of liability. * // * * // * This code implementation is the result of the scientific and * // * technical work of the GEANT4 collaboration. * // * By using, copying, modifying or distributing the software (or * // * any work based on the software) you agree to acknowledge its * // * use in resulting scientific publications, and indicate your * // * acceptance of all terms of the Geant4 Software license. * // ******************************************************************** // // // $Id: G4CsDataLib.hh,v 1.1 2007/10/12 23:07:10 pia Exp $ // GEANT4 tag $Name: geant4-09-01-ref-00 $ // // Contact Author: Maria Grazia Pia (Maria.Grazia.Pia@cern.ch) // // History: // ----------- // Date Name Modification // 17 Feb 2008 M.G. Pia Created // 02 Mar 2009 // Jan 2013 M.C. Han Created // 31 Mar 2014 M.G. Pia Fix compilation errors in 9.6-ref07 // 1 Apr 2014 M.G. Pia Refactored to remove dependency on G4SandiaTable // ------------------------------------------------------------------- // Class description: // Photoelectric cross-section computation with respect to the // standard physics // ------------------------------------------------------------------- #include "G4CsPhotoelectricAPC.hh" #include "globals.hh" #include "G4Element.hh" #include "G4PhysicalConstants.hh" #include "G4SystemOfUnits.hh" #include #include G4CsPhotoelectricAPC::G4CsPhotoelectricAPC(const G4String& name): eMin(10.*eV), eMax(100.*GeV), model(name), nCoeffs(4) { LoadData(); } G4CsPhotoelectricAPC::~G4CsPhotoelectricAPC() { // dummy } double G4CsPhotoelectricAPC::CrossSection(int Z, double e) { // Cross section value double cross = DBL_MIN; if (e >= eMin && e <= eMax) { int z1 = Z - 1; std::vector& energies = energiesZ[z1]; std::vector::iterator pos = std::lower_bound(energies.begin(),energies.end(),e); int index = pos - energies.begin() - 1; int iStart = index * nCoeffs; std::vector& coeffs = coeffZ[z1]; double invertE = 1./(e); double eSquare = invertE * invertE; double eCube = invertE * eSquare; double eFour = invertE * eCube; cross = coeffs[iStart]*invertE + coeffs[iStart+1]*eSquare + coeffs[iStart+2]*eCube + coeffs[iStart+3]*eFour; } return cross; } double G4CsPhotoelectricAPC::ApplicableRangeMin() { // Applicability limits return eMin; } double G4CsPhotoelectricAPC::ApplicableRangeMax() { // Applicability limits return eMax; } void G4CsPhotoelectricAPC::LoadData() { char* path = getenv("APCDIR"); if (!path) G4Exception("G4CsPhotoelectricAPC::LoadData", "dummy", FatalException, "APCDIR environment variable not set"); // Zmax up to which APC & Lighthill parameterisation is applicable (Zmin = 1) int nZ = 100; int nRows = 0; double e = 0.; double ratio = 0.; double c1 = 0.; double c2 = 0.; double c3 = 0.; double c4 = 0.; // ---- Load the Z/A ratio for each Z in Biggs & Lighthill parameterisation G4String ratioFile("ratio.dat"); std::ostringstream ratioFileNameS; ratioFileNameS << path << "/parametersAPC/" << model << "/" << ratioFile; G4String ratioFileName(ratioFileNameS.str().c_str()); std::ifstream inRatio(ratioFileName); if (!inRatio.is_open()) { std::ostringstream message; message << "G4CsPhotoelectricAPC::LoadData - data file " << ratioFileName << " not found"; G4Exception("G4CsPhotoelectricAPC::LoadData", "dummy", FatalException, message.str().c_str()); } // ---- Load the number of rows for each Z in APC & Lighthill parameterisation G4String rowsFile("nrows.dat"); std::ostringstream rowsFileNameS; rowsFileNameS << path << "/parametersAPC/" << model << "/" << rowsFile; G4String rowsFileName(rowsFileNameS.str().c_str()); std::ifstream inRows(rowsFileName); if (!inRows.is_open()) { std::ostringstream message; message << "G4CsPhotoelectricAPC::LoadData - data file " << rowsFileName << " not found"; G4Exception("G4CsPhotoelectricAPC::LoadData", "dummy", FatalException, message.str().c_str()); } // ---- Load the rows for each Z in APC & Lighthill parameterisation // Each rows contains the energy and 4 coefficients double u1 = CLHEP::cm2*CLHEP::keV/CLHEP::g; double u2 = CLHEP::cm2*CLHEP::keV*CLHEP::keV/CLHEP::g; double u3 = CLHEP::cm2*CLHEP::keV*CLHEP::keV*CLHEP::keV/CLHEP::g; double u4 = CLHEP::cm2*CLHEP::keV*CLHEP::keV*CLHEP::keV*CLHEP::keV/CLHEP::g; std::vector energies; std::vector coeffs; for (int i=0; i> ratio; // Read in the number of rows holding data for the current Z inRows >> nRows; int Z = i + 1; std::ostringstream coefFileNameS; coefFileNameS << path << "/parametersAPC/" << model << "/coeff_" << Z << ".dat"; G4String coefFileName(coefFileNameS.str().c_str()); std::ifstream inFileZ(coefFileName); if (!inFileZ.is_open()) { std::ostringstream message; message << "G4CsPhotoelectricAPC::LoadData - data file " << coefFileName << " not found"; G4Exception("G4CsPhotoelectricAPC::LoadData", "dummy", FatalException, message.str().c_str()); } double AoverAvo = Z*CLHEP::amu / ratio; // Read in the rows holding data for the current Z energies.clear(); coeffs.clear(); for (int iRow=0; iRow> e >> c1 >> c2 >> c3 >> c4; energies.push_back(e * CLHEP::keV); coeffs.push_back(c1 * AoverAvo * u1); coeffs.push_back(c2 * AoverAvo * u2); coeffs.push_back(c3 * AoverAvo * u3); coeffs.push_back(c4 * AoverAvo * u4); } energiesZ.push_back(energies); coeffZ.push_back(coeffs); } return; }