ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4LENDManager.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4LENDManager.cc
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 
54 
55 
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( std::getenv("G4LENDDATA") == NULL ) {
70  throw G4HadronicException(__FILE__, __LINE__, " Please setenv G4LENDDATA to point to the LEND files." );
71  } else {
72  xmcf = std::getenv("G4LENDDATA");
73  //xmcf += "/xmcf.n_1.map";
74  xmcf += "/neutrons.map";
75  xmcf_gamma = std::getenv("G4LENDDATA");
76  xmcf_gamma += "/gammas.map";
77  xmcf_p = std::getenv("G4LENDDATA");
78  xmcf_p += "/protons.map";
79  xmcf_d = std::getenv("G4LENDDATA");
80  xmcf_d += "/deuterons.map";
81  xmcf_t = std::getenv("G4LENDDATA");
82  xmcf_t += "/tritons.map";
83  xmcf_he3 = std::getenv("G4LENDDATA");
84  xmcf_he3 += "/He3s.map";
85  xmcf_a = std::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();
145 
146  //Prepare table of excitation energy of excited isomers
147  G4int pdgCode;
148  // iZ iA iM ->Co58m1
149  pdgCode= 10000 * 27 + 10 * 58 + 1;
150  pdgCode = GetNucleusEncoding( 27 , 58 , 1 );
151  mExcitationEnergy.insert(std::pair<G4int,G4double>( pdgCode, 24890 *CLHEP::eV));
152  pdgCode= 10000 * 47 + 10 * 110 + 1;
153  pdgCode = GetNucleusEncoding( 47 , 110 , 1 );
154  mExcitationEnergy.insert(std::pair<G4int,G4double>( pdgCode, 117590 *CLHEP::eV));
155  pdgCode= 10000 * 48 + 10 * 115 + 1;
156  pdgCode = GetNucleusEncoding( 48 , 115 , 1 );
157  mExcitationEnergy.insert(std::pair<G4int,G4double>( pdgCode, 181000 *CLHEP::eV));
158  pdgCode= 10000 * 52 + 10 * 127 + 1;
159  pdgCode = GetNucleusEncoding( 52 , 127 , 1 );
160  mExcitationEnergy.insert(std::pair<G4int,G4double>( pdgCode, 88260 *CLHEP::eV));
161  pdgCode= 10000 * 52 + 10 * 129 + 1;
162  pdgCode = GetNucleusEncoding( 52 , 129 , 1 );
163  mExcitationEnergy.insert(std::pair<G4int,G4double>( pdgCode, 105280 *CLHEP::eV));
164  pdgCode= 10000 * 61 + 10 * 148 + 1;
165  pdgCode = GetNucleusEncoding( 61 , 148 , 1 );
166  mExcitationEnergy.insert(std::pair<G4int,G4double>( pdgCode, 137900 *CLHEP::eV));
167  pdgCode= 10000 * 67 + 10 * 166 + 1;
168  pdgCode = GetNucleusEncoding( 67 , 166 , 1 );
169  mExcitationEnergy.insert(std::pair<G4int,G4double>( pdgCode, 5985 *CLHEP::eV));
170  pdgCode= 10000 * 95 + 10 * 242 + 1;
171  pdgCode = GetNucleusEncoding( 95 , 242 , 1 );
172  mExcitationEnergy.insert(std::pair<G4int,G4double>( pdgCode, 48600 *CLHEP::eV));
173  pdgCode= 10000 * 95 + 10 * 244 + 1;
174  pdgCode = GetNucleusEncoding( 95 , 244 , 1 );
175  mExcitationEnergy.insert(std::pair<G4int,G4double>( pdgCode, 87999.9*CLHEP::eV));
176  pdgCode= 10000 * 99 + 10 * 254 + 1;
177  pdgCode = GetNucleusEncoding( 99 , 254 , 1 );
178  mExcitationEnergy.insert(std::pair<G4int,G4double>( pdgCode, 84200 *CLHEP::eV));
179 
180 }
181 
182 
183 
185 {
186 
187 // deleting target
188  for ( std::vector < lend_target >::iterator
189  it = v_lend_target.begin() ; it != v_lend_target.end() ; it++ )
190  {
191  (*it).lend->freeTarget( it->target );
192  }
193 
194 // deleting lend
195  for ( std::map < G4ParticleDefinition* , G4GIDI* >::iterator
196  it = proj_lend_map.begin() ; it != proj_lend_map.end() ; it++ )
197  {
198  delete it->second;
199  }
200 
201  //delete ionTable;
202  delete nistElementBuilder;
203 
204 }
205 
206 
207 
209 {
210 
211  G4GIDI_target* anLENDTarget = NULL;
212 
213  if ( iM > 9 ) {
214  throw G4HadronicException(__FILE__, __LINE__, "Requested isomer level of target is too high." );
215  }
216 
217  G4int iTarg = GetNucleusEncoding( iZ , iA , iM );
218 
219  // Searching in current map
220  for ( std::vector < lend_target >::iterator
221  it = v_lend_target.begin() ; it != v_lend_target.end() ; it++ )
222  {
223  if ( it->proj == proj && it->target_code == iTarg && it->evaluation == evaluation )
224  {
225  //find!
226  return it->target;
227  }
228  }
229 
230 
231  if ( proj_lend_map.find ( proj ) == proj_lend_map.end() ) {
232  G4cout << proj->GetParticleName() << " is not supported by this LEND library." << G4endl;
233  return anLENDTarget; // return NULL
234  }
235 
236  G4GIDI* xlend = proj_lend_map.find ( proj ) -> second;
237 
238  if ( xlend->isThisDataAvailable( evaluation, iZ, iA , iM ) )
239  {
240 
241  if ( verboseLevel > 1 ) {
242  G4cout << evaluation << " for " << ionTable->GetIonName( iZ , iA , 0 )
243  << " with Isomer level of " << iM << " is exist in this LEND." << G4endl;
244  }
245 
246  anLENDTarget = xlend->readTarget( evaluation , iZ , iA , iM );
247 
248  lend_target new_target;
249  new_target.lend = xlend;
250  new_target.target = anLENDTarget;
251  new_target.proj = proj;
252  new_target.evaluation = evaluation;
253  new_target.target_code = iTarg;
254 
255  v_lend_target.push_back( new_target );
256 
257 // found EXACT
258  return anLENDTarget;
259 
260  }
261  else
262  {
263 // NO EXACT DATA (Evaluatino & Z,A,M)
264 
265  //Searching available evaluation and natural abundance data and give suggestions.
266  //
267  if ( verboseLevel > 1 )
268  G4cout << evaluation << " for " << ionTable->GetIonName( iZ , iA , 0 )
269  << " with Isomer level of " << iM << " is not exist in this LEND." << G4endl;
270 
271  std::vector< std::string >* available = xlend->getNamesOfAvailableLibraries( iZ, iA , iM );
272  if ( available->size() > 0 ) {
273 // EXACT Z,A,M but Evaluation is different
274  if ( verboseLevel > 1 )
275  {
276  G4cout << " However you can use following evaluation(s) for the target. " << G4endl;
277 
278  std::vector< std::string >::iterator its;
279  for ( its = available->begin() ; its != available->end() ; its++ )
280  G4cout << *its << G4endl;
281 
282  G4cout << G4endl;
283  }
284  } else if ( xlend->isThisDataAvailable( evaluation, iZ, 0 , iM ) ) {
285 //
286 // checking natural abundance data for Z
287 //
288 // EXACT natural abundance data for the evaluation
289  if ( verboseLevel > 1 )
290  G4cout << " However you can use natural abundance data for the target. " << G4endl;
291  }
292  else
293  {
294  std::vector< std::string >* available_nat = xlend->getNamesOfAvailableLibraries( iZ, 0 , iM );
295 //
296  if ( available_nat->size() > 0 ) {
297 // EXACT natural abundance data for Z but differnet evaluation
298  if ( verboseLevel > 1 ) {
299  G4cout << " However you can use following evaluation(s) for natural abundace of the target. " << G4endl;
300 
301  std::vector< std::string >::iterator its;
302  for ( its = available_nat->begin() ; its != available_nat->end() ; its++ )
303  G4cout << *its << G4endl;
304  G4cout << G4endl;
305  }
306  }
307  delete available_nat;
308  }
309  delete available;
310 // return NULL if exact data is not available
311  return anLENDTarget; // return NULL
312  }
313 
314  return anLENDTarget;
315 }
316 
317 
319 {
320 
321  std::vector< G4String > vEvaluation;
322  if ( proj_lend_map.find ( proj ) == proj_lend_map.end() )
323  {
324  G4cout << proj->GetParticleName() << " is not supported by this LEND." << G4endl;
325  return vEvaluation; // return empty
326  }
327 
328  G4GIDI* xlend = proj_lend_map.find ( proj ) -> second;
329  std::vector< std::string >* available = xlend->getNamesOfAvailableLibraries( iZ, iA , iM );
330 
331  if ( available->size() > 0 ) {
332  std::vector< std::string >::iterator its;
333  for ( its = available->begin() ; its != available->end() ; its++ )
334  vEvaluation.push_back ( *its );
335  }
336  delete available;
337 
338  return vEvaluation;
339 }
340 
341 
342 
344 {
345  G4int value = ionTable->GetNucleusEncoding( iZ , iA ); // Ground State
346  // G4double E=0.0, G4int J=0);
347  value += iM;
348  return value;
349 }
350 
351 
352 
354 {
355  G4cout << " <<BEGIN-copyright>> " << G4endl;
356  G4cout << " Copyright (c) 2010, Lawrence Livermore National Security, LLC. " << G4endl;
357  G4cout << " Produced at the Lawrence Livermore National Laboratory " << G4endl;
358  G4cout << " Written by Bret R. Beck, beck6@llnl.gov. " << G4endl;
359  G4cout << " CODE-461393 " << G4endl;
360  G4cout << " All rights reserved. " << G4endl;
361  G4cout << " " << G4endl;
362  G4cout << " This file is part of GIDI. For details, see nuclear.llnl.gov. " << G4endl;
363  G4cout << " Please also read the \"Additional BSD Notice\" at nuclear.llnl.gov. " << G4endl;
364  G4cout << " " << G4endl;
365  G4cout << " Redistribution and use in source and binary forms, with or without modification, " << G4endl;
366  G4cout << " are permitted provided that the following conditions are met: " << G4endl;
367  G4cout << " " << G4endl;
368  G4cout << " 1) Redistributions of source code must retain the above copyright notice, " << G4endl;
369  G4cout << " this list of conditions and the disclaimer below. " << G4endl;
370  G4cout << " 2) Redistributions in binary form must reproduce the above copyright notice, " << G4endl;
371  G4cout << " this list of conditions and the disclaimer (as noted below) in the " << G4endl;
372  G4cout << " documentation and/or other materials provided with the distribution. " << G4endl;
373  G4cout << " 3) Neither the name of the LLNS/LLNL nor the names of its contributors may be " << G4endl;
374  G4cout << " used to endorse or promote products derived from this software without " << G4endl;
375  G4cout << " specific prior written permission. " << G4endl;
376  G4cout << " " << G4endl;
377  G4cout << " THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND ANY " << G4endl;
378  G4cout << " EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES " << G4endl;
379  G4cout << " OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT " << G4endl;
380  G4cout << " SHALL LAWRENCE LIVERMORE NATIONAL SECURITY, LLC, THE U.S. DEPARTMENT OF ENERGY OR " << G4endl;
381  G4cout << " CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR " << G4endl;
382  G4cout << " CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS " << G4endl;
383  G4cout << " OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED " << G4endl;
384  G4cout << " AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT " << G4endl;
385  G4cout << " (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, " << G4endl;
386  G4cout << " EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. " << G4endl;
387  G4cout << " <<END-copyright>> " << G4endl;
388 }
389 
390 
392 {
393  G4bool result=false;
394  if ( newValue >= verboseLevel)
395  {
396  verboseLevel = newValue;
397  result=true;
398  }
399  else
400  {
401  G4cout << "Since other LEND model or cross section have set the higher verbose level (" << verboseLevel << ") in LENDManager, you cannot change the value now." << G4endl;
402  }
403 
404  return result;
405 }
406 
408 {
409  G4double EE = 0.0;
410  G4int nucCode = GetNucleusEncoding( iZ , iA , iM );
411  auto it = mExcitationEnergy.find( nucCode );
412  if ( it != mExcitationEnergy.end() ) {
413  EE = it->second;
414  } else {
415  if ( iM == 0 ) {
416  G4cout << "G4LENDManager::GetExcitationEnergyOfExcitedIsomer is called for ground state (iM=0) nucleus" << G4endl;
417  } else {
418  G4cout << "Can not find excitation energy for Z = " << iZ << ", A = " << iA << ", M = " << iM << " and the energy set to 0." << G4endl;
419  }
420  }
421  return EE;
422 }