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