How to run the simulation 1000 times?


I have a simulation to calculate deposited energy and dose with the markers “G4PSDoseDeposit.hh” and "G4PSEnergyDeposit.hh. As a source I have a .mac file with specifications for the quantity of particles with different energies and input angles, with about 100000 particles.
Is there a command to run the simulation 1000 times and the result of Edep and dose it be the averagel value?
I tried control/loop and /control /foreach, but it doesn’t work.
Can someone help me? I send a macro file that exemplifies the I use in the simulation.
fonteproton.txt (5.1 KB)


1 Like

Would a single run of 100M events not be useful?

No, I need the average of the 1000 simulations.

When you average your 1000 runs, are you including the uncertainties and different populations that went into each run? If so, then a properly weighted “average of averages” should be the same as a single global average. But if you want to see the distribution of the 1000 runs’ output, then obviously they’re different.

This sounds like an “analysis” level thing. You run your 1000 simulations, each run goes into a separate output file, then you read all those outputs in together an do the averaging/plotting you want to do. If you use ROOT, TChain can do this for you. For other analysis tools, you’d have to check their documentation.

1 Like

Understood and will try this.