G4BOptnChangeCrossSection with G4WrapperProcess

Dear experts,

I’m trying to alter the cross section of a process (already wrapped by G4WrapperProcess) using the standard G4BOptnChangeCrossSection.

At the moment, the GetCurrentInteractionLength() invoked in the biasing operator returns “-1”, which is unphysical.

Here are some relevant passages of the code I’m using.

/// PhysicsLists.cc
    G4ParticleDefintion *def = G4MuonPlus::Definition();
    G4ProcessTable *processTable = G4ProcessTable::GetProcessTable();
    G4VProcess *Decay = processTable->FindProcess("Decay", def);
    G4ProcessManager *Manager = def->GetProcessManager();

    MyWrapper *wrapper = new MyWrapper();
    wrapper->RegisterProcess(Decay);

    if(Manager) {
      if(Decay)
        Manager->RemoveProcess(Decay);

      Manager->AddProcess(wrapper);
      Manager->SetProcessOrdering(wrapper, idxPostStep);
      Manager->SetProcessOrdering(wrapper, idxAtRest);
    }
/// ... later on still in PhysicsLists.cc
  G4VProcess *Decay = processTable->FindProcess("Decay", G4MuonPlus::Definition());
  processesToBias.push_back(Decay->GetProcessName());
  fBiasPhysics->Bias("mu+", processesToBias);  
// MyBiasingOperator.cc adapted from GB01 and GB02 
  G4double analogInteractionLength = callingProcess->GetWrappedProcess()->GetCurrentInteractionLength() / mm; // this is -1
  G4BOptnChangeCrossSection *operation = fChangeCrossSectionOperations[callingProcess];
  operation->SetBiasedCrossSection(XStransformation * analogXS);
  operation->Sample(); // this issues a warning
  return operation;

First of all: is this use case foreseen? Maybe I’m going wrong about the problem and I should try something else.

Regards,
Stefan

Geant4 Version: 11.0.3
Operating System: AlmaLinux 9
Compiler/Version: gcc 13
CMake Version: 3.20.0