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 // G4ProcessManager implementation 26 // G4ProcessManager implementation 27 // 27 // 28 // Authors: 28 // Authors: 29 // - 02.12.1995, G.Cosmo - First implementatio 29 // - 02.12.1995, G.Cosmo - First implementation, based on object model 30 // - 06.05.1996, G.Cosmo - Revised; added vect 30 // - 06.05.1996, G.Cosmo - Revised; added vector of processes at rest 31 // - 08.01.1997, H.Kurashige - New Physics sch 31 // - 08.01.1997, H.Kurashige - New Physics scheme 32 // ------------------------------------------- 32 // -------------------------------------------------------------------- 33 33 34 #include <iomanip> 34 #include <iomanip> 35 35 36 #include "G4ios.hh" 36 #include "G4ios.hh" 37 #include "G4ProcessManager.hh" 37 #include "G4ProcessManager.hh" 38 #include "G4ProcessManagerMessenger.hh" 38 #include "G4ProcessManagerMessenger.hh" 39 #include "G4ProcessAttribute.hh" 39 #include "G4ProcessAttribute.hh" 40 #include "G4StateManager.hh" 40 #include "G4StateManager.hh" 41 #include "G4ProcessTable.hh" 41 #include "G4ProcessTable.hh" 42 42 43 G4ThreadLocal G4ProcessManagerMessenger* 43 G4ThreadLocal G4ProcessManagerMessenger* 44 G4ProcessManager::fProcessManage 44 G4ProcessManager::fProcessManagerMessenger = nullptr; 45 G4ThreadLocal G4int G4ProcessManager::counterO 45 G4ThreadLocal G4int G4ProcessManager::counterOfObjects = 0; 46 46 47 // ------------------------------------------- 47 // -------------------------------------------------------------------- 48 G4ProcessManager::G4ProcessManager(const G4Par 48 G4ProcessManager::G4ProcessManager(const G4ParticleDefinition* aParticleType) 49 : theParticleType(aParticleType) 49 : theParticleType(aParticleType) 50 { 50 { 51 // create the process List 51 // create the process List 52 theProcessList = new G4ProcessVector(); 52 theProcessList = new G4ProcessVector(); 53 if ( theProcessList == nullptr) 53 if ( theProcessList == nullptr) 54 { 54 { 55 G4Exception( "G4ProcessManager::G4ProcessM 55 G4Exception( "G4ProcessManager::G4ProcessManager()","ProcMan012", 56 FatalException, "Can not crea 56 FatalException, "Can not create G4ProcessList "); 57 } 57 } 58 58 59 // create process vector 59 // create process vector 60 for (G4int i=0; i<SizeOfProcVectorArray; ++i 60 for (G4int i=0; i<SizeOfProcVectorArray; ++i) 61 { 61 { 62 theProcVector[i] = new G4ProcessVector(); 62 theProcVector[i] = new G4ProcessVector(); 63 if ( theProcVector[i] == nullptr) 63 if ( theProcVector[i] == nullptr) 64 { 64 { 65 G4Exception( "G4ProcessManager::G4Proces 65 G4Exception( "G4ProcessManager::G4ProcessManager()","ProcMan012", 66 FatalException, "Can not cr 66 FatalException, "Can not create G4ProcessVector "); 67 } 67 } 68 } 68 } 69 69 70 // create Process Attribute vector 70 // create Process Attribute vector 71 theAttrVector = new G4ProcessAttrVector(); 71 theAttrVector = new G4ProcessAttrVector(); 72 72 73 // create Process Manager Messenger 73 // create Process Manager Messenger 74 if (fProcessManagerMessenger == nullptr) 74 if (fProcessManagerMessenger == nullptr) 75 { 75 { 76 fProcessManagerMessenger = new G4ProcessMa 76 fProcessManagerMessenger = new G4ProcessManagerMessenger(); 77 } 77 } 78 78 79 for (G4int i=0; i<NDoit; ++i) 79 for (G4int i=0; i<NDoit; ++i) 80 { 80 { 81 isSetOrderingFirstInvoked[i] = false; 81 isSetOrderingFirstInvoked[i] = false; 82 isSetOrderingLastInvoked[i] = false; 82 isSetOrderingLastInvoked[i] = false; 83 } 83 } 84 84 85 // Increment counter of G4ProcessManager obj 85 // Increment counter of G4ProcessManager objects 86 ++counterOfObjects; 86 ++counterOfObjects; 87 } 87 } 88 88 89 // ------------------------------------------- 89 // -------------------------------------------------------------------- 90 G4ProcessManager::G4ProcessManager(G4ProcessMa 90 G4ProcessManager::G4ProcessManager(G4ProcessManager& right) 91 : theParticleType(right.theParticleType), 91 : theParticleType(right.theParticleType), 92 verboseLevel(right.verboseLevel) 92 verboseLevel(right.verboseLevel) 93 { 93 { 94 #ifdef G4VERBOSE 94 #ifdef G4VERBOSE 95 if (GetVerboseLevel() > 2) 95 if (GetVerboseLevel() > 2) 96 { 96 { 97 G4cout << "G4ProcessManager::G4ProcessMan 97 G4cout << "G4ProcessManager::G4ProcessManager() [copy constructor]" 98 << G4endl; 98 << G4endl; 99 } 99 } 100 #endif 100 #endif 101 101 102 // create the process List and ProcessAttr 102 // create the process List and ProcessAttr Vector 103 theProcessList = new G4ProcessVector(); 103 theProcessList = new G4ProcessVector(); 104 theAttrVector = new G4ProcessAttrVector(); 104 theAttrVector = new G4ProcessAttrVector(); 105 if ( ( theProcessList == nullptr) || (theAt 105 if ( ( theProcessList == nullptr) || (theAttrVector == nullptr) ) 106 { 106 { 107 G4Exception( "G4ProcessManager::G4Process 107 G4Exception( "G4ProcessManager::G4ProcessManager() [copy constructor]", 108 "ProcMan011",FatalException, 108 "ProcMan011",FatalException, "Cannot create G4ProcessList"); 109 } 109 } 110 110 111 for (G4int idx=0; idx < right.numberOfProce 111 for (G4int idx=0; idx < right.numberOfProcesses; ++idx) 112 { 112 { 113 // copy contents in theProcessList 113 // copy contents in theProcessList 114 theProcessList->insert((*right.theProcess 114 theProcessList->insert((*right.theProcessList)[idx]); 115 // create a G4ProcessAttribute same as so 115 // create a G4ProcessAttribute same as source's one 116 G4ProcessAttribute* sAttr = (*right.theAt 116 G4ProcessAttribute* sAttr = (*right.theAttrVector)[idx]; 117 G4ProcessAttribute* dAttr = new G4Process 117 G4ProcessAttribute* dAttr = new G4ProcessAttribute(*sAttr); 118 // adds a G4ProcessAttribute object 118 // adds a G4ProcessAttribute object 119 theAttrVector->push_back(dAttr); 119 theAttrVector->push_back(dAttr); 120 ++numberOfProcesses; 120 ++numberOfProcesses; 121 } 121 } 122 122 123 // fill up theProcVector 123 // fill up theProcVector 124 for (G4int i=0; i<SizeOfProcVectorArray; ++ 124 for (G4int i=0; i<SizeOfProcVectorArray; ++i) 125 { 125 { 126 // create i-th ProcessVector in theProcVe 126 // create i-th ProcessVector in theProcVector 127 theProcVector[i] = new G4ProcessVector(); 127 theProcVector[i] = new G4ProcessVector(); 128 if ( theProcVector[i] == nullptr ) 128 if ( theProcVector[i] == nullptr ) 129 { 129 { 130 G4Exception("G4ProcessManager::G4Proces 130 G4Exception("G4ProcessManager::G4ProcessManager() [copy constructor]", 131 "ProcMan011",FatalException, 131 "ProcMan011",FatalException, "Cannot create G4ProcessVector"); 132 } 132 } 133 133 134 G4ProcessTable* theProcessTable = G4Proce 134 G4ProcessTable* theProcessTable = G4ProcessTable::GetProcessTable(); 135 G4ProcessVector* src = right.theProcVecto 135 G4ProcessVector* src = right.theProcVector[i]; 136 for (G4int j=0; j< (G4int)src->entries() << 136 for (std::size_t j=0; j< src->entries() ; ++j) 137 { 137 { 138 // copy j-th process in i-th ProcessVec 138 // copy j-th process in i-th ProcessVector 139 theProcVector[i]->insert((*src)[j]); 139 theProcVector[i]->insert((*src)[j]); 140 //add aProcess and this ProcessManager 140 //add aProcess and this ProcessManager into ProcesssTable 141 if ( (*src)[j] != nullptr ) 141 if ( (*src)[j] != nullptr ) 142 { 142 { 143 theProcessTable->Insert((*src)[j], th 143 theProcessTable->Insert((*src)[j], this); 144 } 144 } 145 } 145 } 146 } 146 } 147 147 148 for (G4int i=0; i<NDoit; ++i) 148 for (G4int i=0; i<NDoit; ++i) 149 { 149 { 150 isSetOrderingFirstInvoked[i]= right.isSet 150 isSetOrderingFirstInvoked[i]= right.isSetOrderingFirstInvoked[i]; 151 isSetOrderingLastInvoked[i] = right.isSet 151 isSetOrderingLastInvoked[i] = right.isSetOrderingLastInvoked[i]; 152 } 152 } 153 153 154 // Increment counter of G4ProcessManager ob 154 // Increment counter of G4ProcessManager objects 155 ++counterOfObjects; 155 ++counterOfObjects; 156 } 156 } 157 157 158 // ------------------------------------------- 158 // -------------------------------------------------------------------- 159 G4ProcessManager::~G4ProcessManager() 159 G4ProcessManager::~G4ProcessManager() 160 { 160 { 161 for (G4int i=0; i<SizeOfProcVectorArray; ++i 161 for (G4int i=0; i<SizeOfProcVectorArray; ++i) 162 { 162 { 163 if (theProcVector[i]) 163 if (theProcVector[i]) 164 { 164 { 165 theProcVector[i]->clear(); 165 theProcVector[i]->clear(); 166 delete theProcVector[i]; 166 delete theProcVector[i]; 167 } 167 } 168 } 168 } 169 theProcessList->clear(); 169 theProcessList->clear(); 170 delete theProcessList; 170 delete theProcessList; 171 171 172 for (auto itr = theAttrVector->cbegin(); itr 172 for (auto itr = theAttrVector->cbegin(); itr!= theAttrVector->cend(); ++itr) 173 { 173 { 174 delete (*itr); 174 delete (*itr); 175 } 175 } 176 theAttrVector->clear(); 176 theAttrVector->clear(); 177 delete theAttrVector; 177 delete theAttrVector; 178 178 179 --counterOfObjects; 179 --counterOfObjects; 180 180 181 // delete messenger if this object is last o 181 // delete messenger if this object is last one 182 if ( counterOfObjects == 0 ) 182 if ( counterOfObjects == 0 ) 183 { 183 { 184 delete fProcessManagerMessenger; 184 delete fProcessManagerMessenger; 185 fProcessManagerMessenger = nullptr; 185 fProcessManagerMessenger = nullptr; 186 #ifdef G4VERBOSE 186 #ifdef G4VERBOSE 187 if (GetVerboseLevel() > 1) 187 if (GetVerboseLevel() > 1) 188 { 188 { 189 G4cout << "G4ProcessManagerMessenger is 189 G4cout << "G4ProcessManagerMessenger is deleted" << G4endl; 190 } 190 } 191 #endif 191 #endif 192 } 192 } 193 } 193 } 194 194 195 // ------------------------------------------- 195 // -------------------------------------------------------------------- 196 G4int G4ProcessManager::GetProcessVectorIndex( 196 G4int G4ProcessManager::GetProcessVectorIndex( 197 G4VProcess* aProces 197 G4VProcess* aProcess, 198 G4ProcessVectorDoIt 198 G4ProcessVectorDoItIndex idx, 199 G4ProcessVectorType 199 G4ProcessVectorTypeIndex typ 200 ) const 200 ) const 201 { 201 { 202 G4int idxVect = -1; 202 G4int idxVect = -1; 203 G4int idxProc = GetProcessIndex(aProcess); 203 G4int idxProc = GetProcessIndex(aProcess); 204 G4int ivec = GetProcessVectorId(idx, typ); 204 G4int ivec = GetProcessVectorId(idx, typ); 205 205 206 if ( ( idxProc >=0) && (ivec >=0) ) 206 if ( ( idxProc >=0) && (ivec >=0) ) 207 { 207 { 208 idxVect = GetAttribute(idxProc)->idxProcVe 208 idxVect = GetAttribute(idxProc)->idxProcVector[ivec]; 209 } 209 } 210 else 210 else 211 { 211 { 212 #ifdef G4VERBOSE 212 #ifdef G4VERBOSE 213 if (verboseLevel>0) 213 if (verboseLevel>0) 214 { 214 { 215 G4cout << " G4ProcessManager::GetProcess 215 G4cout << " G4ProcessManager::GetProcessVectorIndex:"; 216 G4cout << "particle[" << theParticleType 216 G4cout << "particle[" << theParticleType->GetParticleName() << "] " ; 217 G4cout << "process[" << aProcess->GetPr 217 G4cout << "process[" << aProcess->GetProcessName() << "]" ; 218 G4cout << G4endl; 218 G4cout << G4endl; 219 if (idxProc <0) 219 if (idxProc <0) 220 { 220 { 221 G4cout << " is not registered yet "; 221 G4cout << " is not registered yet "; 222 } 222 } 223 if (ivec <0) 223 if (ivec <0) 224 { 224 { 225 G4cout << " illegal DoIt Index [= " << 225 G4cout << " illegal DoIt Index [= " << G4int(idx) << "," 226 << 226 << G4int(typ) << "]"; 227 } 227 } 228 G4cout << G4endl; 228 G4cout << G4endl; 229 } 229 } 230 #endif 230 #endif 231 } 231 } 232 return idxVect; 232 return idxVect; 233 } 233 } 234 234 235 // ------------------------------------------- 235 // -------------------------------------------------------------------- 236 G4ProcessAttribute* G4ProcessManager::GetAttri 236 G4ProcessAttribute* G4ProcessManager::GetAttribute(G4int index) const 237 { 237 { 238 // check index range 238 // check index range 239 if ((index<0) || (index>=numberOfProcesses)) 239 if ((index<0) || (index>=numberOfProcesses)) 240 { 240 { 241 #ifdef G4VERBOSE 241 #ifdef G4VERBOSE 242 if (GetVerboseLevel()>0) 242 if (GetVerboseLevel()>0) 243 { 243 { 244 G4cout << "G4ProcessManager::GetAttribut 244 G4cout << "G4ProcessManager::GetAttribute():"; 245 G4cout << " particle[" << theParticleTyp 245 G4cout << " particle[" << theParticleType->GetParticleName() << "]"; 246 G4cout << G4endl; 246 G4cout << G4endl; 247 G4cout << " index out of range " << G4e 247 G4cout << " index out of range " << G4endl; 248 G4cout << " #processes[" << numberOfPro 248 G4cout << " #processes[" << numberOfProcesses << "]"; 249 G4cout << " index [" << index << "]" << 249 G4cout << " index [" << index << "]" << G4endl; 250 } 250 } 251 #endif 251 #endif 252 return nullptr; 252 return nullptr; 253 } 253 } 254 254 255 // check process pointer is not null 255 // check process pointer is not null 256 G4VProcess* aProcess = (*theProcessList)[ind 256 G4VProcess* aProcess = (*theProcessList)[index]; 257 if (aProcess == nullptr) 257 if (aProcess == nullptr) 258 { 258 { 259 G4String aErrorMessage("Bad ProcessList: N 259 G4String aErrorMessage("Bad ProcessList: Null Pointer for "); 260 aErrorMessage += theParticleType->GetParti 260 aErrorMessage += theParticleType->GetParticleName() ; 261 G4Exception("G4ProcessManager::GetAttribut 261 G4Exception("G4ProcessManager::GetAttribute()","ProcMan012", 262 FatalException, aErrorMessage) 262 FatalException, aErrorMessage); 263 return nullptr; 263 return nullptr; 264 } 264 } 265 265 266 // find the process attribute 266 // find the process attribute 267 if ( ((*theAttrVector)[index])->idxProcessLi 267 if ( ((*theAttrVector)[index])->idxProcessList == index ) 268 { 268 { 269 return (*theAttrVector)[index]; 269 return (*theAttrVector)[index]; 270 } 270 } 271 else 271 else 272 { 272 { 273 // !! Error !! 273 // !! Error !! 274 // attribute vector index is inconsistent 274 // attribute vector index is inconsistent with process List index 275 #ifdef G4VERBOSE 275 #ifdef G4VERBOSE 276 if (GetVerboseLevel()>0) 276 if (GetVerboseLevel()>0) 277 { 277 { 278 G4cout << "G4ProcessManager::GetAttribut 278 G4cout << "G4ProcessManager::GetAttribute():"; 279 G4cout << " particle[" << theParticleTyp 279 G4cout << " particle[" << theParticleType->GetParticleName() << "]" 280 << G4endl; 280 << G4endl; 281 G4cout << "Warning: attribute vector ind 281 G4cout << "Warning: attribute vector index is inconsistent" 282 << " with process List index" 282 << " with process List index" 283 << G4endl; 283 << G4endl; 284 } 284 } 285 #endif 285 #endif 286 // re-ordering attribute vector 286 // re-ordering attribute vector 287 G4ProcessAttribute* pAttr = nullptr; 287 G4ProcessAttribute* pAttr = nullptr; 288 for (auto itr = theAttrVector->cbegin(); i 288 for (auto itr = theAttrVector->cbegin(); itr!= theAttrVector->cend(); ++itr) 289 { 289 { 290 if ( (*itr)->idxProcessList == index) 290 if ( (*itr)->idxProcessList == index) 291 { 291 { 292 pAttr = (*itr); 292 pAttr = (*itr); 293 break; 293 break; 294 } 294 } 295 } 295 } 296 return pAttr; 296 return pAttr; 297 } 297 } 298 } 298 } 299 299 300 // ------------------------------------------- 300 // -------------------------------------------------------------------- 301 G4ProcessAttribute * G4ProcessManager::GetAttr 301 G4ProcessAttribute * G4ProcessManager::GetAttribute(G4VProcess* aProcess) const 302 { 302 { 303 return GetAttribute( GetProcessIndex(aProces 303 return GetAttribute( GetProcessIndex(aProcess)); 304 } 304 } 305 305 306 // ------------------------------------------- 306 // -------------------------------------------------------------------- 307 G4int G4ProcessManager::InsertAt(G4int ip, G4V 307 G4int G4ProcessManager::InsertAt(G4int ip, G4VProcess* process, G4int ivec) 308 { 308 { 309 G4ProcessVector* pVector = theProcVector[ive 309 G4ProcessVector* pVector = theProcVector[ivec]; 310 // check position 310 // check position 311 if ( (ip<0) || (ip > G4int(pVector->entries( 311 if ( (ip<0) || (ip > G4int(pVector->entries())) ) return -1; 312 312 313 // insert in pVector 313 // insert in pVector 314 pVector->insertAt(ip, process); 314 pVector->insertAt(ip, process); 315 315 316 // correct index in ProcessAttributes of pro 316 // correct index in ProcessAttributes of processes 317 for (G4int iproc=0; iproc<numberOfProcesses; 317 for (G4int iproc=0; iproc<numberOfProcesses; ++iproc) 318 { 318 { 319 G4ProcessAttribute* aAttr = (*theAttrVecto 319 G4ProcessAttribute* aAttr = (*theAttrVector)[iproc]; 320 if (aAttr != nullptr) 320 if (aAttr != nullptr) 321 { 321 { 322 if (aAttr->idxProcVector[ivec] >= ip) 322 if (aAttr->idxProcVector[ivec] >= ip) 323 { 323 { 324 aAttr->idxProcVector[ivec] += 1; 324 aAttr->idxProcVector[ivec] += 1; 325 } 325 } 326 } 326 } 327 else 327 else 328 { 328 { 329 #ifdef G4VERBOSE 329 #ifdef G4VERBOSE 330 if (GetVerboseLevel()>0) 330 if (GetVerboseLevel()>0) 331 { 331 { 332 G4cout << " G4ProcessManager::InsertAt 332 G4cout << " G4ProcessManager::InsertAt : No Process Attribute " 333 << G4endl; 333 << G4endl; 334 } 334 } 335 #endif 335 #endif 336 } 336 } 337 } 337 } 338 return ip; 338 return ip; 339 } 339 } 340 340 341 // ------------------------------------------- 341 // -------------------------------------------------------------------- 342 G4int G4ProcessManager::RemoveAt(G4int ip, G4V 342 G4int G4ProcessManager::RemoveAt(G4int ip, G4VProcess*, G4int ivec) 343 { 343 { 344 G4ProcessVector* pVector = theProcVector[ive 344 G4ProcessVector* pVector = theProcVector[ivec]; 345 345 346 // check position 346 // check position 347 if ( (ip<0) || (ip >= G4int(pVector->entries 347 if ( (ip<0) || (ip >= G4int(pVector->entries())) ) return -1; 348 348 349 // remove process 349 // remove process 350 pVector->removeAt(ip); 350 pVector->removeAt(ip); 351 351 352 // correct index 352 // correct index 353 for(G4int iproc=0; iproc<numberOfProcesses; 353 for(G4int iproc=0; iproc<numberOfProcesses; ++iproc) 354 { 354 { 355 G4ProcessAttribute* aAttr = (*theAttrVecto 355 G4ProcessAttribute* aAttr = (*theAttrVector)[iproc]; 356 if (aAttr != nullptr) 356 if (aAttr != nullptr) 357 { 357 { 358 if (ip < aAttr->idxProcVector[ivec]) 358 if (ip < aAttr->idxProcVector[ivec]) 359 { 359 { 360 aAttr->idxProcVector[ivec] -=1; 360 aAttr->idxProcVector[ivec] -=1; 361 } 361 } 362 else if (ip == aAttr->idxProcVector[ive 362 else if (ip == aAttr->idxProcVector[ivec]) 363 { 363 { 364 aAttr->idxProcVector[ivec] = -1; 364 aAttr->idxProcVector[ivec] = -1; 365 aAttr->ordProcVector[ivec] = ordInActi 365 aAttr->ordProcVector[ivec] = ordInActive; 366 } 366 } 367 } 367 } 368 else 368 else 369 { 369 { 370 #ifdef G4VERBOSE 370 #ifdef G4VERBOSE 371 if (GetVerboseLevel()>0) 371 if (GetVerboseLevel()>0) 372 { 372 { 373 G4cout << " G4ProcessManager::RemoveAt 373 G4cout << " G4ProcessManager::RemoveAt(): No Process Attribute " 374 << G4endl; 374 << G4endl; 375 } 375 } 376 #endif 376 #endif 377 } 377 } 378 } 378 } 379 return ip; 379 return ip; 380 } 380 } 381 381 382 // ------------------------------------------- 382 // -------------------------------------------------------------------- 383 G4int G4ProcessManager::FindInsertPosition(G4i 383 G4int G4ProcessManager::FindInsertPosition(G4int ord, G4int ivec) 384 { 384 { 385 G4ProcessVector* pVector = theProcVector[ive 385 G4ProcessVector* pVector = theProcVector[ivec]; 386 G4int ip = (G4int)pVector->entries(); << 386 G4int ip = pVector->entries(); 387 G4int tmp = INT_MAX; 387 G4int tmp = INT_MAX; 388 if (ord == ordLast) return ip; 388 if (ord == ordLast) return ip; 389 389 390 // find insert position 390 // find insert position 391 for (G4int iproc=0; iproc<numberOfProcesses; 391 for (G4int iproc=0; iproc<numberOfProcesses; ++iproc) 392 { 392 { 393 G4ProcessAttribute* aAttr = (*theAttrVecto 393 G4ProcessAttribute* aAttr = (*theAttrVector)[iproc]; 394 if ( (aAttr->ordProcVector[ivec] > ord ) 394 if ( (aAttr->ordProcVector[ivec] > ord ) 395 && (tmp > aAttr->ordProcVector[ivec])) 395 && (tmp > aAttr->ordProcVector[ivec])) 396 { 396 { 397 tmp = aAttr->ordProcVector[ivec] ; 397 tmp = aAttr->ordProcVector[ivec] ; 398 if (ip > aAttr->idxProcVector[ivec]) ip 398 if (ip > aAttr->idxProcVector[ivec]) ip = aAttr->idxProcVector[ivec]; 399 } 399 } 400 } 400 } 401 return ip; 401 return ip; 402 } 402 } 403 403 404 // ------------------------------------------- 404 // -------------------------------------------------------------------- 405 G4int G4ProcessManager::AddProcess( 405 G4int G4ProcessManager::AddProcess( 406 G4VProcess* aProcess, 406 G4VProcess* aProcess, 407 G4int ordAtRestDoIt, 407 G4int ordAtRestDoIt, 408 G4int ordAlongStepDoIt, 408 G4int ordAlongStepDoIt, 409 G4int ordPostStepDoIt 409 G4int ordPostStepDoIt 410 ) 410 ) 411 { 411 { 412 // check the process is applicable to this p 412 // check the process is applicable to this particle type 413 if ( !aProcess->IsApplicable(*theParticleTy 413 if ( !aProcess->IsApplicable(*theParticleType) ) 414 { 414 { 415 #ifdef G4VERBOSE 415 #ifdef G4VERBOSE 416 if (GetVerboseLevel()>1) 416 if (GetVerboseLevel()>1) 417 { 417 { 418 G4cout << "G4ProcessManager::AddProcess( 418 G4cout << "G4ProcessManager::AddProcess()" << G4endl; 419 G4cout << "This process is not applicabl 419 G4cout << "This process is not applicable to this particle" << G4endl; 420 } 420 } 421 #endif 421 #endif 422 return -1; 422 return -1; 423 } 423 } 424 424 425 #ifdef G4VERBOSE 425 #ifdef G4VERBOSE 426 if (GetVerboseLevel()>2) 426 if (GetVerboseLevel()>2) 427 { 427 { 428 G4cout << "G4ProcessManager::AddProcess()" 428 G4cout << "G4ProcessManager::AddProcess()" << G4endl; 429 } 429 } 430 #endif 430 #endif 431 431 432 // add aProcess and this ProcessManager into 432 // add aProcess and this ProcessManager into ProcesssTable 433 G4ProcessTable* theProcessTable = G4ProcessT 433 G4ProcessTable* theProcessTable = G4ProcessTable::GetProcessTable(); 434 theProcessTable->Insert(aProcess, this); 434 theProcessTable->Insert(aProcess, this); 435 435 436 // add aProcess to process List 436 // add aProcess to process List 437 theProcessList->insert(aProcess); 437 theProcessList->insert(aProcess); 438 G4int idx = G4int(theProcessList->entries() << 438 G4int idx = (theProcessList->entries()) - 1; 439 439 440 // check size of the ProcessVector[0] 440 // check size of the ProcessVector[0] 441 if (numberOfProcesses != idx) 441 if (numberOfProcesses != idx) 442 { 442 { 443 theProcessList->removeLast(); 443 theProcessList->removeLast(); 444 G4String anErrorMessage("Inconsistent proc 444 G4String anErrorMessage("Inconsistent process List size for "); 445 anErrorMessage += "process[" + aProcess->G 445 anErrorMessage += "process[" + aProcess->GetProcessName() + "]"; 446 anErrorMessage += " particle[" + thePartic 446 anErrorMessage += " particle[" + theParticleType->GetParticleName() + "]"; 447 G4Exception("G4ProcessManager::AddProcess( 447 G4Exception("G4ProcessManager::AddProcess()", "ProcMan012", 448 FatalException, anErrorMessage 448 FatalException, anErrorMessage); 449 return -1; 449 return -1; 450 } 450 } 451 451 452 // create ProcessAttribute 452 // create ProcessAttribute 453 G4ProcessAttribute* pAttr = new G4ProcessAtt 453 G4ProcessAttribute* pAttr = new G4ProcessAttribute(aProcess); 454 pAttr->idxProcessList = idx; 454 pAttr->idxProcessList = idx; 455 455 456 // check if ordering parameter is non-zero 456 // check if ordering parameter is non-zero 457 if (ordAtRestDoIt==0) ordAtRestDoIt = 457 if (ordAtRestDoIt==0) ordAtRestDoIt = 1; 458 if (ordAlongStepDoIt==0) ordAlongStepDoIt = 458 if (ordAlongStepDoIt==0) ordAlongStepDoIt = 1; 459 if (ordPostStepDoIt==0) ordPostStepDoIt = 459 if (ordPostStepDoIt==0) ordPostStepDoIt = 1; 460 460 461 // ordering parameter 461 // ordering parameter 462 pAttr->ordProcVector[0] = ordAtRestDoIt; 462 pAttr->ordProcVector[0] = ordAtRestDoIt; 463 pAttr->ordProcVector[1] = ordAtRestDoIt; 463 pAttr->ordProcVector[1] = ordAtRestDoIt; 464 pAttr->ordProcVector[2] = ordAlongStepDoIt; 464 pAttr->ordProcVector[2] = ordAlongStepDoIt; 465 pAttr->ordProcVector[3] = ordAlongStepDoIt; 465 pAttr->ordProcVector[3] = ordAlongStepDoIt; 466 pAttr->ordProcVector[4] = ordPostStepDoIt; 466 pAttr->ordProcVector[4] = ordPostStepDoIt; 467 pAttr->ordProcVector[5] = ordPostStepDoIt; 467 pAttr->ordProcVector[5] = ordPostStepDoIt; 468 468 469 // add aProccess in Process vectors 469 // add aProccess in Process vectors 470 for (G4int ivec=1; ivec<SizeOfProcVectorArra 470 for (G4int ivec=1; ivec<SizeOfProcVectorArray; ivec+=2) 471 { 471 { 472 if (pAttr->ordProcVector[ivec] < 0 ) 472 if (pAttr->ordProcVector[ivec] < 0 ) 473 { 473 { 474 // DoIt is inactive if ordering paramete 474 // DoIt is inactive if ordering parameter is negative 475 pAttr->idxProcVector[ivec] = -1; 475 pAttr->idxProcVector[ivec] = -1; 476 } 476 } 477 else 477 else 478 { 478 { 479 // add aProcess in ordering of ordProcVe 479 // add aProcess in ordering of ordProcVector 480 // G4ProcessVector* pVector = theProcVec 480 // G4ProcessVector* pVector = theProcVector[ivec]; 481 // find insert position 481 // find insert position 482 G4int ip = FindInsertPosition(pAttr->ord 482 G4int ip = FindInsertPosition(pAttr->ordProcVector[ivec], ivec); 483 // insert 483 // insert 484 InsertAt(ip, aProcess, ivec); 484 InsertAt(ip, aProcess, ivec); 485 // set index in Process Attribute 485 // set index in Process Attribute 486 pAttr->idxProcVector[ivec] = ip; 486 pAttr->idxProcVector[ivec] = ip; 487 487 488 #ifdef G4VERBOSE 488 #ifdef G4VERBOSE 489 if (verboseLevel>2) 489 if (verboseLevel>2) 490 { 490 { 491 G4cout << "G4ProcessManager::AddProces 491 G4cout << "G4ProcessManager::AddProcess()" << G4endl; 492 G4cout << aProcess->GetProcessName() < 492 G4cout << aProcess->GetProcessName() << " is inserted at "<< ip; 493 G4cout << " in ProcessVetor[" << ivec< 493 G4cout << " in ProcessVetor[" << ivec<< "]"; 494 G4cout << " with Ordering parameter = 494 G4cout << " with Ordering parameter = " ; 495 G4cout << pAttr->ordProcVector[ivec] 495 G4cout << pAttr->ordProcVector[ivec] << G4endl; 496 } 496 } 497 #endif 497 #endif 498 } 498 } 499 } 499 } 500 500 501 // add ProcessAttribute to ProcessAttrVector 501 // add ProcessAttribute to ProcessAttrVector 502 theAttrVector->push_back(pAttr); 502 theAttrVector->push_back(pAttr); 503 503 504 numberOfProcesses += 1; 504 numberOfProcesses += 1; 505 505 506 // check consistencies between ordering para 506 // check consistencies between ordering parameters and process 507 CheckOrderingParameters(aProcess); 507 CheckOrderingParameters(aProcess); 508 508 509 CreateGPILvectors(); 509 CreateGPILvectors(); 510 510 511 // inform process manager pointer to the pro 511 // inform process manager pointer to the process 512 aProcess->SetProcessManager(this); 512 aProcess->SetProcessManager(this); 513 513 514 return idx; 514 return idx; 515 } 515 } 516 516 517 // ------------------------------------------- 517 // -------------------------------------------------------------------- 518 G4VProcess* G4ProcessManager::RemoveProcess(G4 518 G4VProcess* G4ProcessManager::RemoveProcess(G4int index) 519 { 519 { 520 //find the process attribute 520 //find the process attribute 521 G4ProcessAttribute* pAttr = GetAttribute(ind 521 G4ProcessAttribute* pAttr = GetAttribute(index); 522 if (pAttr == nullptr) return nullptr; 522 if (pAttr == nullptr) return nullptr; 523 523 524 // remove process 524 // remove process 525 G4VProcess* removedProcess = (*theProcessLis 525 G4VProcess* removedProcess = (*theProcessList)[index]; 526 526 527 if (!(pAttr->isActive)) { ActivateProcess(in 527 if (!(pAttr->isActive)) { ActivateProcess(index);} 528 // remove process from vectors if the proces 528 // remove process from vectors if the process is active 529 for (G4int ivec=0; ivec<SizeOfProcVectorArra 529 for (G4int ivec=0; ivec<SizeOfProcVectorArray; ++ivec) 530 { 530 { 531 G4ProcessVector* pVector = theProcVector[i 531 G4ProcessVector* pVector = theProcVector[ivec]; 532 G4int idx = pAttr->idxProcVector[ivec]; 532 G4int idx = pAttr->idxProcVector[ivec]; 533 if ((idx >= 0) && (idx < G4int(pVector->en 533 if ((idx >= 0) && (idx < G4int(pVector->entries()))) 534 { 534 { 535 // remove 535 // remove 536 if (RemoveAt(idx, removedProcess, ivec) 536 if (RemoveAt(idx, removedProcess, ivec) <0) 537 { 537 { 538 G4String anErrorMessage("Bad index in 538 G4String anErrorMessage("Bad index in attribute"); 539 anErrorMessage += "for particle[" 539 anErrorMessage += "for particle[" 540 + theParticleType->G 540 + theParticleType->GetParticleName() + "] "; 541 anErrorMessage += "process[" 541 anErrorMessage += "process[" 542 + removedProcess->Ge 542 + removedProcess->GetProcessName() + "] " ; 543 G4Exception( "G4ProcessManager::Remove 543 G4Exception( "G4ProcessManager::RemoveProcess()","Fatal Error", 544 FatalException,anErrorMes 544 FatalException,anErrorMessage); 545 return nullptr; 545 return nullptr; 546 } 546 } 547 } 547 } 548 else if (idx<0) 548 else if (idx<0) 549 { 549 { 550 // corresponding DoIt is not active 550 // corresponding DoIt is not active 551 } 551 } 552 else 552 else 553 { 553 { 554 // idx is out of range 554 // idx is out of range 555 G4String anErrorMessage("Bad ProcessList 555 G4String anErrorMessage("Bad ProcessList: Index is out of range "); 556 anErrorMessage += "for particle[" + theP 556 anErrorMessage += "for particle[" + theParticleType->GetParticleName() + "] "; 557 anErrorMessage += "process[" + removedPr 557 anErrorMessage += "process[" + removedProcess->GetProcessName() + "] " ; 558 G4Exception( "G4ProcessManager::RemovePr 558 G4Exception( "G4ProcessManager::RemoveProcess()","ProcMan012", 559 FatalException,anErrorMessa 559 FatalException,anErrorMessage); 560 return nullptr; 560 return nullptr; 561 } 561 } 562 } 562 } 563 pAttr->isActive = false; 563 pAttr->isActive = false; 564 // remove from the process List and delete t 564 // remove from the process List and delete the attribute 565 theProcessList->removeAt(index); 565 theProcessList->removeAt(index); 566 for (auto itr = theAttrVector->cbegin(); itr 566 for (auto itr = theAttrVector->cbegin(); itr!= theAttrVector->cend(); ++itr) 567 { 567 { 568 if ( (*itr) == pAttr) 568 if ( (*itr) == pAttr) 569 { 569 { 570 theAttrVector->erase(itr); 570 theAttrVector->erase(itr); 571 break; 571 break; 572 } 572 } 573 } 573 } 574 delete pAttr; 574 delete pAttr; 575 --numberOfProcesses; 575 --numberOfProcesses; 576 576 577 // correct index 577 // correct index 578 for(G4int i=0; i<numberOfProcesses; ++i) 578 for(G4int i=0; i<numberOfProcesses; ++i) 579 { 579 { 580 G4ProcessAttribute* aAttr = (*theAttrVecto 580 G4ProcessAttribute* aAttr = (*theAttrVector)[i]; 581 if (index < aAttr->idxProcessList) aAttr-> 581 if (index < aAttr->idxProcessList) aAttr->idxProcessList -=1; 582 } 582 } 583 583 584 CreateGPILvectors(); 584 CreateGPILvectors(); 585 585 586 // remove aProcess from ProcesssTable 586 // remove aProcess from ProcesssTable 587 G4ProcessTable* theProcessTable = G4ProcessT 587 G4ProcessTable* theProcessTable = G4ProcessTable::GetProcessTable(); 588 theProcessTable->Remove(removedProcess, this 588 theProcessTable->Remove(removedProcess, this); 589 589 590 return removedProcess; 590 return removedProcess; 591 } 591 } 592 592 593 // ------------------------------------------- 593 // -------------------------------------------------------------------- 594 G4VProcess* G4ProcessManager::RemoveProcess(G4 594 G4VProcess* G4ProcessManager::RemoveProcess(G4VProcess *aProcess) 595 { 595 { 596 return RemoveProcess(GetProcessIndex(aProces 596 return RemoveProcess(GetProcessIndex(aProcess)); 597 } 597 } 598 598 599 // ------------------------------------------- 599 // -------------------------------------------------------------------- 600 G4int G4ProcessManager::GetProcessOrdering( 600 G4int G4ProcessManager::GetProcessOrdering( 601 G4VProcess *aProcess, 601 G4VProcess *aProcess, 602 G4ProcessVectorDoItInd 602 G4ProcessVectorDoItIndex idDoIt 603 ) 603 ) 604 { 604 { 605 // get Process Vector Id 605 // get Process Vector Id 606 G4int ivec = GetProcessVectorId(idDoIt, type 606 G4int ivec = GetProcessVectorId(idDoIt, typeDoIt); 607 if (ivec >=0 ) 607 if (ivec >=0 ) 608 { 608 { 609 // get attribute 609 // get attribute 610 G4ProcessAttribute* pAttr = GetAttribute(a 610 G4ProcessAttribute* pAttr = GetAttribute(aProcess); 611 if (pAttr != nullptr) 611 if (pAttr != nullptr) 612 { 612 { 613 return pAttr->ordProcVector[ivec]; 613 return pAttr->ordProcVector[ivec]; 614 } 614 } 615 } 615 } 616 return -1; 616 return -1; 617 } 617 } 618 618 619 // ------------------------------------------- 619 // -------------------------------------------------------------------- 620 void G4ProcessManager::SetProcessOrdering( 620 void G4ProcessManager::SetProcessOrdering( 621 G4VProcess *aProcess, 621 G4VProcess *aProcess, 622 G4ProcessVectorDoItInd 622 G4ProcessVectorDoItIndex idDoIt, 623 G4int ordDoIt 623 G4int ordDoIt 624 ) 624 ) 625 { 625 { 626 const G4String aErrorMessage("G4ProcessManag 626 const G4String aErrorMessage("G4ProcessManager::SetProcessOrdering() - "); 627 627 628 #ifdef G4VERBOSE 628 #ifdef G4VERBOSE 629 if (GetVerboseLevel()>2) 629 if (GetVerboseLevel()>2) 630 { 630 { 631 G4cout << aErrorMessage ; 631 G4cout << aErrorMessage ; 632 G4cout << "particle[" + theParticleType->G 632 G4cout << "particle[" + theParticleType->GetParticleName() +"] " ; 633 G4cout <<"process[" + aProcess->GetProcess 633 G4cout <<"process[" + aProcess->GetProcessName() + "]"<< G4endl; 634 } 634 } 635 #endif 635 #endif 636 636 637 // get Process Vector Id 637 // get Process Vector Id 638 G4int ivec = GetProcessVectorId(idDoIt, type 638 G4int ivec = GetProcessVectorId(idDoIt, typeDoIt); 639 if (ivec <0 ) 639 if (ivec <0 ) 640 { 640 { 641 #ifdef G4VERBOSE 641 #ifdef G4VERBOSE 642 if (verboseLevel>0) 642 if (verboseLevel>0) 643 { 643 { 644 G4cout << aErrorMessage << G4endl; 644 G4cout << aErrorMessage << G4endl; 645 G4cout << "particle[" << theParticleType 645 G4cout << "particle[" << theParticleType->GetParticleName() << "] " ; 646 G4cout << "process[" << aProcess->GetPro 646 G4cout << "process[" << aProcess->GetProcessName() << "]"<< G4endl; 647 G4cout << " illegal DoIt Index [= " << G 647 G4cout << " illegal DoIt Index [= " << G4int(idDoIt) << "]"; 648 G4cout << G4endl; 648 G4cout << G4endl; 649 } 649 } 650 #endif 650 #endif 651 return; 651 return; 652 } 652 } 653 653 654 if (ordDoIt>ordLast) ordDoIt = ordLast; 654 if (ordDoIt>ordLast) ordDoIt = ordLast; 655 // get attribute 655 // get attribute 656 G4ProcessAttribute* pAttr = GetAttribute(aPr 656 G4ProcessAttribute* pAttr = GetAttribute(aProcess); 657 if (pAttr == nullptr) 657 if (pAttr == nullptr) 658 { 658 { 659 // can not get process attribute 659 // can not get process attribute 660 return; 660 return; 661 } 661 } 662 else 662 else 663 { 663 { 664 G4int ip = pAttr->idxProcVector[ivec]; 664 G4int ip = pAttr->idxProcVector[ivec]; 665 // remove a process from the process vecto 665 // remove a process from the process vector 666 if ( ip >=0 ) 666 if ( ip >=0 ) 667 { 667 { 668 RemoveAt(ip, aProcess, ivec); 668 RemoveAt(ip, aProcess, ivec); 669 } 669 } 670 670 671 // set ordering parameter to non-zero 671 // set ordering parameter to non-zero 672 if (ordDoIt == 0) ordDoIt = 1; 672 if (ordDoIt == 0) ordDoIt = 1; 673 pAttr->ordProcVector[ivec-1] = ordDoIt; 673 pAttr->ordProcVector[ivec-1] = ordDoIt; 674 pAttr->ordProcVector[ivec] = ordDoIt; 674 pAttr->ordProcVector[ivec] = ordDoIt; 675 675 676 // insert in process vector if ordDoIt >0 676 // insert in process vector if ordDoIt >0 677 if (ordDoIt >0) 677 if (ordDoIt >0) 678 { 678 { 679 // find insert position 679 // find insert position 680 ip = FindInsertPosition(pAttr->ordProcVe 680 ip = FindInsertPosition(pAttr->ordProcVector[ivec], ivec); 681 // insert 681 // insert 682 InsertAt(ip, aProcess, ivec); 682 InsertAt(ip, aProcess, ivec); 683 // set index in Process Attribute 683 // set index in Process Attribute 684 pAttr->idxProcVector[ivec] = ip; 684 pAttr->idxProcVector[ivec] = ip; 685 #ifdef G4VERBOSE 685 #ifdef G4VERBOSE 686 if (verboseLevel>2) 686 if (verboseLevel>2) 687 { 687 { 688 G4cout << aErrorMessage << G4endl; 688 G4cout << aErrorMessage << G4endl; 689 G4cout << "particle[" << theParticleTy 689 G4cout << "particle[" << theParticleType->GetParticleName() << "] " ; 690 G4cout <<"process[" << aProcess->GetPr 690 G4cout <<"process[" << aProcess->GetProcessName() << "]"<< G4endl; 691 G4cout << aProcess->GetProcessName() < 691 G4cout << aProcess->GetProcessName() << " is inserted at "<< ip; 692 G4cout << " in ProcessVetor[" << ivec< 692 G4cout << " in ProcessVetor[" << ivec<< "]"; 693 G4cout << " with Ordering parameter = 693 G4cout << " with Ordering parameter = " << ordDoIt ; 694 G4cout << G4endl; 694 G4cout << G4endl; 695 } 695 } 696 #endif 696 #endif 697 } 697 } 698 } 698 } 699 // check consistencies between ordering para 699 // check consistencies between ordering parameters and process 700 CheckOrderingParameters(aProcess); 700 CheckOrderingParameters(aProcess); 701 701 702 // create GPIL vectors 702 // create GPIL vectors 703 CreateGPILvectors(); 703 CreateGPILvectors(); 704 } 704 } 705 705 706 // ------------------------------------------- 706 // -------------------------------------------------------------------- 707 void G4ProcessManager::SetProcessOrderingToFir 707 void G4ProcessManager::SetProcessOrderingToFirst( 708 G4VProcess *aPr 708 G4VProcess *aProcess, 709 G4ProcessVector 709 G4ProcessVectorDoItIndex idDoIt 710 ) 710 ) 711 { 711 { 712 // get Process Vector Id 712 // get Process Vector Id 713 G4int ivec = GetProcessVectorId(idDoIt, type 713 G4int ivec = GetProcessVectorId(idDoIt, typeDoIt); 714 if (ivec <0 ) 714 if (ivec <0 ) 715 { 715 { 716 #ifdef G4VERBOSE 716 #ifdef G4VERBOSE 717 if (verboseLevel>0) 717 if (verboseLevel>0) 718 { 718 { 719 G4cout << "G4ProcessManager::SetProcessO 719 G4cout << "G4ProcessManager::SetProcessOrderingToFirst(): "; 720 G4cout << " illegal DoIt Index [= " << G 720 G4cout << " illegal DoIt Index [= " << G4int(idDoIt) << "]"; 721 G4cout << G4endl; 721 G4cout << G4endl; 722 } 722 } 723 #endif 723 #endif 724 return; 724 return; 725 } 725 } 726 726 727 // get attribute 727 // get attribute 728 G4ProcessAttribute* pAttr = GetAttribute(aP 728 G4ProcessAttribute* pAttr = GetAttribute(aProcess); 729 if (pAttr == nullptr) 729 if (pAttr == nullptr) 730 { 730 { 731 return; 731 return; 732 } 732 } 733 else 733 else 734 { 734 { 735 G4int ip = pAttr->idxProcVector[ivec]; 735 G4int ip = pAttr->idxProcVector[ivec]; 736 736 737 // remove a process from the process vect 737 // remove a process from the process vector 738 if ( ip >=0 ) 738 if ( ip >=0 ) 739 { 739 { 740 RemoveAt(ip, aProcess, ivec); 740 RemoveAt(ip, aProcess, ivec); 741 } 741 } 742 742 743 // set ordering parameter to zero 743 // set ordering parameter to zero 744 pAttr->ordProcVector[ivec] = 0; 744 pAttr->ordProcVector[ivec] = 0; 745 pAttr->ordProcVector[ivec-1] = 0; 745 pAttr->ordProcVector[ivec-1] = 0; 746 746 747 // insert 747 // insert 748 InsertAt(0, aProcess, ivec); 748 InsertAt(0, aProcess, ivec); 749 749 750 // set index in Process Attribute 750 // set index in Process Attribute 751 pAttr->idxProcVector[ivec] = 0; 751 pAttr->idxProcVector[ivec] = 0; 752 752 753 #ifdef G4VERBOSE 753 #ifdef G4VERBOSE 754 if (verboseLevel>2) 754 if (verboseLevel>2) 755 { 755 { 756 G4cout << "G4ProcessManager::SetProcess 756 G4cout << "G4ProcessManager::SetProcessOrderingToFirst(): "; 757 G4cout << aProcess->GetProcessName() << 757 G4cout << aProcess->GetProcessName() << " is inserted at top "; 758 G4cout << " in ProcessVetor[" << ivec<< 758 G4cout << " in ProcessVetor[" << ivec<< "]"; 759 G4cout << G4endl; 759 G4cout << G4endl; 760 } 760 } 761 #endif 761 #endif 762 } 762 } 763 763 764 if (isSetOrderingFirstInvoked[idDoIt]) 764 if (isSetOrderingFirstInvoked[idDoIt]) 765 { 765 { 766 G4String anErrMsg = "Set Ordering First i 766 G4String anErrMsg = "Set Ordering First is invoked twice for "; 767 anErrMsg += aProcess->GetProcessName(); 767 anErrMsg += aProcess->GetProcessName(); 768 anErrMsg += " to "; 768 anErrMsg += " to "; 769 anErrMsg += theParticleType->GetParticleN 769 anErrMsg += theParticleType->GetParticleName(); 770 G4Exception("G4ProcessManager::SetProcess 770 G4Exception("G4ProcessManager::SetProcessOrderingToFirst()", 771 "ProcMan113", JustWarning, an 771 "ProcMan113", JustWarning, anErrMsg); 772 } 772 } 773 isSetOrderingFirstInvoked[idDoIt] = true; 773 isSetOrderingFirstInvoked[idDoIt] = true; 774 774 775 // check consistencies between ordering par 775 // check consistencies between ordering parameters and process 776 CheckOrderingParameters(aProcess); 776 CheckOrderingParameters(aProcess); 777 777 778 // create GPIL vectors 778 // create GPIL vectors 779 CreateGPILvectors(); 779 CreateGPILvectors(); 780 } 780 } 781 781 782 // ------------------------------------------- 782 // -------------------------------------------------------------------- 783 void G4ProcessManager::SetProcessOrderingToSec 783 void G4ProcessManager::SetProcessOrderingToSecond( 784 G4VProcess *aProcess, 784 G4VProcess *aProcess, 785 G4ProcessVectorDoItInd 785 G4ProcessVectorDoItIndex idDoIt 786 ) 786 ) 787 { 787 { 788 const G4String aErrorMessage("G4ProcessManag 788 const G4String aErrorMessage("G4ProcessManager::SetProcessOrderingToSecond() - "); 789 789 790 #ifdef G4VERBOSE 790 #ifdef G4VERBOSE 791 if (GetVerboseLevel()>2) 791 if (GetVerboseLevel()>2) 792 { 792 { 793 G4cout << aErrorMessage ; 793 G4cout << aErrorMessage ; 794 G4cout << "particle[" << theParticleType-> 794 G4cout << "particle[" << theParticleType->GetParticleName() << "] " ; 795 G4cout <<"process[" << aProcess->GetProces 795 G4cout <<"process[" << aProcess->GetProcessName() << "]"<< G4endl; 796 } 796 } 797 #endif 797 #endif 798 798 799 // get Process Vector Id 799 // get Process Vector Id 800 G4int ivec = GetProcessVectorId(idDoIt, type 800 G4int ivec = GetProcessVectorId(idDoIt, typeDoIt); 801 if (ivec <0 ) 801 if (ivec <0 ) 802 { 802 { 803 #ifdef G4VERBOSE 803 #ifdef G4VERBOSE 804 if (verboseLevel>0) 804 if (verboseLevel>0) 805 { 805 { 806 G4cout << aErrorMessage << G4endl; 806 G4cout << aErrorMessage << G4endl; 807 G4cout << "particle[" << theParticleType 807 G4cout << "particle[" << theParticleType->GetParticleName() << "] " ; 808 G4cout << "process[" << aProcess->GetPro 808 G4cout << "process[" << aProcess->GetProcessName() << "]"<< G4endl; 809 G4cout << " illegal DoIt Index [= " << G 809 G4cout << " illegal DoIt Index [= " << G4int(idDoIt) << "]"; 810 G4cout << G4endl; 810 G4cout << G4endl; 811 } 811 } 812 #endif 812 #endif 813 return; 813 return; 814 } 814 } 815 815 816 // get attribute 816 // get attribute 817 G4ProcessAttribute* pAttr = GetAttribute(aPr 817 G4ProcessAttribute* pAttr = GetAttribute(aProcess); 818 if (pAttr == nullptr) 818 if (pAttr == nullptr) 819 { 819 { 820 // can not get process attribute 820 // can not get process attribute 821 return; 821 return; 822 } 822 } 823 else 823 else 824 { 824 { 825 G4int ip = pAttr->idxProcVector[ivec]; 825 G4int ip = pAttr->idxProcVector[ivec]; 826 // remove a process from the process vecto 826 // remove a process from the process vector 827 if ( ip >=0 ) 827 if ( ip >=0 ) 828 { 828 { 829 RemoveAt(ip, aProcess, ivec); 829 RemoveAt(ip, aProcess, ivec); 830 } 830 } 831 } 831 } 832 832 833 // set ordering parameter 833 // set ordering parameter 834 pAttr->ordProcVector[ivec-1] = 0; 834 pAttr->ordProcVector[ivec-1] = 0; 835 pAttr->ordProcVector[ivec] = 0; 835 pAttr->ordProcVector[ivec] = 0; 836 836 837 // find insert position 837 // find insert position 838 G4ProcessVector* pVector = theProcVector[ive 838 G4ProcessVector* pVector = theProcVector[ivec]; 839 G4int ip = (G4int)pVector->entries(); << 839 G4int ip = pVector->entries(); 840 G4int tmp = INT_MAX; 840 G4int tmp = INT_MAX; 841 841 842 // find insert position 842 // find insert position 843 for (G4int iproc=0; iproc<numberOfProcesses; 843 for (G4int iproc=0; iproc<numberOfProcesses; ++iproc) 844 { 844 { 845 G4ProcessAttribute* aAttr = (*theAttrVecto 845 G4ProcessAttribute* aAttr = (*theAttrVector)[iproc]; 846 if ( aAttr->idxProcVector[ivec] >= 0 ) 846 if ( aAttr->idxProcVector[ivec] >= 0 ) 847 { 847 { 848 if ( (aAttr->ordProcVector[ivec] !=0 ) 848 if ( (aAttr->ordProcVector[ivec] !=0 ) && 849 (tmp >= aAttr->ordProcVector[ivec]) 849 (tmp >= aAttr->ordProcVector[ivec]) ) 850 { 850 { 851 tmp = aAttr->ordProcVector[ivec]; 851 tmp = aAttr->ordProcVector[ivec]; 852 if ( ip > aAttr->idxProcVector[ivec] ) 852 if ( ip > aAttr->idxProcVector[ivec] ) 853 { 853 { 854 ip = aAttr->idxProcVector[ivec] ; 854 ip = aAttr->idxProcVector[ivec] ; 855 } 855 } 856 } 856 } 857 } 857 } 858 } 858 } 859 859 860 // insert 860 // insert 861 InsertAt(ip, aProcess, ivec); 861 InsertAt(ip, aProcess, ivec); 862 862 863 // set index in Process Attribute 863 // set index in Process Attribute 864 pAttr->idxProcVector[ivec] = ip; 864 pAttr->idxProcVector[ivec] = ip; 865 #ifdef G4VERBOSE 865 #ifdef G4VERBOSE 866 if (verboseLevel>2) 866 if (verboseLevel>2) 867 { 867 { 868 G4cout << aErrorMessage << G4endl; 868 G4cout << aErrorMessage << G4endl; 869 G4cout << "particle[" << theParticleType-> 869 G4cout << "particle[" << theParticleType->GetParticleName() << "] " ; 870 G4cout <<"process[" << aProcess->GetProces 870 G4cout <<"process[" << aProcess->GetProcessName() << "]"<< G4endl; 871 G4cout << aProcess->GetProcessName() << " 871 G4cout << aProcess->GetProcessName() << " is inserted at "<< ip; 872 G4cout << " in ProcessVetor[" << ivec<< "] 872 G4cout << " in ProcessVetor[" << ivec<< "]"; 873 G4cout << " with Ordering parameter = 1 "; 873 G4cout << " with Ordering parameter = 1 "; 874 G4cout << G4endl; 874 G4cout << G4endl; 875 } 875 } 876 #endif 876 #endif 877 877 878 // check consistencies between ordering para 878 // check consistencies between ordering parameters and process 879 CheckOrderingParameters(aProcess); 879 CheckOrderingParameters(aProcess); 880 880 881 // create GPIL vectors 881 // create GPIL vectors 882 CreateGPILvectors(); 882 CreateGPILvectors(); 883 } 883 } 884 884 885 // ------------------------------------------- 885 // -------------------------------------------------------------------- 886 void G4ProcessManager::SetProcessOrderingToLas 886 void G4ProcessManager::SetProcessOrderingToLast( 887 G4VProcess *aPr 887 G4VProcess *aProcess, 888 G4ProcessVector 888 G4ProcessVectorDoItIndex idDoIt 889 ) 889 ) 890 { 890 { 891 SetProcessOrdering(aProcess, idDoIt, ordLast 891 SetProcessOrdering(aProcess, idDoIt, ordLast ); 892 892 893 if (isSetOrderingLastInvoked[idDoIt]) 893 if (isSetOrderingLastInvoked[idDoIt]) 894 { 894 { 895 G4String anErrMsg = "Set Ordering Last is 895 G4String anErrMsg = "Set Ordering Last is invoked twice for "; 896 anErrMsg += aProcess->GetProcessName(); 896 anErrMsg += aProcess->GetProcessName(); 897 anErrMsg += " to "; 897 anErrMsg += " to "; 898 anErrMsg += theParticleType->GetParticleNa 898 anErrMsg += theParticleType->GetParticleName(); 899 G4Exception( "G4ProcessManager::SetProcess 899 G4Exception( "G4ProcessManager::SetProcessOrderingToLast()","ProcMan114", 900 JustWarning,anErrMsg); 900 JustWarning,anErrMsg); 901 } 901 } 902 isSetOrderingLastInvoked[idDoIt] = true; 902 isSetOrderingLastInvoked[idDoIt] = true; 903 } 903 } 904 904 905 // ------------------------------------------- 905 // -------------------------------------------------------------------- 906 G4VProcess* G4ProcessManager::InActivateProces 906 G4VProcess* G4ProcessManager::InActivateProcess(G4int index) 907 { 907 { 908 G4ApplicationState currentState 908 G4ApplicationState currentState 909 = G4StateManager::GetStateManager()->GetCur 909 = G4StateManager::GetStateManager()->GetCurrentState(); 910 if ( (currentState == G4State_PreInit) || (c 910 if ( (currentState == G4State_PreInit) || (currentState == G4State_Init) ) 911 { 911 { 912 #ifdef G4VERBOSE 912 #ifdef G4VERBOSE 913 if (GetVerboseLevel()>1) 913 if (GetVerboseLevel()>1) 914 { 914 { 915 G4cout << "G4ProcessManager::InActivateP 915 G4cout << "G4ProcessManager::InActivateProcess is not valid in "; 916 if (currentState == G4State_PreInit ) 916 if (currentState == G4State_PreInit ) 917 { 917 { 918 G4cout << "PreInit "; 918 G4cout << "PreInit "; 919 } 919 } 920 else if (currentState == G4State_Init ) 920 else if (currentState == G4State_Init ) 921 { 921 { 922 G4cout << "Init "; 922 G4cout << "Init "; 923 } 923 } 924 G4cout << "state !" << G4endl; 924 G4cout << "state !" << G4endl; 925 } 925 } 926 #endif 926 #endif 927 return nullptr; 927 return nullptr; 928 } 928 } 929 929 930 // find the process attribute 930 // find the process attribute 931 G4ProcessAttribute* pAttr = GetAttribute(ind 931 G4ProcessAttribute* pAttr = GetAttribute(index); 932 if (pAttr == nullptr) return nullptr; 932 if (pAttr == nullptr) return nullptr; 933 933 934 // remove process 934 // remove process 935 G4VProcess* pProcess = (*theProcessList)[ind 935 G4VProcess* pProcess = (*theProcessList)[index]; 936 936 937 const G4String aErrorMessage("G4ProcessManag 937 const G4String aErrorMessage("G4ProcessManager::InactivateProcess() - "); 938 938 939 if (pAttr->isActive) 939 if (pAttr->isActive) 940 { 940 { 941 // remove process from vectors if the proc 941 // remove process from vectors if the process is active 942 for (G4int i=0; i<SizeOfProcVectorArray; + 942 for (G4int i=0; i<SizeOfProcVectorArray; ++i) 943 { 943 { 944 G4ProcessVector* pVector = theProcVector 944 G4ProcessVector* pVector = theProcVector[i]; 945 G4int idx = pAttr->idxProcVector[i]; 945 G4int idx = pAttr->idxProcVector[i]; 946 946 947 if (idx<0) 947 if (idx<0) 948 { 948 { 949 // corresponding DoIt is not active 949 // corresponding DoIt is not active 950 } 950 } 951 else if ((idx >= 0) && (idx < G4int(pVec 951 else if ((idx >= 0) && (idx < G4int(pVector->entries()))) 952 { 952 { 953 //check pointer and set to 0 953 //check pointer and set to 0 954 if ((*pVector)[idx]== pProcess) 954 if ((*pVector)[idx]== pProcess) 955 { 955 { 956 (*pVector)[idx]= nullptr; 956 (*pVector)[idx]= nullptr; 957 } 957 } 958 else 958 else 959 { 959 { 960 G4String anErrorMessage("Bad Process 960 G4String anErrorMessage("Bad ProcessList: Bad index in attribute"); 961 anErrorMessage += "for particle[" + 961 anErrorMessage += "for particle[" + theParticleType->GetParticleName() + "] "; 962 anErrorMessage += "process[" + pProc 962 anErrorMessage += "process[" + pProcess->GetProcessName() + "] " ; 963 G4Exception( "G4ProcessManager::Inac 963 G4Exception( "G4ProcessManager::InactivateProcess()", "ProcMan012", 964 FatalException, anError 964 FatalException, anErrorMessage); 965 return nullptr; 965 return nullptr; 966 } 966 } 967 } 967 } 968 else 968 else 969 { 969 { 970 // idx is out of range 970 // idx is out of range 971 G4String anErrorMessage("Bad ProcessLi 971 G4String anErrorMessage("Bad ProcessList: Index is out of range"); 972 anErrorMessage += "for particle[" + th 972 anErrorMessage += "for particle[" + theParticleType->GetParticleName() + "] "; 973 anErrorMessage += "process[" + pProces 973 anErrorMessage += "process[" + pProcess->GetProcessName() + "] " ; 974 G4Exception( "G4ProcessManager::Inacti 974 G4Exception( "G4ProcessManager::InactivateProcess()", "ProcMan012", 975 FatalException, anErrorMe 975 FatalException, anErrorMessage); 976 return nullptr; 976 return nullptr; 977 } 977 } 978 } 978 } 979 pAttr->isActive = false; 979 pAttr->isActive = false; 980 } 980 } 981 return pProcess; 981 return pProcess; 982 } 982 } 983 983 984 // ------------------------------------------- 984 // -------------------------------------------------------------------- 985 G4VProcess* G4ProcessManager::ActivateProcess( 985 G4VProcess* G4ProcessManager::ActivateProcess(G4int index) 986 { 986 { 987 G4ApplicationState currentState 987 G4ApplicationState currentState 988 = G4StateManager::GetStateManager()->GetCur 988 = G4StateManager::GetStateManager()->GetCurrentState(); 989 if ( (currentState == G4State_PreInit) || (c 989 if ( (currentState == G4State_PreInit) || (currentState == G4State_Init) ) 990 { 990 { 991 #ifdef G4VERBOSE 991 #ifdef G4VERBOSE 992 if (GetVerboseLevel()>1) 992 if (GetVerboseLevel()>1) 993 { 993 { 994 G4cout << "G4ProcessManager::ActivatePro 994 G4cout << "G4ProcessManager::ActivateProcess() is not valid in "; 995 if (currentState == G4State_PreInit ) 995 if (currentState == G4State_PreInit ) 996 { 996 { 997 G4cout << "PreInit "; 997 G4cout << "PreInit "; 998 } 998 } 999 else if (currentState == G4State_Init ) 999 else if (currentState == G4State_Init ) 1000 { 1000 { 1001 G4cout << "Init "; 1001 G4cout << "Init "; 1002 } 1002 } 1003 G4cout << "state !" << G4endl; 1003 G4cout << "state !" << G4endl; 1004 } 1004 } 1005 #endif 1005 #endif 1006 return nullptr; 1006 return nullptr; 1007 } 1007 } 1008 1008 1009 //find the process attribute 1009 //find the process attribute 1010 G4ProcessAttribute* pAttr = GetAttribute(in 1010 G4ProcessAttribute* pAttr = GetAttribute(index); 1011 if (pAttr == nullptr) return nullptr; 1011 if (pAttr == nullptr) return nullptr; 1012 1012 1013 // remove process 1013 // remove process 1014 G4VProcess* pProcess = (*theProcessList)[in 1014 G4VProcess* pProcess = (*theProcessList)[index]; 1015 1015 1016 if (!pAttr->isActive) 1016 if (!pAttr->isActive) 1017 { 1017 { 1018 // remove process from vectors if the pro 1018 // remove process from vectors if the process is active 1019 for (G4int i=0; i<SizeOfProcVectorArray; 1019 for (G4int i=0; i<SizeOfProcVectorArray; ++i) 1020 { 1020 { 1021 G4ProcessVector* pVector = theProcVecto 1021 G4ProcessVector* pVector = theProcVector[i]; 1022 G4int idx = pAttr->idxProcVector[i]; 1022 G4int idx = pAttr->idxProcVector[i]; 1023 if (idx<0) 1023 if (idx<0) 1024 { 1024 { 1025 // corresponding DoIt is not active 1025 // corresponding DoIt is not active 1026 } 1026 } 1027 else if ((idx >= 0) && (idx < G4int(pVe 1027 else if ((idx >= 0) && (idx < G4int(pVector->entries()))) 1028 { 1028 { 1029 // check pointer and set 1029 // check pointer and set 1030 if ((*pVector)[idx] == nullptr) 1030 if ((*pVector)[idx] == nullptr) 1031 { 1031 { 1032 (*pVector)[idx] = pProcess; 1032 (*pVector)[idx] = pProcess; 1033 } 1033 } 1034 else 1034 else 1035 { 1035 { 1036 G4String anErrorMessage("Bad Proces 1036 G4String anErrorMessage("Bad ProcessList: Bad index in attribute"); 1037 anErrorMessage += "for particle[" + 1037 anErrorMessage += "for particle[" + theParticleType->GetParticleName() + "] "; 1038 anErrorMessage += "process[" + pPro 1038 anErrorMessage += "process[" + pProcess->GetProcessName() + "] " ; 1039 G4Exception("G4ProcessManager::Acti 1039 G4Exception("G4ProcessManager::ActivateProcess()", "ProcMan012", 1040 FatalException, anError 1040 FatalException, anErrorMessage); 1041 return nullptr; 1041 return nullptr; 1042 } 1042 } 1043 } 1043 } 1044 else 1044 else 1045 { 1045 { 1046 // idx is out of range 1046 // idx is out of range 1047 G4String anErrorMessage("bad ProcessL 1047 G4String anErrorMessage("bad ProcessList: Index is out of range"); 1048 anErrorMessage += "for particle[" 1048 anErrorMessage += "for particle[" 1049 + theParticleType-> 1049 + theParticleType->GetParticleName() + "] "; 1050 anErrorMessage += "process[" + pProce 1050 anErrorMessage += "process[" + pProcess->GetProcessName() + "] " ; 1051 G4Exception("G4ProcessManager::Activa 1051 G4Exception("G4ProcessManager::ActivateProcess()", "ProcMan012", 1052 FatalException, anErrorMe 1052 FatalException, anErrorMessage); 1053 return nullptr; 1053 return nullptr; 1054 } 1054 } 1055 } 1055 } 1056 pAttr->isActive = true; 1056 pAttr->isActive = true; 1057 } 1057 } 1058 return pProcess; 1058 return pProcess; 1059 } 1059 } 1060 1060 1061 // ------------------------------------------ 1061 // -------------------------------------------------------------------- 1062 G4bool G4ProcessManager::operator==(const G4P 1062 G4bool G4ProcessManager::operator==(const G4ProcessManager &right) const 1063 { 1063 { 1064 return (this == &right); 1064 return (this == &right); 1065 } 1065 } 1066 1066 1067 // ------------------------------------------ 1067 // -------------------------------------------------------------------- 1068 G4bool G4ProcessManager::operator!=(const G4P 1068 G4bool G4ProcessManager::operator!=(const G4ProcessManager &right) const 1069 { 1069 { 1070 return (this != &right); 1070 return (this != &right); 1071 } 1071 } 1072 1072 1073 // ------------------------------------------ 1073 // -------------------------------------------------------------------- 1074 void G4ProcessManager::DumpInfo() 1074 void G4ProcessManager::DumpInfo() 1075 { 1075 { 1076 // Dump Information 1076 // Dump Information 1077 1077 1078 // particle type 1078 // particle type 1079 G4cout << "G4ProcessManager: particle[" 1079 G4cout << "G4ProcessManager: particle[" 1080 << theParticleType->GetParticleName( 1080 << theParticleType->GetParticleName() << "]" 1081 << G4endl; 1081 << G4endl; 1082 1082 1083 // loop over all processes 1083 // loop over all processes 1084 for (G4int idx=0; idx < (G4int)theProcessLi << 1084 for (std::size_t idx=0; idx < theProcessList->entries(); ++idx) 1085 { 1085 { 1086 // process name/type 1086 // process name/type 1087 G4cout << "[" << idx << "]"; 1087 G4cout << "[" << idx << "]"; 1088 G4cout << "=== process[" << ((*theProcess 1088 G4cout << "=== process[" << ((*theProcessList)(idx))->GetProcessName() 1089 << " :"; 1089 << " :"; 1090 G4cout << G4VProcess::GetProcessTypeName( 1090 G4cout << G4VProcess::GetProcessTypeName( ((*theProcessList)(idx))->GetProcessType() ) 1091 << "]"; 1091 << "]"; 1092 1092 1093 // process attribute 1093 // process attribute 1094 G4ProcessAttribute* pAttr = (*theAttrVect 1094 G4ProcessAttribute* pAttr = (*theAttrVector)[idx]; 1095 // status 1095 // status 1096 if ( pAttr-> isActive ) 1096 if ( pAttr-> isActive ) 1097 { 1097 { 1098 G4cout << " Active "; 1098 G4cout << " Active "; 1099 } 1099 } 1100 else 1100 else 1101 { 1101 { 1102 G4cout << " InActive "; 1102 G4cout << " InActive "; 1103 } 1103 } 1104 G4cout << G4endl; 1104 G4cout << G4endl; 1105 1105 1106 #ifdef G4VERBOSE 1106 #ifdef G4VERBOSE 1107 if (verboseLevel>0) 1107 if (verboseLevel>0) 1108 { 1108 { 1109 // order parameter 1109 // order parameter 1110 G4cout << " Ordering:: "; 1110 G4cout << " Ordering:: "; 1111 G4cout << " AtRest A 1111 G4cout << " AtRest AlongStep PostStep "; 1112 G4cout << G4endl; 1112 G4cout << G4endl; 1113 G4cout << " "; 1113 G4cout << " "; 1114 G4cout << " GetPIL/ DoIt GetPIL 1114 G4cout << " GetPIL/ DoIt GetPIL/ DoIt GetPIL/ DoIt "; 1115 G4cout << G4endl; 1115 G4cout << G4endl; 1116 G4cout << " Ordering:: " << G4end 1116 G4cout << " Ordering:: " << G4endl; 1117 G4cout << " index "; 1117 G4cout << " index "; 1118 for (G4int idx2 = 0; idx2 <6 ; ++idx2) 1118 for (G4int idx2 = 0; idx2 <6 ; ++idx2) 1119 { 1119 { 1120 G4cout << std::setw(8) << pAttr->idxP 1120 G4cout << std::setw(8) << pAttr->idxProcVector[idx2] << ":"; 1121 } 1121 } 1122 G4cout << G4endl; 1122 G4cout << G4endl; 1123 G4cout << " parameter "; 1123 G4cout << " parameter "; 1124 for (G4int idx3 = 0; idx3 <6 ; ++idx3) 1124 for (G4int idx3 = 0; idx3 <6 ; ++idx3) 1125 { 1125 { 1126 G4cout << std::setw(8) << pAttr->ordP 1126 G4cout << std::setw(8) << pAttr->ordProcVector[idx3] << ":"; 1127 } 1127 } 1128 G4cout << G4endl; 1128 G4cout << G4endl; 1129 } 1129 } 1130 #endif 1130 #endif 1131 } 1131 } 1132 } 1132 } 1133 1133 1134 // ------------------------------------------ 1134 // -------------------------------------------------------------------- 1135 void G4ProcessManager::CreateGPILvectors() 1135 void G4ProcessManager::CreateGPILvectors() 1136 { 1136 { 1137 // Create GetPhysicalInteractionLength proc 1137 // Create GetPhysicalInteractionLength process vectors just as the inverse 1138 // order of DoIt() process vector 1138 // order of DoIt() process vector 1139 1139 1140 for(G4int k=0; k<(G4int)theProcessList->ent << 1140 for(std::size_t k=0; k<theProcessList->entries(); ++k) 1141 { 1141 { 1142 GetAttribute((*theProcessList)[k])->idxPr 1142 GetAttribute((*theProcessList)[k])->idxProcVector[0]=-1; 1143 GetAttribute((*theProcessList)[k])->idxPr 1143 GetAttribute((*theProcessList)[k])->idxProcVector[2]=-1; 1144 GetAttribute((*theProcessList)[k])->idxPr 1144 GetAttribute((*theProcessList)[k])->idxProcVector[4]=-1; 1145 } 1145 } 1146 1146 1147 for(G4int i=0; i<SizeOfProcVectorArray; i + 1147 for(G4int i=0; i<SizeOfProcVectorArray; i += 2) 1148 { 1148 { 1149 G4ProcessVector* procGPIL = theProcVector 1149 G4ProcessVector* procGPIL = theProcVector[i]; 1150 G4ProcessVector* procDoIt = theProcVector 1150 G4ProcessVector* procDoIt = theProcVector[i+1]; 1151 G4int nproc = (G4int)procDoIt->entries(); << 1151 G4int nproc = procDoIt->entries(); 1152 procGPIL->clear(); 1152 procGPIL->clear(); 1153 for(G4int j=nproc-1;j>=0;--j) 1153 for(G4int j=nproc-1;j>=0;--j) 1154 { 1154 { 1155 G4VProcess* aProc = (*procDoIt)[j]; 1155 G4VProcess* aProc = (*procDoIt)[j]; 1156 procGPIL->insert(aProc); 1156 procGPIL->insert(aProc); 1157 GetAttribute(aProc)->idxProcVector[i] = << 1157 GetAttribute(aProc)->idxProcVector[i] = procGPIL->entries()-1; 1158 } 1158 } 1159 } 1159 } 1160 } 1160 } 1161 1161 1162 // ------------------------------------------ 1162 // -------------------------------------------------------------------- 1163 void G4ProcessManager::StartTracking(G4Track* 1163 void G4ProcessManager::StartTracking(G4Track* aTrack) 1164 { 1164 { 1165 for (G4int idx = 0; idx<(G4int)theProcessLi << 1165 for (std::size_t idx = 0; idx<theProcessList->entries(); ++idx) 1166 { 1166 { 1167 if (GetAttribute(idx)->isActive) 1167 if (GetAttribute(idx)->isActive) 1168 ((*theProcessList)[idx])->StartTracking 1168 ((*theProcessList)[idx])->StartTracking(aTrack); 1169 } 1169 } 1170 if(aTrack) duringTracking = true; 1170 if(aTrack) duringTracking = true; 1171 } 1171 } 1172 1172 1173 // ------------------------------------------ 1173 // -------------------------------------------------------------------- 1174 void G4ProcessManager::EndTracking() 1174 void G4ProcessManager::EndTracking() 1175 { 1175 { 1176 for (G4int idx = 0; idx<(G4int)theProcessLi << 1176 for (std::size_t idx = 0; idx<theProcessList->entries(); ++idx) 1177 { 1177 { 1178 if (GetAttribute(idx)->isActive) 1178 if (GetAttribute(idx)->isActive) 1179 ((*theProcessList)[idx])->EndTracking() 1179 ((*theProcessList)[idx])->EndTracking(); 1180 } 1180 } 1181 duringTracking = false; 1181 duringTracking = false; 1182 } 1182 } 1183 1183 1184 // ------------------------------------------ 1184 // -------------------------------------------------------------------- 1185 G4VProcess* G4ProcessManager::GetProcess(cons 1185 G4VProcess* G4ProcessManager::GetProcess(const G4String& processName) const 1186 { 1186 { 1187 for (G4int k=0; k<numberOfProcesses; ++k) 1187 for (G4int k=0; k<numberOfProcesses; ++k) 1188 { 1188 { 1189 G4VProcess* process = (*theProcessList)[k 1189 G4VProcess* process = (*theProcessList)[k]; 1190 if (process->GetProcessName() == processN 1190 if (process->GetProcessName() == processName) return process; 1191 } 1191 } 1192 return nullptr; 1192 return nullptr; 1193 } 1193 } 1194 1194 1195 // ------------------------------------------ 1195 // -------------------------------------------------------------------- 1196 G4VProcess* G4ProcessManager::SetProcessActiv 1196 G4VProcess* G4ProcessManager::SetProcessActivation(G4VProcess* aProcess, 1197 1197 G4bool fActive ) 1198 { 1198 { 1199 return SetProcessActivation(GetProcessIndex 1199 return SetProcessActivation(GetProcessIndex(aProcess), fActive); 1200 } 1200 } 1201 1201 1202 // ------------------------------------------ 1202 // -------------------------------------------------------------------- 1203 G4VProcess* G4ProcessManager::SetProcessActiv 1203 G4VProcess* G4ProcessManager::SetProcessActivation(G4int index, G4bool fActive) 1204 { 1204 { 1205 if (fActive) return ActivateProcess(index); 1205 if (fActive) return ActivateProcess(index); 1206 else return InActivateProcess(index 1206 else return InActivateProcess(index); 1207 } 1207 } 1208 1208 1209 // ------------------------------------------ 1209 // -------------------------------------------------------------------- 1210 G4bool G4ProcessManager::GetProcessActivatio 1210 G4bool G4ProcessManager::GetProcessActivation(G4VProcess* aProcess) const 1211 { 1211 { 1212 return GetProcessActivation(GetProcessIndex 1212 return GetProcessActivation(GetProcessIndex(aProcess)); 1213 } 1213 } 1214 1214 1215 // ------------------------------------------ 1215 // -------------------------------------------------------------------- 1216 G4bool G4ProcessManager::GetProcessActivation 1216 G4bool G4ProcessManager::GetProcessActivation(G4int index) const 1217 { 1217 { 1218 if (index <0) 1218 if (index <0) 1219 { 1219 { 1220 #ifdef G4VERBOSE 1220 #ifdef G4VERBOSE 1221 if (GetVerboseLevel()>0) 1221 if (GetVerboseLevel()>0) 1222 { 1222 { 1223 G4cout << "G4ProcessManager::GetProcess 1223 G4cout << "G4ProcessManager::GetProcessActivation "; 1224 G4cout << " process (or its index) not 1224 G4cout << " process (or its index) not found "; 1225 } 1225 } 1226 #endif 1226 #endif 1227 return false; 1227 return false; 1228 } 1228 } 1229 // process attribute 1229 // process attribute 1230 G4ProcessAttribute* pAttr = (*theAttrVector 1230 G4ProcessAttribute* pAttr = (*theAttrVector)[index]; 1231 // status 1231 // status 1232 return pAttr->isActive; 1232 return pAttr->isActive; 1233 } 1233 } 1234 1234 1235 // ------------------------------------------ 1235 // -------------------------------------------------------------------- 1236 void G4ProcessManager::CheckOrderingParameter 1236 void G4ProcessManager::CheckOrderingParameters(G4VProcess* aProcess) const 1237 { 1237 { 1238 if (aProcess == nullptr) return; 1238 if (aProcess == nullptr) return; 1239 G4ProcessAttribute* pAttr = GetAttribute(aP 1239 G4ProcessAttribute* pAttr = GetAttribute(aProcess); 1240 if (pAttr == nullptr) 1240 if (pAttr == nullptr) 1241 { 1241 { 1242 #ifdef G4VERBOSE 1242 #ifdef G4VERBOSE 1243 if (GetVerboseLevel()>0) 1243 if (GetVerboseLevel()>0) 1244 { 1244 { 1245 G4cout << "G4ProcessManager::CheckOrder 1245 G4cout << "G4ProcessManager::CheckOrderingParameters()" << G4endl; 1246 G4cout << " process " << aProcess->GetP 1246 G4cout << " process " << aProcess->GetProcessName() 1247 << " has no attribute" << G4endl 1247 << " has no attribute" << G4endl; 1248 } 1248 } 1249 #endif 1249 #endif 1250 return; 1250 return; 1251 } 1251 } 1252 1252 1253 // check consistencies between ordering par 1253 // check consistencies between ordering parameters and 1254 // validity of DoIt of the Process 1254 // validity of DoIt of the Process 1255 G4bool isOK =true; 1255 G4bool isOK =true; 1256 if ( (pAttr->ordProcVector[0]>=0) && (!aPro 1256 if ( (pAttr->ordProcVector[0]>=0) && (!aProcess->isAtRestDoItIsEnabled()) ) 1257 { 1257 { 1258 #ifdef G4VERBOSE 1258 #ifdef G4VERBOSE 1259 if (GetVerboseLevel()>0) 1259 if (GetVerboseLevel()>0) 1260 { 1260 { 1261 G4cerr << "G4ProcessManager::CheckOrder 1261 G4cerr << "G4ProcessManager::CheckOrderingParameters()" << G4endl; 1262 G4cerr << "You cannot set ordering para 1262 G4cerr << "You cannot set ordering parameter [" 1263 << pAttr->ordProcVector[0] 1263 << pAttr->ordProcVector[0] 1264 << "] for AtRest DoIt to the pr 1264 << "] for AtRest DoIt to the process " 1265 << aProcess->GetProcessName() << 1265 << aProcess->GetProcessName() << G4endl; 1266 } 1266 } 1267 #endif 1267 #endif 1268 isOK = false; 1268 isOK = false; 1269 } 1269 } 1270 1270 1271 if ((pAttr->ordProcVector[2]>=0) && (!aProc 1271 if ((pAttr->ordProcVector[2]>=0) && (!aProcess->isAlongStepDoItIsEnabled())) 1272 { 1272 { 1273 #ifdef G4VERBOSE 1273 #ifdef G4VERBOSE 1274 if (GetVerboseLevel()>0) 1274 if (GetVerboseLevel()>0) 1275 { 1275 { 1276 G4cerr << "G4ProcessManager::CheckOrder 1276 G4cerr << "G4ProcessManager::CheckOrderingParameters()" << G4endl; 1277 G4cerr << "You cannot set ordering para 1277 G4cerr << "You cannot set ordering parameter [" 1278 << pAttr->ordProcVector[2] 1278 << pAttr->ordProcVector[2] 1279 << "] for AlongStep DoIt to the 1279 << "] for AlongStep DoIt to the process " 1280 << aProcess->GetProcessName() << 1280 << aProcess->GetProcessName() << G4endl; 1281 1281 1282 } 1282 } 1283 #endif 1283 #endif 1284 isOK = false; 1284 isOK = false; 1285 } 1285 } 1286 1286 1287 if ((pAttr->ordProcVector[4]>=0) && (!aProc 1287 if ((pAttr->ordProcVector[4]>=0) && (!aProcess->isPostStepDoItIsEnabled())) 1288 { 1288 { 1289 #ifdef G4VERBOSE 1289 #ifdef G4VERBOSE 1290 if (GetVerboseLevel()>0) 1290 if (GetVerboseLevel()>0) 1291 { 1291 { 1292 G4cerr << "G4ProcessManager::CheckOrder 1292 G4cerr << "G4ProcessManager::CheckOrderingParameters()" << G4endl; 1293 G4cerr << "You cannot set ordering para 1293 G4cerr << "You cannot set ordering parameter [" 1294 << pAttr->ordProcVector[4] 1294 << pAttr->ordProcVector[4] 1295 << "] for PostStep DoIt to the p 1295 << "] for PostStep DoIt to the process" 1296 << aProcess->GetProcessName() << 1296 << aProcess->GetProcessName() << G4endl; 1297 } 1297 } 1298 #endif 1298 #endif 1299 isOK = false; 1299 isOK = false; 1300 } 1300 } 1301 1301 1302 if (!isOK) 1302 if (!isOK) 1303 { 1303 { 1304 G4String msg; 1304 G4String msg; 1305 msg = "Invalid ordering parameters are se 1305 msg = "Invalid ordering parameters are set for "; 1306 msg += aProcess->GetProcessName(); 1306 msg += aProcess->GetProcessName(); 1307 G4Exception( "G4ProcessManager::CheckOrde 1307 G4Exception( "G4ProcessManager::CheckOrderingParameters()", 1308 "ProcMan013", FatalException 1308 "ProcMan013", FatalException, msg); 1309 } 1309 } 1310 1310 1311 return; 1311 return; 1312 } 1312 } 1313 1313