Skip to content

Instantly share code, notes, and snippets.

@ndawe
Last active August 3, 2017 04:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ndawe/f25040f4a103110be6671144464f4029 to your computer and use it in GitHub Desktop.
Save ndawe/f25040f4a103110be6671144464f4029 to your computer and use it in GitHub Desktop.
Jet clustering CMS data without CMSSW
from pyjet import cluster
from root_numpy import root2array, stretch
branches = [
'recoPFCandidates_particleFlow__RECO.obj.pt_',
'recoPFCandidates_particleFlow__RECO.obj.eta_',
'recoPFCandidates_particleFlow__RECO.obj.phi_',
'recoPFCandidates_particleFlow__RECO.obj.mass_',
]
# http://opendata.cern.ch/research/CMS
filename = ("root://eospublic.cern.ch//eos/opendata/cms/Run2011A/DoubleMu/AOD/"
"12Oct2013-v1/10000/000D143E-9535-E311-B88B-002618943934.root")
# Read the first event
events = root2array(filename, "Events", branches=branches, stop=1)
for event in events:
flattened_event = stretch(event.reshape(-1)) # Stretch out the nestedness of the subarrays
sequence = cluster(flattened_event, R=0.5, p=-1) # Anti-kt with R=0.5
jets = sequence.inclusive_jets(ptmin=3) # You get the same jets as CMS! Just need to calibrate them...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment