00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 #include "G4ProcessPlacer.hh"
00037 #include "G4ProcessManager.hh"
00038 #include "G4VProcess.hh"
00039 #include "G4ParticleTable.hh"
00040
00041 G4ProcessPlacer::G4ProcessPlacer(const G4String &particlename)
00042 : fParticleName(particlename)
00043 {
00044 }
00045
00046 G4ProcessPlacer::~G4ProcessPlacer()
00047 {
00048 }
00049
00050 void G4ProcessPlacer::RemoveProcess(G4VProcess *process)
00051 {
00052 G4cout << "=== G4ProcessPlacer::RemoveProcess: for: " << fParticleName
00053 << G4endl;
00054 G4cout << " ProcessName: " << process->GetProcessName()
00055 << ", will be removed!" << G4endl;
00056
00057 G4cout << " The initial AlongStep Vectors: " << G4endl;
00058 PrintAlongStepGPILVec();
00059 PrintAlongStepDoItVec();
00060
00061 G4cout << " The initial PostStep Vectors: " << G4endl;
00062 PrintPostStepGPILVec();
00063 PrintPostStepDoItVec();
00064
00065 GetProcessManager()->RemoveProcess(process);
00066
00067 G4cout << " The final AlongStep Vectors: " << G4endl;
00068 PrintAlongStepGPILVec();
00069 PrintAlongStepDoItVec();
00070
00071 G4cout << " The final PostStep Vectors: " << G4endl;
00072 PrintPostStepGPILVec();
00073 PrintPostStepDoItVec();
00074
00075 G4cout << "================================================" << G4endl;
00076
00077 }
00078
00079 void G4ProcessPlacer::AddProcessAs(G4VProcess *process, SecondOrLast sol)
00080 {
00081 G4cout << " Modifying Process Order for ProcessName: " << process->GetProcessName() << G4endl;
00082
00083 G4cout << " The initial AlongStep Vectors: " << G4endl;
00084 PrintAlongStepGPILVec();
00085 PrintAlongStepDoItVec();
00086
00087 G4cout << "The initial PostStep Vectors: " << G4endl;
00088 PrintPostStepGPILVec();
00089 PrintPostStepDoItVec();
00090
00091 if (sol == eLast)
00092 {
00093 GetProcessManager()->AddProcess(process, ordInActive, ordInActive, ordLast);
00094 }
00095 else if (sol == eSecond)
00096 {
00097
00098 G4VProcess *transportation =
00099 (* (GetProcessManager()->GetProcessList()))[0];
00100
00101 if (!transportation)
00102 {
00103 G4Exception("G4ProcessPlacer::AddProcessAs","Bias0001",RunMustBeAborted," could not get process id=0");
00104 }
00105 if (transportation->GetProcessName() != "Transportation" && transportation->GetProcessName() != "Transportation8" && transportation->GetProcessName() != "CoupledTransportation")
00106 {
00107
00108 G4cout << transportation->GetProcessName() << G4endl;
00109 G4Exception("G4ProcessPlacer::AddProcessAs","Bias0002",RunMustBeAborted," process id=0 is not Transportation");
00110 }
00111
00112
00113
00114
00115 GetProcessManager()->AddProcess(process);
00116 GetProcessManager()->SetProcessOrderingToSecond(process,
00117 idxAlongStep);
00118 GetProcessManager()->SetProcessOrderingToSecond(process,
00119 idxPostStep);
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129 }
00130
00131
00132 G4cout << " The final AlongStep Vectors: " << G4endl;
00133 PrintAlongStepGPILVec();
00134 PrintAlongStepDoItVec();
00135
00136 G4cout << "The final PostStep Vectors: " << G4endl;
00137 PrintPostStepGPILVec();
00138 PrintPostStepDoItVec();
00139
00140 G4cout << "================================================" << G4endl;
00141 }
00142
00143 void G4ProcessPlacer::AddProcessAsSecondDoIt(G4VProcess *process)
00144 {
00145 G4cout << "=== G4ProcessPlacer::AddProcessAsSecondDoIt: for: "
00146 << fParticleName << G4endl;
00147 AddProcessAs(process, eSecond);
00148 }
00149
00150 void G4ProcessPlacer::AddProcessAsLastDoIt(G4VProcess *process)
00151 {
00152 G4cout << "=== G4ProcessPlacer::AddProcessAsLastDoIt: for: "
00153 << fParticleName << G4endl;
00154 AddProcessAs(process, eLast);
00155 }
00156
00157 G4ProcessManager *G4ProcessPlacer::GetProcessManager()
00158 {
00159
00160 G4ParticleTable* theParticleTable = 0;
00161 G4ParticleTable::G4PTblDicIterator* theParticleIterator = 0;
00162 theParticleTable = G4ParticleTable::GetParticleTable();
00163 theParticleIterator = theParticleTable->GetIterator();
00164
00165 G4ProcessManager *processmanager = 0;
00166
00167 theParticleIterator->reset();
00168 while( (*theParticleIterator)() )
00169 {
00170 G4ParticleDefinition* particle = theParticleIterator->value();
00171 if (particle->GetParticleName() == fParticleName)
00172 {
00173 processmanager = particle->GetProcessManager();
00174 break;
00175 }
00176 }
00177
00178 if (!processmanager)
00179 {
00180 G4Exception("G4ProcessPlacer::GetProcessManager()", "InvalidSetup",
00181 FatalException, "NULL pointer to Process Manager ! Sampler.Configure() must be after PhysicsList instantiation");
00182 }
00183 return processmanager;
00184 }
00185
00186 void G4ProcessPlacer::PrintAlongStepGPILVec()
00187 {
00188 G4cout << "GPIL Vector: " << G4endl;
00189 G4ProcessVector* processGPILVec =
00190 GetProcessManager()->GetAlongStepProcessVector(typeGPIL);
00191 PrintProcVec(processGPILVec);
00192 }
00193
00194 void G4ProcessPlacer::PrintAlongStepDoItVec()
00195 {
00196 G4cout << "DoIt Vector: " << G4endl;
00197 G4ProcessVector* processDoItVec =
00198 GetProcessManager()->GetAlongStepProcessVector(typeDoIt);
00199 PrintProcVec(processDoItVec);
00200 }
00201
00202
00203 void G4ProcessPlacer::PrintPostStepGPILVec()
00204 {
00205 G4cout << "GPIL Vector: " << G4endl;
00206 G4ProcessVector* processGPILVec =
00207 GetProcessManager()->GetPostStepProcessVector(typeGPIL);
00208 PrintProcVec(processGPILVec);
00209 }
00210
00211 void G4ProcessPlacer::PrintPostStepDoItVec()
00212 {
00213 G4cout << "DoIt Vector: " << G4endl;
00214 G4ProcessVector* processDoItVec =
00215 GetProcessManager()->GetPostStepProcessVector(typeDoIt);
00216 PrintProcVec(processDoItVec);
00217 }
00218
00219
00220 void G4ProcessPlacer::PrintProcVec(G4ProcessVector* processVec)
00221 {
00222 if (!processVec)
00223 {
00224 G4Exception("G4ProcessPlacer::G4ProcessPlacer()", "InvalidArgument",
00225 FatalException, "NULL pointer to process-vector !");
00226 }
00227 size_t len = processVec->length();
00228 if (len==0)
00229 {
00230 G4Exception("G4ProcessPlacer::G4ProcessPlacer()", "InvalidSetup",
00231 FatalException, "Length of process-vector is zero !");
00232 }
00233 for (size_t i=0; i<len; i++)
00234 {
00235 G4VProcess *p = (*processVec)[i];
00236 if (p)
00237 {
00238 G4cout << " " << p->GetProcessName() << G4endl;
00239 }
00240 else
00241 {
00242 G4cout << " " << "no process found for position: " << i
00243 << ", in vector of length: " << len << G4endl;
00244 }
00245 }
00246 }