Import Geant4 10.6.0 source tree
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -39,6 +39,9 @@
|
||||
#include "G4ProcessTableMessenger.hh"
|
||||
#include "G4ProcessTable.hh"
|
||||
|
||||
// Static class variable: ptr to single instance of class in a thread
|
||||
G4ThreadLocal G4ProcessTable* G4ProcessTable::fProcessTable = nullptr;
|
||||
|
||||
// constructor //////////////////////////
|
||||
G4ProcessTable::G4ProcessTable()
|
||||
:verboseLevel(1)
|
||||
@@ -51,31 +54,12 @@ G4ProcessTable::G4ProcessTable()
|
||||
fProcTblVector = new G4ProcTableVector();
|
||||
fProcNameVector = new G4ProcNameVector();
|
||||
tmpTblVector = new G4ProcTableVector();
|
||||
fProcTblMessenger = nullptr;
|
||||
}
|
||||
|
||||
// copy constructor //////////////////////////
|
||||
G4ProcessTable::G4ProcessTable(const G4ProcessTable &)
|
||||
:verboseLevel(1)
|
||||
{
|
||||
fProcTblVector = nullptr;
|
||||
fProcNameVector = nullptr;
|
||||
tmpTblVector = nullptr;
|
||||
fProcTblMessenger = nullptr;
|
||||
#ifdef G4VERBOSE
|
||||
G4cout << "-- G4ProcessTable copy constructor --" << G4endl;
|
||||
#endif
|
||||
fProcTblMessenger = new G4ProcessTableMessenger(this);
|
||||
}
|
||||
|
||||
// destructor //////////////////////////
|
||||
G4ProcessTable::~G4ProcessTable()
|
||||
{
|
||||
#ifdef G4VERBOSE
|
||||
if (verboseLevel>1){
|
||||
G4cout << "-- G4ProcessTable destructor --" << G4endl;
|
||||
}
|
||||
#endif
|
||||
|
||||
if ( tmpTblVector != nullptr) {
|
||||
tmpTblVector ->clear();
|
||||
delete tmpTblVector;
|
||||
@@ -99,66 +83,17 @@ G4ProcessTable::~G4ProcessTable()
|
||||
fProcNameVector = nullptr;
|
||||
}
|
||||
fProcessTable = nullptr;
|
||||
delete fProcTblMessenger;
|
||||
}
|
||||
|
||||
/////////////////////////
|
||||
G4UImessenger* G4ProcessTable::CreateMessenger()
|
||||
{
|
||||
if (fProcTblMessenger == nullptr) {
|
||||
fProcTblMessenger = new G4ProcessTableMessenger(this);
|
||||
}
|
||||
return fProcTblMessenger;
|
||||
}
|
||||
|
||||
/////////////////////////
|
||||
void G4ProcessTable::DeleteMessenger()
|
||||
{
|
||||
if (fProcTblMessenger != nullptr) {
|
||||
delete fProcTblMessenger;
|
||||
fProcTblMessenger = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////
|
||||
G4ProcessTable & G4ProcessTable::operator=(const G4ProcessTable &)
|
||||
{
|
||||
#ifdef G4VERBOSE
|
||||
if (verboseLevel>0){
|
||||
G4cout << "-- G4ProcessTable assignment operator --" << G4endl;
|
||||
}
|
||||
#endif
|
||||
return *this;
|
||||
}
|
||||
|
||||
//////////////////////////
|
||||
G4bool G4ProcessTable::operator==(const G4ProcessTable &right) const
|
||||
{
|
||||
return (this == &right);
|
||||
}
|
||||
|
||||
//////////////////////////
|
||||
G4bool G4ProcessTable::operator!=(const G4ProcessTable &right) const
|
||||
{
|
||||
return (this != &right);
|
||||
}
|
||||
|
||||
// Static class variable: ptr to single instance of class
|
||||
G4ThreadLocal G4ProcessTable* G4ProcessTable::fProcessTable = nullptr;
|
||||
|
||||
|
||||
//////////////////////////
|
||||
G4ProcessTable* G4ProcessTable::GetProcessTable()
|
||||
{
|
||||
static G4ThreadLocal G4ProcessTable *theProcessTable_G4MT_TLS_ = nullptr ;
|
||||
if (theProcessTable_G4MT_TLS_ == nullptr) {
|
||||
theProcessTable_G4MT_TLS_ = new G4ProcessTable ;
|
||||
}
|
||||
G4ProcessTable &theProcessTable = *theProcessTable_G4MT_TLS_;
|
||||
if (fProcessTable == nullptr){
|
||||
fProcessTable = &theProcessTable;
|
||||
}
|
||||
return fProcessTable;
|
||||
if(!fProcessTable) {
|
||||
static G4ThreadLocalSingleton<G4ProcessTable> inst;
|
||||
fProcessTable = inst.Instance();
|
||||
}
|
||||
return fProcessTable;
|
||||
}
|
||||
|
||||
//////////////////////////
|
||||
@@ -184,12 +119,12 @@ G4int G4ProcessTable::Insert(G4VProcess* aProcess,
|
||||
}
|
||||
#endif
|
||||
|
||||
G4ProcTableVector::iterator itr;
|
||||
G4int idxTbl=0;
|
||||
G4ProcTblElement* anElement = nullptr;
|
||||
G4bool isFoundInTbl = false;
|
||||
// loop over all elements
|
||||
for (itr=fProcTblVector->begin(); itr!=fProcTblVector->end(); ++itr, ++idxTbl) {
|
||||
for (auto itr=fProcTblVector->begin();
|
||||
itr!=fProcTblVector->end(); ++itr, ++idxTbl) {
|
||||
anElement = (*itr);
|
||||
// check if this process is included
|
||||
if (aProcess == anElement->GetProcess()) {
|
||||
@@ -214,9 +149,8 @@ G4int G4ProcessTable::Insert(G4VProcess* aProcess,
|
||||
newElement->Insert(aProcMgr);
|
||||
fProcTblVector->push_back(newElement);
|
||||
// add into name vector
|
||||
G4ProcNameVector::iterator ip;
|
||||
G4bool isFound = false;
|
||||
for (ip=fProcNameVector->begin(); ip!=fProcNameVector->end(); ++ip) {
|
||||
for (auto ip=fProcNameVector->cbegin(); ip!=fProcNameVector->cend(); ++ip) {
|
||||
isFound |= (aProcess->GetProcessName() == (*ip));
|
||||
}
|
||||
if (!isFound) {
|
||||
@@ -297,8 +231,7 @@ G4int G4ProcessTable::Remove( G4VProcess* aProcess,
|
||||
}
|
||||
// remove from name vector
|
||||
if (!isSameName ) {
|
||||
G4ProcNameVector::iterator i;
|
||||
for (i=fProcNameVector->begin(); i!=fProcNameVector->end(); ++i) {
|
||||
for (auto i=fProcNameVector->begin(); i!=fProcNameVector->end(); ++i) {
|
||||
if ( *i == aProcess->GetProcessName() ) {
|
||||
fProcNameVector->erase(i);
|
||||
break;
|
||||
@@ -319,11 +252,11 @@ G4VProcess* G4ProcessTable::FindProcess(const G4String& processName,
|
||||
const G4ProcessManager* processManager)
|
||||
const
|
||||
{
|
||||
G4ProcTableVector::iterator itr;
|
||||
G4int idxTbl = 0;
|
||||
G4bool isFound = false;
|
||||
G4ProcTblElement* anElement =nullptr;
|
||||
for (itr=fProcTblVector->begin(); itr!=fProcTblVector->end(); ++itr, ++idxTbl) {
|
||||
for (auto itr=fProcTblVector->cbegin();
|
||||
itr!=fProcTblVector->cend(); ++itr, ++idxTbl) {
|
||||
anElement = (*itr);
|
||||
// check name
|
||||
if ( anElement->GetProcessName() == processName ) {
|
||||
@@ -353,10 +286,9 @@ G4ProcessTable::G4ProcTableVector* G4ProcessTable::Find(
|
||||
{
|
||||
tmpTblVector->clear();
|
||||
|
||||
G4ProcTableVector::iterator itr;
|
||||
G4bool isFound = false;
|
||||
G4ProcTblElement* anElement =nullptr;
|
||||
for (itr=fProcTblVector->begin(); itr!=fProcTblVector->end(); ++itr) {
|
||||
for (auto itr=fProcTblVector->cbegin(); itr!=fProcTblVector->cend(); ++itr) {
|
||||
anElement = (*itr);
|
||||
// check name
|
||||
if ( anElement->GetProcessName() == processName ) {
|
||||
@@ -382,10 +314,9 @@ G4ProcessTable::G4ProcTableVector* G4ProcessTable::Find(
|
||||
{
|
||||
tmpTblVector->clear();
|
||||
|
||||
G4ProcTableVector::iterator itr;
|
||||
G4bool isFound = false;
|
||||
G4ProcTblElement* anElement =nullptr;
|
||||
for (itr=fProcTblVector->begin(); itr!=fProcTblVector->end(); ++itr) {
|
||||
for (auto itr=fProcTblVector->cbegin(); itr!=fProcTblVector->cend(); ++itr) {
|
||||
anElement = (*itr);
|
||||
// check name
|
||||
if ( anElement->GetProcess()->GetProcessType() == processType ) {
|
||||
@@ -409,9 +340,8 @@ G4ProcessTable::G4ProcTableVector* G4ProcessTable::Find(
|
||||
G4ProcessVector* G4ProcessTable::ExtractProcesses( G4ProcTableVector* procTblVector)
|
||||
{
|
||||
G4ProcessVector* procList = new G4ProcessVector();
|
||||
G4ProcTableVector::iterator itr;
|
||||
// loop over all elements
|
||||
for (itr=procTblVector->begin(); itr!=procTblVector->end(); ++itr) {
|
||||
for (auto itr=procTblVector->cbegin(); itr!=procTblVector->cend(); ++itr) {
|
||||
G4ProcTblElement* anElement = (*itr);
|
||||
procList->insert( anElement->GetProcess() );
|
||||
}
|
||||
@@ -457,10 +387,9 @@ void G4ProcessTable::SetProcessActivation( const G4String& processName,
|
||||
#endif
|
||||
|
||||
G4ProcTableVector* pTblVector = Find(fProcTblVector, processName);
|
||||
G4ProcTableVector::iterator itr;
|
||||
G4ProcTblElement* anElement;
|
||||
// loop over all elements
|
||||
for (itr=pTblVector->begin(); itr!=pTblVector->end(); ++itr) {
|
||||
for (auto itr=pTblVector->cbegin(); itr!=pTblVector->cend(); ++itr) {
|
||||
anElement = (*itr);
|
||||
G4VProcess* process = anElement->GetProcess();
|
||||
for (G4int idx = 0 ; idx < anElement->Length(); idx++) {
|
||||
@@ -515,10 +444,9 @@ void G4ProcessTable::SetProcessActivation( G4ProcessType processType,
|
||||
#endif
|
||||
|
||||
G4ProcTableVector* pTblVector = Find(fProcTblVector, processType);
|
||||
G4ProcTableVector::iterator itr;
|
||||
G4ProcTblElement* anElement;
|
||||
// loop over all elements
|
||||
for (itr=pTblVector->begin(); itr!=pTblVector->end(); ++itr) {
|
||||
for (auto itr=pTblVector->cbegin(); itr!=pTblVector->cend(); ++itr) {
|
||||
anElement = (*itr);
|
||||
G4VProcess* process = anElement->GetProcess();
|
||||
#ifdef G4VERBOSE
|
||||
@@ -526,7 +454,7 @@ void G4ProcessTable::SetProcessActivation( G4ProcessType processType,
|
||||
G4cout << " The Process[" << process->GetProcessName()<< "] "<< G4endl;
|
||||
}
|
||||
#endif
|
||||
for (G4int idx = 0 ; idx < anElement->Length(); idx++) {
|
||||
for (G4int idx = 0 ; idx < anElement->Length(); ++idx) {
|
||||
G4ProcessManager* manager = anElement->GetProcessManager(idx);
|
||||
manager->SetProcessActivation(process, fActive);
|
||||
#ifdef G4VERBOSE
|
||||
@@ -553,7 +481,7 @@ void G4ProcessTable::SetProcessActivation(
|
||||
#endif
|
||||
|
||||
G4ProcessVector* procList = processManager->GetProcessList();
|
||||
for (G4int idx = 0; idx < procList->length(); idx++) {
|
||||
for (std::size_t idx = 0; idx < procList->length(); ++idx) {
|
||||
G4VProcess* process = (*procList)(idx);
|
||||
if ( process->GetProcessType() == processType) {
|
||||
processManager->SetProcessActivation(process, fActive);
|
||||
@@ -573,14 +501,14 @@ void G4ProcessTable::SetProcessActivation(
|
||||
void G4ProcessTable::DumpInfo(G4VProcess* process,
|
||||
G4ParticleDefinition* particle)
|
||||
{
|
||||
G4ProcTableVector::iterator itr;
|
||||
G4int idxTbl=0;
|
||||
G4ProcTblElement* anElement =nullptr;
|
||||
G4bool isFoundInTbl = false;
|
||||
G4ProcessManager* manager =nullptr;
|
||||
G4int idx;
|
||||
// loop over all elements
|
||||
for (itr=fProcTblVector->begin(); itr!=fProcTblVector->end(); ++itr, ++idxTbl) {
|
||||
for (auto itr=fProcTblVector->cbegin();
|
||||
itr!=fProcTblVector->cend(); ++itr, ++idxTbl) {
|
||||
anElement = (*itr);
|
||||
if (process == anElement->GetProcess() ){
|
||||
if (particle != nullptr) {
|
||||
|
||||
@@ -239,8 +239,8 @@ void G4ProcessTableMessenger::SetNewValue(G4UIcommand * command,G4String newValu
|
||||
}
|
||||
}
|
||||
idx =0;
|
||||
G4ProcessTable::G4ProcNameVector::iterator itr;
|
||||
for (itr=procNameVector->begin(); itr!=procNameVector->end(); ++itr) {
|
||||
for (auto itr=procNameVector->cbegin(); itr!=procNameVector->cend(); ++itr)
|
||||
{
|
||||
idx +=1;
|
||||
G4ProcessVector* tmpVector = theProcessTable->FindProcesses(*itr);
|
||||
G4VProcess* p = (*tmpVector)(0);
|
||||
@@ -314,7 +314,7 @@ void G4ProcessTableMessenger::SetNewValue(G4UIcommand * command,G4String newValu
|
||||
} else {
|
||||
tmpVector = theProcessTable->FindProcesses(G4ProcessType(type));
|
||||
}
|
||||
for (G4int i=0; i<tmpVector->length(); i++) {
|
||||
for (std::size_t i=0; i<tmpVector->length(); ++i) {
|
||||
theProcessTable->DumpInfo( (*tmpVector)(i), currentParticle );
|
||||
}
|
||||
delete tmpVector;
|
||||
@@ -379,7 +379,7 @@ G4String G4ProcessTableMessenger::GetProcessTypeName(G4ProcessType aType) const
|
||||
G4int G4ProcessTableMessenger::GetProcessType(const G4String& aTypeName) const
|
||||
{
|
||||
G4int type = -1;
|
||||
for (G4int idx = 0; idx < NumberOfProcessType ; idx ++ ) {
|
||||
for (G4int idx = 0; idx < NumberOfProcessType ; ++idx ) {
|
||||
if (aTypeName == G4VProcess::GetProcessTypeName(G4ProcessType(idx)) ) {
|
||||
type = idx;
|
||||
break;
|
||||
@@ -394,7 +394,7 @@ void G4ProcessTableMessenger::SetNumberOfProcessType()
|
||||
{
|
||||
G4bool isFoundEndMark = false;
|
||||
G4int idx;
|
||||
for (idx = 0; idx < 1000 ; idx ++ ) {
|
||||
for (idx = 0; idx < 1000 ; ++idx ) {
|
||||
G4String typeName = G4VProcess::GetProcessTypeName(G4ProcessType(idx));
|
||||
isFoundEndMark = typeName.contains("---");
|
||||
if ( isFoundEndMark ) break;
|
||||
|
||||
@@ -23,13 +23,8 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// G4ProcessVector implementation
|
||||
//
|
||||
//
|
||||
//
|
||||
// ------------------------------------------------------------
|
||||
// GEANT 4 class header file
|
||||
//
|
||||
// This class is a container for pointers to physics process objects.
|
||||
// ------------------------------------------------------------
|
||||
|
||||
#include "G4VProcess.hh"
|
||||
@@ -48,14 +43,14 @@ G4ProcessVector::G4ProcessVector(size_t siz)
|
||||
}
|
||||
|
||||
G4ProcessVector::G4ProcessVector(const G4ProcessVector& right)
|
||||
:pProcVector(nullptr)
|
||||
: pProcVector(nullptr)
|
||||
{
|
||||
pProcVector = new G4ProcVector();
|
||||
|
||||
// copy all contents in pProcVector
|
||||
//
|
||||
G4ProcVector::iterator i;
|
||||
for (i = right.pProcVector->begin(); i!= right.pProcVector->end(); ++i){
|
||||
for (auto i = right.pProcVector->begin(); i!= right.pProcVector->end(); ++i)
|
||||
{
|
||||
pProcVector->push_back(*i);
|
||||
}
|
||||
}
|
||||
@@ -66,7 +61,8 @@ G4ProcessVector::~G4ProcessVector()
|
||||
{
|
||||
// delete pProcVector
|
||||
//
|
||||
if (pProcVector != nullptr ){
|
||||
if (pProcVector != nullptr )
|
||||
{
|
||||
pProcVector->clear();
|
||||
delete pProcVector;
|
||||
}
|
||||
@@ -76,9 +72,11 @@ G4ProcessVector::~G4ProcessVector()
|
||||
//
|
||||
G4ProcessVector & G4ProcessVector::operator=(const G4ProcessVector & right)
|
||||
{
|
||||
if (this != &right){
|
||||
if (this != &right)
|
||||
{
|
||||
// delete pProcVector
|
||||
if (pProcVector != nullptr ){
|
||||
if (pProcVector != nullptr )
|
||||
{
|
||||
pProcVector->clear();
|
||||
delete pProcVector;
|
||||
}
|
||||
@@ -87,8 +85,8 @@ G4ProcessVector & G4ProcessVector::operator=(const G4ProcessVector & right)
|
||||
|
||||
// copy all contents in pProcVector
|
||||
//
|
||||
G4ProcVector::iterator i;
|
||||
for (i = right.pProcVector->begin(); i!= right.pProcVector->end(); ++i){
|
||||
for (auto i = right.pProcVector->begin(); i!= right.pProcVector->end(); ++i)
|
||||
{
|
||||
pProcVector->push_back(*i);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user