# Reading Pthia8 file in the ProMC format using [[http://jwork.org/dmelt | DataMelt]] # S.Chekanov (ANL) from java.io import * from java.awt import * from promc.io import * from proto import * # import FileMC from jhplot import * # import DatMelt graphics file = FileMC("Pythia8.promc") print "ProMC version=",file.getVersion() print "Last Modified=",file.getLastModified() header = file.getHeader() # get header file unit=float(header.getMomentumUnit()) lunit=float(header.getLengthUnit()) print "Momentum unit=",unit print "Length unit=",lunit for j in range(header.getParticleDataCount()): # look at PDG info stored in the header d = header.getParticleData(j) pid = d.getId(); mass = d.getMass(); name = d.getName(); print name, pid, mass h1= H1D("Px",100,0,10) # create a histogram print "File size=",file.size() for i in range(file.size()): # run over all events if (i%100==0): print "Event=",i entry = file.read(i) p = entry.getParticles() # get particles for j in range( p.getPxCount() ): h1.fill(p.getPx(j)/unit) c1 = HPlot("Canvas",600,400) # plot histogram c1.visible() c1.setAutoRange() c1.draw(h1) c1.export("px.pdf") # create PDF file