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