61 theParticleType(aParticleType),
63 duringTracking(false),
68 if ( theProcessList == 0) {
69 G4Exception(
"G4ProcessManager::G4ProcessManager()",
"ProcMan012",
76 if ( theProcVector[i] == 0) {
77 G4Exception(
"G4ProcessManager::G4ProcessManager()",
"ProcMan012",
83 theAttrVector =
new G4ProcessAttrVector();
86 if (fProcessManagerMessenger == 0){
91 isSetOrderingFirstInvoked[i]=
false;
92 isSetOrderingLastInvoked[i]=
false;
101 : theParticleType(right.theParticleType),
102 numberOfProcesses(0),
103 duringTracking(false),
104 verboseLevel(right.verboseLevel)
108 G4cout <<
"G4ProcessManageer:: copy constructor " <<
G4endl;
114 theAttrVector =
new G4ProcessAttrVector();
115 if ( ( theProcessList == 0) || (theAttrVector == 0) ){
116 G4Exception(
"G4ProcessManager::G4ProcessManager() [coopy constructor]",
120 for (
G4int idx=0; idx < right.numberOfProcesses; idx++) {
122 theProcessList->
insert((*right.theProcessList)[idx]);
127 theAttrVector->push_back(dAttr);
128 numberOfProcesses +=1;
136 if ( theProcVector[i] == 0) {
137 G4Exception(
"G4ProcessManager::G4ProcessManager() [coopy constructor]",
145 theProcVector[i]->
insert((*src)[j]);
147 if ( (*src)[j] !=0 ) {
148 theProcessTable->
Insert((*src)[j],
this);
154 isSetOrderingFirstInvoked[i]= right.isSetOrderingFirstInvoked[i];
155 isSetOrderingLastInvoked[i] = right.isSetOrderingLastInvoked[i];
163 G4ProcessManager::G4ProcessManager():
165 numberOfProcesses(0),
166 duringTracking(false),
173 G4Exception(
"G4ProcessManager::G4ProcessManager()",
"ProcMan111",
182 isSetOrderingFirstInvoked[i]=
false;
183 isSetOrderingLastInvoked[i]=
false;
194 G4Exception(
"G4ProcessManager::operator=",
"ProcMan112",
204 if (theProcVector[i]) {
205 theProcVector[i]->
clear();
206 delete theProcVector[i];
209 theProcessList->
clear();
210 delete theProcessList;
212 G4ProcessAttrVector::iterator itr;
213 for (itr = theAttrVector->begin(); itr!= theAttrVector->end(); ++itr) {
216 theAttrVector->clear();
217 delete theAttrVector;
222 if ( counterOfObjects == 0 ){
223 if (fProcessManagerMessenger != 0){
224 delete fProcessManagerMessenger;
225 fProcessManagerMessenger = 0;
228 G4cout <<
"G4ProcessManagerMessenger is deleted" <<
G4endl;
246 if ( ( idxProc >=0) && (ivec >=0) ){
251 G4cout <<
" G4ProcessManager::GetProcessVectorIndex:";
256 G4cout <<
" is not registered yet ";
259 G4cout <<
" illegal DoIt Index [= " <<
G4int(idx) <<
","
260 <<
G4int(typ) <<
"]";
273 if ((index<0) || (index>=numberOfProcesses)) {
276 G4cout <<
"G4ProcessManager::GetAttribute():";
280 G4cout <<
" #processes[" << numberOfProcesses <<
"]";
290 G4String aErrorMessage(
"Bad ProcessList: Null Pointer for");
292 G4Exception(
"G4ProcessManager::GetAttribute()",
"ProcMan012",
298 if ( ((*theAttrVector)[index])->idxProcessList == index ){
299 return (*theAttrVector)[
index];
305 G4cout <<
"G4ProcessManager::GetAttribute():";
308 G4cout <<
"Warning:: attribute vector index is inconsistent with process List index"
314 G4ProcessAttrVector::iterator itr;
315 for (itr = theAttrVector->begin(); itr!= theAttrVector->end(); ++itr) {
316 if ( (*itr)->idxProcessList == index) {
336 if ( (ip<0) || (ip > pVector->
entries()) )
return -1;
342 for (
G4int iproc=0; iproc<numberOfProcesses; iproc++) {
351 G4cout <<
" G4ProcessManager::InsertAt : No Process Attribute " <<
G4endl;
364 if ( (ip<0) || (ip >= pVector->
entries()) )
return -1;
370 for(
G4int iproc=0; iproc<numberOfProcesses; iproc++) {
373 if (ip < aAttr->idxProcVector[ivec]) {
382 G4cout <<
" G4ProcessManager::RemoveAt : No Process Attribute " <<
G4endl;
399 for (
G4int iproc=0; iproc<numberOfProcesses; iproc++) {
413 G4int ordAlongStepDoIt,
414 G4int ordPostStepDoIt
423 G4cout <<
"This process is not applicable to this particle" <<
G4endl;
437 theProcessTable->
Insert(aProcess,
this);
440 theProcessList->
insert(aProcess);
444 if (numberOfProcesses != idx){
446 G4String anErrorMessage(
"Bad ProcessList: Inconsistent process List size for ");
448 anErrorMessage +=
" particle[" + theParticleType->
GetParticleName() +
"]";
449 G4Exception(
"G4ProcessManager::AddProcess()",
"ProcMan012",
459 if (ordAtRestDoIt==0) ordAtRestDoIt = 1;
460 if (ordAlongStepDoIt==0) ordAlongStepDoIt = 1;
461 if (ordPostStepDoIt==0) ordPostStepDoIt = 1;
491 G4cout <<
" in ProcessVetor[" << ivec<<
"]";
492 G4cout <<
" with Ordering parameter = " ;
500 theAttrVector->push_back(pAttr);
502 numberOfProcesses += 1;
521 if (pAttr == 0)
return 0;
526 if (!(pAttr->
isActive)) { ActivateProcess(index);}
531 if ((idx >= 0) && (idx < pVector->entries())) {
533 if (
RemoveAt(idx, removedProcess, ivec) <0) {
534 G4String anErrorMessage(
"Bad index in attribute");
535 anErrorMessage +=
"for particle[" + theParticleType->
GetParticleName() +
"] ";
536 anErrorMessage +=
"process[" + removedProcess->
GetProcessName() +
"] " ;
537 G4Exception(
"G4ProcessManager::RemoveProcess()",
"Fatal Error",
545 G4String anErrorMessage(
"Bad ProcessList : Index is out of range ");
546 anErrorMessage +=
"for particle[" + theParticleType->
GetParticleName() +
"] ";
547 anErrorMessage +=
"process[" + removedProcess->
GetProcessName() +
"] " ;
548 G4Exception(
"G4ProcessManager::RemoveProcess()",
"ProcMan012",
556 G4ProcessAttrVector::iterator itr;
557 for (itr = theAttrVector->begin(); itr!= theAttrVector->end(); ++itr) {
558 if ( (*itr) == pAttr) {
559 theAttrVector->erase(itr);
564 numberOfProcesses -= 1;
567 for(
G4int i=0; i<numberOfProcesses; i++) {
576 theProcessTable->
Remove(removedProcess,
this);
578 return removedProcess;
613 const G4String aErrorMessage(
" G4ProcessManager::SetProcessOrdering");
631 G4cout <<
" illegal DoIt Index [= " <<
G4int(idDoIt) <<
"]";
653 if (ordDoIt == 0) ordDoIt = 1;
671 G4cout <<
" in ProcessVetor[" << ivec<<
"]";
672 G4cout <<
" with Ordering parameter = " << ordDoIt ;
698 G4cout <<
"G4ProcessManager::SetProcessOrdering: ";
699 G4cout <<
" illegal DoIt Index [= " <<
G4int(idDoIt) <<
"]";
730 G4cout <<
"G4ProcessManager::SetProcessOrderingToFirst: ";
732 G4cout <<
" in ProcessVetor[" << ivec<<
"]";
738 if (isSetOrderingFirstInvoked[idDoIt]){
739 G4String anErrMsg =
"Set Ordering First is invoked twice for ";
743 G4Exception(
"G4ProcessManager::SetProcessOrderingToFirst()",
747 isSetOrderingFirstInvoked[idDoIt] =
true;
763 const G4String aErrorMessage(
" G4ProcessManager::SetProcessOrderingToSecond");
781 G4cout <<
" illegal DoIt Index [= " <<
G4int(idDoIt) <<
"]";
811 for (
G4int iproc=0; iproc<numberOfProcesses; iproc++) {
835 G4cout <<
" in ProcessVetor[" << ivec<<
"]";
836 G4cout <<
" with Ordering parameter = 1 ";
856 if (isSetOrderingLastInvoked[idDoIt]){
857 G4String anErrMsg =
"Set Ordering Last is invoked twice for ";
861 G4Exception(
"G4ProcessManager::SetProcessOrderingToLast()",
"ProcMan114",
864 isSetOrderingLastInvoked[idDoIt] =
true;
875 G4cout <<
"G4ProcessManager::InActivateProcess is not valid in ";
889 if (pAttr == 0)
return 0;
894 const G4String aErrorMessage(
" G4ProcessManager::InactivateProcess():");
905 }
else if ((idx >= 0) && (idx < pVector->entries())) {
907 if ((*pVector)[idx]== pProcess) {
910 G4String anErrorMessage(
"Bad ProcessList: Bad index in attribute");
911 anErrorMessage +=
"for particle[" + theParticleType->
GetParticleName() +
"] ";
912 anErrorMessage +=
"process[" + pProcess->
GetProcessName() +
"] " ;
913 G4Exception(
"G4ProcessManager::InactivateProcess():",
"ProcMan012",
919 G4String anErrorMessage(
"Bad ProcessList: Index is out of range");
920 anErrorMessage +=
"for particle[" + theParticleType->
GetParticleName() +
"] ";
921 anErrorMessage +=
"process[" + pProcess->
GetProcessName() +
"] " ;
922 G4Exception(
"G4ProcessManager::InactivateProcess():",
"ProcMan012",
940 G4cout <<
"G4ProcessManager::ActivateProcess is not valid in ";
954 if (pAttr == 0)
return 0;
966 }
else if ((idx >= 0) && (idx < pVector->entries())) {
968 if ((*pVector)[idx]== 0) {
969 (*pVector)[idx] = pProcess;
971 G4String anErrorMessage(
"Bad ProcessList: Bad index in attribute");
972 anErrorMessage +=
"for particle[" + theParticleType->
GetParticleName() +
"] ";
973 anErrorMessage +=
"process[" + pProcess->
GetProcessName() +
"] " ;
974 G4Exception(
"G4ProcessManager::ActivateProcess():",
"ProcMan012",
980 G4String anErrorMessage(
"bad ProcessList: Index is out of range");
981 anErrorMessage +=
"for particle[" + theParticleType->
GetParticleName() +
"] ";
982 anErrorMessage +=
"process[" + pProcess->
GetProcessName() +
"] " ;
983 G4Exception(
"G4ProcessManager::ActivateProcess():",
"ProcMan012",
997 return (
this == &right);
1003 return (
this != &right);
1012 G4cout <<
"G4ProcessManager: particle["
1017 for (
G4int idx=0; idx <theProcessList->
entries(); idx++){
1019 G4cout <<
"[" << idx <<
"]";
1020 G4cout <<
"=== process[" << ((*theProcessList)(idx))->GetProcessName()<<
" :";
1026 if ( pAttr-> isActive ) {
1036 G4cout <<
" Ordering:: ";
1037 G4cout <<
" AtRest AlongStep PostStep ";
1040 G4cout <<
" GetPIL/ DoIt GetPIL/ DoIt GetPIL/ DoIt ";
1044 for (
G4int idx2 = 0; idx2 <6 ; idx2++) {
1049 for (
G4int idx3 = 0; idx3 <6 ; idx3++) {
1058 void G4ProcessManager::CreateGPILvectors()
1073 for(
G4int j=nproc-1;j>=0;j--) {
1090 for (
G4int idx = 0; idx<theProcessList->
entries(); idx++){
1094 if(aTrack) duringTracking =
true;
1100 for (
G4int idx = 0; idx<theProcessList->
entries(); idx++){
1104 duringTracking =
false;
1119 if (fActive)
return ActivateProcess(index);
1120 else return InActivateProcess(index);
1136 G4cout <<
"G4ProcessManager::GetProcessActivation ";
1137 G4cout <<
" process (or its index) not found ";
1145 return pAttr-> isActive;
1151 if (aProcess==0)
return;
1156 G4cout <<
"G4ProcessManager::CheckOrderingParameters ";
1158 <<
" has no attribute" <<
G4endl;
1170 G4cerr <<
"G4ProcessManager::CheckOrderingParameters ";
1171 G4cerr <<
"You cannot set ordering parameter ["
1173 <<
"] for AtRest DoIt to the process "
1183 G4cerr <<
"G4ProcessManager::CheckOrderingParameters ";
1184 G4cerr <<
"You cannot set ordering parameter ["
1186 <<
"] for AlongStep DoIt to the process "
1197 G4cerr <<
"G4ProcessManager::CheckOrderingParameters ";
1198 G4cerr <<
"You cannot set ordering parameter ["
1200 <<
"] for PostStep DoIt to the process"
1209 msg =
"Invalid ordering parameters are set for ";
1211 G4Exception(
"G4ProcessManager::CheckOrderingParameters ",
static const G4String & GetProcessTypeName(G4ProcessType)
G4int GetProcessVectorIndex(G4VProcess *aProcess, G4ProcessVectorDoItIndex idx, G4ProcessVectorTypeIndex typ=typeGPIL) const
G4bool insertAt(G4int i, G4VProcess *aProcess)
virtual void SetProcessManager(const G4ProcessManager *)
G4int Insert(G4VProcess *aProcess, G4ProcessManager *aProcMgr)
G4ProcessVectorTypeIndex typ
void SetProcessOrderingToFirst(G4VProcess *aProcess, G4ProcessVectorDoItIndex idDoIt)
G4bool isAlongStepDoItIsEnabled() const
void SetProcessOrderingToSecond(G4VProcess *aProcess, G4ProcessVectorDoItIndex idDoIt)
G4bool isPostStepDoItIsEnabled() const
G4VProcess * removeLast()
G4int Remove(G4VProcess *aProcess, G4ProcessManager *aProcMgr)
G4bool isAtRestDoItIsEnabled() const
G4int GetProcessOrdering(G4VProcess *aProcess, G4ProcessVectorDoItIndex idDoIt)
G4int operator==(const G4ProcessManager &right) const
G4int GetVerboseLevel() const
G4int InsertAt(G4int position, G4VProcess *process, G4int ivec)
const G4String & GetParticleName() const
void CheckOrderingParameters(G4VProcess *) const
G4int operator!=(const G4ProcessManager &right) const
G4VProcess * SetProcessActivation(G4VProcess *aProcess, G4bool fActive)
G4ProcessManager(G4ProcessManager &right)
static G4StateManager * GetStateManager()
G4int RemoveAt(G4int position, G4VProcess *process, G4int ivec)
G4GLOB_DLL std::ostream G4cout
G4int ordProcVector[G4ProcessManager::SizeOfProcVectorArray]
G4int FindInsertPosition(G4int ord, G4int ivec)
G4int AddProcess(G4VProcess *aProcess, G4int ordAtRestDoIt=ordInActive, G4int ordAlongSteptDoIt=ordInActive, G4int ordPostStepDoIt=ordInActive)
G4int idxProcVector[G4ProcessManager::SizeOfProcVectorArray]
G4ApplicationState GetCurrentState() const
void SetProcessOrdering(G4VProcess *aProcess, G4ProcessVectorDoItIndex idDoIt, G4int ordDoIt=ordDefault)
const G4String & GetProcessName() const
G4int GetProcessVectorId(G4ProcessVectorDoItIndex idx, G4ProcessVectorTypeIndex typ=typeGPIL) const
G4bool insert(G4VProcess *aProcess)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
void SetProcessOrderingToLast(G4VProcess *aProcess, G4ProcessVectorDoItIndex idDoIt)
void StartTracking(G4Track *aTrack=0)
G4VProcess * removeAt(G4int i)
G4int GetProcessIndex(G4VProcess *) const
G4bool GetProcessActivation(G4VProcess *aProcess) const
G4VProcess * RemoveProcess(G4VProcess *aProcess)
static G4ProcessTable * GetProcessTable()
virtual G4bool IsApplicable(const G4ParticleDefinition &)
G4GLOB_DLL std::ostream G4cerr