Skip to content

Instantly share code, notes, and snippets.

@betatim
Created September 12, 2014 12:08
Show Gist options
  • Save betatim/071b714c406c85c38780 to your computer and use it in GitHub Desktop.
Save betatim/071b714c406c85c38780 to your computer and use it in GitHub Desktop.
def cluster2mc_particles(cluster, event):
links = event['/Event/Link/Raw/VP/Clusters']
refs = links.linkReference()
mc_particles = event['MC/Particles']
next_idx = -1
particles = []
for channel, key in links.keyIndex():
if channel == cluster.channelID().channelID():
mc_key = refs[key].objectKey()
particles.append(mc_particles.object(mc_key))
next_idx = refs[key].nextIndex()
break
while next_idx != -1:
particles.append(mc_particles.object(refs[next_idx].objectKey()))
next_idx = refs[next_idx].nextIndex()
return particles
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment