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