#!/usr/bin/env python # This example shows basic a basic aanet event loop and the many # options there are for printing event information. """ Usage print_event.py -f input_file Prints event information for the first events in a file. The file can be any format readable by aanet. options: -f : input file default="" -n : process this many events, default=10 -p : print 1-line event summaries, default=True -d : print all members of event structures (dump) default=False -u : print the "usr" information default=False -m : print MC tracks showing parent-child relation default=False -a : print ascii format, default=False -j : print json default=False -t : print tree information (for root files) default=False -q : print info on first 10 hits default=False -r : print reconstructed tracks default=False -H : print Header information (if available) default=False -h : this help message and exit default=False -i : Python interative mode (prompt when done) default=False """ from __future__ import print_function import sys, aa from ROOT import EventFile, pretty_mc_tracks, dump import ROOT # aa.py contains helper to deal with cmd line options options = aa.Options( __doc__, sys.argv[1:] ) # open the Event File ; can by any format understood by aanet f = EventFile( options.f ) if options.t : if f.roottree() : f.roottree().Print() sys.exit() if options.H : print (f.header) sys.exit() for evt in f : if options.p : print (evt) # calls Evt::__str__() if options.j : print (jsons( evt )) if options.d : dump( evt ) if options.u : evt.printusr() if options.m : print (pretty_mc_tracks( evt )) if options.q : print ("-------------------------------------------------") print (" hits : ", evt.hits.size()) for h in evt.hits[:10]: print (h, h.pmt_id, h.dom_id, h.channel_id, h.pos) print() print ("MC hits : ", evt.mc_hits.size()) for h in evt.mc_hits[:10]: print (h) if options.a : s = ROOT.ostringstream() ROOT.write( evt, s) print (s.str()) if options.r : for t in evt.trks : print (t, t.rec_type, list(t.rec_stages)) print ("----------------------------------------------") if f.index >= options.n : break