User Tools

Site Tools


asc:promc:examples

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
asc:promc:examples [2014/07/16 14:52]
asc [Accessing data in PHP]
asc:promc:examples [2015/05/10 21:08] (current)
asc
Line 6: Line 6:
 (written by S.Chekanov, ANL) (written by S.Chekanov, ANL)
  
-ProMC binary files are very compact and self-describing files, typically 30-50% smaller than   ROOT files or gzipped HEPMC files due to variable-byte encoding (small numbers use smaller number of bytes). Look at the examples below which show how to write,read, browser and convert HEPMC files +ProMC files are compact and self-describing binary files, typically 30-50% smaller than   ROOT files or gzipped HEPMC files due to the use of a variable-byte encoding (small numbers use smaller number of bytes). They can be processed in C++, Java, Python and other languages. Look at the examples below which show how to write,read, browser and convert HEPMC files 
-to ProMC files. More information is in the [[asc:promc:introduction|Introduction]].+to ProMC files. More information is in the [[asc:promc:introduction|Introduction]]. Since ProMC is the main format for [[http://atlaswww.hep.anl.gov/hepsim/| HepSim]], check the description of that database.
  
  
Line 18: Line 18:
 wget  http://atlaswww.hep.anl.gov/asc/promc/download/Pythia8.promc      # get example file wget  http://atlaswww.hep.anl.gov/asc/promc/download/Pythia8.promc      # get example file
 wget  http://atlaswww.hep.anl.gov/asc/promc/download/browser_promc.jar  # get GUI browser wget  http://atlaswww.hep.anl.gov/asc/promc/download/browser_promc.jar  # get GUI browser
-java -jar browser_promc.jar  Pythia8.promc                              # run GUI browser on this file+java -jar browser_promc.jar Pythia8.promc                               # run GUI browser on this file
 </code> </code>
 This will bring up a GUI window so one can look at separate events and the data layout (see the example below).  This will bring up a GUI window so one can look at separate events and the data layout (see the example below). 
Line 33: Line 33:
 Look at the Python examples discussed bellow how to  use a random access via the network. Look at the Python examples discussed bellow how to  use a random access via the network.
  
 +
 +Note that the browser can open ProMC files of any size, since it loads only a fraction of data. This is especially useful compared to limitations
 +of some formats that cannot be viewed in text editors if their sizes are too large.
  
  
Line 55: Line 58:
 After the installation, all examples are located in the directory: After the installation, all examples are located in the directory:
  
-<code>+<code bash>
 $PROMC/examples  $PROMC/examples 
 </code> </code>
  
-Take a look at themEach director has "Makefileto compile examples.+If you already know that your file include information from typical parton-shower Monte Carlo model, look at the example: 
 + 
 +<code bash> 
 +$PROMC/examples/reader_mc  
 +</code> 
 +that reads a ProMC fileThe makefile links "libpromc.alibrary which describes the event structure. 
 + 
 +If you know that stored data are from a NLO program, looks at: 
 + 
 +<code bash> 
 +$PROMC/examples/reader_nlo 
 +</code> 
 +that links the "libpronlo.a" library describing a typical NLO record.
  
-ProMC files are self-describing. You can generate  analysis codes in C++, Java, Python +ProMC files are self-describing, therefore you can read and write any type of data and generate static libraries from platform-neutral templates 
 +You can generate  analysis codes in C++, Java, Python 
 if you happen to have a ProMC file but do not know how the data are organized inside the file. You need to install [[asc:promc:installation|ProMC]]. if you happen to have a ProMC file but do not know how the data are organized inside the file. You need to install [[asc:promc:installation|ProMC]].
  
Line 73: Line 89:
 promc_info  Pythia8.promc  # check information about this file promc_info  Pythia8.promc  # check information about this file
 promc_proto Pythia8.promc  # extracts data layouts into the directory "proto" promc_proto Pythia8.promc  # extracts data layouts into the directory "proto"
-promc_code                                  generate analysis code in src/, java/, python/ +promc_code                 creates  C++/Java/Python analysis codes in src/, java/, python/ 
-make                                        # compiles C++ code reader.cc+make                       # compiles C++ code reader.cc
 ./reader   Pythia8.promc   # runs the C++ analysis code ./reader   Pythia8.promc   # runs the C++ analysis code
 </code> </code>
Line 196: Line 212:
 The example given in the directory "examples/root" shows how to fill ROOT tree from ProMC record. We assume that the file "output.promc" from the previous example was already created. Go to " examples/root" and type "make" (ROOT should be installed). Then dump the ProMC record to the ROOT  Tree file. We assume that 4-momenta is written as "Double32_t"  (written as a 4 bytes floats). The output file will be found "out/output.root" The example given in the directory "examples/root" shows how to fill ROOT tree from ProMC record. We assume that the file "output.promc" from the previous example was already created. Go to " examples/root" and type "make" (ROOT should be installed). Then dump the ProMC record to the ROOT  Tree file. We assume that 4-momenta is written as "Double32_t"  (written as a 4 bytes floats). The output file will be found "out/output.root"
  
- 
-===== Benchmark summary   ===== 
- 
-Here is a comparison of file sizes for the same event records written by "examples/random/out/output.promc". The benchmarks is done using examples from  "examples" directory 
- 
- 
-^   File format                          ^  Size (MB) ^ 
-|   ASCII TXT file  ("HEPMC"           |  346       | 
-|   gzipped ASCII TXT file                138       | 
-|   ROOT tree (Double32_t)                158       | 
-|   ProMC                                |  112       | 
- 
- 
-As one can see,  the ProMC files are 40% more compact than the equivalent ROOT files and 23% more compact than gzipped ASCII TXT ("HEPMC"). 
  
  
Line 240: Line 242:
 </code> </code>
  
-An example program which fills ProMC file record is given here  +An example program which fills ProMC file record is given in 
-[[http://atlaswww.hep.anl.gov/asc/WebSVN/filedetails.php?repname=ProMC&path=%2FProMC%2Ftrunk%2Fexamples%2Fpythia%2Fwriter_pythia.cc|writer_pythia.cc]]. The make file is located here [[http://atlaswww.hep.anl.gov/asc/WebSVN/filedetails.php?repname=ProMC&path=%2FProMC%2Ftrunk%2Fexamples%2Fpythia%2FMakefile|Makefile]]+[[https://github.com/Argonne-National-Laboratory/ProMC/blob/master/examples/pythia/|Pythia8 to ProMC example]] 
  
  
Line 330: Line 332:
 ===== Reading data using Jython ===== ===== Reading data using Jython =====
  
-You can make histograms on any platform (Windows/Linux/Mac) when using [[http://jwork.org/scavis/|SCaVis]].  Copy "browser_promc.jar" file  from  +You can make histograms on any platform (Windows/Linux/Mac) when using [[http://jwork.org/dmelt/|DataMelt]].  Copy "browser_promc.jar" file  from  
-"example/browser/"  of the installation directory to the directory "lib/user" of the ScaVis installation. +"example/browser/"  of the installation directory to the directory "lib/user" of the DatMelt installation. 
-To avoid a clash with the library shipped with Scavis, remove "promc-protobuf.jar" inside the Scavis installation directory. +To avoid a clash with the library shipped with DatMelt, remove "promc-protobuf.jar" inside the DatMelt installation directory. 
  
 <code bash> <code bash>
 rm   lib/system/promc-protobuf.jar rm   lib/system/promc-protobuf.jar
 </code> </code>
-(in Windows, go to this directory and remove this file) and restart the ScaVis. Then you can write a small Jython script like this:+(in Windows, go to this directory and remove this file) and restart the DatMelt. Then you can write a small Jython script like this:
  
 <code python promc.py> <code python promc.py>
-# Reading Pthia8 file in the ProMC format using ScaVis http://jwork.org/scavis+# Reading Pthia8 file in the ProMC format using [[http://jwork.org/dmelt | DataMelt]]
 # S.Chekanov (ANL) # S.Chekanov (ANL)
 from java.io import * from java.io import *
Line 346: Line 348:
 from promc.io import * from promc.io import *
 from proto import *   # import FileMC from proto import *   # import FileMC
-from jhplot import *  # import ScaVis graphics+from jhplot import *  # import DatMelt graphics
  
 file = FileMC("Pythia8.promc") file = FileMC("Pythia8.promc")
Line 382: Line 384:
 wget  http://atlaswww.hep.anl.gov/asc/promc/download/Pythia8.promc wget  http://atlaswww.hep.anl.gov/asc/promc/download/Pythia8.promc
 </code> </code>
-Start SCaVis and run this script. It will show the Px spectra for  all stored particles.  +Start DatMelt and run this script. It will show the Px spectra for  all stored particles.  
-(You can load this file as "scavis.sh promc.py"+(You can load this file as "dmelt.sh promc.py"
  
  
Line 462: Line 464:
  
  
-  - [[http://atlaswww.hep.anl.gov/asc/WebSVN/filedetails.php?repname=ProMC&path=%2FProMC%2Ftrunk%2Fproto%2Fpromc%2FProMC.proto|ProMC.proto]] - This is simplest data layout to keep only truth particle information. It is shipped with the default ProMC installation. +  - [[https://github.com/Argonne-National-Laboratory/ProMC/tree/master/proto/promc|ProMC record]] - This is simplest data layout to keep only truth particle information. It is shipped with the default ProMC installation. 
-  - [[http://atlaswww.hep.anl.gov/asc/WebSVN/filedetails.php?repname=ProMC&path=%2FProMC%2Ftrunk%2Fexamples%2Fproto%2Fdelphes%2FProMC.proto | ProMC.proto for Delphes]] - This is a more complicated data layout suitable for data and reconstructed MC. It shows how to include reconstructed objects (jets,photons, muons)+  - [[https://github.com/Argonne-National-Laboratory/ProMC/tree/master/proto/proreco | ProMC for Delphes]] - This is a more complicated data layout suitable for data and reconstructed MC. It shows how to include reconstructed objects (jets,photons, muons)
   - [[http://atlaswww.hep.anl.gov/asc/WebSVN/filedetails.php?repname=ProMC&path=%2FProMC%2Ftrunk%2Fexamples%2Fproto%2Fdelphes_constituents%2FProMC.proto | ProMC.proto for Delphes plus jet constituents]] - This is more complicated layout. It shows how to include clusters (jet constituents) for each jet   - [[http://atlaswww.hep.anl.gov/asc/WebSVN/filedetails.php?repname=ProMC&path=%2FProMC%2Ftrunk%2Fexamples%2Fproto%2Fdelphes_constituents%2FProMC.proto | ProMC.proto for Delphes plus jet constituents]] - This is more complicated layout. It shows how to include clusters (jet constituents) for each jet
 +  - [[https://github.com/Argonne-National-Laboratory/ProMC/tree/master/proto/pronlo|ProMC NLO record]] - This is a data layout to keep NLO calculations 
 +   
 +   
 More complex layout files (for example, foe Delphes fast simulation) can be found More complex layout files (for example, foe Delphes fast simulation) can be found
 inside the directory "examples/" inside the directory "examples/"
asc/promc/examples.1405522329.txt.gz · Last modified: 2014/07/16 14:52 by asc