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