Merging Ntuples?

Hi G4ers!

I am still new to Geant4 and just starting to get the hang of it. However, I do not know how to solve this problem. I am simulating environmental neutron flux with a gps. Because I can’t make an energy-dependent angle distribution I have divided the energy spectrum in fast, epithermal and thermal. My macro looks somewhat like this:

#thermal region
/gps/ang/type iso
/gps/ene/type User
/gps/hist/type energy
/gps/hist/point 0.001 0.1
/gps/hist/point …
/run/beamOn 1000

#epithermal region
/gps/ang/type cos
/gps/ene/type User
/gps/hist/type energy
/gps/hist/point 0.4 0.2
/gps/hist/point …
/run/beamOn 1000

#fast region

You get the idea. So everytime the beamOn is called, an ntuple is created (in myRunAction) but it overwrites leaving me with only the data from the last region.

Is there a way to get the analysismanager to record multiple runs? Is there a way to merge ntuples? Or is there a way to change the filename for every run so it does not overwrite and I can do the merging afterwards?

Thanks in advance!

I found a fix already.

I made a new class based on G4GenericMessenger which records a NumberOfRunsLeft int. The messenger has a Set and Get method for this value. Using a custom command of the messenger you can set this value to the number of runs you want to record. In RunAction this value is set to 1 if none is specified and it will diminish the NumberOfRunsLeft by one every Run. When NumberOfRunsLeft is zero, only then will the analysismanager write to file.

Hello,

You can merge ntuples for ROOT output type. Please, see the section on Parallel Processing in the Application Developers Guide

If you ar not using Geant4 version 10.6, check in the class reference the meaning of the SetNtupleMerging() function parameters.

Best regards,