[[snowmass2013:montecarlo| < wget http://atlaswww.hep.anl.gov/asc/promc/download/browser_promc.jar http://mc.hep.anl.gov/asc/snowmass2013/delphes36/promc/MadGraph5Pythia_wjets/MadGraph5Pythia_wjets_mu0.promc java -jar browser_promc.jar MadGraph5Pythia_wjets_mu0.promc This brings up a GUI window to look at the stored events. Use Java7 (check as "//java -version//"). Read more about this browser [[asc:promc:examples | here]]. To analyze truth particle information and reconstructed objects (jets, electrons, photons) use the approaches shown below. ==== Reading Delphes data in C++ ==== Here are the steps to analyze data in C++, but without ROOT. Install [[https://atlaswww.hep.anl.gov/asc/promc| ProMC]] library. Then generate analysis code from the ProMC input file and run it: mkdir test wget http://mc.hep.anl.gov/asc/snowmass2013/delphes36/promc/MadGraph5Pythia_wjets_mu0.promc promc_proto # generate layout files in the directory proto promc_code # generate analysis code in C++/Java/Python make # compiles C++ reader.cc ./reader MadGraph5Pythia_wjets_mu0.promc # read the data ==== Reading Delphes data in Java ==== The above example also generates Java code to read the data. Try this: cd java/ run.sh MadGraph5Pythia_wjets_mu0.promc # read the data ==== Reading Delphes data in Python ==== The above example also generates the Python code to read the ProMC files. Try this: cd python/ python reader.py MadGraph5Pythia_wjets_mu0.promc # read the data Look at the "modules" directory to learn about the methods, ===== Reading data using Java without ProMC ===== A more advanced code uses a Java histogramming package, without the ProMC installation: wget http://mc.hep.anl.gov/asc/snowmass2013/delphes36/packages/delphes_read.tgz # get analysis package tar -zvxf delphes_read.tgz # untar it cd delphes_read # go to the analysis directory wget http://mc.hep.anl.gov/asc/snowmass2013/delphes36/promc/MadGraph5Pythia_wjets/MadGraph5Pythia_wjets_mu0.promc run.sh MadGraph5Pythia_wjets_mu0.promc # compile and run it. It fills a few histograms and show them in a canvas. ==== Browser the truth particle record ==== You can browser the events in the file using the same "lib/browser_promc.jar" file as: java -jar lib/browser_promc.jar herwigpp_ttbar_mu0.promc It will shows the header file. If you double click on even numbers (left), you will see particle records for a selected event. **For Windows:** Go to "lib" and double click "browser_promc.jar". Open any ProMC file as File->Open ProMC". You can setup a NetBeans or Eclipse to identify all methods for each class (for jets, electrons, muons). Look at the [[http://mc.hep.anl.gov/asc/snowmass2013/delphes36/packages/delphes_read/api/promc/io/ProMC.ProMCEvent.html| Java API of ProMCEvent]] which keeps all Jets, Particles etc. (and their methods). See more info below. You can also find all methods using Java API included in this example. Read Java API as: firefox api/index.html Make the needed modifications in the main Java class "ReadProMC.java" to make this example useful for your analysis. ==== Using Python/Jython ==== You can also use Jython (Python implemented in Java), instead of Java, and run the code on any platform (Windows, Mac, Linux). Install [[http://jwork.org/scavis|SCaVis]], and copy an additional jar file "browser_promc.jar" to the ScaVis directory "lib/users". This is how to do this: cd scavis/lib/user wget http://mc.hep.anl.gov/asc/snowmass2013/delphes36/packages/delphes_read/lib/browser_promc.jar Restart SCaVis IDE. Now you can make a simple Python script which reads data in the ProMC format: Here is a small Python/Jython example which plots jet pT. Save this file as "delphes.py" and open it in the ScaVis IDE. Then press "run". # Reading Delphes file in the ProMC format using ScaVis http://jwork.org/scavis # S.Chekanov (ANL) from java.io import * from java.awt import * from promc.io import * from proto import * # import FileMC from jhplot import * # import ScaVis graphics file = FileMC("herwigpp_ttbar_mu0.promc") version=file.getVersion() print "ProMC version=",version header = file.getHeader() unit=float(header.getMomentumUnit()) lunit=float(header.getLengthUnit()) print "Momentum unit=",unit print "Length unit=",lunit h1= H1D("PT (ele)",50,0,1000) # create a histogram print "File size=",file.size() for i in range(file.size()): if (i%1000==0): print "Event=",i entry = file.read(i) jets = entry.getJets() # get jets for j in range(jets.getPTCount()): h1.fill(jets.getPT(j)/unit) c1 = HPlot("Canvas",600,400) # plot histogram c1.visible() c1.setAutoRange() c1.draw(h1) c1.export("jetpt.pdf") # create PDF file You will see a plot of jet pT in a pop-up window. The example uses two classes: * [[http://jwork.org/scavis/api/doc.php/jhplot/H1D.html |H1D]] histogram class * [[http://jwork.org/scavis/api/doc.php/jhplot/HPlot.html |HPlot]] canvas to show the histogram Note that we use **unit** (unit for energy) and **lunit** (unit for length) to convert internal (Google's "variant") representation of ProMC into real numbers representing GeV. Here is the rule: * Energy-related variables, such as E,Mass,PT,and Px,Py,Pz should be divided by **unit**. * Length-related based (X,Y,Z,T) and Eta and Phi should be divided by **lunit**. We map ROOT branches to Java classes in the following way: * getEvent() returns [[http://mc.hep.anl.gov/asc/snowmass2013/delphes36/packages/delphes_read/api/promc/io/ProMC.ProMCEvent.Event.html | ProMC.ProMCEvent.Event]] class * getJets() returns [[http://mc.hep.anl.gov/asc/snowmass2013/delphes36/packages/delphes_read/api/promc/io/ProMC.ProMCEvent.Jets.html | ProMC.PMCEvroent.Jets]] class * getGenJets() returns [[http://mc.hep.anl.gov/asc/snowmass2013/delphes36/packages/delphes_read/api/promc/io/ProMC.ProMCEvent.GenJets.html | ProMC.ProMCEvent.GenJets]] class * getParticles() returns [[http://mc.hep.anl.gov/asc/snowmass2013/delphes36/packages/delphes_read/api/promc/io/ProMC.ProMCEvent.Particles.html | ProMC.ProMCEvent.Particles]] class * getElectrons() returns [[http://mc.hep.anl.gov/asc/snowmass2013/delphes36/packages/delphes_read/api/promc/io/ProMC.ProMCEvent.Electrons.html | ProMC.ProMCEvent.Electrons]] class * getMuons() returns [[http://mc.hep.anl.gov/asc/snowmass2013/delphes36/packages/delphes_read/api/promc/io/ProMC.ProMCEvent.Muons.html | ProMC.ProMCEvent.Muons]] class * getPhotons() returns [[http://mc.hep.anl.gov/asc/snowmass2013/delphes36/packages/delphes_read/api/promc/io/ProMC.ProMCEvent.Photons.html | ProMC.ProMCEvent.Photons]] class * getTracks() returns [[http://mc.hep.anl.gov/asc/snowmass2013/delphes36/packages/delphes_read/api/promc/io/ProMC.ProMCEvent.Tracks.html | ProMC.ProMCEvent.Tracks]] class * getBLJets() returns [[http://mc.hep.anl.gov/asc/snowmass2013/delphes36/packages/delphes_read/api/promc/io/ProMC.ProMCEvent.CAJets.html | ProMC.ProMCEvent.CAJets]] class * getMissingET() returns [[http://mc.hep.anl.gov/asc/snowmass2013/delphes36/packages/delphes_read/api/promc/io/ProMC.ProMCEvent.MissingET.html | ProMC.ProMCEvent.MissingET]] class Use methods of these classes to access the needed variables. ==== Useful methods ==== As in ROOT, there are a high-level Java classes included to the library to manipulate with particles or jets (i.e. similar to TLorenzVector in ROOT). Look at the Java API of the following classes: * [[http://jwork.org/scavis/api/doc.php/hephysics/particle/LParticle.html | LParticle class]] (or) * [[http://jwork.org/scavis/api/doc.php/hephysics/vec/HepLorentzVector.html | HepLorentzVector class]] Some examples using Python (and Java) are shown [[http://jwork.org/scavis/wikidoc/doku.php?id=man:science:physics| here]]. To create [[http://jwork.org/scavis/api/doc.php/hephysics/particle/LParticle.html | LParticle]] from the classes of the ProMC format with viable byte compression, do this: If you know px,py,pz,and energy in the integer representation from ProMC, simply do this: p=LParticle(px,py,pz,energy) p.dividePxPyPzE(unit); where unit=float(header.getMomentumUnit()) (can be defined at the beginning of this file). This converts integer representation of momenta to the GeV representation. If you know PT,Eta,Phi and mass of a jet or other object from the ProMC, create the [[http://jwork.org/scavis/api/doc.php/hephysics/particle/LParticle.html | LParticle]] object as: p=LParticle() p.setPtEtaPhiM(pt/unit, eta/lunit, phi/lunit, mass/unit); Note we use "unit" for pt and mass, while lunit is used for eta and phi. ==== Reading Delphes ProMC files in C++ ==== You can read Delphes ProMC files in C++ (still can be without installing ROOT). Install [[https://atlaswww.hep.anl.gov/asc/promc| ProMC library]]. wget http://mc.hep.anl.gov/asc/snowmass2013/delphes36/packages/delphes_read_cpp.tgz tar -zvxf delphes_read_cpp.tgz cd delphes_read_cpp wget http://mc.hep.anl.gov/asc/snowmass2013/delphes36/promc/MadGraph5Pythia_wjets_mu0.promc promc_proto MadGraph5Pythia_wjets_mu0.promc # generates data templates promc_code # generates source code from the data make # compiles delphes_read_cpp MadGraph5Pythia_wjets_mu0.promc --- //[[chekanov@anl.gov|Sergei Chekanov]] 2013/04/27 23:02//