I’ve got a problem where I would like to turn on some diagnostic info for a specific event deep in a run (event number 1.7 million or so). In Aug 2020, I asked this same question (Example of within-event macro file with /run/beamOn?) but got no useful reply.
The full syntax of the /run/beamOn command is:
/run/beamOn <nEvents> [event-macro] [nSelect]
where event-macro is a G4 UI macro file which will be called for each of the first [nSelect] events (or all events).
I would like to know whether the current event number is available to event-macro. If so, how do I access it (an alias? /control/getVal? Something else?
There is no documentation for this anywhere in the Application Developers Guide (or any of the other documentation). There is no example that uses this optional feature.
A second specific question – when is the macro called? Is it called before the start of the event, or is it called at the end of the event? I’m trying to use the optional event-macro to turn on tracking verbosity for just specific events, but it’s not working. I put a /control/echo line in, and it appears to be getting called after the event finishes. Is that correct?
I resolved this by going through the source code. runManager->BeamOn() calls DoEventLoop() which calls ProcessOneEvent(). In that function, the UI ApplyCommand() call happens after eventManager->ProcessOneEvent().
I also eventually found in help /run/beamOn the text
The second and third arguments can be used for
executing a macro file at the end of each event.