G4LENDManager.cc

Go to the documentation of this file.
00001 //
00002 // ********************************************************************
00003 // * License and Disclaimer                                           *
00004 // *                                                                  *
00005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
00006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
00007 // * conditions of the Geant4 Software License,  included in the file *
00008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
00009 // * include a list of copyright holders.                             *
00010 // *                                                                  *
00011 // * Neither the authors of this software system, nor their employing *
00012 // * institutes,nor the agencies providing financial support for this *
00013 // * work  make  any representation or  warranty, express or implied, *
00014 // * regarding  this  software system or assume any liability for its *
00015 // * use.  Please see the license in the file  LICENSE  and URL above *
00016 // * for the full disclaimer and the limitation of liability.         *
00017 // *                                                                  *
00018 // * This  code  implementation is the result of  the  scientific and *
00019 // * technical work of the GEANT4 collaboration.                      *
00020 // * By using,  copying,  modifying or  distributing the software (or *
00021 // * any work based  on the software)  you  agree  to acknowledge its *
00022 // * use  in  resulting  scientific  publications,  and indicate your *
00023 // * acceptance of all terms of the Geant4 Software license.          *
00024 // ********************************************************************
00025 //
00026 // Class Description
00027 // Manager of LEND (Low Energy Nuclear Data) target (nucleus) 
00028 // LEND is Geant4 interface for GIDI (General Interaction Data Interface) 
00029 // which gives a discription of nuclear and atomic reactions, such as
00030 //    Binary collision cross sections
00031 //    Particle number multiplicity distributions of reaction products
00032 //    Energy and angular distributions of reaction products
00033 //    Derived calculational constants
00034 // GIDI is developped at Lawrence Livermore National Laboratory
00035 // Class Description - End
00036 
00037 // 071025 First implementation done by T. Koi (SLAC/SCCS)
00038 // 101118 Name modifications for release T. Koi (SLAC/PPA)
00039 
00040 #include "G4LENDManager.hh"
00041 #include "G4HadronicException.hh"
00042 
00043 #include "G4Neutron.hh"
00044 
00045 G4LENDManager* G4LENDManager::lend_manager = NULL;
00046 
00047 G4LENDManager::G4LENDManager()
00048 :verboseLevel( 0 )
00049 {
00050 
00051    printBanner();
00052 
00053    if(!getenv("G4LENDDATA")) 
00054       throw G4HadronicException(__FILE__, __LINE__, " Please setenv G4LENDDATA to point to the LEND files." );
00055 
00056    G4String xmcf = getenv("G4LENDDATA");
00057    xmcf = xmcf+"/xmcf.n_1.map";
00058 
00059 // for neutron
00060 
00061    G4GIDI* axLEND = new G4GIDI( 1 , xmcf );
00062 
00063    if ( proj_lend_map.find ( G4Neutron::Neutron() ) == proj_lend_map.end() )
00064    {
00065       proj_lend_map.insert ( std::pair < G4ParticleDefinition* , G4GIDI* > ( G4Neutron::Neutron() , axLEND ) ); 
00066    }
00067       
00068    v_lend_target.clear();
00069 
00070    ionTable = new G4IonTable();
00071    nistElementBuilder = new G4NistElementBuilder( 0 );
00072 
00073 }
00074    
00075 
00076 
00077 G4LENDManager::~G4LENDManager()
00078 {
00079    
00080 // deleting target
00081    for ( std::vector < lend_target >::iterator 
00082          it = v_lend_target.begin() ; it != v_lend_target.end() ; it++ )
00083    {
00084         (*it).lend->freeTarget( it->target ); 
00085    }
00086 
00087 // deleting lend
00088    for ( std::map < G4ParticleDefinition* , G4GIDI* >::iterator 
00089          it = proj_lend_map.begin() ; it != proj_lend_map.end() ; it++ )
00090    {
00091       delete it->second;
00092    }
00093 
00094    delete ionTable;
00095    delete nistElementBuilder;
00096 
00097 }
00098 
00099 
00100 
00101 G4GIDI_target* G4LENDManager::GetLENDTarget( G4ParticleDefinition* proj , G4String evaluation , G4int iZ , G4int iA , G4int iM )
00102 {
00103 
00104    G4GIDI_target* anLENDTarget = NULL;
00105 
00106    G4int iTarg = ionTable->GetNucleusEncoding( iZ , iA );
00107                                                      // G4double E=0.0, G4int J=0);
00108 
00109    for ( std::vector < lend_target >::iterator 
00110          it = v_lend_target.begin() ; it != v_lend_target.end() ; it++ )
00111    {
00112 //    find the target
00113       if ( it->proj == proj && it->target_code == iTarg && it->evaluation == evaluation ) 
00114       {
00115          return it->target;
00116       }
00117    }
00118 
00119    if ( proj_lend_map.find ( proj ) == proj_lend_map.end() ) 
00120    {
00121       G4cout << proj->GetParticleName() << " is not supported by this LEND." << G4endl;
00122       return anLENDTarget; // return NULL 
00123    }
00124 
00125    G4GIDI* xlend = proj_lend_map.find ( proj ) -> second; 
00126 
00127    if ( xlend->isThisDataAvailable( evaluation, iZ, iA , iM ) )
00128    {
00129 
00130       if ( verboseLevel > 1 ) 
00131          G4cout << evaluation << " for " << ionTable->GetIonName( iZ , iA , 0 ) << " is exist in this LEND." << G4endl;
00132 
00133       anLENDTarget = xlend->readTarget( evaluation , iZ , iA , iM );
00134 
00135       lend_target new_target; 
00136       new_target.lend = xlend; 
00137       new_target.target = anLENDTarget; 
00138       new_target.proj = proj;
00139       new_target.evaluation = evaluation;
00140       new_target.target_code = iTarg;
00141       
00142       v_lend_target.push_back( new_target );
00143 
00144 //    found EXACT
00145       return anLENDTarget;
00146 
00147    }
00148    else 
00149    {
00150 //    NO EXACT DATA (Evaluatino & Z,A,M)
00151                                                                         // This is for ground state
00152       if ( verboseLevel > 1 ) 
00153          G4cout << evaluation << " for " << ionTable->GetIonName( iZ , iA , 0 ) << " is not exist in this LEND." << G4endl;
00154 
00155       std::vector< std::string >* available =  xlend->getNamesOfAvailableLibraries( iZ, iA , iM );
00156       if ( available->size() > 0 )
00157       {
00158 //       EXACT Z,A,M but Evaluation is different 
00159          if ( verboseLevel > 1 ) 
00160          {
00161             G4cout << " However you can use following evaluation(s) for the target. " << G4endl;
00162 
00163             std::vector< std::string >::iterator its;
00164             for ( its = available->begin() ; its != available->end() ; its++ ) 
00165                G4cout << *its << G4endl;
00166 
00167             G4cout << G4endl;
00168          }
00169       }
00170 //      
00171 //    checking natural abundance data for Z
00172 //
00173       else if ( xlend->isThisDataAvailable( evaluation, iZ, 0 , iM ) )
00174       {
00175 //       EXACT natural abundance data for the evaluation 
00176          if ( verboseLevel > 1 ) 
00177             G4cout << " However you can use natural abundance data for the target. " << G4endl;
00178       }
00179       else
00180       {
00181          std::vector< std::string >* available_nat =  xlend->getNamesOfAvailableLibraries( iZ, 0 , iM );
00182 //
00183          if ( available_nat->size() > 0 )
00184          {
00185 //          EXACT natural abundance data for Z but differnet evaluation
00186             if ( verboseLevel > 1 ) 
00187             {
00188                G4cout << " However you can use following evaluation(s) for natural abundace of the target. " << G4endl;
00189 
00190                std::vector< std::string >::iterator its;
00191                for ( its = available_nat->begin() ; its != available_nat->end() ; its++ ) 
00192                   G4cout << *its << G4endl;
00193                G4cout << G4endl;
00194             }
00195          }
00196       }
00197 
00198 //    return NULL if exact data is not available               
00199       return anLENDTarget; // return NULL   
00200    }
00201    
00202    return anLENDTarget; 
00203 }
00204 
00205 
00206 
00207 std::vector< G4String > G4LENDManager::IsLENDTargetAvailable ( G4ParticleDefinition* proj , G4int iZ , G4int iA , G4int iM )
00208 {
00209 
00210    std::vector< G4String > answer;
00211    if ( proj_lend_map.find ( proj ) == proj_lend_map.end() ) 
00212    {
00213       G4cout << proj->GetParticleName() << " is not supported by this LEND." << G4endl;
00214       return answer; // return NULL 
00215    }
00216 
00217    G4GIDI* xlend = proj_lend_map.find ( proj ) -> second; 
00218    std::vector< std::string >* available =  xlend->getNamesOfAvailableLibraries( iZ, iA , iM );
00219 
00220    if ( available->size() > 0 )
00221    {
00222       std::vector< std::string >::iterator its;
00223       for ( its = available->begin() ; its != available->end() ; its++ ) 
00224          answer.push_back ( *its );
00225    }
00226 
00227    return answer;
00228 }
00229 
00230 
00231 
00232 void G4LENDManager::printBanner()
00233 {
00234    G4cout << " <<BEGIN-copyright>> " << G4endl;
00235    G4cout << " Copyright (c) 2010, Lawrence Livermore National Security, LLC.  " << G4endl;
00236    G4cout << " Produced at the Lawrence Livermore National Laboratory " << G4endl;
00237    G4cout << " Written by Bret R. Beck, beck6@llnl.gov.  " << G4endl;
00238    G4cout << " CODE-461393 " << G4endl;
00239    G4cout << " All rights reserved.  " << G4endl;
00240    G4cout << "  " << G4endl;
00241    G4cout << " This file is part of GIDI. For details, see nuclear.llnl.gov.  " << G4endl;
00242    G4cout << " Please also read the \"Additional BSD Notice\" at nuclear.llnl.gov.  " << G4endl;
00243    G4cout << " " << G4endl;
00244    G4cout << " Redistribution and use in source and binary forms, with or without modification, " << G4endl;
00245    G4cout << " are permitted provided that the following conditions are met: " << G4endl;
00246    G4cout << " " << G4endl;
00247    G4cout << "      1) Redistributions of source code must retain the above copyright notice, " << G4endl;
00248    G4cout << "         this list of conditions and the disclaimer below.  " << G4endl;
00249    G4cout << "      2) Redistributions in binary form must reproduce the above copyright notice, " << G4endl;
00250    G4cout << "         this list of conditions and the disclaimer (as noted below) in the " << G4endl;
00251    G4cout << "          documentation and/or other materials provided with the distribution.  " << G4endl;
00252    G4cout << "      3) Neither the name of the LLNS/LLNL nor the names of its contributors may be " << G4endl;
00253    G4cout << "         used to endorse or promote products derived from this software without " << G4endl;
00254    G4cout << "         specific prior written permission.  " << G4endl;
00255    G4cout << " " << G4endl;
00256    G4cout << " THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND ANY " << G4endl;
00257    G4cout << " EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES " << G4endl;
00258    G4cout << " OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT " << G4endl;
00259    G4cout << " SHALL LAWRENCE LIVERMORE NATIONAL SECURITY, LLC, THE U.S. DEPARTMENT OF ENERGY OR " << G4endl;
00260    G4cout << " CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR " << G4endl;
00261    G4cout << " CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS " << G4endl;
00262    G4cout << " OR SERVICES;  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED " << G4endl; 
00263    G4cout << " AND ON  ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT " << G4endl; 
00264    G4cout << " (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, " << G4endl;
00265    G4cout << " EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  " << G4endl;
00266    G4cout << " <<END-copyright>> " << G4endl;
00267 }
00268 
00269 
00270 G4bool G4LENDManager::RequestChangeOfVerboseLevel( G4int newValue )
00271 {
00272    G4bool result=false;
00273    if ( newValue >= verboseLevel) 
00274    {
00275       verboseLevel = newValue;
00276       result=true;
00277    }
00278    else
00279    {
00280       G4cout << "Since other LEND model or cross section have set the higher verbose level (" << verboseLevel << ") in LENDManager, you cannot change the value now." << G4endl; 
00281    }
00282 
00283    return result;
00284 }

Generated on Mon May 27 17:48:45 2013 for Geant4 by  doxygen 1.4.7