import ROOT,argparse parser=argparse.ArgumentParser(description='loop over fopi tree and do stuff') parser.add_argument('rootfile',help='the root file with the fopi tree',type=str) parser.add_argument('--hlp',help='display help',action='store_true') args=parser.parse_args() if args.hlp: parser.print_help() exit(0) ROOT.gROOT.ProcessLine(".x rootlogon.C") ROOT.gROOT.ProcessLine('gROOT->SetStyle("Plain")') ROOT.gROOT.LoadMacro("stlPYROOT.h+") rfile=ROOT.TFile.Open(args.rootfile,'READ') tree=rfile.Get('FOPITree') if tree == None : print "No FOPITree in file", file if type(Rfile)==ROOT.TFile: Rfile.Close() exit() tree.SetBranchStatus("*",1) evt=-1 for e in tree: evt+=1 print 'event:',evt for ctrk in e.CdcTrackBr: print 'rpc hit id:', ctrk.GetRpcHitID() if ctrk.GetRpcHitID()!=0: print 'rpc branch hit id:',e.RpcTrackBr.At(ctrk.GetRpcHitID()-1).GetID() for rtrk in e.RpcTrackBr: print 'rpc id:',rtrk.GetID()