62 material_cache = NULL;
64 indexOfThermalElement.clear();
89 if ( dic.find( std::pair < const G4Material* , const G4Element* > ( (
G4Material*)NULL , element ) ) != dic.end()
90 || dic.find( std::pair < const G4Material* , const G4Element* > ( material , element ) ) != dic.end() )
return true;
110 if ( dp->
GetKineticEnergy() == ke_cache && element == element_cache && material == material_cache )
return xs_cache;
113 element_cache = element;
122 void G4NeutronHPThermalScatteringData::clearCurrentXSData()
124 std::map< G4int , std::map< G4double , G4NeutronHPVector* >* >::iterator it;
125 std::map< G4double , G4NeutronHPVector* >::iterator itt;
127 for ( it = coherent.begin() ; it != coherent.end() ; it++ )
129 if ( it->second != NULL )
131 for ( itt = it->second->begin() ; itt != it->second->end() ; itt++ )
139 for ( it = incoherent.begin() ; it != incoherent.end() ; it++ )
141 if ( it->second != NULL )
143 for ( itt = it->second->begin() ; itt != it->second->end() ; itt++ )
151 for ( it = inelastic.begin() ; it != inelastic.end() ; it++ )
153 if ( it->second != NULL )
155 for ( itt = it->second->begin() ; itt != it->second->end() ; itt++ )
184 std::vector < G4int >::iterator it;
185 for ( it = indexOfThermalElement.begin() ; it != indexOfThermalElement.end() ; it++ )
187 if ( ie == *it )
return true;
208 throw G4HadronicException(__FILE__, __LINE__,
"Attempt to use NeutronHP data for particles other than neutrons!!!");
212 clearCurrentXSData();
213 std::map < G4String , G4int > co_dic;
218 for (
size_t i = 0 ; i < numberOfMaterials ; i++ )
222 for (
size_t j = 0 ; j < numberOfElements ; j++ )
227 G4int ts_ID_of_this_geometry;
229 if ( co_dic.find ( ts_ndl_name ) != co_dic.end() )
231 ts_ID_of_this_geometry = co_dic.find ( ts_ndl_name ) ->
second;
235 ts_ID_of_this_geometry = co_dic.size();
236 co_dic.insert ( std::pair< G4String , G4int >( ts_ndl_name , ts_ID_of_this_geometry ) );
243 dic.insert( std::pair < std::pair < G4Material* , const G4Element* > ,
G4int > ( std::pair < G4Material* , const G4Element* > ( material , element ) , ts_ID_of_this_geometry ) );
252 for (
size_t i = 0 ; i < numberOfElements ; i++ )
254 const G4Element* element = (*theElementTable)[i];
259 G4int ts_ID_of_this_geometry;
261 if ( co_dic.find ( ts_ndl_name ) != co_dic.end() )
263 ts_ID_of_this_geometry = co_dic.find ( ts_ndl_name ) ->
second;
267 ts_ID_of_this_geometry = co_dic.size();
268 co_dic.insert ( std::pair< G4String , G4int >( ts_ndl_name , ts_ID_of_this_geometry ) );
275 dic.insert( std::pair < std::pair < const G4Material* , const G4Element* > ,
G4int > ( std::pair < const G4Material* , const G4Element* > ( (
G4Material*)NULL , element ) , ts_ID_of_this_geometry ) );
281 G4cout <<
"Neutron HP Thermal Scattering Data: Following material-element pairs and/or elements are registered." <<
G4endl;
282 for ( std::map < std::pair < const G4Material* , const G4Element* > ,
G4int >::iterator it = dic.begin() ; it != dic.end() ; it++ )
284 if ( it->first.first != NULL )
286 G4cout <<
"Material " << it->first.first->GetName() <<
" - Element " << it->first.second->GetName() <<
", internal thermal scattering id " << it->second <<
G4endl;
290 G4cout <<
"Element " << it->first.second->GetName() <<
", internal thermal scattering id " << it->second <<
G4endl;
306 if ( !getenv(
"G4NEUTRONHPDATA" ) )
307 throw G4HadronicException(__FILE__, __LINE__,
"Please setenv G4NEUTRONHPDATA to point to the neutron cross-section files.");
308 G4String baseName = getenv(
"G4NEUTRONHPDATA" );
310 dirName = baseName +
"/ThermalScattering";
315 for ( std::map < G4String , G4int >::iterator it = co_dic.begin() ; it != co_dic.end() ; it++ )
317 ndl_filename = it->
first;
318 G4int ts_ID = it->second;
321 full_name = dirName +
"/Coherent/CrossSection/" + ndl_filename;
322 std::map< G4double , G4NeutronHPVector* >* coh_amapTemp_EnergyCross = readData( full_name );
323 coherent.insert ( std::pair <
G4int , std::map< G4double , G4NeutronHPVector* >* > ( ts_ID , coh_amapTemp_EnergyCross ) );
326 full_name = dirName +
"/Incoherent/CrossSection/" + ndl_filename;
327 std::map< G4double , G4NeutronHPVector* >* incoh_amapTemp_EnergyCross = readData( full_name );
328 incoherent.insert ( std::pair <
G4int , std::map< G4double , G4NeutronHPVector* >* > ( ts_ID , incoh_amapTemp_EnergyCross ) );
331 full_name = dirName +
"/Inelastic/CrossSection/" + ndl_filename;
332 std::map< G4double , G4NeutronHPVector* >* inela_amapTemp_EnergyCross = readData( full_name );
333 inelastic.insert ( std::pair <
G4int , std::map< G4double , G4NeutronHPVector* >* > ( ts_ID , inela_amapTemp_EnergyCross ) );
341 std::map< G4double , G4NeutronHPVector* >* G4NeutronHPThermalScatteringData::readData (
G4String full_name )
344 std::map< G4double , G4NeutronHPVector* >* aData =
new std::map< G4double , G4NeutronHPVector* >;
346 std::ifstream theChannel( full_name.c_str() );
351 while ( theChannel >> dummy )
359 anEnergyCross->
Init ( theChannel , nData ,
eV ,
barn );
360 aData->insert ( std::pair < G4double , G4NeutronHPVector* > ( temp , anEnergyCross ) );
373 throw G4HadronicException(__FILE__, __LINE__,
"Attempt to use NeutronHP data for particles other than neutrons!!!");
423 G4int ts_id =getTS_ID( aM , anE );
425 if ( ts_id == -1 )
return result;
429 G4double Xcoh = GetX ( aP , aT , coherent.find(ts_id)->second );
430 G4double Xincoh = GetX ( aP , aT , incoherent.find(ts_id)->second );
431 G4double Xinela = GetX ( aP , aT , inelastic.find(ts_id)->second );
433 result = Xcoh + Xincoh + Xinela;
444 G4int ts_id = getTS_ID( aM , anE );
446 result = GetX ( aP , aT , inelastic.find( ts_id )->second );
453 G4int ts_id = getTS_ID( aM , anE );
455 result = GetX ( aP , aT , coherent.find( ts_id )->second );
462 G4int ts_id = getTS_ID( aM , anE );
464 result = GetX ( aP , aT , incoherent.find( ts_id )->second );
473 if ( dic.find( std::pair < const G4Material* , const G4Element* > ( (
G4Material*)NULL , element ) ) != dic.end() )
474 return dic.find( std::pair < const G4Material* , const G4Element* > ( (
G4Material*)NULL , element ) )->second;
475 if ( dic.find( std::pair < const G4Material* , const G4Element* > ( material , element ) ) != dic.end() )
476 return dic.find( std::pair < const G4Material* , const G4Element* > ( material , element ) )->second;
487 if ( amapTemp_EnergyCross->size() == 0 )
return result;
492 if ( amapTemp_EnergyCross->size() == 1 ) {
493 if ( std::fabs ( aT - amapTemp_EnergyCross->begin()->first ) / amapTemp_EnergyCross->begin()->first > 0.1 ) {
494 G4cout <<
"G4NeutronHPThermalScatteringData:: The temperature of material ("
495 << aT/
kelvin <<
"K) is different more than 10% from temperature of thermal scattering file expected ("
496 << amapTemp_EnergyCross->begin()->first <<
"K). Result may not be reliable."
499 result = amapTemp_EnergyCross->begin()->second->GetXsec ( eKinetic );
503 std::map< G4double , G4NeutronHPVector* >::iterator it;
504 for ( it = amapTemp_EnergyCross->begin() ; it != amapTemp_EnergyCross->end() ; it++ ) {
505 if ( aT < it->
first )
break;
507 if ( it == amapTemp_EnergyCross->begin() && it != amapTemp_EnergyCross->end() ) it++;
508 if ( it != amapTemp_EnergyCross->begin() && it == amapTemp_EnergyCross->end() ) it--;
511 G4double XH = it->second->GetXsec ( eKinetic );
515 if ( it != amapTemp_EnergyCross->begin() ) it--;
517 G4double XL = it->second->GetXsec ( eKinetic );
525 G4double X = ( XH - XL ) / ( TH - TL ) * ( T - TL ) + XL;
G4double GetIsoCrossSection(const G4DynamicParticle *, G4int, G4int, const G4Isotope *, const G4Element *, const G4Material *)
G4double GetKineticEnergy() const
G4NeutronHPThermalScatteringData()
G4double GetCoherentCrossSection(const G4DynamicParticle *, const G4Element *, const G4Material *)
const G4String & GetName() const
static G4MaterialTable * GetMaterialTable()
std::vector< G4Material * > G4MaterialTable
G4double G4NeutronHPJENDLHEData::G4double result
G4bool IsApplicable(const G4DynamicParticle *, const G4Element *)
void Init(std::istream &aDataFile, G4int total, G4double ux=1., G4double uy=1.)
G4ParticleDefinition * GetDefinition() const
const G4Element * GetElement(G4int iel) const
void AddThermalElement(G4String, G4String)
G4GLOB_DLL std::ostream G4cout
static size_t GetNumberOfElements()
void SetMinKinEnergy(G4double value)
~G4NeutronHPThermalScatteringData()
static G4Neutron * Neutron()
static size_t GetNumberOfMaterials()
G4double GetIncoherentCrossSection(const G4DynamicParticle *, const G4Element *, const G4Material *)
void AddUserThermalScatteringFile(G4String, G4String)
void BuildPhysicsTable(const G4ParticleDefinition &)
G4double GetCrossSection(const G4DynamicParticle *, const G4Element *, const G4Material *)
G4bool IsIsoApplicable(const G4DynamicParticle *, G4int, G4int, const G4Element *, const G4Material *)
void SetMaxKinEnergy(G4double value)
void DumpPhysicsTable(const G4ParticleDefinition &)
G4double GetInelasticCrossSection(const G4DynamicParticle *, const G4Element *, const G4Material *)
G4String GetTS_NDL_Name(G4String nameG4Element)
G4double GetTemperature() const
size_t GetNumberOfElements() const
std::vector< G4Element * > G4ElementTable
const G4String & GetName() const
static G4ElementTable * GetElementTable()
G4bool IsThisThermalElement(G4String)