00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
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
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
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
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
00108
00109 for ( std::vector < lend_target >::iterator
00110 it = v_lend_target.begin() ; it != v_lend_target.end() ; it++ )
00111 {
00112
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;
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
00145 return anLENDTarget;
00146
00147 }
00148 else
00149 {
00150
00151
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
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
00172
00173 else if ( xlend->isThisDataAvailable( evaluation, iZ, 0 , iM ) )
00174 {
00175
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
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
00199 return anLENDTarget;
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;
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 }