Hi,
When I am trying to run the geant4 simulation for 10M events, it keeps giving me this error:
Error in TFile::TFile: file /Users/brianhuang/Simulation_2/build/simulation.root already exists
can anyone help me to fix it? because I’m doing build, then run.
Can you provide more details like, is there any such file already existing?
you code snippet? does multiple runs creating multiple leaves in root file?
Since you mentioned TFile, it seems you are using ROOT to manage your output data. The error message you encountered typically means that ROOT is refusing to overwrite an existing file unless explicitly instructed to do so (default mode is read-only).
Alternatively, for a standalone Geant4 simulation, you may find it easier to use the G4Analysis tools, which provide dedicated support for file handling and data output in ROOT and other formats. You can find a good example in the extended examples [1].