Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer 3 // * License and Disclaimer * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/ 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. 9 // * include a list of copyright holders. * 10 // * 10 // * * 11 // * Neither the authors of this software syst 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitatio 16 // * for the full disclaimer and the limitation of liability. * 17 // * 17 // * * 18 // * This code implementation is the result 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboratio 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distri 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you ag 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publicati 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Sof 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************* 24 // ******************************************************************** 25 // 25 // 26 // G4ProcessPlacer << 26 // 27 // ------------------------------------------- << 27 // >> 28 // ---------------------------------------------------------------------- >> 29 // GEANT 4 class source file >> 30 // >> 31 // G4ProcessPlacer.cc >> 32 // >> 33 // ---------------------------------------------------------------------- 28 34 29 #include "G4ProcessPlacer.hh" 35 #include "G4ProcessPlacer.hh" 30 #include "G4ProcessManager.hh" 36 #include "G4ProcessManager.hh" 31 #include "G4VProcess.hh" 37 #include "G4VProcess.hh" 32 #include "G4ParticleTable.hh" 38 #include "G4ParticleTable.hh" 33 39 34 G4ProcessPlacer::G4ProcessPlacer(const G4Strin << 40 G4ProcessPlacer::G4ProcessPlacer(const G4String &particlename) 35 : fParticleName(particlename) 41 : fParticleName(particlename) 36 { 42 { 37 } 43 } 38 44 39 G4ProcessPlacer::~G4ProcessPlacer() 45 G4ProcessPlacer::~G4ProcessPlacer() 40 { 46 { 41 } 47 } 42 48 43 void G4ProcessPlacer::RemoveProcess(G4VProcess << 49 void G4ProcessPlacer::RemoveProcess(G4VProcess *process) 44 { 50 { 45 G4cout << "=== G4ProcessPlacer::RemoveProces 51 G4cout << "=== G4ProcessPlacer::RemoveProcess: for: " << fParticleName 46 << G4endl; 52 << G4endl; 47 G4cout << " ProcessName: " << process->GetP 53 G4cout << " ProcessName: " << process->GetProcessName() 48 << ", will be removed!" << G4endl; 54 << ", will be removed!" << G4endl; 49 55 50 G4cout << " The initial AlongStep Vectors: 56 G4cout << " The initial AlongStep Vectors: " << G4endl; 51 PrintAlongStepGPILVec(); 57 PrintAlongStepGPILVec(); 52 PrintAlongStepDoItVec(); 58 PrintAlongStepDoItVec(); 53 59 54 G4cout << " The initial PostStep Vectors: " 60 G4cout << " The initial PostStep Vectors: " << G4endl; 55 PrintPostStepGPILVec(); 61 PrintPostStepGPILVec(); 56 PrintPostStepDoItVec(); 62 PrintPostStepDoItVec(); 57 63 58 GetProcessManager()->RemoveProcess(process); 64 GetProcessManager()->RemoveProcess(process); 59 65 60 G4cout << " The final AlongStep Vectors: " 66 G4cout << " The final AlongStep Vectors: " << G4endl; 61 PrintAlongStepGPILVec(); 67 PrintAlongStepGPILVec(); 62 PrintAlongStepDoItVec(); 68 PrintAlongStepDoItVec(); 63 69 64 G4cout << " The final PostStep Vectors: " < 70 G4cout << " The final PostStep Vectors: " << G4endl; 65 PrintPostStepGPILVec(); 71 PrintPostStepGPILVec(); 66 PrintPostStepDoItVec(); 72 PrintPostStepDoItVec(); 67 73 68 G4cout << "================================= 74 G4cout << "================================================" << G4endl; 69 75 70 } 76 } 71 77 72 void G4ProcessPlacer::AddProcessAs(G4VProcess* << 78 void G4ProcessPlacer::AddProcessAs(G4VProcess *process, SecondOrLast sol) 73 { 79 { 74 G4cout << " Modifying Process Order for Pro 80 G4cout << " Modifying Process Order for ProcessName: " << process->GetProcessName() << G4endl; 75 81 76 G4cout << " The initial AlongStep Vectors: 82 G4cout << " The initial AlongStep Vectors: " << G4endl; 77 PrintAlongStepGPILVec(); 83 PrintAlongStepGPILVec(); 78 PrintAlongStepDoItVec(); 84 PrintAlongStepDoItVec(); 79 85 80 G4cout << "The initial PostStep Vectors: " < 86 G4cout << "The initial PostStep Vectors: " << G4endl; 81 PrintPostStepGPILVec(); 87 PrintPostStepGPILVec(); 82 PrintPostStepDoItVec(); 88 PrintPostStepDoItVec(); 83 89 84 if (sol == eLast) 90 if (sol == eLast) 85 { 91 { 86 GetProcessManager()->AddProcess(process, o 92 GetProcessManager()->AddProcess(process, ordInActive, ordInActive, ordLast); 87 } 93 } 88 else if (sol == eSecond) 94 else if (sol == eSecond) 89 { 95 { 90 // get transportation process 96 // get transportation process 91 G4VProcess *transportation = 97 G4VProcess *transportation = 92 (* (GetProcessManager()->GetProcessList() 98 (* (GetProcessManager()->GetProcessList()))[0]; 93 99 94 if (!transportation) 100 if (!transportation) 95 { 101 { 96 G4Exception("G4ProcessPlacer::AddProcess 102 G4Exception("G4ProcessPlacer::AddProcessAs","Bias0001",RunMustBeAborted," could not get process id=0"); 97 } 103 } 98 if (transportation->GetProcessName() != "T 104 if (transportation->GetProcessName() != "Transportation" && transportation->GetProcessName() != "Transportation8" && transportation->GetProcessName() != "CoupledTransportation") 99 { 105 { 100 // G4cout << " GOT HERE CoupledTran 106 // G4cout << " GOT HERE CoupledTransportation" << G4endl; 101 G4cout << transportation->GetProcessName 107 G4cout << transportation->GetProcessName() << G4endl; 102 G4Exception("G4ProcessPlacer::AddProcess 108 G4Exception("G4ProcessPlacer::AddProcessAs","Bias0002",RunMustBeAborted," process id=0 is not Transportation"); 103 } 109 } 104 110 105 // place the given proces as first for the 111 // place the given proces as first for the moment 106 // 31/5/11 previously set to first, then t 112 // 31/5/11 previously set to first, then transportation set ahead of it, 107 // which is more conveniently correctly se 113 // which is more conveniently correctly set with placing it second! 108 GetProcessManager()->AddProcess(process); 114 GetProcessManager()->AddProcess(process); 109 GetProcessManager()->SetProcessOrderingToS 115 GetProcessManager()->SetProcessOrderingToSecond(process, 110 116 idxAlongStep); 111 GetProcessManager()->SetProcessOrderingToS 117 GetProcessManager()->SetProcessOrderingToSecond(process, 112 118 idxPostStep); >> 119 // xx test >> 120 // if(process->GetProcessName() == "ImportanceProcess") >> 121 //bug31/10/07 GetProcessManager()->SetProcessOrdering(process, >> 122 //bug31/10/07 idxAlongStep, 1); >> 123 // place transportation first again >> 124 // GetProcessManager()->SetProcessOrderingToFirst(transportation, >> 125 // idxAlongStep); >> 126 // GetProcessManager()->SetProcessOrderingToFirst(transportation, >> 127 // idxPostStep); 113 } 128 } 114 129 115 // for verification inly 130 // for verification inly 116 G4cout << " The final AlongStep Vectors: " 131 G4cout << " The final AlongStep Vectors: " << G4endl; 117 PrintAlongStepGPILVec(); 132 PrintAlongStepGPILVec(); 118 PrintAlongStepDoItVec(); 133 PrintAlongStepDoItVec(); 119 134 120 G4cout << "The final PostStep Vectors: " << 135 G4cout << "The final PostStep Vectors: " << G4endl; 121 PrintPostStepGPILVec(); 136 PrintPostStepGPILVec(); 122 PrintPostStepDoItVec(); 137 PrintPostStepDoItVec(); 123 138 124 G4cout << "================================= 139 G4cout << "================================================" << G4endl; 125 } 140 } 126 141 127 void G4ProcessPlacer::AddProcessAsSecondDoIt(G << 142 void G4ProcessPlacer::AddProcessAsSecondDoIt(G4VProcess *process) 128 { 143 { 129 G4cout << "=== G4ProcessPlacer::AddProcessAs 144 G4cout << "=== G4ProcessPlacer::AddProcessAsSecondDoIt: for: " 130 << fParticleName << G4endl; 145 << fParticleName << G4endl; 131 AddProcessAs(process, eSecond); 146 AddProcessAs(process, eSecond); 132 } 147 } 133 148 134 void G4ProcessPlacer::AddProcessAsLastDoIt(G4V << 149 void G4ProcessPlacer::AddProcessAsLastDoIt(G4VProcess *process) 135 { 150 { 136 G4cout << "=== G4ProcessPlacer::AddProcessAs 151 G4cout << "=== G4ProcessPlacer::AddProcessAsLastDoIt: for: " 137 << fParticleName << G4endl; 152 << fParticleName << G4endl; 138 AddProcessAs(process, eLast); 153 AddProcessAs(process, eLast); 139 } 154 } 140 155 141 G4ProcessManager* G4ProcessPlacer::GetProcessM << 156 G4ProcessManager *G4ProcessPlacer::GetProcessManager() 142 { 157 { 143 // get particle iterator to add processes -- 158 // get particle iterator to add processes --------------------- 144 G4ParticleTable* theParticleTable = nullptr; << 159 G4ParticleTable* theParticleTable = 0; 145 G4ParticleTable::G4PTblDicIterator* theParti << 160 G4ParticleTable::G4PTblDicIterator* theParticleIterator = 0; 146 theParticleTable = G4ParticleTable::GetParti 161 theParticleTable = G4ParticleTable::GetParticleTable(); 147 theParticleIterator = theParticleTable->GetI 162 theParticleIterator = theParticleTable->GetIterator(); 148 // ----------------------------------------- 163 // ------------------------------------------------------- 149 G4ProcessManager* processmanager = nullptr; << 164 G4ProcessManager *processmanager = 0; 150 // find process manager -------------------- 165 // find process manager --------------------------- 151 theParticleIterator->reset(); 166 theParticleIterator->reset(); 152 while( (*theParticleIterator)() ) /* while c 167 while( (*theParticleIterator)() ) /* while checked for unending loop, 30.05.2016, Marc Verderi */ 153 { 168 { 154 G4ParticleDefinition* particle = thePartic 169 G4ParticleDefinition* particle = theParticleIterator->value(); 155 if (particle->GetParticleName() == fPartic 170 if (particle->GetParticleName() == fParticleName) 156 { 171 { 157 processmanager = particle->GetProcessMa 172 processmanager = particle->GetProcessManager(); 158 break; 173 break; 159 } 174 } 160 } 175 } 161 // ----------------------------------------- 176 // --------------------------------------------------------- 162 if (!processmanager) 177 if (!processmanager) 163 { 178 { 164 G4Exception("G4ProcessPlacer::GetProcessMa 179 G4Exception("G4ProcessPlacer::GetProcessManager()", "InvalidSetup", 165 FatalException, "NULL pointer 180 FatalException, "NULL pointer to Process Manager ! Sampler.Configure() must be after PhysicsList instantiation"); 166 } 181 } 167 return processmanager; 182 return processmanager; 168 } 183 } 169 184 170 void G4ProcessPlacer::PrintAlongStepGPILVec() 185 void G4ProcessPlacer::PrintAlongStepGPILVec() 171 { 186 { 172 G4cout << "GPIL Vector: " << G4endl; 187 G4cout << "GPIL Vector: " << G4endl; 173 G4ProcessVector* processGPILVec = 188 G4ProcessVector* processGPILVec = 174 GetProcessManager()->GetAlongStepProcessVe 189 GetProcessManager()->GetAlongStepProcessVector(typeGPIL); 175 PrintProcVec(processGPILVec); 190 PrintProcVec(processGPILVec); 176 } 191 } 177 192 178 void G4ProcessPlacer::PrintAlongStepDoItVec() 193 void G4ProcessPlacer::PrintAlongStepDoItVec() 179 { 194 { 180 G4cout << "DoIt Vector: " << G4endl; 195 G4cout << "DoIt Vector: " << G4endl; 181 G4ProcessVector* processDoItVec = 196 G4ProcessVector* processDoItVec = 182 GetProcessManager()->GetAlongStepProcessVe 197 GetProcessManager()->GetAlongStepProcessVector(typeDoIt); 183 PrintProcVec(processDoItVec); 198 PrintProcVec(processDoItVec); 184 } 199 } 185 200 186 201 187 void G4ProcessPlacer::PrintPostStepGPILVec() 202 void G4ProcessPlacer::PrintPostStepGPILVec() 188 { 203 { 189 G4cout << "GPIL Vector: " << G4endl; 204 G4cout << "GPIL Vector: " << G4endl; 190 G4ProcessVector* processGPILVec = 205 G4ProcessVector* processGPILVec = 191 GetProcessManager()->GetPostStepProcessVec 206 GetProcessManager()->GetPostStepProcessVector(typeGPIL); 192 PrintProcVec(processGPILVec); 207 PrintProcVec(processGPILVec); 193 } 208 } 194 209 195 void G4ProcessPlacer::PrintPostStepDoItVec() 210 void G4ProcessPlacer::PrintPostStepDoItVec() 196 { 211 { 197 G4cout << "DoIt Vector: " << G4endl; 212 G4cout << "DoIt Vector: " << G4endl; 198 G4ProcessVector* processDoItVec = 213 G4ProcessVector* processDoItVec = 199 GetProcessManager()->GetPostStepProcessVec 214 GetProcessManager()->GetPostStepProcessVector(typeDoIt); 200 PrintProcVec(processDoItVec); 215 PrintProcVec(processDoItVec); 201 } 216 } 202 217 203 218 204 void G4ProcessPlacer::PrintProcVec(G4ProcessVe 219 void G4ProcessPlacer::PrintProcVec(G4ProcessVector* processVec) 205 { 220 { 206 if (!processVec) 221 if (!processVec) 207 { 222 { 208 G4Exception("G4ProcessPlacer::G4ProcessPla 223 G4Exception("G4ProcessPlacer::G4ProcessPlacer()", "InvalidArgument", 209 FatalException, "NULL pointer 224 FatalException, "NULL pointer to process-vector !"); 210 } 225 } 211 G4int len = (G4int)processVec->length(); 226 G4int len = (G4int)processVec->length(); 212 if (len==0) 227 if (len==0) 213 { 228 { 214 G4Exception("G4ProcessPlacer::G4ProcessPla 229 G4Exception("G4ProcessPlacer::G4ProcessPlacer()", "InvalidSetup", 215 FatalException, "Length of pro 230 FatalException, "Length of process-vector is zero !"); 216 } 231 } 217 for (G4int i=0; i<len; ++i) 232 for (G4int i=0; i<len; ++i) 218 { 233 { 219 G4VProcess *p = (*processVec)[i]; 234 G4VProcess *p = (*processVec)[i]; 220 if (p) 235 if (p) 221 { 236 { 222 G4cout << " " << p->GetProcessName() < 237 G4cout << " " << p->GetProcessName() << G4endl; 223 } 238 } 224 else 239 else 225 { 240 { 226 G4cout << " " << "no process found for 241 G4cout << " " << "no process found for position: " << i 227 << ", in vector of length: " << l 242 << ", in vector of length: " << len << G4endl; 228 } 243 } 229 } 244 } 230 } 245 } 231 246