Import Geant4 11.0.0 source tree
This commit is contained in:
committed by
Ben Morgan
parent
6399a014b6
commit
80e2389dd8
@@ -29,9 +29,12 @@
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#include "G4PhysicsTableHelper.hh"
|
||||
#include "G4ProductionCutsTable.hh"
|
||||
#include "G4ProductionCutsTable.hh"
|
||||
#include "G4MCCIndexConversionTable.hh"
|
||||
#include "G4Threading.hh"
|
||||
#include "G4ios.hh"
|
||||
|
||||
G4ThreadLocal G4int G4PhysicsTableHelper::verboseLevel = 1;
|
||||
G4int G4PhysicsTableHelper::verboseLevel = 1;
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
G4PhysicsTableHelper::G4PhysicsTableHelper()
|
||||
@@ -51,68 +54,47 @@ G4PhysicsTableHelper::PreparePhysicsTable(G4PhysicsTable* physTable)
|
||||
= G4ProductionCutsTable::GetProductionCutsTable();
|
||||
std::size_t numberOfMCC = cutTable->GetTableSize();
|
||||
|
||||
if ( physTable != nullptr)
|
||||
if ( physTable != nullptr )
|
||||
{
|
||||
// compare size of physics table and number of material-cuts-couple
|
||||
if ( physTable->size() < numberOfMCC)
|
||||
if ( physTable->size() < numberOfMCC )
|
||||
{
|
||||
// enlarge physics table
|
||||
physTable->resize(numberOfMCC, nullptr);
|
||||
#ifdef G4VERBOSE
|
||||
if (verboseLevel>2)
|
||||
{
|
||||
G4cerr << "G4PhysicsTableHelper::PreparePhysicsTable ";
|
||||
G4cerr << "Physics Table "<< physTable ;
|
||||
G4cerr << " is resized to " << numberOfMCC << G4endl;
|
||||
G4cout << "G4PhysicsTableHelper::PreparePhysicsTable: "
|
||||
<< " the table " << physTable << " size="
|
||||
<< physTable->size()
|
||||
<< " will be is resized to " << numberOfMCC << G4endl;
|
||||
}
|
||||
#endif
|
||||
// enlarge physics table
|
||||
physTable->resize(numberOfMCC, nullptr);
|
||||
}
|
||||
else if ( physTable->size() > numberOfMCC)
|
||||
else if ( physTable->size() > numberOfMCC )
|
||||
{
|
||||
// ERROR: this situation should not occur
|
||||
// size of physics table is shorter than number of material-cuts-couple
|
||||
physTable->resize(numberOfMCC);
|
||||
#ifdef G4VERBOSE
|
||||
if (verboseLevel>0)
|
||||
{
|
||||
G4cerr << "G4PhysicsTableHelper::PreparePhysicsTable ";
|
||||
G4cerr << "Physics Table "<< physTable ;
|
||||
G4cerr << " is longer than number of material-cuts-couple " << G4endl;
|
||||
}
|
||||
#endif
|
||||
// size of physics table is larger than number of material-cuts-couple
|
||||
G4ExceptionDescription ed;
|
||||
ed << "table " << physTable << " size=" << physTable->size()
|
||||
<< " is longer than number of material-cuts-couple " << numberOfMCC;
|
||||
G4Exception( "G4PhysicsTableHelper::PreparePhysicsTable()",
|
||||
"ProcCuts001", FatalException,
|
||||
"Physics Table is inconsistent with material-cuts-couple");
|
||||
"ProcCuts001", FatalException, ed);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// create PhysicsTable is given poitner is null
|
||||
physTable = new G4PhysicsTable(numberOfMCC);
|
||||
if (physTable != nullptr)
|
||||
{
|
||||
physTable->resize(numberOfMCC, nullptr);
|
||||
}
|
||||
else
|
||||
{
|
||||
G4Exception( "G4PhysicsTableHelper::PreparePhysicsTable()",
|
||||
"ProcCuts002", FatalException,
|
||||
"Can't create Physics Table");
|
||||
}
|
||||
physTable = new G4PhysicsTable();
|
||||
physTable->resize(numberOfMCC, nullptr);
|
||||
}
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
if (verboseLevel>2)
|
||||
{
|
||||
if ( physTable != nullptr)
|
||||
{
|
||||
G4cerr << "Physics Table size "<< physTable->size();
|
||||
}
|
||||
else
|
||||
{
|
||||
G4cerr << "Physics Table does not exist ";
|
||||
}
|
||||
G4cerr << ": number of material-cuts-couple " << numberOfMCC << G4endl;
|
||||
G4cout << "G4PhysicsTableHelper::PreparePhysicsTable: "
|
||||
<< " the table "<< physTable
|
||||
<< " size=" << numberOfMCC << G4endl;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -145,16 +127,10 @@ G4bool G4PhysicsTableHelper::RetrievePhysicsTable(G4PhysicsTable* physTable,
|
||||
G4PhysicsTable* tempTable = new G4PhysicsTable();
|
||||
if (! tempTable->RetrievePhysicsTable(fileName,ascii,spline) )
|
||||
{
|
||||
#ifdef G4VERBOSE
|
||||
if (verboseLevel>1)
|
||||
{
|
||||
G4cerr << "G4PhysicsTableHelper::RetrievePhysicsTable ";
|
||||
G4cerr << "Fail to retrieve from "<< fileName << G4endl;
|
||||
}
|
||||
#endif
|
||||
G4ExceptionDescription ed;
|
||||
ed << "Cannot retrieve physics table from the file <" << fileName << ">";
|
||||
G4Exception( "G4ProductionCutsTable::RetrievePhysicsTable()",
|
||||
"ProcCuts105",
|
||||
JustWarning, "Can not retrieve physics tables from file");
|
||||
"ProcCuts105", JustWarning, ed);
|
||||
delete tempTable;
|
||||
return false;
|
||||
}
|
||||
@@ -167,20 +143,13 @@ G4bool G4PhysicsTableHelper::RetrievePhysicsTable(G4PhysicsTable* physTable,
|
||||
// check physics table size
|
||||
if ( tempTable->size() != converter->size())
|
||||
{
|
||||
#ifdef G4VERBOSE
|
||||
if (verboseLevel>0)
|
||||
{
|
||||
G4cerr << "G4PhysicsTableHelper::RetrievePhysicsTable ";
|
||||
G4cerr << "Size of the physics table in "<< fileName;
|
||||
G4cerr << "( size =" << tempTable->size() << ")";
|
||||
G4cerr << " is inconsistent with material-cut info";
|
||||
G4cerr << "( size =" << converter->size() << ")";
|
||||
G4cerr << G4endl;
|
||||
}
|
||||
#endif
|
||||
G4ExceptionDescription ed;
|
||||
ed << "Physics table in " << fileName
|
||||
<< "\n size=" << tempTable->size() << " "
|
||||
<< " is inconsistent with material-cut-couple "
|
||||
<< "size=" << converter->size() << " the table is not retrieved!";
|
||||
G4Exception("G4ProductionCutsTable::RetrievePhysicsTable()",
|
||||
"ProcCuts106", JustWarning,
|
||||
"Retrieved file is inconsistent with current physics tables!");
|
||||
"ProcCuts106", JustWarning, ed);
|
||||
delete tempTable;
|
||||
return false;
|
||||
}
|
||||
@@ -190,8 +159,13 @@ G4bool G4PhysicsTableHelper::RetrievePhysicsTable(G4PhysicsTable* physTable,
|
||||
{
|
||||
if (converter->IsUsed(idx))
|
||||
{
|
||||
if (converter->GetIndex(idx)<0) continue;
|
||||
std::size_t i = converter->GetIndex(idx);
|
||||
G4int i = converter->GetIndex(idx);
|
||||
if(i < 0)
|
||||
{
|
||||
tempTable->clearAndDestroy();
|
||||
delete tempTable;
|
||||
return false;
|
||||
}
|
||||
G4PhysicsVector* vec = (*physTable)[i];
|
||||
if (vec != nullptr ) delete vec;
|
||||
(*physTable)[i] = (*tempTable)[idx];
|
||||
@@ -213,19 +187,13 @@ void G4PhysicsTableHelper::SetPhysicsVector(G4PhysicsTable* physTable,
|
||||
|
||||
if ( physTable->size() <= idx)
|
||||
{
|
||||
#ifdef G4VERBOSE
|
||||
if (verboseLevel>0)
|
||||
{
|
||||
G4cerr << "G4PhysicsTableHelper::SetPhysicsVector ";
|
||||
G4cerr << "Given index (" << idx << ") exceeds ";
|
||||
G4cerr << "size of the physics table ";
|
||||
G4cerr << "( size =" << physTable->size()<< ")";
|
||||
G4cerr << G4endl;
|
||||
}
|
||||
#endif
|
||||
G4ExceptionDescription ed;
|
||||
ed << "Given index (" << idx << ") exceeds "
|
||||
<< "the size of the physics table "
|
||||
<< "( size =" << physTable->size() << ") the vector is not added!";
|
||||
G4Exception("G4ProductionCutsTable::SetPhysicsVector()",
|
||||
"ProcCuts107",
|
||||
JustWarning, "Illegal index!");
|
||||
JustWarning, ed);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -236,9 +204,9 @@ void G4PhysicsTableHelper::SetPhysicsVector(G4PhysicsTable* physTable,
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
void G4PhysicsTableHelper::SetVerboseLevel(G4int value)
|
||||
void G4PhysicsTableHelper::SetVerboseLevel(G4int value)
|
||||
{
|
||||
verboseLevel = value;
|
||||
if( !G4Threading::IsWorkerThread() ) verboseLevel = value;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user