Geant4 11.4.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4LENDManager.cc
Go to the documentation of this file.
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//
26// Class Description
27// Manager of LEND (Low Energy Nuclear Data) target (nucleus)
28// LEND is Geant4 interface for GIDI (General Interaction Data Interface)
29// which gives a discription of nuclear and atomic reactions, such as
30// Binary collision cross sections
31// Particle number multiplicity distributions of reaction products
32// Energy and angular distributions of reaction products
33// Derived calculational constants
34// GIDI is developped at Lawrence Livermore National Laboratory
35// Class Description - End
36
37// 071025 First implementation done by T. Koi (SLAC/SCCS)
38// 101118 Name modifications for release T. Koi (SLAC/PPA)
39
40#include "G4LENDManager.hh"
42
43#include "G4Neutron.hh"
44#include "G4Gamma.hh"
45#include "G4Proton.hh"
46#include "G4Deuteron.hh"
47#include "G4Triton.hh"
48#include "G4He3.hh"
49#include "G4Alpha.hh"
50
51#include <fstream>
52
53G4LENDManager* G4LENDManager::lend_manager = NULL;
54
55
56G4LENDManager::G4LENDManager()
57:verboseLevel( 0 )
58{
59
60 //printBanner();
61
62 const char *dataDir = G4FindDataDir("G4LENDDATA");
63 if( dataDir == NULL ) {
64 throw G4HadronicException(__FILE__, __LINE__, " Please setenv G4LENDDATA to point to the LEND files." );
65 }
66
67 std::string G4LENDDATA(dataDir);
68 G4GIDI_initialize(G4LENDDATA);
69
70 G4String xmcf = G4LENDDATA + "/neutrons.map";
71 G4String xmcf_gamma = G4LENDDATA + "/gammas.map";
72 G4String xmcf_p = G4LENDDATA + "/protons.map";
73 G4String xmcf_d = G4LENDDATA + "/deuterons.map";
74 G4String xmcf_t = G4LENDDATA + "/tritons.map";
75 G4String xmcf_h = G4LENDDATA + "/helions.map";
76 G4String xmcf_a = G4LENDDATA + "/alphas.map";
77
78//Example of xmcf.n_1.map
79//<map>
80//<target schema="MonteCarlo" evaluation="ENDF.B-VII.0" projectile="n_1" target="H_1" path="000_n_1/xMC.000_n_1.001_H_1/xMC.000_n_1.001_H_1.xml"/>
81//</map>
82//
83// for neutron "1" for neutron; see G4GIDI::init
84 proj_lend_map.insert ( std::pair < G4ParticleDefinition* , G4GIDI* > ( G4Neutron::Neutron() , new G4GIDI( 1 , xmcf ) ) );
85// for gamma "0" for gamma; see G4GIDI::init
86 proj_lend_map.insert ( std::pair < G4ParticleDefinition* , G4GIDI* > ( G4Gamma::Gamma() , new G4GIDI( 0 , xmcf_gamma ) ) );
87//
88 std::ifstream aFile;
89 aFile.open( xmcf_p.c_str() );
90 if ( aFile.good() ) {
91 aFile.close();
92 proj_lend_map.insert ( std::pair < G4ParticleDefinition* , G4GIDI* > ( G4Proton::Proton() , new G4GIDI( 2 , xmcf_p ) ) );
93 } else {
94 aFile.close();
95 }
96 aFile.open( xmcf_d.c_str() );
97 if ( aFile.good() ) {
98 aFile.close();
99 proj_lend_map.insert ( std::pair < G4ParticleDefinition* , G4GIDI* > ( G4Deuteron::Deuteron() , new G4GIDI( 3 , xmcf_d ) ) );
100 } else {
101 aFile.close();
102 }
103 aFile.open( xmcf_t.c_str() );
104 if ( aFile.good() ) {
105 aFile.close();
106 proj_lend_map.insert ( std::pair < G4ParticleDefinition* , G4GIDI* > ( G4Triton::Triton() , new G4GIDI( 4 , xmcf_t ) ) );
107 } else {
108 aFile.close();
109 }
110 aFile.open( xmcf_h.c_str() );
111 if ( aFile.good() ) {
112 aFile.close();
113 proj_lend_map.insert ( std::pair < G4ParticleDefinition* , G4GIDI* > ( G4He3::He3() , new G4GIDI( 5 , xmcf_h ) ) );
114 } else {
115 aFile.close();
116 }
117 aFile.open( xmcf_a.c_str() );
118 if ( aFile.good() ) {
119 aFile.close();
120 proj_lend_map.insert ( std::pair < G4ParticleDefinition* , G4GIDI* > ( G4Alpha::Alpha() , new G4GIDI( 6 , xmcf_a ) ) );
121 } else {
122 aFile.close();
123 }
124
125
126
127// proj_lend_map.insert ( std::pair < G4ParticleDefinition* , G4GIDI* > ( xxx , new G4GIDI( xxx , xmcf ) ) );
128
129 v_lend_target.clear();
130
131 //ionTable = new G4IonTable();
133 nistElementBuilder = new G4NistElementBuilder( 0 );
134
135 //Prepare table of excitation energy of excited isomers
136 G4int pdgCode;
137 // iZ iA iM ->Co58m1
138 pdgCode= 10000 * 27 + 10 * 58 + 1;
139 pdgCode = GetNucleusEncoding( 27 , 58 , 1 );
140 mExcitationEnergy.insert(std::pair<G4int,G4double>( pdgCode, 24890 *CLHEP::eV));
141 pdgCode= 10000 * 47 + 10 * 110 + 1;
142 pdgCode = GetNucleusEncoding( 47 , 110 , 1 );
143 mExcitationEnergy.insert(std::pair<G4int,G4double>( pdgCode, 117590 *CLHEP::eV));
144 pdgCode= 10000 * 48 + 10 * 115 + 1;
145 pdgCode = GetNucleusEncoding( 48 , 115 , 1 );
146 mExcitationEnergy.insert(std::pair<G4int,G4double>( pdgCode, 181000 *CLHEP::eV));
147 pdgCode= 10000 * 52 + 10 * 127 + 1;
148 pdgCode = GetNucleusEncoding( 52 , 127 , 1 );
149 mExcitationEnergy.insert(std::pair<G4int,G4double>( pdgCode, 88260 *CLHEP::eV));
150 pdgCode= 10000 * 52 + 10 * 129 + 1;
151 pdgCode = GetNucleusEncoding( 52 , 129 , 1 );
152 mExcitationEnergy.insert(std::pair<G4int,G4double>( pdgCode, 105280 *CLHEP::eV));
153 pdgCode= 10000 * 61 + 10 * 148 + 1;
154 pdgCode = GetNucleusEncoding( 61 , 148 , 1 );
155 mExcitationEnergy.insert(std::pair<G4int,G4double>( pdgCode, 137900 *CLHEP::eV));
156 pdgCode= 10000 * 67 + 10 * 166 + 1;
157 pdgCode = GetNucleusEncoding( 67 , 166 , 1 );
158 mExcitationEnergy.insert(std::pair<G4int,G4double>( pdgCode, 5985 *CLHEP::eV));
159 pdgCode= 10000 * 95 + 10 * 242 + 1;
160 pdgCode = GetNucleusEncoding( 95 , 242 , 1 );
161 mExcitationEnergy.insert(std::pair<G4int,G4double>( pdgCode, 48600 *CLHEP::eV));
162 pdgCode= 10000 * 95 + 10 * 244 + 1;
163 pdgCode = GetNucleusEncoding( 95 , 244 , 1 );
164 mExcitationEnergy.insert(std::pair<G4int,G4double>( pdgCode, 87999.9*CLHEP::eV));
165 pdgCode= 10000 * 99 + 10 * 254 + 1;
166 pdgCode = GetNucleusEncoding( 99 , 254 , 1 );
167 mExcitationEnergy.insert(std::pair<G4int,G4double>( pdgCode, 84200 *CLHEP::eV));
168
169}
170
171
172
173G4LENDManager::~G4LENDManager()
174{
175
176// deleting target
177 for ( auto it = v_lend_target.cbegin() ; it != v_lend_target.cend() ; ++it )
178 {
179 (*it).lend->freeTarget( it->target );
180 }
181
182// deleting lend
183 for ( auto it = proj_lend_map.cbegin() ; it != proj_lend_map.cend() ; ++it )
184 {
185 delete it->second;
186 }
187
188 //delete ionTable;
189 delete nistElementBuilder;
190
191}
192
193
194
196{
197
198 G4GIDI_target* anLENDTarget = NULL;
199
200 if ( iM > 9 ) {
201 throw G4HadronicException(__FILE__, __LINE__, "Requested isomer level of target is too high." );
202 }
203
204 G4int iTarg = GetNucleusEncoding( iZ , iA , iM );
205
206 // Searching in current map
207 for ( auto it = v_lend_target.cbegin() ; it != v_lend_target.cend() ; ++it )
208 {
209 if ( it->proj == proj && it->target_code == iTarg && it->evaluation == evaluation )
210 {
211 //find!
212 return it->target;
213 }
214 }
215
216
217 if ( proj_lend_map.find ( proj ) == proj_lend_map.cend() ) {
218 G4cout << proj->GetParticleName() << " is not supported by this LEND library." << G4endl;
219 return anLENDTarget; // return NULL
220 }
221
222 G4GIDI* xlend = proj_lend_map.find ( proj ) -> second;
223
224 if ( xlend->isThisDataAvailable( evaluation, iZ, iA , iM ) )
225 {
226
227 if ( verboseLevel > 1 ) {
228 G4cout << evaluation << " for " << ionTable->GetIonName( iZ , iA , 0 )
229 << " with Isomer level of " << iM << " is exist in this LEND." << G4endl;
230 }
231
232 anLENDTarget = xlend->readTarget( evaluation , iZ , iA , iM );
233
234 lend_target new_target;
235 new_target.lend = xlend;
236 new_target.target = anLENDTarget;
237 new_target.proj = proj;
238 new_target.evaluation = evaluation;
239 new_target.target_code = iTarg;
240
241 v_lend_target.push_back( std::move(new_target) );
242
243// found EXACT
244 return anLENDTarget;
245
246 }
247 else
248 {
249// NO EXACT DATA (Evaluatino & Z,A,M)
250
251 //Searching available evaluation and natural abundance data and give suggestions.
252 //
253 if ( verboseLevel > 1 )
254 G4cout << evaluation << " for " << ionTable->GetIonName( iZ , iA , 0 )
255 << " with Isomer level of " << iM << " is not exist in this LEND." << G4endl;
256
257 std::vector< std::string >* available = xlend->getNamesOfAvailableLibraries( iZ, iA , iM );
258 if ( available->size() > 0 ) {
259// EXACT Z,A,M but Evaluation is different
260 if ( verboseLevel > 1 )
261 {
262 G4cout << " However you can use following evaluation(s) for the target. " << G4endl;
263
264 for ( auto its = available->cbegin() ; its != available->cend() ; ++its )
265 G4cout << *its << G4endl;
266
267 G4cout << G4endl;
268 }
269 } else if ( xlend->isThisDataAvailable( evaluation, iZ, 0 , iM ) ) {
270//
271// checking natural abundance data for Z
272//
273// EXACT natural abundance data for the evaluation
274 if ( verboseLevel > 1 )
275 G4cout << " However you can use natural abundance data for the target. " << G4endl;
276 }
277 else
278 {
279 std::vector< std::string >* available_nat = xlend->getNamesOfAvailableLibraries( iZ, 0 , iM );
280//
281 if ( available_nat->size() > 0 ) {
282// EXACT natural abundance data for Z but differnet evaluation
283 if ( verboseLevel > 1 ) {
284 G4cout << " However you can use following evaluation(s) for natural abundace of the target. " << G4endl;
285
286 for ( auto its = available_nat->cbegin() ; its != available_nat->cend() ; ++its )
287 G4cout << *its << G4endl;
288 G4cout << G4endl;
289 }
290 }
291 delete available_nat;
292 }
293 delete available;
294// return NULL if exact data is not available
295 return anLENDTarget; // return NULL
296 }
297
298 return anLENDTarget;
299}
300
301
302std::vector< G4String > G4LENDManager::IsLENDTargetAvailable ( G4ParticleDefinition* proj , G4int iZ , G4int iA , G4int iM )
303{
304
305 std::vector< G4String > vEvaluation;
306 if ( proj_lend_map.find ( proj ) == proj_lend_map.cend() )
307 {
308 G4cout << proj->GetParticleName() << " is not supported by this LEND." << G4endl;
309 return vEvaluation; // return empty
310 }
311
312 G4GIDI* xlend = proj_lend_map.find ( proj ) -> second;
313 std::vector< std::string >* available = xlend->getNamesOfAvailableLibraries( iZ, iA , iM );
314
315 if ( available->size() > 0 ) {
316 for ( auto its = available->cbegin() ; its != available->cend() ; ++its )
317 vEvaluation.push_back ( *its );
318 }
319 delete available;
320
321 return vEvaluation;
322}
323
324
325
327{
328 G4int value = ionTable->GetNucleusEncoding( iZ , iA ); // Ground State
329 // G4double E=0.0, G4int J=0);
330 value += iM;
331 return value;
332}
333
334
335
336void G4LENDManager::printBanner()
337{
338 G4cout << " <<BEGIN-copyright>> " << G4endl;
339 G4cout << " Copyright (c) 2010, Lawrence Livermore National Security, LLC. " << G4endl;
340 G4cout << " Produced at the Lawrence Livermore National Laboratory " << G4endl;
341 G4cout << " Written by Bret R. Beck, beck6@llnl.gov. " << G4endl;
342 G4cout << " CODE-461393 " << G4endl;
343 G4cout << " All rights reserved. " << G4endl;
344 G4cout << " " << G4endl;
345 G4cout << " This file is part of GIDI. For details, see nuclear.llnl.gov. " << G4endl;
346 G4cout << " Please also read the \"Additional BSD Notice\" at nuclear.llnl.gov. " << G4endl;
347 G4cout << " " << G4endl;
348 G4cout << " Redistribution and use in source and binary forms, with or without modification, " << G4endl;
349 G4cout << " are permitted provided that the following conditions are met: " << G4endl;
350 G4cout << " " << G4endl;
351 G4cout << " 1) Redistributions of source code must retain the above copyright notice, " << G4endl;
352 G4cout << " this list of conditions and the disclaimer below. " << G4endl;
353 G4cout << " 2) Redistributions in binary form must reproduce the above copyright notice, " << G4endl;
354 G4cout << " this list of conditions and the disclaimer (as noted below) in the " << G4endl;
355 G4cout << " documentation and/or other materials provided with the distribution. " << G4endl;
356 G4cout << " 3) Neither the name of the LLNS/LLNL nor the names of its contributors may be " << G4endl;
357 G4cout << " used to endorse or promote products derived from this software without " << G4endl;
358 G4cout << " specific prior written permission. " << G4endl;
359 G4cout << " " << G4endl;
360 G4cout << " THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND ANY " << G4endl;
361 G4cout << " EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES " << G4endl;
362 G4cout << " OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT " << G4endl;
363 G4cout << " SHALL LAWRENCE LIVERMORE NATIONAL SECURITY, LLC, THE U.S. DEPARTMENT OF ENERGY OR " << G4endl;
364 G4cout << " CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR " << G4endl;
365 G4cout << " CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS " << G4endl;
366 G4cout << " OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED " << G4endl;
367 G4cout << " AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT " << G4endl;
368 G4cout << " (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, " << G4endl;
369 G4cout << " EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. " << G4endl;
370 G4cout << " <<END-copyright>> " << G4endl;
371}
372
373
375{
376 G4bool result=false;
377 if ( newValue >= verboseLevel)
378 {
379 verboseLevel = newValue;
380 result=true;
381 }
382 else
383 {
384 G4cout << "Since other LEND model or cross section have set the higher verbose level (" << verboseLevel << ") in LENDManager, you cannot change the value now." << G4endl;
385 }
386
387 return result;
388}
389
391{
392 G4double EE = 0.0;
393 G4int nucCode = GetNucleusEncoding( iZ , iA , iM );
394 auto it = mExcitationEnergy.find( nucCode );
395 if ( it != mExcitationEnergy.cend() ) {
396 EE = it->second;
397 } else {
398 if ( iM == 0 ) {
399 G4cout << "G4LENDManager::GetExcitationEnergyOfExcitedIsomer is called for ground state (iM=0) nucleus" << G4endl;
400 } else {
401 G4cout << "Can not find excitation energy for Z = " << iZ << ", A = " << iA << ", M = " << iM << " and the energy set to 0." << G4endl;
402 }
403 }
404 return EE;
405}
const char * G4FindDataDir(const char *)
void G4GIDI_initialize(std::string const &a_dataPath)
Definition G4GIDI.cc:66
double G4double
Definition G4Types.hh:83
bool G4bool
Definition G4Types.hh:86
int G4int
Definition G4Types.hh:85
#define G4endl
Definition G4ios.hh:67
G4GLOB_DLL std::ostream G4cout
static G4Alpha * Alpha()
Definition G4Alpha.cc:83
static G4Deuteron * Deuteron()
Definition G4Deuteron.cc:90
std::vector< std::string > * getNamesOfAvailableLibraries(G4int a_Z, G4int a_A, G4int a_M=0) const
Definition G4GIDI.cc:268
G4GIDI_target * readTarget(std::string const &lib_name, G4int a_Z, G4int a_A, G4int a_M=0, bool a_bind=true)
Definition G4GIDI.cc:331
bool isThisDataAvailable(std::string const &a_lib_name, G4int a_Z, G4int a_A, G4int a_M=0) const
Definition G4GIDI.cc:199
static G4Gamma * Gamma()
Definition G4Gamma.cc:81
static G4He3 * He3()
Definition G4He3.cc:90
G4double GetExcitationEnergyOfExcitedIsomer(G4int, G4int, G4int)
G4GIDI_target * GetLENDTarget(G4ParticleDefinition *, const G4String &, G4int iZ, G4int iA, G4int iM=0)
std::vector< G4String > IsLENDTargetAvailable(G4ParticleDefinition *, G4int iZ, G4int iA, G4int iM=0)
G4bool RequestChangeOfVerboseLevel(G4int)
G4int GetNucleusEncoding(G4int iZ, G4int iA, G4int iM)
static G4Neutron * Neutron()
Definition G4Neutron.cc:101
const G4String & GetParticleName() const
G4IonTable * GetIonTable() const
static G4ParticleTable * GetParticleTable()
static G4Proton * Proton()
Definition G4Proton.cc:90
static G4Triton * Triton()
Definition G4Triton.cc:90
G4ParticleDefinition * proj
G4GIDI_target * target
G4GIDI * lend
G4String evaluation