Import Geant4 10.5.0 source tree
This commit is contained in:
@@ -29,37 +29,36 @@
|
||||
// 121031 First implementation done by T. Koi (SLAC/PPA)
|
||||
// P. Arce, June-2014 Conversion neutron_hp to particle_hp
|
||||
//
|
||||
#include <zlib.h>
|
||||
#include <fstream>
|
||||
|
||||
#include "G4ParticleHPManager.hh"
|
||||
#include "G4ParticleHPThreadLocalManager.hh"
|
||||
#include "G4ParticleHPMessenger.hh"
|
||||
#include "G4HadronicException.hh"
|
||||
|
||||
//G4ThreadLocal G4ParticleHPManager* G4ParticleHPManager::instance = NULL;
|
||||
G4ParticleHPManager* G4ParticleHPManager::instance = G4ParticleHPManager::GetInstance();
|
||||
G4ParticleHPManager* G4ParticleHPManager::instance = 0;
|
||||
|
||||
G4ParticleHPManager::G4ParticleHPManager()
|
||||
:/*RWB(NULL),*/
|
||||
verboseLevel(1)
|
||||
: verboseLevel(1)
|
||||
,USE_ONLY_PHOTONEVAPORATION(false)
|
||||
,SKIP_MISSING_ISOTOPES(false)
|
||||
,NEGLECT_DOPPLER(false)
|
||||
,DO_NOT_ADJUST_FINAL_STATE(false)
|
||||
,PRODUCE_FISSION_FRAGMENTS(false)
|
||||
,USE_NRESP71_MODEL(false)
|
||||
,theElasticCrossSections(NULL)
|
||||
,theCaptureCrossSections(NULL)
|
||||
//,theInelasticCrossSections(NULL)
|
||||
,theFissionCrossSections(NULL)
|
||||
,theElasticFSs(NULL)
|
||||
//,theInelasticFSs(NULL)
|
||||
,theCaptureFSs(NULL)
|
||||
,theFissionFSs(NULL)
|
||||
,theTSCoherentCrossSections(NULL)
|
||||
,theTSIncoherentCrossSections(NULL)
|
||||
,theTSInelasticCrossSections(NULL)
|
||||
,theTSCoherentFinalStates(NULL)
|
||||
,theTSIncoherentFinalStates(NULL)
|
||||
,theTSInelasticFinalStates(NULL)
|
||||
,theElasticCrossSections(0)
|
||||
,theCaptureCrossSections(0)
|
||||
,theFissionCrossSections(0)
|
||||
,theElasticFSs(0)
|
||||
,theCaptureFSs(0)
|
||||
,theFissionFSs(0)
|
||||
,theTSCoherentCrossSections(0)
|
||||
,theTSIncoherentCrossSections(0)
|
||||
,theTSInelasticCrossSections(0)
|
||||
,theTSCoherentFinalStates(0)
|
||||
,theTSIncoherentFinalStates(0)
|
||||
,theTSInelasticFinalStates(0)
|
||||
{
|
||||
messenger = new G4ParticleHPMessenger( this );
|
||||
if ( getenv( "G4NEUTRONHP_DO_NOT_ADJUST_FINAL_STATE" ) || getenv("G4PHP_DO_NOT_ADJUST_FINAL_STATE") ) DO_NOT_ADJUST_FINAL_STATE = true;
|
||||
@@ -69,59 +68,60 @@ G4ParticleHPManager::G4ParticleHPManager()
|
||||
if ( getenv( "G4NEUTRONHP_PRODUCE_FISSION_FRAGMENTS" ) ) PRODUCE_FISSION_FRAGMENTS = true;
|
||||
if ( getenv( "G4PHP_USE_NRESP71_MODEL" ) ) USE_NRESP71_MODEL = true;
|
||||
}
|
||||
|
||||
G4ParticleHPManager::~G4ParticleHPManager()
|
||||
{
|
||||
delete messenger;
|
||||
}
|
||||
|
||||
G4ParticleHPManager* G4ParticleHPManager::GetInstance()
|
||||
{
|
||||
static G4ParticleHPManager manager;
|
||||
if (!instance)
|
||||
{
|
||||
instance = &manager;
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
void G4ParticleHPManager::OpenReactionWhiteBoard()
|
||||
{
|
||||
// if ( RWB != NULL ) {
|
||||
// G4cout << "Warning: G4ParticleHPReactionWhiteBoard is tried doubly opening" << G4endl;
|
||||
// RWB = new G4ParticleHPReactionWhiteBoard();
|
||||
// }
|
||||
//
|
||||
// RWB = new G4ParticleHPReactionWhiteBoard();
|
||||
G4ParticleHPThreadLocalManager::GetInstance()->OpenReactionWhiteBoard();
|
||||
}
|
||||
|
||||
G4ParticleHPReactionWhiteBoard* G4ParticleHPManager::GetReactionWhiteBoard()
|
||||
{
|
||||
// if ( RWB == NULL ) {
|
||||
// G4cout << "Warning: try to access G4ParticleHPReactionWhiteBoard before opening" << G4endl;
|
||||
// RWB = new G4ParticleHPReactionWhiteBoard();
|
||||
// }
|
||||
// return RWB;
|
||||
return G4ParticleHPThreadLocalManager::GetInstance()->GetReactionWhiteBoard();
|
||||
}
|
||||
|
||||
void G4ParticleHPManager::CloseReactionWhiteBoard()
|
||||
{
|
||||
G4ParticleHPThreadLocalManager::GetInstance()->CloseReactionWhiteBoard();
|
||||
}
|
||||
|
||||
#include "zlib.h"
|
||||
#include <fstream>
|
||||
void G4ParticleHPManager::GetDataStream( G4String filename , std::istringstream& iss )
|
||||
{
|
||||
//if ( getenv( "TEST04" ) && filename != "INVALID" ) G4cout << "Reading " << filename << G4endl;
|
||||
G4String* data=NULL;
|
||||
G4String* data=0;
|
||||
G4String compfilename(filename);
|
||||
compfilename += ".z";
|
||||
std::ifstream* in = new std::ifstream ( compfilename , std::ios::binary | std::ios::ate );
|
||||
if ( in->good() )
|
||||
{
|
||||
// Use the compressed file
|
||||
// Use the compressed file
|
||||
G4int file_size = in->tellg();
|
||||
in->seekg( 0 , std::ios::beg );
|
||||
Bytef* compdata = new Bytef[ file_size ];
|
||||
|
||||
while ( *in ) { // Loop checking, 11.05.2015, T. Koi
|
||||
while ( *in )
|
||||
{ // Loop checking, 11.05.2015, T. Koi
|
||||
in->read( (char*)compdata , file_size );
|
||||
}
|
||||
|
||||
uLongf complen = (uLongf) ( file_size*4 );
|
||||
Bytef* uncompdata = new Bytef[complen];
|
||||
|
||||
while ( Z_OK != uncompress ( uncompdata , &complen , compdata , file_size ) ) { // Loop checking, 11.05.2015, T. Koi
|
||||
//G4cout << "Too small, retry 2 times bigger size." << G4endl;
|
||||
while ( Z_OK != uncompress ( uncompdata , &complen , compdata , file_size ) )
|
||||
{ // Loop checking, 11.05.2015, T. Koi
|
||||
delete[] uncompdata;
|
||||
complen *= 2;
|
||||
uncompdata = new Bytef[complen];
|
||||
@@ -130,60 +130,76 @@ void G4ParticleHPManager::GetDataStream( G4String filename , std::istringstream&
|
||||
// Now "complen" has uncomplessed size
|
||||
data = new G4String ( (char*)uncompdata , (G4long)complen );
|
||||
delete [] uncompdata;
|
||||
} else {
|
||||
// Use regular text file
|
||||
}
|
||||
else
|
||||
{
|
||||
// Use regular text file
|
||||
std::ifstream thefData( filename , std::ios::in | std::ios::ate );
|
||||
if ( thefData.good() ) {
|
||||
if ( thefData.good() )
|
||||
{
|
||||
G4int file_size = thefData.tellg();
|
||||
thefData.seekg( 0 , std::ios::beg );
|
||||
char* filedata = new char[ file_size ];
|
||||
while ( thefData ) { // Loop checking, 11.05.2015, T. Koi
|
||||
while ( thefData )
|
||||
{ // Loop checking, 11.05.2015, T. Koi
|
||||
thefData.read( filedata , file_size );
|
||||
}
|
||||
thefData.close();
|
||||
data = new G4String ( filedata , file_size );
|
||||
delete [] filedata;
|
||||
} else {
|
||||
// found no data file
|
||||
// set error bit to the stream
|
||||
}
|
||||
else
|
||||
{
|
||||
// found no data file
|
||||
// set error bit to the stream
|
||||
iss.setstate( std::ios::badbit );
|
||||
}
|
||||
}
|
||||
if ( data != NULL ) {
|
||||
if ( data != 0 )
|
||||
{
|
||||
iss.str(*data);
|
||||
G4String id;
|
||||
iss >> id;
|
||||
if ( id == "G4NDL" ) {
|
||||
if ( id == "G4NDL" )
|
||||
{
|
||||
//Register information of file
|
||||
G4String source;
|
||||
iss >> source;
|
||||
register_data_file(filename,source);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
iss.seekg( 0 , std::ios::beg );
|
||||
}
|
||||
}
|
||||
//G4cout << iss.rdbuf()->in_avail() << G4endl;
|
||||
in->close(); delete in;
|
||||
delete data;
|
||||
}
|
||||
// Checking existance of data file
|
||||
|
||||
void G4ParticleHPManager::GetDataStream2( G4String filename , std::istringstream& iss )
|
||||
{
|
||||
// Checking existance of data file
|
||||
|
||||
G4String compfilename(filename);
|
||||
compfilename += ".z";
|
||||
std::ifstream* in = new std::ifstream ( compfilename , std::ios::binary | std::ios::ate );
|
||||
if ( in->good() )
|
||||
{
|
||||
// Compressed file is exist
|
||||
// Compressed file is exist
|
||||
in->close();
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
std::ifstream thefData( filename , std::ios::in | std::ios::ate );
|
||||
if ( thefData.good() ) {
|
||||
// Regular text file is exist
|
||||
if ( thefData.good() )
|
||||
{
|
||||
// Regular text file is exist
|
||||
thefData.close();
|
||||
} else {
|
||||
// found no data file
|
||||
// set error bit to the stream
|
||||
}
|
||||
else
|
||||
{
|
||||
// found no data file
|
||||
// set error bit to the stream
|
||||
iss.setstate( std::ios::badbit );
|
||||
}
|
||||
}
|
||||
@@ -207,30 +223,35 @@ void G4ParticleHPManager::DumpDataSource()
|
||||
|
||||
G4cout << "Data source of this Partile HP calculation are " << G4endl;
|
||||
for ( std::map< G4String , G4String >::iterator
|
||||
it = mDataEvaluation.begin() ; it != mDataEvaluation.end() ; it++ ) {
|
||||
it = mDataEvaluation.begin() ; it != mDataEvaluation.end() ; it++ )
|
||||
{
|
||||
G4cout << it->first << " " << it->second << G4endl;
|
||||
}
|
||||
G4cout << G4endl;
|
||||
}
|
||||
|
||||
G4PhysicsTable* G4ParticleHPManager::GetInelasticCrossSections(const G4ParticleDefinition* particle ){
|
||||
G4PhysicsTable* G4ParticleHPManager::GetInelasticCrossSections(const G4ParticleDefinition* particle )
|
||||
{
|
||||
if ( theInelasticCrossSections.end() != theInelasticCrossSections.find( particle ) )
|
||||
return theInelasticCrossSections.find( particle )->second;
|
||||
else
|
||||
return NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void G4ParticleHPManager::RegisterInelasticCrossSections( const G4ParticleDefinition* particle, G4PhysicsTable* val ){
|
||||
void G4ParticleHPManager::RegisterInelasticCrossSections( const G4ParticleDefinition* particle, G4PhysicsTable* val )
|
||||
{
|
||||
theInelasticCrossSections.insert( std::pair<const G4ParticleDefinition* , G4PhysicsTable* >( particle , val ) );
|
||||
}
|
||||
|
||||
std::vector<G4ParticleHPChannelList*>* G4ParticleHPManager::GetInelasticFinalStates(const G4ParticleDefinition* particle) {
|
||||
std::vector<G4ParticleHPChannelList*>* G4ParticleHPManager::GetInelasticFinalStates(const G4ParticleDefinition* particle)
|
||||
{
|
||||
if ( theInelasticFSs.end() != theInelasticFSs.find( particle ) )
|
||||
return theInelasticFSs.find( particle )->second;
|
||||
else
|
||||
return NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void G4ParticleHPManager::RegisterInelasticFinalStates( const G4ParticleDefinition* particle , std::vector<G4ParticleHPChannelList*>* val ) {
|
||||
void G4ParticleHPManager::RegisterInelasticFinalStates( const G4ParticleDefinition* particle , std::vector<G4ParticleHPChannelList*>* val )
|
||||
{
|
||||
theInelasticFSs.insert ( std::pair<const G4ParticleDefinition*,std::vector<G4ParticleHPChannelList*>*>( particle , val ) );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user