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)