Example of within-event macro file with /run/beamOn?

Does anyone have an example of how to write and use a macro file that is called from within the event loop? The documentation for /run/beamOn says

Command /run/beamOn

Guidance :
Start a Run.
If G4 kernel is not initialized, it will be initialized. Default number of events to be processed is 1. The second and third arguments can be used for executing a macro file at the end of each event. If the second argument, i.e. name of the macro file, is given but the third argument is not, the macro file will be executed for all of the event.

I did not find any further explanation for the second argument in the App Guide, nor are there any examples in the G4 10.06.p02 distribution which make use of this feature (using grep /run/beamOn on every .mac file in the examples/ directory tree).

If anyone has made use of this, I’d love to hear more. Is the event number available as an alias, for instance? If aliases are modified within the macro, are the new values preserved across events? Are the new values available back in the main macro when the run finishes?

Macro file for example B1

Can be run in batch, without graphic

or interactively: Idle> /control/execute run1.mac

Change the default number of workers (in multi-threading mode)

#/run/numberOfThreads 4

Initialize kernel

/run/initialize

/material/nist/listMaterials

/material/nist/listMaterials phybf3

/material/g4/printMaterial
/material/g4/printMaterial phybf3
/material/g4/printMaterial Soil
/material/g4/printMaterial compound

/control/verbose 2
/run/verbose 2
/event/verbose 0

/tracking/verbose 1

/gun/particle neutron

/gun/energy 2 MeV

Tracking level verbose

#/tracking/verbose 2

/run/beamOn 20000000