Running the anti-Kt jet algorithm using a realistic pp event
Source code name: "hep_jets_all.py"
Programming language: Python
Topic: Physics/HEP
DMelt Version 1. Last modified: 03/03/2021. License: Free
https://datamelt.org/code/cache/hep_jets_all_6814.py
To run this script using the DMelt IDE, copy the above URL link to the menu [File]→[Read script from URL] of the DMelt IDE.



from java.awt import Color
from java.util import ArrayList
from jhplot  import *
from hephysics.jet import *
from hephysics.particle import *
from jhplot.shapes import *

# get data from FastJet example
data=PND("particles","https://datamelt.org/examples/data/single-event_orgin.dat")
print data.toString()

plist=ArrayList()
for i in range(data.size()):
       raw=data.get(i)
       p=ParticleD(raw[0],raw[1],raw[2],raw[3]) 
       plist.add(p) # add 

R=0.6 # jet radius. use antikT jets 
ktjet = SCJet(R, 1, -1, 50.0,True);
ktjet.setDebug(False);
ktjet.buildJets(plist);
ktjet.printJets()
jets=ktjet.getJetsSorted()

c1 = HPlot("Canvas",600,600)
c1.setGTitle("anti-kT jets")
c1.visible(1)
c1.setRange(-4,4,-7,7)
c1.setNameX("η")
c1.setNameY("φ [rad]")

pp=P1D("particles")
for i in range(plist.size()):
      p=plist.get(i)
      eta=p.getRapidity()
      phi=p.getPhi()
      pp.add(eta,phi)
      pp.setSymbolSize(3)

# show jets
for k in range(jets.size()):
    jet=P1D("jet Nr "+str(k))
    jet.setColor(Color.red)
    jet.setSymbolSize(7)
    jj=jets.get(k)
    etaJ=jj.getRapidity()   
    phiJ=jj.phi()
    jet.add(etaJ,phiJ)
    c1.draw(jet)
    cic= Circle(etaJ, phiJ, R)
    cic.setFill(0)
    cic.setColor(Color.red)
    cic.setTransparency(0.5)
    c1.add(cic)

c1.draw(pp)