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