Multiple runs one ROOT output file

Hi all,

During my simulation I’m saving the information (energy, position, etc ) of a particle that hits my SD detector, using the G4AnalysisManager::Instance() and the g4tools option with the root header. It works as expected when doing one run, but when there’s more than one the output file gets rewritten and saves only the last run information. There is a way to pass an option to the analysis manager instance so it just reopens and update the file if it exist?

I know there’s a workaround using directly the root API in G4 and passing the option "UPDATE" when opening the file, but would be simpler and perhaps more generic with the analysis manager?

Thank you :smiley:

Geant4 Version: v10.6 with Multithread
OS: Ubuntu 18.04


We do not provide the “UPDATE” mode; this is in planned development for the next Geant4 version.
At present, to avoid overwrite the output file with each run, you have to define a different file name in OpenFile() call at the BeginOfRun() action. Then you can use Root TChain to chain the produced files and process the written ntuple.

Best regards,