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