G4WorkerSubEvtRunManager unable to use more than 1 sub-event stack

Geant4 Version: 11.4.1
Operating System: AlmaLinux 10 (RHEL)
Compiler/Version: GCC 14.3.1
CMake Version: 3.30.5


Hey G4 folks,

I have been quite interested in implementing sub-event parallelism in my application space for quite a while, so now that it’s available in Geant4, I’m eager to try it out. The extended/runAndEvent/RE03 example provided a good starting place, but I haven’t had success in expanding beyond that. I know sub-event parallelism is a work in progress, so this may be a byproduct of its phased introduction.

The issue occurs when you try to register more than one sub-event type for a given run. The second sub-event type will be appropriately registered to the master sub-event run manager, but no workers will ever be created to handle its sub-event type. This is because the worker sub-event run managers are created by G4UserSubEvtThreadInitialization, which doesn’t pass any arguments to the G4WorkerSubEvtRunManager constructor in CreateWorkerRunManager, and so all of the workers are created with sub-event type 0 (corresponding to track classification 100, or fSubEvent_0), the default in the G4WorkerSubEvtRunManager ctor. So if you set a particle’s (or track status’s) default classification to the second sub-event type you registered, the run will crash as soon as that particle/track status is encountered in the simulation.

It seems like there needs to be a way to pass sub-event type information to G4UserSubEvtThreadInitialization so that worker threads can be assigned to those types. The most generic method would be to just split workers evenly among sub-event types, which could be achieved by just passing the sub-event type map (or even just its size).

Have others encountered this bug?