Geant4  10.03.p01
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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"
41 #include "G4HadronicException.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 
53 G4LENDManager* G4LENDManager::lend_manager = NULL;
54 
55 
56 G4LENDManager::G4LENDManager()
57 :verboseLevel( 0 )
58 {
59 
60  //printBanner();
61 
62  G4String xmcf;
63  G4String xmcf_gamma;
64  G4String xmcf_p;
65  G4String xmcf_d;
66  G4String xmcf_t;
67  G4String xmcf_he3;
68  G4String xmcf_a;
69  if( getenv("G4LENDDATA") == NULL ) {
70  throw G4HadronicException(__FILE__, __LINE__, " Please setenv G4LENDDATA to point to the LEND files." );
71  } else {
72  xmcf = getenv("G4LENDDATA");
73  //xmcf += "/xmcf.n_1.map";
74  xmcf += "/neutrons.map";
75  xmcf_gamma = getenv("G4LENDDATA");
76  xmcf_gamma += "/gammas.map";
77  xmcf_p = getenv("G4LENDDATA");
78  xmcf_p += "/protons.map";
79  xmcf_d = getenv("G4LENDDATA");
80  xmcf_d += "/deuterons.map";
81  xmcf_t = getenv("G4LENDDATA");
82  xmcf_t += "/tritons.map";
83  xmcf_he3 = getenv("G4LENDDATA");
84  xmcf_he3 += "/He3s.map";
85  xmcf_a = getenv("G4LENDDATA");
86  xmcf_a += "/alphas.map";
87  }
88 
89 //Example of xmcf.n_1.map
90 //<map>
91 //<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"/>
92 //</map>
93 //
94 // for neutron "1" for neutron; see G4GIDI::init
95  proj_lend_map.insert ( std::pair < G4ParticleDefinition* , G4GIDI* > ( G4Neutron::Neutron() , new G4GIDI( 1 , xmcf ) ) );
96 // for gamma "0" for gamma; see G4GIDI::init
97  proj_lend_map.insert ( std::pair < G4ParticleDefinition* , G4GIDI* > ( G4Gamma::Gamma() , new G4GIDI( 0 , xmcf_gamma ) ) );
98 //
99  std::ifstream aFile;
100  aFile.open( xmcf_p.c_str() );
101  if ( aFile.good() ) {
102  aFile.close();
103  proj_lend_map.insert ( std::pair < G4ParticleDefinition* , G4GIDI* > ( G4Proton::Proton() , new G4GIDI( 2 , xmcf_p ) ) );
104  } else {
105  aFile.close();
106  }
107  aFile.open( xmcf_d.c_str() );
108  if ( aFile.good() ) {
109  aFile.close();
110  proj_lend_map.insert ( std::pair < G4ParticleDefinition* , G4GIDI* > ( G4Deuteron::Deuteron() , new G4GIDI( 3 , xmcf_d ) ) );
111  } else {
112  aFile.close();
113  }
114  aFile.open( xmcf_t.c_str() );
115  if ( aFile.good() ) {
116  aFile.close();
117  proj_lend_map.insert ( std::pair < G4ParticleDefinition* , G4GIDI* > ( G4Triton::Triton() , new G4GIDI( 4 , xmcf_t ) ) );
118  } else {
119  aFile.close();
120  }
121  aFile.open( xmcf_he3.c_str() );
122  if ( aFile.good() ) {
123  aFile.close();
124  proj_lend_map.insert ( std::pair < G4ParticleDefinition* , G4GIDI* > ( G4He3::He3() , new G4GIDI( 5 , xmcf_he3 ) ) );
125  } else {
126  aFile.close();
127  }
128  aFile.open( xmcf_a.c_str() );
129  if ( aFile.good() ) {
130  aFile.close();
131  proj_lend_map.insert ( std::pair < G4ParticleDefinition* , G4GIDI* > ( G4Alpha::Alpha() , new G4GIDI( 6 , xmcf_a ) ) );
132  } else {
133  aFile.close();
134  }
135 
136 
137 
138 // proj_lend_map.insert ( std::pair < G4ParticleDefinition* , G4GIDI* > ( xxx , new G4GIDI( xxx , xmcf ) ) );
139 
140  v_lend_target.clear();
141 
142  //ionTable = new G4IonTable();
144  nistElementBuilder = new G4NistElementBuilder( 0 );
145 
146 }
147 
148 
149 
150 G4LENDManager::~G4LENDManager()
151 {
152 
153 // deleting target
154  for ( std::vector < lend_target >::iterator
155  it = v_lend_target.begin() ; it != v_lend_target.end() ; it++ )
156  {
157  (*it).lend->freeTarget( it->target );
158  }
159 
160 // deleting lend
161  for ( std::map < G4ParticleDefinition* , G4GIDI* >::iterator
162  it = proj_lend_map.begin() ; it != proj_lend_map.end() ; it++ )
163  {
164  delete it->second;
165  }
166 
167  //delete ionTable;
168  delete nistElementBuilder;
169 
170 }
171 
172 
173 
175 {
176 
177  G4GIDI_target* anLENDTarget = NULL;
178 
179  if ( iM > 9 ) {
180  throw G4HadronicException(__FILE__, __LINE__, "Requested isomer level of target is too high." );
181  }
182 
183  G4int iTarg = GetNucleusEncoding( iZ , iA , iM );
184 
185  // Searching in current map
186  for ( std::vector < lend_target >::iterator
187  it = v_lend_target.begin() ; it != v_lend_target.end() ; it++ )
188  {
189  if ( it->proj == proj && it->target_code == iTarg && it->evaluation == evaluation )
190  {
191  //find!
192  return it->target;
193  }
194  }
195 
196 
197  if ( proj_lend_map.find ( proj ) == proj_lend_map.end() ) {
198  G4cout << proj->GetParticleName() << " is not supported by this LEND library." << G4endl;
199  return anLENDTarget; // return NULL
200  }
201 
202  G4GIDI* xlend = proj_lend_map.find ( proj ) -> second;
203 
204  if ( xlend->isThisDataAvailable( evaluation, iZ, iA , iM ) )
205  {
206 
207  if ( verboseLevel > 1 ) {
208  G4cout << evaluation << " for " << ionTable->GetIonName( iZ , iA , 0 )
209  << " with Isomer level of " << iM << " is exist in this LEND." << G4endl;
210  }
211 
212  anLENDTarget = xlend->readTarget( evaluation , iZ , iA , iM );
213 
214  lend_target new_target;
215  new_target.lend = xlend;
216  new_target.target = anLENDTarget;
217  new_target.proj = proj;
218  new_target.evaluation = evaluation;
219  new_target.target_code = iTarg;
220 
221  v_lend_target.push_back( new_target );
222 
223 // found EXACT
224  return anLENDTarget;
225 
226  }
227  else
228  {
229 // NO EXACT DATA (Evaluatino & Z,A,M)
230 
231  //Searching available evaluation and natural abundance data and give suggestions.
232  //
233  if ( verboseLevel > 1 )
234  G4cout << evaluation << " for " << ionTable->GetIonName( iZ , iA , 0 )
235  << " with Isomer level of " << iM << " is not exist in this LEND." << G4endl;
236 
237  std::vector< std::string >* available = xlend->getNamesOfAvailableLibraries( iZ, iA , iM );
238  if ( available->size() > 0 ) {
239 // EXACT Z,A,M but Evaluation is different
240  if ( verboseLevel > 1 )
241  {
242  G4cout << " However you can use following evaluation(s) for the target. " << G4endl;
243 
244  std::vector< std::string >::iterator its;
245  for ( its = available->begin() ; its != available->end() ; its++ )
246  G4cout << *its << G4endl;
247 
248  G4cout << G4endl;
249  }
250  } else if ( xlend->isThisDataAvailable( evaluation, iZ, 0 , iM ) ) {
251 //
252 // checking natural abundance data for Z
253 //
254 // EXACT natural abundance data for the evaluation
255  if ( verboseLevel > 1 )
256  G4cout << " However you can use natural abundance data for the target. " << G4endl;
257  }
258  else
259  {
260  std::vector< std::string >* available_nat = xlend->getNamesOfAvailableLibraries( iZ, 0 , iM );
261 //
262  if ( available_nat->size() > 0 ) {
263 // EXACT natural abundance data for Z but differnet evaluation
264  if ( verboseLevel > 1 ) {
265  G4cout << " However you can use following evaluation(s) for natural abundace of the target. " << G4endl;
266 
267  std::vector< std::string >::iterator its;
268  for ( its = available_nat->begin() ; its != available_nat->end() ; its++ )
269  G4cout << *its << G4endl;
270  G4cout << G4endl;
271  }
272  }
273  delete available_nat;
274  }
275  delete available;
276 // return NULL if exact data is not available
277  return anLENDTarget; // return NULL
278  }
279 
280  return anLENDTarget;
281 }
282 
283 
284 std::vector< G4String > G4LENDManager::IsLENDTargetAvailable ( G4ParticleDefinition* proj , G4int iZ , G4int iA , G4int iM )
285 {
286 
287  std::vector< G4String > vEvaluation;
288  if ( proj_lend_map.find ( proj ) == proj_lend_map.end() )
289  {
290  G4cout << proj->GetParticleName() << " is not supported by this LEND." << G4endl;
291  return vEvaluation; // return empty
292  }
293 
294  G4GIDI* xlend = proj_lend_map.find ( proj ) -> second;
295  std::vector< std::string >* available = xlend->getNamesOfAvailableLibraries( iZ, iA , iM );
296 
297  if ( available->size() > 0 ) {
298  std::vector< std::string >::iterator its;
299  for ( its = available->begin() ; its != available->end() ; its++ )
300  vEvaluation.push_back ( *its );
301  }
302  delete available;
303 
304  return vEvaluation;
305 }
306 
307 
308 
310 {
311  G4int value = ionTable->GetNucleusEncoding( iZ , iA ); // Ground State
312  // G4double E=0.0, G4int J=0);
313  value += iM;
314  return value;
315 }
316 
317 
318 
319 void G4LENDManager::printBanner()
320 {
321  G4cout << " <<BEGIN-copyright>> " << G4endl;
322  G4cout << " Copyright (c) 2010, Lawrence Livermore National Security, LLC. " << G4endl;
323  G4cout << " Produced at the Lawrence Livermore National Laboratory " << G4endl;
324  G4cout << " Written by Bret R. Beck, beck6@llnl.gov. " << G4endl;
325  G4cout << " CODE-461393 " << G4endl;
326  G4cout << " All rights reserved. " << G4endl;
327  G4cout << " " << G4endl;
328  G4cout << " This file is part of GIDI. For details, see nuclear.llnl.gov. " << G4endl;
329  G4cout << " Please also read the \"Additional BSD Notice\" at nuclear.llnl.gov. " << G4endl;
330  G4cout << " " << G4endl;
331  G4cout << " Redistribution and use in source and binary forms, with or without modification, " << G4endl;
332  G4cout << " are permitted provided that the following conditions are met: " << G4endl;
333  G4cout << " " << G4endl;
334  G4cout << " 1) Redistributions of source code must retain the above copyright notice, " << G4endl;
335  G4cout << " this list of conditions and the disclaimer below. " << G4endl;
336  G4cout << " 2) Redistributions in binary form must reproduce the above copyright notice, " << G4endl;
337  G4cout << " this list of conditions and the disclaimer (as noted below) in the " << G4endl;
338  G4cout << " documentation and/or other materials provided with the distribution. " << G4endl;
339  G4cout << " 3) Neither the name of the LLNS/LLNL nor the names of its contributors may be " << G4endl;
340  G4cout << " used to endorse or promote products derived from this software without " << G4endl;
341  G4cout << " specific prior written permission. " << G4endl;
342  G4cout << " " << G4endl;
343  G4cout << " THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND ANY " << G4endl;
344  G4cout << " EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES " << G4endl;
345  G4cout << " OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT " << G4endl;
346  G4cout << " SHALL LAWRENCE LIVERMORE NATIONAL SECURITY, LLC, THE U.S. DEPARTMENT OF ENERGY OR " << G4endl;
347  G4cout << " CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR " << G4endl;
348  G4cout << " CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS " << G4endl;
349  G4cout << " OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED " << G4endl;
350  G4cout << " AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT " << G4endl;
351  G4cout << " (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, " << G4endl;
352  G4cout << " EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. " << G4endl;
353  G4cout << " <<END-copyright>> " << G4endl;
354 }
355 
356 
358 {
359  G4bool result=false;
360  if ( newValue >= verboseLevel)
361  {
362  verboseLevel = newValue;
363  result=true;
364  }
365  else
366  {
367  G4cout << "Since other LEND model or cross section have set the higher verbose level (" << verboseLevel << ") in LENDManager, you cannot change the value now." << G4endl;
368  }
369 
370  return result;
371 }
G4double G4ParticleHPJENDLHEData::G4double result
static G4int GetNucleusEncoding(G4int Z, G4int A, G4double E=0.0, G4int lvl=0)
Definition: G4IonTable.cc:949
G4String evaluation
static constexpr double second
Definition: G4SIunits.hh:157
int G4int
Definition: G4Types.hh:78
const G4String & GetParticleName() const
const G4String & GetIonName(G4int Z, G4int A, G4int lvl=0) const
Definition: G4IonTable.cc:1094
G4int GetNucleusEncoding(G4int iZ, G4int iA, G4int iM)
G4GIDI_target * GetLENDTarget(G4ParticleDefinition *, G4String, G4int iZ, G4int iA, G4int iM=0)
G4ParticleDefinition * proj
G4IonTable * GetIonTable() const
G4GLOB_DLL std::ostream G4cout
const XML_Char int const XML_Char * value
Definition: expat.h:331
std::vector< std::string > * getNamesOfAvailableLibraries(int iZ, int iA, int iM=0)
Definition: G4GIDI.cc:237
bool G4bool
Definition: G4Types.hh:79
static G4Triton * Triton()
Definition: G4Triton.cc:95
static G4Proton * Proton()
Definition: G4Proton.cc:93
bool isThisDataAvailable(std::string &lib_name, int iZ, int iA, int iM=0)
Definition: G4GIDI.cc:169
static G4Neutron * Neutron()
Definition: G4Neutron.cc:104
std::vector< G4String > IsLENDTargetAvailable(G4ParticleDefinition *, G4int iZ, G4int iA, G4int iM=0)
static G4Gamma * Gamma()
Definition: G4Gamma.cc:86
static G4Deuteron * Deuteron()
Definition: G4Deuteron.cc:94
static G4ParticleTable * GetParticleTable()
G4GIDI_target * readTarget(std::string &lib_name, int iZ, int iA, int iM=0, bool bind=true)
Definition: G4GIDI.cc:289
G4int target_code
#define G4endl
Definition: G4ios.hh:61
G4GIDI_target * target
static G4Alpha * Alpha()
Definition: G4Alpha.cc:89
G4GIDI * lend
G4bool RequestChangeOfVerboseLevel(G4int)
static G4He3 * He3()
Definition: G4He3.cc:94
Definition: G4GIDI.hh:43