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.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

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