#!/usr/bin/env python """ Usage any_to_aa.py -f input_file -o output_file Convert input file to aanet format. The file can be any format readable by aanet. A sensible default is provided for the output file name. Options exist to remove the hits from the output file. options: -f : input file default=/sps/km3net/repo/mc/atm_neutrino/KM3NeT_-00000001_20171212/v5.1/reco/mcv5.1.genhen_numuCC.sirene.jte.jchain.aashower.98.root -o : output file default=auto -n : process this many events, default=-1 -p : print 1-line summaries of the events default=True -x : remove the hits from the events default=False -y : remove the mc_hits from the events default=False -h : this help message and exit default=False -i : Python interative mode (prompt when done) default=False -s : sample/prescale: process every nth event default=1 """ from __future__ import print_function print (__doc__) import sys, aa from ROOT import EventFile options = aa.Options( __doc__, sys.argv[1:] ) if options.o == "auto" : options.o = options.f.split("/")[-1]+".aa.root" infile, outfile = options.f, options.o print (options) # open the input file f = EventFile( infile ) # If we set an output file, the output TTree is filled automatically f.set_output( outfile ) # this opens an aanet output file f.autosave = True # true = default, but just illustrate for evt in f : if options.p : print (evt) if options.x : evt.hits.clear() if options.y : evt.mc_hits.clear() if options.n > 0 and f.index>=options.n : break if f.index % options.s == 0 : f.write() del f