Muonic Atom Physics crashing in MT mode

Geant4 Version: 11.4.0
Operating System: macOS 26.3.1
Compiler/Version: Apple clang version 17.0.0
CMake Version: 4.2.3


I implemented the following physics list:

#include "PhysicsList.hh"

#include "G4EmStandardPhysics_option4.hh"
#include "G4MuonMinusAtomicCapture.hh"
#include "G4MuonicAtomDecayPhysics.hh"
#include "G4ProcessManager.hh"
#include "G4ProcessVector.hh"

PhysicsList::PhysicsList() : QBBC() {
  // Replace default EM physics
  ReplacePhysics(new G4EmStandardPhysics_option4());

  RegisterPhysics(new G4MuonicAtomDecayPhysics());
}

void PhysicsList::ConstructParticle() { QBBC::ConstructParticle(); }

void PhysicsList::ConstructProcess() {
  // Build default processes
  QBBC::ConstructProcess();

  auto particleIterator = GetParticleIterator();
  particleIterator->reset();

  while ((*particleIterator)()) {
    G4ParticleDefinition *particle = particleIterator->value();
    G4ProcessManager *pmanager = particle->GetProcessManager();
    G4String particleName = particle->GetParticleName();

    if (particleName == "mu-") {
      // remove muMinusCaptureAtRest
      auto processList = pmanager->GetProcessList();
      for (size_t i = 0; i < processList->size(); ++i) {
        if ((*processList)[i]->GetProcessName() == "muMinusCaptureAtRest") {
          pmanager->RemoveProcess(i);
          break;
        }
      }

      // add atomic capture
      G4bool alreadyExists = false;
      for (size_t i = 0; i < processList->size(); ++i) {
        if ((*processList)[i]->GetProcessName() == "muMinusAtomicCaptureAtRest") {
          alreadyExists = true;
          break;
        }
      }
      if (!alreadyExists) {
        auto proc = new G4MuonMinusAtomicCapture();
        pmanager->AddRestProcess(new G4MuonMinusAtomicCapture());
      }
    }
  }
}

With the aim of simulating muonic atom X-ray cascade + decay in orbit / nuclear capture.

It seems to run fine for the first run, however in the second run it always crashes with the following exception:

-------- EEEE ------- G4Exception-START -------- EEEE -------
*** G4Exception : Run0116
      issued by : G4WorkerRunManagerKernel::SetupShadowProcess()
Process manager or process manager shadow to master are not set.
Particle : MuC12 (0x935dcc600), proc-manager: 0x943a115c0 proc-manager-shadow: 0x0
*** Fatal Exception *** core dump ***

The specific muonic atom in the exception will change but the message is always the same.

Am I defining something wrongly in my physics or is this a bug the MuonicAtom class?

Hello @MigFerro ,

I think this thread lead to a bug on Geant4 being opened.

Thank you for your post. Stay tuned :wink:

/Pico

1 Like

Thank you for letting me know!