I have been running a simulation, which produces an output file in every event. The file name (e.g., ‘Event_1.txt’) is determined in BeginOfEventAction() using the event ID, and writing on the file happens in EndOfEventAction().
Now I am trying to run many simulations for different parameters, which are iterated in a macro (e.g., /control/loop sub.mac pos 0 100 10). I am hoping to save the output files for each parameter in a different folder or to modify the file name by including the parameter (e.g., ‘Pos_0_Event_1.txt’).
Any suggestions will be deeply appreciated. Thank you.
Add a G4String parameter to your EventAction with the name prefix you want. Add a Messenger class (e.g., G4GenericMessenger) to your EventAction with a UI command to set the parameter.
Assuming that your /control/loop happens after /run/initialize, then you can put the extra macro command into your sub.mac, something like /3doptics/setPrefix Pos_{pos}, before calling /run/beamOn.
Rather than a bazillion tiny plain text files, have you considered using a single N-tuple, and doing the splitting and analysis separately? You could then include the position value, along with the eventID, as N-tuple columns.