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