from ROOT import *
import funcsByBarbara as tools

#def makeInputSmallReco():
    


fScan = file("forElena_Ethr.txt")
freco = TFile("../Geraldine/KLONG/ship.10.0.Genie-TGeant4_70cc30nc.root")
t = freco.Get("cbmsim")

lines = fScan.readlines()

lines = lines[3:-1]
events = []
for line in lines:
    events.append(int(line.rsplit("*")[1].replace(" ","")))

count = 0
for entry in events:
    t.GetEntry(entry)
    particles = t.Particles
    for p in particles:
        print p, entry
        t1,t2 = p.GetDaughter(0),p.GetDaughter(1) 
        tpdg, mumpdg, x, y, z = tools.retrieveMCParticleInfo(t, t1)
        print tpdg, mumpdg, x, y, z
        tpdg, mumpdg, x, y, z = tools.retrieveMCParticleInfo(t, t2)
        print tpdg, mumpdg, x, y, z
        count+=1
        #print entry, p.GetPdgCode()

print count
