44 G4ProcessManager::fProcessManagerMessenger =
nullptr;
49 : theParticleType(aParticleType)
53 if ( theProcessList ==
nullptr)
55 G4Exception(
"G4ProcessManager::G4ProcessManager()",
"ProcMan012",
63 if ( theProcVector[i] ==
nullptr)
65 G4Exception(
"G4ProcessManager::G4ProcessManager()",
"ProcMan012",
71 theAttrVector =
new G4ProcessAttrVector();
74 if (fProcessManagerMessenger ==
nullptr)
81 isSetOrderingFirstInvoked[i] =
false;
82 isSetOrderingLastInvoked[i] =
false;
91 : theParticleType(right.theParticleType),
92 verboseLevel(right.verboseLevel)
97 G4cout <<
"G4ProcessManager::G4ProcessManager() [copy constructor]"
104 theAttrVector =
new G4ProcessAttrVector();
105 if ( ( theProcessList ==
nullptr) || (theAttrVector ==
nullptr) )
107 G4Exception(
"G4ProcessManager::G4ProcessManager() [copy constructor]",
111 for (
G4int idx=0; idx < right.numberOfProcesses; ++idx)
114 theProcessList->
insert((*right.theProcessList)[idx]);
119 theAttrVector->push_back(dAttr);
128 if ( theProcVector[i] ==
nullptr )
130 G4Exception(
"G4ProcessManager::G4ProcessManager() [copy constructor]",
136 for (std::size_t j=0; j< src->
entries() ; ++j)
139 theProcVector[i]->
insert((*src)[j]);
141 if ( (*src)[j] !=
nullptr )
143 theProcessTable->
Insert((*src)[j],
this);
150 isSetOrderingFirstInvoked[i]= right.isSetOrderingFirstInvoked[i];
151 isSetOrderingLastInvoked[i] = right.isSetOrderingLastInvoked[i];
163 if (theProcVector[i])
165 theProcVector[i]->
clear();
166 delete theProcVector[i];
169 theProcessList->
clear();
170 delete theProcessList;
172 for (
auto itr = theAttrVector->cbegin(); itr!= theAttrVector->cend(); ++itr)
176 theAttrVector->clear();
177 delete theAttrVector;
182 if ( counterOfObjects == 0 )
184 delete fProcessManagerMessenger;
185 fProcessManagerMessenger =
nullptr;
189 G4cout <<
"G4ProcessManagerMessenger is deleted" <<
G4endl;
204 G4int ivec = GetProcessVectorId(idx, typ);
206 if ( ( idxProc >=0) && (ivec >=0) )
215 G4cout <<
" G4ProcessManager::GetProcessVectorIndex:";
221 G4cout <<
" is not registered yet ";
225 G4cout <<
" illegal DoIt Index [= " <<
G4int(idx) <<
","
226 <<
G4int(typ) <<
"]";
239 if ((index<0) || (index>=numberOfProcesses))
244 G4cout <<
"G4ProcessManager::GetAttribute():";
248 G4cout <<
" #processes[" << numberOfProcesses <<
"]";
256 G4VProcess* aProcess = (*theProcessList)[index];
257 if (aProcess ==
nullptr)
259 G4String aErrorMessage(
"Bad ProcessList: Null Pointer for ");
261 G4Exception(
"G4ProcessManager::GetAttribute()",
"ProcMan012",
267 if ( ((*theAttrVector)[index])->idxProcessList == index )
269 return (*theAttrVector)[index];
278 G4cout <<
"G4ProcessManager::GetAttribute():";
281 G4cout <<
"Warning: attribute vector index is inconsistent"
282 <<
" with process List index"
288 for (
auto itr = theAttrVector->cbegin(); itr!= theAttrVector->cend(); ++itr)
290 if ( (*itr)->idxProcessList == index)
311 if ( (ip<0) || (ip >
G4int(pVector->
entries())) )
return -1;
317 for (
G4int iproc=0; iproc<numberOfProcesses; ++iproc)
320 if (aAttr !=
nullptr)
332 G4cout <<
" G4ProcessManager::InsertAt : No Process Attribute "
347 if ( (ip<0) || (ip >=
G4int(pVector->
entries())) )
return -1;
353 for(
G4int iproc=0; iproc<numberOfProcesses; ++iproc)
356 if (aAttr !=
nullptr)
358 if (ip < aAttr->idxProcVector[ivec])
373 G4cout <<
" G4ProcessManager::RemoveAt(): No Process Attribute "
391 for (
G4int iproc=0; iproc<numberOfProcesses; ++iproc)
408 G4int ordAlongStepDoIt,
409 G4int ordPostStepDoIt
419 G4cout <<
"This process is not applicable to this particle" <<
G4endl;
434 theProcessTable->
Insert(aProcess,
this);
437 theProcessList->
insert(aProcess);
441 if (numberOfProcesses != idx)
444 G4String anErrorMessage(
"Inconsistent process List size for ");
446 anErrorMessage +=
" particle[" + theParticleType->
GetParticleName() +
"]";
447 G4Exception(
"G4ProcessManager::AddProcess()",
"ProcMan012",
457 if (ordAtRestDoIt==0) ordAtRestDoIt = 1;
458 if (ordAlongStepDoIt==0) ordAlongStepDoIt = 1;
459 if (ordPostStepDoIt==0) ordPostStepDoIt = 1;
484 InsertAt(ip, aProcess, ivec);
493 G4cout <<
" in ProcessVetor[" << ivec<<
"]";
494 G4cout <<
" with Ordering parameter = " ;
502 theAttrVector->push_back(pAttr);
504 numberOfProcesses += 1;
507 CheckOrderingParameters(aProcess);
522 if (pAttr ==
nullptr)
return nullptr;
525 G4VProcess* removedProcess = (*theProcessList)[index];
527 if (!(pAttr->
isActive)) { ActivateProcess(index);}
536 if (RemoveAt(idx, removedProcess, ivec) <0)
538 G4String anErrorMessage(
"Bad index in attribute");
539 anErrorMessage +=
"for particle["
541 anErrorMessage +=
"process["
543 G4Exception(
"G4ProcessManager::RemoveProcess()",
"Fatal Error",
555 G4String anErrorMessage(
"Bad ProcessList: Index is out of range ");
556 anErrorMessage +=
"for particle[" + theParticleType->
GetParticleName() +
"] ";
557 anErrorMessage +=
"process[" + removedProcess->
GetProcessName() +
"] " ;
558 G4Exception(
"G4ProcessManager::RemoveProcess()",
"ProcMan012",
566 for (
auto itr = theAttrVector->cbegin(); itr!= theAttrVector->cend(); ++itr)
568 if ( (*itr) == pAttr)
570 theAttrVector->erase(itr);
578 for(
G4int i=0; i<numberOfProcesses; ++i)
588 theProcessTable->
Remove(removedProcess,
this);
590 return removedProcess;
611 if (pAttr !=
nullptr)
626 const G4String aErrorMessage(
"G4ProcessManager::SetProcessOrdering() - ");
647 G4cout <<
" illegal DoIt Index [= " <<
G4int(idDoIt) <<
"]";
657 if (pAttr ==
nullptr)
668 RemoveAt(ip, aProcess, ivec);
672 if (ordDoIt == 0) ordDoIt = 1;
682 InsertAt(ip, aProcess, ivec);
692 G4cout <<
" in ProcessVetor[" << ivec<<
"]";
693 G4cout <<
" with Ordering parameter = " << ordDoIt ;
700 CheckOrderingParameters(aProcess);
719 G4cout <<
"G4ProcessManager::SetProcessOrderingToFirst(): ";
720 G4cout <<
" illegal DoIt Index [= " <<
G4int(idDoIt) <<
"]";
729 if (pAttr ==
nullptr)
740 RemoveAt(ip, aProcess, ivec);
748 InsertAt(0, aProcess, ivec);
756 G4cout <<
"G4ProcessManager::SetProcessOrderingToFirst(): ";
758 G4cout <<
" in ProcessVetor[" << ivec<<
"]";
764 if (isSetOrderingFirstInvoked[idDoIt])
766 G4String anErrMsg =
"Set Ordering First is invoked twice for ";
770 G4Exception(
"G4ProcessManager::SetProcessOrderingToFirst()",
773 isSetOrderingFirstInvoked[idDoIt] =
true;
776 CheckOrderingParameters(aProcess);
788 const G4String aErrorMessage(
"G4ProcessManager::SetProcessOrderingToSecond() - ");
809 G4cout <<
" illegal DoIt Index [= " <<
G4int(idDoIt) <<
"]";
818 if (pAttr ==
nullptr)
829 RemoveAt(ip, aProcess, ivec);
843 for (
G4int iproc=0; iproc<numberOfProcesses; ++iproc)
861 InsertAt(ip, aProcess, ivec);
872 G4cout <<
" in ProcessVetor[" << ivec<<
"]";
873 G4cout <<
" with Ordering parameter = 1 ";
879 CheckOrderingParameters(aProcess);
893 if (isSetOrderingLastInvoked[idDoIt])
895 G4String anErrMsg =
"Set Ordering Last is invoked twice for ";
899 G4Exception(
"G4ProcessManager::SetProcessOrderingToLast()",
"ProcMan114",
902 isSetOrderingLastInvoked[idDoIt] =
true;
915 G4cout <<
"G4ProcessManager::InActivateProcess is not valid in ";
932 if (pAttr ==
nullptr)
return nullptr;
935 G4VProcess* pProcess = (*theProcessList)[index];
937 const G4String aErrorMessage(
"G4ProcessManager::InactivateProcess() - ");
951 else if ((idx >= 0) && (idx <
G4int(pVector->
entries())))
954 if ((*pVector)[idx]== pProcess)
956 (*pVector)[idx]=
nullptr;
960 G4String anErrorMessage(
"Bad ProcessList: Bad index in attribute");
961 anErrorMessage +=
"for particle[" + theParticleType->
GetParticleName() +
"] ";
962 anErrorMessage +=
"process[" + pProcess->
GetProcessName() +
"] " ;
963 G4Exception(
"G4ProcessManager::InactivateProcess()",
"ProcMan012",
971 G4String anErrorMessage(
"Bad ProcessList: Index is out of range");
972 anErrorMessage +=
"for particle[" + theParticleType->
GetParticleName() +
"] ";
973 anErrorMessage +=
"process[" + pProcess->
GetProcessName() +
"] " ;
974 G4Exception(
"G4ProcessManager::InactivateProcess()",
"ProcMan012",
994 G4cout <<
"G4ProcessManager::ActivateProcess() is not valid in ";
1011 if (pAttr ==
nullptr)
return nullptr;
1014 G4VProcess* pProcess = (*theProcessList)[index];
1027 else if ((idx >= 0) && (idx <
G4int(pVector->
entries())))
1030 if ((*pVector)[idx] ==
nullptr)
1032 (*pVector)[idx] = pProcess;
1036 G4String anErrorMessage(
"Bad ProcessList: Bad index in attribute");
1037 anErrorMessage +=
"for particle[" + theParticleType->
GetParticleName() +
"] ";
1038 anErrorMessage +=
"process[" + pProcess->
GetProcessName() +
"] " ;
1039 G4Exception(
"G4ProcessManager::ActivateProcess()",
"ProcMan012",
1047 G4String anErrorMessage(
"bad ProcessList: Index is out of range");
1048 anErrorMessage +=
"for particle["
1050 anErrorMessage +=
"process[" + pProcess->
GetProcessName() +
"] " ;
1051 G4Exception(
"G4ProcessManager::ActivateProcess()",
"ProcMan012",
1064 return (
this == &right);
1070 return (
this != &right);
1079 G4cout <<
"G4ProcessManager: particle["
1084 for (std::size_t idx=0; idx < theProcessList->
entries(); ++idx)
1087 G4cout <<
"[" << idx <<
"]";
1088 G4cout <<
"=== process[" << ((*theProcessList)(idx))->GetProcessName()
1096 if ( pAttr-> isActive )
1110 G4cout <<
" Ordering:: ";
1111 G4cout <<
" AtRest AlongStep PostStep ";
1114 G4cout <<
" GetPIL/ DoIt GetPIL/ DoIt GetPIL/ DoIt ";
1118 for (
G4int idx2 = 0; idx2 <6 ; ++idx2)
1124 for (
G4int idx3 = 0; idx3 <6 ; ++idx3)
1135void G4ProcessManager::CreateGPILvectors()
1140 for(std::size_t k=0; k<theProcessList->
entries(); ++k)
1153 for(
G4int j=nproc-1;j>=0;--j)
1165 for (std::size_t idx = 0; idx<theProcessList->
entries(); ++idx)
1167 if (GetAttribute(idx)->isActive)
1170 if(aTrack) duringTracking =
true;
1176 for (std::size_t idx = 0; idx<theProcessList->
entries(); ++idx)
1178 if (GetAttribute(idx)->isActive)
1181 duringTracking =
false;
1187 for (
G4int k=0; k<numberOfProcesses; ++k)
1205 if (fActive)
return ActivateProcess(index);
1206 else return InActivateProcess(index);
1223 G4cout <<
"G4ProcessManager::GetProcessActivation ";
1224 G4cout <<
" process (or its index) not found ";
1236void G4ProcessManager::CheckOrderingParameters(
G4VProcess* aProcess)
const
1238 if (aProcess ==
nullptr)
return;
1240 if (pAttr ==
nullptr)
1245 G4cout <<
"G4ProcessManager::CheckOrderingParameters()" <<
G4endl;
1247 <<
" has no attribute" <<
G4endl;
1261 G4cerr <<
"G4ProcessManager::CheckOrderingParameters()" <<
G4endl;
1262 G4cerr <<
"You cannot set ordering parameter ["
1264 <<
"] for AtRest DoIt to the process "
1276 G4cerr <<
"G4ProcessManager::CheckOrderingParameters()" <<
G4endl;
1277 G4cerr <<
"You cannot set ordering parameter ["
1279 <<
"] for AlongStep DoIt to the process "
1292 G4cerr <<
"G4ProcessManager::CheckOrderingParameters()" <<
G4endl;
1293 G4cerr <<
"You cannot set ordering parameter ["
1295 <<
"] for PostStep DoIt to the process"
1305 msg =
"Invalid ordering parameters are set for ";
1307 G4Exception(
"G4ProcessManager::CheckOrderingParameters()",
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
G4GLOB_DLL std::ostream G4cerr
G4GLOB_DLL std::ostream G4cout
const G4String & GetParticleName() const
G4int ordProcVector[G4ProcessManager::SizeOfProcVectorArray]
G4int idxProcVector[G4ProcessManager::SizeOfProcVectorArray]
void SetProcessOrdering(G4VProcess *aProcess, G4ProcessVectorDoItIndex idDoIt, G4int ordDoIt=ordDefault)
G4VProcess * GetProcess(const G4String &) const
G4VProcess * SetProcessActivation(G4VProcess *aProcess, G4bool fActive)
G4ProcessManager()=delete
G4int GetProcessVectorIndex(G4VProcess *aProcess, G4ProcessVectorDoItIndex idx, G4ProcessVectorTypeIndex typ=typeGPIL) const
G4int GetProcessOrdering(G4VProcess *aProcess, G4ProcessVectorDoItIndex idDoIt)
void SetProcessOrderingToSecond(G4VProcess *aProcess, G4ProcessVectorDoItIndex idDoIt)
G4bool GetProcessActivation(G4VProcess *aProcess) const
G4int GetProcessIndex(G4VProcess *) const
G4bool operator==(const G4ProcessManager &right) const
G4VProcess * RemoveProcess(G4VProcess *aProcess)
G4int AddProcess(G4VProcess *aProcess, G4int ordAtRestDoIt=ordInActive, G4int ordAlongSteptDoIt=ordInActive, G4int ordPostStepDoIt=ordInActive)
void SetProcessOrderingToLast(G4VProcess *aProcess, G4ProcessVectorDoItIndex idDoIt)
G4int GetVerboseLevel() const
G4bool operator!=(const G4ProcessManager &right) const
void SetProcessOrderingToFirst(G4VProcess *aProcess, G4ProcessVectorDoItIndex idDoIt)
void StartTracking(G4Track *aTrack=nullptr)
static G4ProcessTable * GetProcessTable()
G4int Insert(G4VProcess *aProcess, G4ProcessManager *aProcMgr)
G4int Remove(G4VProcess *aProcess, G4ProcessManager *aProcMgr)
std::size_t entries() const
G4bool insertAt(G4int i, G4VProcess *aProcess)
G4bool insert(G4VProcess *aProcess)
G4VProcess * removeLast()
G4VProcess * removeAt(G4int i)
const G4ApplicationState & GetCurrentState() const
static G4StateManager * GetStateManager()
static const G4String & GetProcessTypeName(G4ProcessType)
virtual G4bool IsApplicable(const G4ParticleDefinition &)
G4bool isAtRestDoItIsEnabled() const
G4bool isPostStepDoItIsEnabled() const
G4bool isAlongStepDoItIsEnabled() const
virtual void SetProcessManager(const G4ProcessManager *)
const G4String & GetProcessName() const