#!/usr/bin/env python import aa, ROOT """ This example shows how to write a km3net-dataformat (aka aanet) file from scratch (e.g. when you want to make a coverter to read some other file format) """ f = ROOT.EventFile() f.set_output("myfile.aa.root") for i in range ( 100 ) : # write 100 events f.evt.clear() # important: the EventFile has only one Evt object : reset it f.evt.id = i f.evt.mc_run_id = i # now we fill the event trk1 = ROOT.Trk() trk1.id = 1 trk1.pos.set(100,200,0) trk1.dir.set(0,0,1.0) trk1.t = 100; trk1.type = 14 # please use PDG type there trk1.mother_id = 0 # refers to the trk.id of the mother # etc f.evt.trks.push_back( trk1 ) # do the same for other tracks if you have them print(f.evt) # when all done filling the Evt: f.write() del f # needed unfortunately