Import Geant4 10.6.0 source tree

This commit is contained in:
Gabriele Cosmo
2019-12-06 15:12:28 +01:00
parent b2a62ae692
commit 5baee230e9
2997 changed files with 141580 additions and 98673 deletions
+13
View File
@@ -15,7 +15,20 @@ committal in the CVS repository !
----------------------------------------------------------
* Reverse chronological order (last date on top), please *
----------------------------------------------------------
- Nov. 26, 2019 Gabriele Cosmo (procman-V10-05-05)
- Fixed more cases of implicit type conversions from size_t to G4int.
- Nov. 21, 2019 Vladimir Ivanchenko (procman-V10-05-04)
- ProcessTable - make it true thread local singleton
- Nov. 19, 2019 Gabriele Cosmo (procman-V10-05-03)
- Fixed more cases of implicit type conversions.
- Nov. 15, 2019 Gabriele Cosmo (procman-V10-05-02)
- Fixed cases of implicit type conversions from size_t to G4int.
- Some code cleanup in G4ProcessManager.
- Mar. 11, 2019 Gabriele Cosmo (procman-V10-05-01)
- Fixed typos in printouts in G4ProcessTableMessenger, G4ProcessManager
and G4VRest*Process.
@@ -23,23 +23,17 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// G4ProcTblElement inline methods implementation
//
//
//
// ------------------------------------------------------------
// GEANT 4 class header file
//
// History: first implementation, based on object model of
// 4th Aug 1998, H.Kurashige
// ------------------------------------------------------------
// Use STL vector instead of RW vector 1. Mar 00 H.Kurashige
// Author: H.Kurashige, 04.08.1998
// --------------------------------------------------------------------
/////////////
inline
G4bool G4ProcTblElement::Contains(const G4ProcessManager* pManager) const
{
G4ProcMgrVector::iterator i;
for (i = pProcMgrVector->begin(); i!= pProcMgrVector->end(); ++i) {
for (auto i = pProcMgrVector->cbegin(); i!= pProcMgrVector->cend(); ++i)
{
if (*i==pManager) return true;
}
return false;
@@ -50,8 +44,8 @@ inline
G4int G4ProcTblElement::GetIndex(const G4ProcessManager* pManager) const
{
G4int index = 0;
G4ProcMgrVector::iterator i;
for (i = pProcMgrVector->begin(); i!= pProcMgrVector->end(); ++i) {
for (auto i = pProcMgrVector->cbegin(); i!= pProcMgrVector->cend(); ++i)
{
if (*i==pManager) return index;
index +=1;
}
@@ -63,17 +57,20 @@ inline
inline
G4int G4ProcTblElement::Length() const
{
return pProcMgrVector->size();
return G4int(pProcMgrVector->size());
}
//////////////////////////
inline
G4ProcessManager* G4ProcTblElement::GetProcessManager(G4int index) const
{
if ((index < G4int(pProcMgrVector->size())) && (index>=0)){
if ((index < G4int(pProcMgrVector->size())) && (index>=0))
{
return (*pProcMgrVector)[index];
} else {
return 0;
}
else
{
return nullptr;
}
}
@@ -97,9 +94,10 @@ inline
inline
void G4ProcTblElement::Remove(G4ProcessManager* aProcMgr)
{
G4ProcMgrVector::iterator i;
for (i = pProcMgrVector->begin(); i!= pProcMgrVector->end(); ++i) {
if (*i==aProcMgr){
for (auto i = pProcMgrVector->cbegin(); i!= pProcMgrVector->cend(); ++i)
{
if (*i==aProcMgr)
{
pProcMgrVector->erase(i);
break;
}
@@ -23,26 +23,20 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// ---------------- G4ProcessManager -----------------
//
// Class Description:
//
//
// ------------------------------------------------------------
// GEANT 4 class header file
//
// History: first implementation, based on object model of
// 2nd December 1995, G.Cosmo
// ---------------- G4ProcessManager -----------------
// Class Description
// It collects all physics a particle can undertake as seven vectors.
// These vectors are
// G4ProcessManager collects all physics a particle can undertake as
// vectors. These vectors are:
// one vector for all processes (called as "process List")
// two vectors for processes with AtRestGetPhysicalInteractionLength
// and AtRestDoIt
// two vectors for processes with AlongStepGetPhysicalInteractionLength
// and AlongStepDoIt
// two vectors for processes with PostStepGetPhysicalInteractionLength
// and PostStepDoIt
// The tracking will message three types of GetPhysicalInteractionLength
// two vectors for processes with AtRestGetPhysicalInteractionLength()
// and AtRestDoIt()
// two vectors for processes with AlongStepGetPhysicalInteractionLength()
// and AlongStepDoIt()
// two vectors for processes with PostStepGetPhysicalInteractionLength()
// and PostStepDoIt()
// The tracking will message three types of GetPhysicalInteractionLength()
// in order to limit the Step and select the occurrence of processes.
// It will message the corresponding DoIt() to apply the selected
// processes. In addition, the Tracking will limit the Step
@@ -51,26 +45,22 @@
// processes at rest, for which the Tracking will select the
// occurrence of the process which returns the shortest mean
// life-time from the GetPhysicalInteractionLength()).
//
// History:
// revised by G.Cosmo, 06 May 1996
// Added vector of processes at rest, 06 May 1996
// ------------------------------------------------------------
// New Physics scheme 8 Jan. 1997 H.Kurahige
// Add SetProcessOrdering methods 27 Mar 1998 H.Kurahige
// Add copy constructor (deep copy) 28 June 1998 H.Kurashige
// Add GetProcessActivation 3 May. 1999 H.Kurashige
// Use STL vector instead of RW vector 1. Mar 00 H.Kurashige
// Modify G4ProcessVectorOrdering to fix FindInsedrtPosition 15 Feb. 2005
// Add
// ------------------------------------------------------------
#ifndef G4ProcessManager_h
#define G4ProcessManager_h 1
// - First implementation, based on object model of
// 2nd December 1995, G.Cosmo
// - Revised; added vector of processes at rest
// 06 May 1996, G.Cosmo
// --------------------------------------------------------------------
// - New Physics scheme - 08.01.1997, H.Kurashige
// - Use STL vector instead of RW vector - 01.03.2000, H.Kurashige
// --------------------------------------------------------------------
#ifndef G4ProcessManager_hh
#define G4ProcessManager_hh 1
#include <vector>
#include "globals.hh"
#include "G4ios.hh"
#include <vector>
#include "G4VProcess.hh"
#include "G4ProcessVector.hh"
@@ -82,29 +72,28 @@ class G4ProcessAttribute;
// Indexes for ProcessVector
enum G4ProcessVectorTypeIndex
{
typeGPIL = 0, // for GetPhysicalInteractionLength
typeDoIt =1 // for DoIt
typeGPIL = 0, // for GetPhysicalInteractionLength
typeDoIt =1 // for DoIt
};
enum G4ProcessVectorDoItIndex
{
idxAll = -1, // for all DoIt/GPIL
idxAtRest = 0, // for AtRestDoIt/GPIL
idxAlongStep = 1, // for AlongStepDoIt/GPIL
idxPostStep =2, // for AlongSTepDoIt/GPIL
NDoit =3
idxAll = -1, // for all DoIt/GPIL
idxAtRest = 0, // for AtRestDoIt/GPIL
idxAlongStep = 1, // for AlongStepDoIt/GPIL
idxPostStep =2, // for AlongSTepDoIt/GPIL
NDoit =3
};
// enumeration for Ordering Parameter
enum G4ProcessVectorOrdering
{
ordInActive = -1, // ordering parameter to indicate InActive DoIt
ordDefault = 1000, // default ordering parameter
ordLast = 9999 // ordering parameter to indicate the last DoIt
ordInActive = -1, // ordering parameter to indicate InActive DoIt
ordDefault = 1000, // default ordering parameter
ordLast = 9999 // ordering parameter to indicate the last DoIt
};
class G4ProcessManager
{
public:
// copy constructor
G4ProcessManager(G4ProcessManager &right);
@@ -138,26 +127,26 @@ class G4ProcessManager
// --------------------------------------
G4ProcessVector* GetProcessVector(
G4ProcessVectorDoItIndex idx,
G4ProcessVectorTypeIndex typ = typeGPIL
) const;
G4ProcessVectorDoItIndex idx,
G4ProcessVectorTypeIndex typ = typeGPIL
) const;
// Returns the address of the vector of processes
G4ProcessVector* GetAtRestProcessVector(
G4ProcessVectorTypeIndex typ = typeGPIL
G4ProcessVectorTypeIndex typ = typeGPIL
) const;
// Returns the address of the vector of processes for
// AtRestGetPhysicalInteractionLength idx =0
// AtRestGetPhysicalDoIt idx =1
G4ProcessVector* GetAlongStepProcessVector(
G4ProcessVectorTypeIndex typ = typeGPIL
G4ProcessVectorTypeIndex typ = typeGPIL
) const;
// Returns the address of the vector of processes for
// AlongStepGetPhysicalInteractionLength idx =0
// AlongStepGetPhysicalDoIt idx =1
G4ProcessVector* GetPostStepProcessVector(
G4ProcessVectorTypeIndex typ = typeGPIL
G4ProcessVectorTypeIndex typ = typeGPIL
) const;
// Returns the address of the vector of processes for
// PostStepGetPhysicalInteractionLength idx =0
@@ -165,21 +154,21 @@ class G4ProcessManager
G4int GetProcessVectorIndex(
G4VProcess* aProcess,
G4ProcessVectorDoItIndex idx,
G4ProcessVectorTypeIndex typ = typeGPIL
) const;
G4ProcessVectorDoItIndex idx,
G4ProcessVectorTypeIndex typ = typeGPIL
) const;
G4int GetAtRestIndex(
G4VProcess* aProcess,
G4ProcessVectorTypeIndex typ = typeGPIL
) const;
G4ProcessVectorTypeIndex typ = typeGPIL
) const;
G4int GetAlongStepIndex(
G4VProcess* aProcess,
G4ProcessVectorTypeIndex typ = typeGPIL
) const;
G4ProcessVectorTypeIndex typ = typeGPIL
) const;
G4int GetPostStepIndex(
G4VProcess* aProcess,
G4ProcessVectorTypeIndex typ = typeGPIL
) const;
G4VProcess* aProcess,
G4ProcessVectorTypeIndex typ = typeGPIL
) const;
// Returns the index for GPIL/DoIt process vector of the process
G4int AddProcess(
@@ -220,14 +209,14 @@ class G4ProcessManager
// Note: AddProcess method should precede these methods
G4int GetProcessOrdering(
G4VProcess *aProcess,
G4ProcessVectorDoItIndex idDoIt
G4VProcess *aProcess,
G4ProcessVectorDoItIndex idDoIt
);
void SetProcessOrdering(
G4VProcess *aProcess,
G4ProcessVectorDoItIndex idDoIt,
G4int ordDoIt = ordDefault
G4VProcess *aProcess,
G4ProcessVectorDoItIndex idDoIt,
G4int ordDoIt = ordDefault
);
// Set ordering parameter for DoIt specified by typeDoIt.
// If a process with same ordering parameter exists,
@@ -237,18 +226,18 @@ class G4ProcessManager
// even if you set ordDoIt = 0
void SetProcessOrderingToFirst(
G4VProcess *aProcess,
G4ProcessVectorDoItIndex idDoIt
);
G4VProcess *aProcess,
G4ProcessVectorDoItIndex idDoIt
);
// Set ordering parameter to the first of all processes
// for DoIt specified by idDoIt.
// Note: If you use this method for two processes,
// a process called later will be first.
void SetProcessOrderingToSecond(
G4VProcess *aProcess,
G4ProcessVectorDoItIndex idDoIt
);
G4VProcess *aProcess,
G4ProcessVectorDoItIndex idDoIt
);
// Set ordering parameter to 1 for DoIt specified by idDoIt
// and the rpocess will be added just after
// the processes with ordering parameter equal to zero
@@ -256,9 +245,9 @@ class G4ProcessManager
// a process called later will be .
void SetProcessOrderingToLast(
G4VProcess *aProcess,
G4ProcessVectorDoItIndex idDoIt
);
G4VProcess *aProcess,
G4ProcessVectorDoItIndex idDoIt
);
// Set ordering parameter to the last of all processes
// for DoIt specified by idDoIt.
// Note: If you use this method for two processes,
@@ -317,7 +306,7 @@ class G4ProcessManager
// in theProcVector[ivec]
G4int GetProcessVectorId(G4ProcessVectorDoItIndex idx,
G4ProcessVectorTypeIndex typ = typeGPIL) const;
G4ProcessVectorTypeIndex typ = typeGPIL) const;
void CheckOrderingParameters(G4VProcess*) const;
// check consistencies between ordering parameters and
@@ -365,7 +354,7 @@ class G4ProcessManager
static G4ThreadLocal G4ProcessManagerMessenger* fProcessManagerMessenger;
static G4ThreadLocal G4int counterOfObjects;
};
#include "G4ProcessManager.icc"
#endif
@@ -23,13 +23,9 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
//
// G4ProcessManager inline function members implementation
// --------------------------------------------------------------------
// -----------------------------------------
// inlined function members implementation
// -----------------------------------------
inline
void G4ProcessManager::SetParticleType(const G4ParticleDefinition* aParticle)
{
@@ -51,7 +47,7 @@ inline
inline
G4int G4ProcessManager::GetProcessIndex(G4VProcess* aProcess) const
{
G4int idx = theProcessList->index(aProcess);
G4int idx = G4int(theProcessList->index(aProcess));
if (idx>=numberOfProcesses) idx = -1;
return idx;
}
@@ -81,32 +77,38 @@ inline
) const
{
G4int ivec = GetProcessVectorId(idx, typ);
if ( ivec >=0 ) {
if ( ivec >=0 )
{
return theProcVector[ivec];
} else {
return 0;
}
else
{
return nullptr;
}
}
inline
G4ProcessVector* G4ProcessManager::GetAtRestProcessVector(G4ProcessVectorTypeIndex typ) const
G4ProcessVector*
G4ProcessManager::GetAtRestProcessVector(G4ProcessVectorTypeIndex typ) const
{
if (typ == typeGPIL) { return theProcVector[0]; }
else { return theProcVector[1]; }
else { return theProcVector[1]; }
}
inline
G4ProcessVector* G4ProcessManager::GetAlongStepProcessVector(G4ProcessVectorTypeIndex typ) const
G4ProcessVector*
G4ProcessManager::GetAlongStepProcessVector(G4ProcessVectorTypeIndex typ) const
{
if (typ == typeGPIL) { return theProcVector[2]; }
else { return theProcVector[3]; }
else { return theProcVector[3]; }
}
inline
G4ProcessVector* G4ProcessManager::GetPostStepProcessVector(G4ProcessVectorTypeIndex typ) const
G4ProcessVector*
G4ProcessManager::GetPostStepProcessVector(G4ProcessVectorTypeIndex typ) const
{
if (typ == typeGPIL) { return theProcVector[4]; }
else { return theProcVector[5]; }
else { return theProcVector[5]; }
}
inline
@@ -137,19 +139,19 @@ inline
}
inline
G4int G4ProcessManager::AddRestProcess(G4VProcess *aProcess,G4int ord)
G4int G4ProcessManager::AddRestProcess(G4VProcess* aProcess, G4int ord)
{
return AddProcess(aProcess, ord, ordInActive, ordInActive);
}
inline
G4int G4ProcessManager::AddContinuousProcess(G4VProcess *aProcess,G4int ord)
G4int G4ProcessManager::AddContinuousProcess(G4VProcess* aProcess, G4int ord)
{
return AddProcess(aProcess, ordInActive, ord, ordInActive);
}
inline
G4int G4ProcessManager::AddDiscreteProcess(G4VProcess *aProcess,G4int ord)
G4int G4ProcessManager::AddDiscreteProcess(G4VProcess* aProcess, G4int ord)
{
return AddProcess(aProcess, ordInActive, ordInActive, ord);
}
@@ -160,7 +162,6 @@ inline
return (G4ParticleDefinition* )theParticleType;
}
inline
void G4ProcessManager::SetVerboseLevel(G4int value)
{
@@ -172,4 +173,3 @@ inline
{
return verboseLevel;
}
@@ -52,11 +52,16 @@
#include "G4ProcTblElement.hh"
#include "G4ProcessVector.hh"
#include "G4ThreadLocalSingleton.hh"
class G4UImessenger;
class G4ProcessTableMessenger;
class G4ProcessTable
{
friend class G4ThreadLocalSingleton<G4ProcessTable>;
public:
G4ProcessTable();
// Constructors
@@ -153,13 +158,7 @@ class G4ProcessTable
void DumpInfo(G4VProcess* process, G4ParticleDefinition* particle=0);
// dump out information of the process table
// second argument is used to specify processes designated by a particle
public: // with description
G4UImessenger* CreateMessenger();
void DeleteMessenger();
// These methods are used by RunManager to let the process table
// know the timing of creation/destructuion of messengers
public: // with description
void SetVerboseLevel(G4int value);
G4int GetVerboseLevel() const;
@@ -23,11 +23,10 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// G4ProcessTable inline methods implementation
//
//
// History:
// Use STL vector instead of RW vector 1. Mar 00 H.Kurashige
//
// Author: H.Kurashige
// --------------------------------------------------------------------
#include "G4ParticleTable.hh"
//////////////////////////
@@ -48,12 +47,12 @@ inline
inline
G4int G4ProcessTable::Length() const
{
return fProcTblVector->size();
return G4int(fProcTblVector->size());
}
//////////////////////////
inline
G4ProcessTable::G4ProcNameVector* G4ProcessTable::GetNameList()
G4ProcessTable::G4ProcNameVector* G4ProcessTable::GetNameList()
{
return fProcNameVector;
}
@@ -65,81 +64,82 @@ inline
return fProcTblVector;
}
//////////////////////////
inline
G4VProcess* G4ProcessTable::FindProcess(const G4String& processName,
const G4ParticleDefinition* particle)
const
const G4ParticleDefinition* particle) const
{
if ( particle == 0 ) return 0;
else return FindProcess(processName, particle->GetProcessManager());
if ( particle == 0 )
return nullptr;
else
return FindProcess(processName, particle->GetProcessManager());
}
//////////////////////////
inline
G4VProcess* G4ProcessTable::FindProcess(const G4String& processName,
const G4String& particleName) const
const G4String& particleName) const
{
return FindProcess(processName,
G4ParticleTable::GetParticleTable()->FindParticle(particleName));
G4ParticleTable::GetParticleTable()->FindParticle(particleName));
}
//////////////////////////
inline
void G4ProcessTable::SetProcessActivation(
const G4String& processName,
G4ParticleDefinition* particle,
G4bool fActive)
{
if ( particle != 0 ) {
SetProcessActivation(processName, particle->GetProcessManager(), fActive);
}
}
void G4ProcessTable::SetProcessActivation(const G4String& processName,
G4ParticleDefinition* particle,
G4bool fActive)
{
if ( particle != nullptr )
{
SetProcessActivation(processName, particle->GetProcessManager(), fActive);
}
}
//////////////////////////
inline
void G4ProcessTable::SetProcessActivation(
const G4String& processName,
const G4String& particleName,
G4bool fActive )
void G4ProcessTable::SetProcessActivation(const G4String& processName,
const G4String& particleName,
G4bool fActive )
{
if (particleName == "ALL" ) {
if (particleName == "ALL" )
{
SetProcessActivation( processName , fActive);
} else {
SetProcessActivation(
processName,
G4ParticleTable::GetParticleTable()->FindParticle(particleName),
fActive );
}
else
{
SetProcessActivation(processName,
G4ParticleTable::GetParticleTable()->FindParticle(particleName),
fActive );
}
}
//////////////////////////
inline
void G4ProcessTable::SetProcessActivation(
G4ProcessType processType,
G4ParticleDefinition* particle,
G4bool fActive)
{
if ( particle != 0 ) {
SetProcessActivation( processType, particle->GetProcessManager(), fActive);
}
}
void G4ProcessTable::SetProcessActivation(G4ProcessType processType,
G4ParticleDefinition* particle,
G4bool fActive)
{
if ( particle != nullptr )
{
SetProcessActivation( processType, particle->GetProcessManager(), fActive);
}
}
//////////////////////////
inline
void G4ProcessTable::SetProcessActivation(
G4ProcessType processType,
const G4String& particleName ,
G4bool fActive)
void G4ProcessTable::SetProcessActivation(G4ProcessType processType,
const G4String& particleName ,
G4bool fActive)
{
if ((particleName == "ALL" )||(particleName == "all" )) {
if ((particleName == "ALL" )||(particleName == "all" ))
{
SetProcessActivation( processType, fActive );
} else {
SetProcessActivation(
processType,
G4ParticleTable::GetParticleTable()->FindParticle(particleName),
fActive );
}
else
{
SetProcessActivation(processType,
G4ParticleTable::GetParticleTable()->FindParticle(particleName),
fActive );
}
}
@@ -23,18 +23,16 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// G4ProcessVector
//
//
// ------------------------------------------------------------
// GEANT 4 class header file
//
// Class Description
// This class is a container for pointers to physics process objects.
// ------------------------------------------------------------
//
// This class is a container for pointers to physics process objects.
#ifndef G4ProcessVector_h
#define G4ProcessVector_h 1
// --------------------------------------------------------------------
#ifndef G4ProcessVector_hh
#define G4ProcessVector_hh 1
#include "globals.hh"
#include "G4ios.hh"
@@ -45,6 +43,7 @@ class G4VProcess;
class G4ProcessVector
{
public:
// Constructors
G4ProcessVector();
explicit G4ProcessVector(size_t);
@@ -53,20 +52,21 @@ class G4ProcessVector
// Destructor.
virtual ~G4ProcessVector();
//assignment operator
// assignment operator
G4ProcessVector & operator=(const G4ProcessVector &right);
// equal operator
// equality operator
G4bool operator==(const G4ProcessVector &right) const;
public: // With Description
// Returns the number of items
G4int entries() const;
G4int length() const;
G4int size() const;
size_t entries() const;
size_t length() const;
size_t size() const;
// Returns the position of the element
G4int index(G4VProcess* aProcess) const;
size_t index(G4VProcess* aProcess) const;
// Returns "true" if the element exists
G4bool contains(G4VProcess* aProcess) const;
@@ -95,7 +95,7 @@ class G4ProcessVector
G4VProcess* & operator()(G4int i);
protected:
// Use STL Vector
typedef std::vector<G4VProcess*> G4ProcVector;
G4ProcVector * pProcVector;
@@ -104,20 +104,3 @@ class G4ProcessVector
#include "G4ProcessVector.icc"
#endif
@@ -23,29 +23,31 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// G4ProcessVector inline methods implementation
//
//
// --------------------------------------------------------------------
inline G4bool G4ProcessVector::operator==(const G4ProcessVector &right) const
{
return (this == (G4ProcessVector *) &right);
}
inline G4int G4ProcessVector::entries() const
inline size_t G4ProcessVector::entries() const
{
return pProcVector->size();
}
inline G4int G4ProcessVector::size() const
inline size_t G4ProcessVector::size() const
{
return pProcVector->size();
}
inline G4int G4ProcessVector::length() const
inline size_t G4ProcessVector::length() const
{
return pProcVector->size();
}
inline G4int G4ProcessVector::index(G4VProcess* aProcess) const
inline size_t G4ProcessVector::index(G4VProcess* aProcess) const
{
G4ProcVector::iterator it;
size_t j=0;
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);
}
}