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