[1197] | 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 | // |
---|
[1340] | 26 | // $Id: G4NeutronInelasticXS.cc,v 1.6 2010/10/15 22:35:32 dennis Exp $ |
---|
| 27 | // GEANT4 tag $Name: hadr-cross-V09-03-12 $ |
---|
[1197] | 28 | // |
---|
| 29 | // ------------------------------------------------------------------- |
---|
| 30 | // |
---|
| 31 | // GEANT4 Class file |
---|
| 32 | // |
---|
| 33 | // |
---|
| 34 | // File name: G4NeutronInelasticXS |
---|
| 35 | // |
---|
| 36 | // Author Ivantchenko, Geant4, 3-Aug-09 |
---|
| 37 | // |
---|
| 38 | // Modifications: |
---|
| 39 | // |
---|
| 40 | |
---|
| 41 | #include "G4NeutronInelasticXS.hh" |
---|
| 42 | #include "G4Neutron.hh" |
---|
| 43 | #include "G4DynamicParticle.hh" |
---|
| 44 | #include "G4Element.hh" |
---|
| 45 | #include "G4ElementTable.hh" |
---|
| 46 | #include "G4PhysicsLogVector.hh" |
---|
| 47 | #include "G4PhysicsVector.hh" |
---|
| 48 | #include "G4GlauberGribovCrossSection.hh" |
---|
[1340] | 49 | #include "G4HadronNucleonXsc.hh" |
---|
[1197] | 50 | #include "G4NistManager.hh" |
---|
[1340] | 51 | #include "G4Proton.hh" |
---|
[1197] | 52 | |
---|
| 53 | #include <iostream> |
---|
| 54 | #include <fstream> |
---|
| 55 | #include <sstream> |
---|
[1340] | 56 | |
---|
[1197] | 57 | using namespace std; |
---|
| 58 | |
---|
| 59 | G4NeutronInelasticXS::G4NeutronInelasticXS() |
---|
[1340] | 60 | : proton(G4Proton::Proton()), maxZ(92) |
---|
[1197] | 61 | { |
---|
[1340] | 62 | // verboseLevel = 0; |
---|
| 63 | if(verboseLevel > 0){ |
---|
| 64 | G4cout << "G4NeutronInelasticXS::G4NeutronInelasticXS Initialise for Z < " |
---|
| 65 | << maxZ + 1 << G4endl; |
---|
[1197] | 66 | } |
---|
[1340] | 67 | data.resize(maxZ+1, 0); |
---|
| 68 | coeff.resize(maxZ+1, 1.0); |
---|
[1197] | 69 | ggXsection = new G4GlauberGribovCrossSection(); |
---|
[1340] | 70 | fNucleon = new G4HadronNucleonXsc(); |
---|
[1197] | 71 | isInitialized = false; |
---|
| 72 | } |
---|
| 73 | |
---|
| 74 | G4NeutronInelasticXS::~G4NeutronInelasticXS() |
---|
| 75 | { |
---|
[1340] | 76 | for(G4int i=0; i<=maxZ; ++i) { |
---|
[1197] | 77 | delete data[i]; |
---|
| 78 | } |
---|
| 79 | } |
---|
| 80 | |
---|
| 81 | G4bool |
---|
| 82 | G4NeutronInelasticXS::IsApplicable(const G4DynamicParticle*, |
---|
| 83 | const G4Element*) |
---|
| 84 | { |
---|
| 85 | return true; |
---|
| 86 | } |
---|
| 87 | |
---|
| 88 | G4bool |
---|
[1340] | 89 | G4NeutronInelasticXS::IsIsoApplicable(const G4DynamicParticle*, |
---|
| 90 | G4int /*ZZ*/, G4int /*AA*/) |
---|
[1197] | 91 | { |
---|
| 92 | return false; |
---|
| 93 | } |
---|
| 94 | |
---|
| 95 | |
---|
| 96 | G4double |
---|
| 97 | G4NeutronInelasticXS::GetCrossSection(const G4DynamicParticle* aParticle, |
---|
| 98 | const G4Element* elm, |
---|
| 99 | G4double) |
---|
| 100 | { |
---|
| 101 | G4double xs = 0.0; |
---|
| 102 | G4double ekin = aParticle->GetKineticEnergy(); |
---|
| 103 | |
---|
| 104 | G4int Z = G4int(elm->GetZ()); |
---|
[1340] | 105 | if(Z < 1 || Z > maxZ) { return xs; } |
---|
[1197] | 106 | G4PhysicsVector* pv = data[Z]; |
---|
| 107 | // G4cout << "G4NeutronInelasticXS::GetCrossSection e= " << ekin << " Z= " << Z << G4endl; |
---|
| 108 | |
---|
| 109 | // element was not initialised |
---|
| 110 | if(!pv) { |
---|
| 111 | Initialise(Z); |
---|
| 112 | pv = data[Z]; |
---|
[1340] | 113 | if(!pv) { return xs; } |
---|
[1197] | 114 | } |
---|
| 115 | |
---|
| 116 | G4double e1 = pv->Energy(0); |
---|
[1340] | 117 | if(ekin <= e1) { return xs; } |
---|
[1197] | 118 | |
---|
| 119 | G4int n = pv->GetVectorLength() - 1; |
---|
| 120 | G4double e2 = pv->Energy(n); |
---|
| 121 | if(ekin <= e2) { |
---|
| 122 | xs = pv->Value(ekin); |
---|
[1340] | 123 | } else if(1 == Z) { |
---|
| 124 | fNucleon->GetHadronNucleonXscPDG(aParticle, proton); |
---|
| 125 | xs = coeff[1]*fNucleon->GetInelasticHadronNucleonXsc(); |
---|
[1197] | 126 | } else { |
---|
| 127 | ggXsection->GetCrossSection(aParticle, elm); |
---|
| 128 | xs = coeff[Z]*ggXsection->GetInelasticGlauberGribovXsc(); |
---|
| 129 | } |
---|
| 130 | |
---|
[1340] | 131 | if(verboseLevel > 0) { |
---|
[1197] | 132 | G4cout << "ekin= " << ekin << ", XSinel= " << xs << G4endl; |
---|
| 133 | } |
---|
| 134 | return xs; |
---|
| 135 | } |
---|
| 136 | |
---|
| 137 | |
---|
| 138 | void |
---|
| 139 | G4NeutronInelasticXS::BuildPhysicsTable(const G4ParticleDefinition& p) |
---|
| 140 | { |
---|
[1340] | 141 | if(verboseLevel > 0){ |
---|
| 142 | G4cout << "G4NeutronInelasticXS::BuildPhysicsTable for " |
---|
| 143 | << p.GetParticleName() << G4endl; |
---|
[1197] | 144 | } |
---|
[1340] | 145 | if(isInitialized || p.GetParticleName() != "neutron") { return; } |
---|
[1197] | 146 | isInitialized = true; |
---|
| 147 | |
---|
| 148 | // check environment variable |
---|
| 149 | // Build the complete string identifying the file with the data set |
---|
[1315] | 150 | char* path = getenv("G4NEUTRONXSDATA"); |
---|
[1197] | 151 | if (!path){ |
---|
[1315] | 152 | G4cout << "G4NEUTRONXSDATA environment variable not set" << G4endl; |
---|
[1197] | 153 | } |
---|
| 154 | |
---|
| 155 | G4DynamicParticle* dynParticle = |
---|
| 156 | new G4DynamicParticle(G4Neutron::Neutron(),G4ThreeVector(1,0,0),1); |
---|
| 157 | |
---|
| 158 | // Access to elements |
---|
| 159 | const G4ElementTable* theElmTable = G4Element::GetElementTable(); |
---|
| 160 | size_t numOfElm = G4Element::GetNumberOfElements(); |
---|
| 161 | if(numOfElm > 0) { |
---|
| 162 | for(size_t i=0; i<numOfElm; ++i) { |
---|
| 163 | G4int Z = G4int(((*theElmTable)[i])->GetZ()); |
---|
[1340] | 164 | if(Z < 1) { Z = 1; } |
---|
| 165 | else if(Z > maxZ) { Z = maxZ; } |
---|
[1197] | 166 | //G4cout << "Z= " << Z << G4endl; |
---|
| 167 | // Initialisation |
---|
| 168 | if(!data[Z]) { Initialise(Z, dynParticle, path); } |
---|
| 169 | } |
---|
| 170 | } |
---|
| 171 | delete dynParticle; |
---|
| 172 | } |
---|
| 173 | |
---|
| 174 | void |
---|
| 175 | G4NeutronInelasticXS::DumpPhysicsTable(const G4ParticleDefinition&) |
---|
| 176 | { |
---|
| 177 | } |
---|
| 178 | |
---|
| 179 | void |
---|
| 180 | G4NeutronInelasticXS::Initialise(G4int Z, G4DynamicParticle* dp, |
---|
| 181 | const char* p) |
---|
| 182 | { |
---|
[1340] | 183 | if(data[Z]) { return; } |
---|
[1197] | 184 | const char* path = p; |
---|
| 185 | if(!p) { |
---|
| 186 | // check environment variable |
---|
| 187 | // Build the complete string identifying the file with the data set |
---|
[1315] | 188 | path = getenv("G4NEUTRONXSDATA"); |
---|
[1197] | 189 | if (!path) { |
---|
| 190 | if(verboseLevel > 1) { |
---|
[1315] | 191 | G4cout << "G4NEUTRONXSDATA environment variable not set" << G4endl; |
---|
[1197] | 192 | } |
---|
| 193 | return; |
---|
| 194 | } |
---|
| 195 | } |
---|
| 196 | G4DynamicParticle* dynParticle = dp; |
---|
| 197 | if(!dp) { |
---|
| 198 | dynParticle = |
---|
| 199 | new G4DynamicParticle(G4Neutron::Neutron(),G4ThreeVector(1,0,0),1); |
---|
| 200 | } |
---|
| 201 | |
---|
| 202 | const G4Element* Elem = |
---|
| 203 | G4NistManager::Instance()->FindOrBuildElement(Z, true); |
---|
| 204 | |
---|
| 205 | // upload data from file |
---|
| 206 | data[Z] = new G4PhysicsLogVector(); |
---|
| 207 | |
---|
| 208 | std::ostringstream ost; |
---|
| 209 | ost << path << "/inelast" << Z ; |
---|
| 210 | std::ifstream filein(ost.str().c_str()); |
---|
| 211 | if (!(filein)) { |
---|
| 212 | G4cout << " file " << ost << " is not opened" << G4endl; |
---|
| 213 | }else{ |
---|
| 214 | if(verboseLevel > 1) { |
---|
| 215 | G4cout << ost << " is opened" << G4endl; |
---|
| 216 | } |
---|
| 217 | // retrieve data from DB |
---|
| 218 | data[Z]->Retrieve(filein, true); |
---|
| 219 | |
---|
| 220 | // smooth transition |
---|
| 221 | size_t n = data[Z]->GetVectorLength() - 1; |
---|
| 222 | G4double emax = data[Z]->Energy(n); |
---|
| 223 | G4double sig1 = (*data[Z])[n]; |
---|
| 224 | dynParticle->SetKineticEnergy(emax); |
---|
[1340] | 225 | G4double sig2 = 0.0; |
---|
| 226 | if(1 == Z) { |
---|
| 227 | fNucleon->GetHadronNucleonXscPDG(dynParticle, proton); |
---|
| 228 | sig2 = fNucleon->GetInelasticHadronNucleonXsc(); |
---|
| 229 | } else { |
---|
| 230 | ggXsection->GetCrossSection(dynParticle, Elem); |
---|
| 231 | sig2 = ggXsection->GetInelasticGlauberGribovXsc(); |
---|
| 232 | } |
---|
[1315] | 233 | if(sig2 > 0.) { coeff[Z] = sig1/sig2; } |
---|
[1197] | 234 | } |
---|
[1315] | 235 | if(!dp) { delete dynParticle; } |
---|
[1197] | 236 | } |
---|