Write Geant4 event output into .root-file

hi,

is there a simple method to write the main info of an event (particle ID, momentum, energy, radLength, etc) generated in Geant4 into a .root-file? or can i just include a file where i build a root-tree in my geant4 file? Or rather embed Geant4 in ROOT?

cheers,
Kati

Hi,

as far as I know, the G4 team has realized that this needs to become a bit easier. So first of all I’d ask them (also to “register” that there are interested users). It would probably be easiest to fill a TNtuple in G4 and write that to a TFile. Alternatively you can work with the G4 team to get their event data (as G4 objects) written to a TFile.

If you really want to do it right then you create your own (set of) class(es) representing the G4 results and you fill them inside a TSelector loop. See tutorials/proof/ProofPythia.C for a non-input driven TSelector. The advantage of this approach is that you can use Proof (-lite), sending it off to a batch system or using all cores in parallel. Let us know if you are interested in this approach and we’ll implement an example setup together with you.

Cheers, Axel.

Hi Axel,

yeah, i wanted to post my question originally on the Geant forum but that didn’t work yesterday…
thanks a lot for your offer, for now i think my needs are rather simple, i don’t really want to generate huge data sets… so maybe i look if i find some easy and straight-forward way in the Geant forum and if not, i’ll contact you again!

Cheers,
Kati