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