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