MCPcopy Create free account
hub / github.com/Geant4/geant4 / RemoveProcess

Method RemoveProcess

source/processes/management/src/G4ProcessManager.cc:518–591  ·  view source on GitHub ↗

--------------------------------------------------------------------

Source from the content-addressed store, hash-verified

516
517// --------------------------------------------------------------------
518G4VProcess* G4ProcessManager::RemoveProcess(G4int index)
519{
520 //find the process attribute
521 G4ProcessAttribute* pAttr = GetAttribute(index);
522 if (pAttr == nullptr) return nullptr;
523
524 // remove process
525 G4VProcess* removedProcess = (*theProcessList)[index];
526
527 if (!(pAttr->isActive)) { ActivateProcess(index);}
528 // remove process from vectors if the process is active
529 for (G4int ivec=0; ivec<SizeOfProcVectorArray; ++ivec)
530 {
531 G4ProcessVector* pVector = theProcVector[ivec];
532 G4int idx = pAttr->idxProcVector[ivec];
533 if ((idx >= 0) && (idx < G4int(pVector->entries())))
534 {
535 // remove
536 if (RemoveAt(idx, removedProcess, ivec) <0)
537 {
538 G4String anErrorMessage("Bad index in attribute");
539 anErrorMessage += "for particle["
540 + theParticleType->GetParticleName() + "] ";
541 anErrorMessage += "process["
542 + removedProcess->GetProcessName() + "] " ;
543 G4Exception( "G4ProcessManager::RemoveProcess()","Fatal Error",
544 FatalException,anErrorMessage);
545 return nullptr;
546 }
547 }
548 else if (idx<0)
549 {
550 // corresponding DoIt is not active
551 }
552 else
553 {
554 // idx is out of range
555 G4String anErrorMessage("Bad ProcessList: Index is out of range ");
556 anErrorMessage += "for particle[" + theParticleType->GetParticleName() + "] ";
557 anErrorMessage += "process[" + removedProcess->GetProcessName() + "] " ;
558 G4Exception( "G4ProcessManager::RemoveProcess()","ProcMan012",
559 FatalException,anErrorMessage);
560 return nullptr;
561 }
562 }
563 pAttr->isActive = false;
564 // remove from the process List and delete the attribute
565 theProcessList->removeAt(index);
566 for (auto itr = theAttrVector->cbegin(); itr!= theAttrVector->cend(); ++itr)
567 {
568 if ( (*itr) == pAttr)
569 {
570 theAttrVector->erase(itr);
571 break;
572 }
573 }
574 delete pAttr;
575 --numberOfProcesses;

Callers 7

ConstructProcessMethod · 0.45
ConstructProcessMethod · 0.45
ConstructProcessMethod · 0.45
ConstructProcessMethod · 0.45

Calls 7

G4ExceptionFunction · 0.85
removeAtMethod · 0.80
entriesMethod · 0.45
GetParticleNameMethod · 0.45
cbeginMethod · 0.45
cendMethod · 0.45
RemoveMethod · 0.45

Tested by

no test coverage detected