| [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: G4NeutronCaptureXS.cc,v 1.5 2010/10/15 22:36:13 dennis Exp $
|
|---|
| 27 | // GEANT4 tag $Name: hadr-cross-V09-03-12 $
|
|---|
| [1197] | 28 | //
|
|---|
| 29 | // -------------------------------------------------------------------
|
|---|
| 30 | //
|
|---|
| 31 | // GEANT4 Class file
|
|---|
| 32 | //
|
|---|
| 33 | //
|
|---|
| 34 | // File name: G4NeutronCaptureXS
|
|---|
| 35 | //
|
|---|
| 36 | // Author Ivantchenko, Geant4, 3-Aug-09
|
|---|
| 37 | //
|
|---|
| 38 | // Modifications:
|
|---|
| 39 | //
|
|---|
| 40 |
|
|---|
| 41 | #include "G4NeutronCaptureXS.hh"
|
|---|
| 42 | #include "G4Element.hh"
|
|---|
| 43 | #include "G4ElementTable.hh"
|
|---|
| 44 | #include "G4PhysicsLogVector.hh"
|
|---|
| 45 | #include "G4PhysicsVector.hh"
|
|---|
| 46 |
|
|---|
| 47 | #include <iostream>
|
|---|
| 48 | #include <fstream>
|
|---|
| 49 | #include <sstream>
|
|---|
| [1340] | 50 |
|
|---|
| [1197] | 51 | using namespace std;
|
|---|
| 52 |
|
|---|
| 53 | G4NeutronCaptureXS::G4NeutronCaptureXS()
|
|---|
| [1340] | 54 | : emax(20*MeV),maxZ(92)
|
|---|
| [1197] | 55 | {
|
|---|
| [1340] | 56 | // verboseLevel = 0;
|
|---|
| 57 | if(verboseLevel > 0){
|
|---|
| 58 | G4cout << "G4NeutronCaptureXS::G4NeutronCaptureXS: Initialise for Z < "
|
|---|
| 59 | << maxZ + 1 << G4endl;
|
|---|
| [1197] | 60 | }
|
|---|
| [1340] | 61 | data.resize(maxZ+1, 0);
|
|---|
| [1197] | 62 | isInitialized = false;
|
|---|
| 63 | }
|
|---|
| 64 |
|
|---|
| 65 | G4NeutronCaptureXS::~G4NeutronCaptureXS()
|
|---|
| 66 | {
|
|---|
| [1340] | 67 | for(G4int i=0; i<=maxZ; ++i) {
|
|---|
| [1197] | 68 | delete data[i];
|
|---|
| 69 | }
|
|---|
| 70 | }
|
|---|
| 71 |
|
|---|
| 72 | G4bool
|
|---|
| 73 | G4NeutronCaptureXS::IsApplicable(const G4DynamicParticle*,
|
|---|
| 74 | const G4Element*)
|
|---|
| 75 | {
|
|---|
| 76 | return true;
|
|---|
| 77 | }
|
|---|
| 78 |
|
|---|
| 79 | G4bool
|
|---|
| [1340] | 80 | G4NeutronCaptureXS::IsIsoApplicable(const G4DynamicParticle*,
|
|---|
| 81 | G4int /*ZZ*/, G4int /*AA*/)
|
|---|
| [1197] | 82 | {
|
|---|
| 83 | return false;
|
|---|
| 84 | }
|
|---|
| 85 |
|
|---|
| 86 |
|
|---|
| 87 | G4double
|
|---|
| 88 | G4NeutronCaptureXS::GetCrossSection(const G4DynamicParticle* aParticle,
|
|---|
| 89 | const G4Element* elm,
|
|---|
| 90 | G4double)
|
|---|
| 91 | {
|
|---|
| 92 | G4double xs = 0.0;
|
|---|
| 93 | G4double ekin = aParticle->GetKineticEnergy();
|
|---|
| [1340] | 94 | if(ekin > emax) { return xs; }
|
|---|
| [1197] | 95 |
|
|---|
| 96 | G4int Z = G4int(elm->GetZ());
|
|---|
| 97 | G4PhysicsVector* pv = data[Z];
|
|---|
| 98 |
|
|---|
| 99 | // element was not initialised
|
|---|
| 100 | if(!pv) {
|
|---|
| 101 | Initialise(Z);
|
|---|
| 102 | pv = data[Z];
|
|---|
| [1340] | 103 | if(!pv) { return xs; }
|
|---|
| [1197] | 104 | }
|
|---|
| 105 |
|
|---|
| 106 | G4int n = pv->GetVectorLength() - 1;
|
|---|
| 107 | G4double e1 = pv->Energy(0);
|
|---|
| 108 | G4double e2 = pv->Energy(n);
|
|---|
| 109 | if(ekin < e1) { xs = (*pv)[0]*std::sqrt(e1/ekin); }
|
|---|
| 110 | else if(ekin <= e2) { xs = pv->Value(ekin); }
|
|---|
| 111 |
|
|---|
| 112 | if(verboseLevel > 0){
|
|---|
| 113 | G4cout << "ekin= " << ekin << ", xs= " << xs << G4endl;
|
|---|
| 114 | }
|
|---|
| 115 | return xs;
|
|---|
| 116 | }
|
|---|
| 117 |
|
|---|
| 118 |
|
|---|
| 119 | void
|
|---|
| 120 | G4NeutronCaptureXS::BuildPhysicsTable(const G4ParticleDefinition& p)
|
|---|
| 121 | {
|
|---|
| [1340] | 122 | if(verboseLevel > 0){
|
|---|
| 123 | G4cout << "G4NeutronCaptureXS::BuildPhysicsTable for "
|
|---|
| 124 | << p.GetParticleName() << G4endl;
|
|---|
| [1197] | 125 | }
|
|---|
| [1340] | 126 | if(isInitialized || p.GetParticleName() != "neutron") { return; }
|
|---|
| [1197] | 127 | isInitialized = true;
|
|---|
| 128 |
|
|---|
| 129 |
|
|---|
| 130 | // check environment variable
|
|---|
| 131 | // Build the complete string identifying the file with the data set
|
|---|
| [1315] | 132 | char* path = getenv("G4NEUTRONXSDATA");
|
|---|
| [1197] | 133 | if (!path){
|
|---|
| [1315] | 134 | G4cout << "G4NEUTRONXSDATA environment variable not set" << G4endl;
|
|---|
| [1197] | 135 | }
|
|---|
| 136 |
|
|---|
| 137 | // Access to elements
|
|---|
| 138 | const G4ElementTable* theElmTable = G4Element::GetElementTable();
|
|---|
| 139 | size_t numOfElm = G4Element::GetNumberOfElements();
|
|---|
| 140 | if(numOfElm > 0) {
|
|---|
| 141 | for(size_t i=0; i<numOfElm; ++i) {
|
|---|
| 142 | G4int Z = G4int(((*theElmTable)[i])->GetZ());
|
|---|
| [1340] | 143 | if(Z < 1) { Z = 1; }
|
|---|
| 144 | else if(Z > maxZ) { Z = maxZ; }
|
|---|
| [1197] | 145 | //G4cout << "Z= " << Z << G4endl;
|
|---|
| 146 | // Initialisation
|
|---|
| 147 | if(!data[Z]) { Initialise(Z, path); }
|
|---|
| 148 | }
|
|---|
| 149 | }
|
|---|
| 150 | }
|
|---|
| 151 |
|
|---|
| 152 | void
|
|---|
| 153 | G4NeutronCaptureXS::DumpPhysicsTable(const G4ParticleDefinition&)
|
|---|
| [1340] | 154 | {}
|
|---|
| [1197] | 155 |
|
|---|
| [1340] | 156 |
|
|---|
| [1197] | 157 | void
|
|---|
| 158 | G4NeutronCaptureXS::Initialise(G4int Z, const char* p)
|
|---|
| 159 | {
|
|---|
| [1340] | 160 | if(data[Z]) { return; }
|
|---|
| [1197] | 161 | const char* path = p;
|
|---|
| 162 | if(!p) {
|
|---|
| 163 | // check environment variable
|
|---|
| 164 | // Build the complete string identifying the file with the data set
|
|---|
| [1315] | 165 | path = getenv("G4NEUTRONXSDATA");
|
|---|
| [1197] | 166 | if (!path) {
|
|---|
| 167 | if(verboseLevel > 1) {
|
|---|
| [1315] | 168 | G4cout << "G4NEUTRONXSDATA environment variable not set" << G4endl;
|
|---|
| [1197] | 169 | }
|
|---|
| 170 | return;
|
|---|
| 171 | }
|
|---|
| 172 | }
|
|---|
| 173 |
|
|---|
| 174 | // upload data from file
|
|---|
| 175 | data[Z] = new G4PhysicsLogVector();
|
|---|
| 176 |
|
|---|
| 177 | std::ostringstream ost;
|
|---|
| 178 | ost << path << "/cap" << Z ;
|
|---|
| 179 | std::ifstream filein(ost.str().c_str());
|
|---|
| 180 | if (!(filein)) {
|
|---|
| 181 | G4cout << " file " << ost << " is not opened" << G4endl;
|
|---|
| 182 | }else{
|
|---|
| 183 | if(verboseLevel > 1) {
|
|---|
| 184 | G4cout << ost << " is opened" << G4endl;
|
|---|
| 185 | }
|
|---|
| 186 | // retrieve data from DB
|
|---|
| 187 | data[Z]->Retrieve(filein, true);
|
|---|
| 188 | }
|
|---|
| 189 | }
|
|---|