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
Last revision Both sides next revision
hepsim:usage_truth [2017/02/07 21:54]
hepsim17 [Programming with HepSim]
hepsim:usage_truth [2020/05/21 23:31]
hepsim17
Line 6: Line 6:
  
 [[http://atlaswww.hep.anl.gov/hepsim/| HepSim repository]] can be used [[http://atlaswww.hep.anl.gov/hepsim/| HepSim repository]] can be used
-to reconstruct any distribution or differential cross section using truth-level files.+for plotting any distribution or differential cross section using truth-level (EVGEN) files.
 Many HepSim MC samples include *.py scripts to calculate differential cross sections. You can run Many HepSim MC samples include *.py scripts to calculate differential cross sections. You can run
 them using downloaded ProMC files (in which case you pass the directory with *promc files as an argument). them using downloaded ProMC files (in which case you pass the directory with *promc files as an argument).
Line 12: Line 12:
 In this case, data will be streamed to computer's memory and processed using your algorithm. In this case, data will be streamed to computer's memory and processed using your algorithm.
  
 +You can create plots using a number of programming languages, Java, Python, C++, Ruby, Groovy etc. Plots can be done on any platform, without modifying your system. C++ analysis programs require ROOT and Linux.
  
- You can create plots using a number of programming languages, Java, Python, C++, Ruby, Groovy etc. Plots can be done on any platform, without modifying your system. C++ analysis programs require ROOT and Linux. +Below we will discuss how to analyse EVGEN data using Java, since this approach works on any
- +
-Below we will discuss how to analyse HepSim data using Java, since this approach works on any+
 platform (Linux, Mac, Windows) and does not require installation of any platform-specific program.  platform (Linux, Mac, Windows) and does not require installation of any platform-specific program. 
-As before, make sure that [[http://java.com/en/download/index.jsp| Java 7]] and above is installed (check it as "java -version").+As before, make sure that [[http://java.com/en/download/index.jsp|Java 7]] and above is installed (check it as "java -version").
  
-===== Method I. Running in a batch mode without downloaded ProMC files =====+======  Streaming over the network  ====== 
  
 You can run validation scripts in a batch mode as: You can run validation scripts in a batch mode as:
Line 28: Line 27:
 </code> </code>
  
-Another approach is to use [[http://atlaswww.hep.anl.gov/asc/jas4pp | Jas4pp]] or  [[http://jwork.org/dmelt/ | DataMelt]]. Such programs +Another approach is to use [[http://atlaswww.hep.anl.gov/asc/jas4pp |Jas4pp]] or  [[http://jwork.org/dmelt/|DataMelt]]. Such programs 
 give more flexibility and more libraries for analysis. give more flexibility and more libraries for analysis.
-In this example, we will run a Python script that downloads data from URL into the computer memory  and runs it in a batch mode. First, you will need an analysis code from HepSim. Look at ttbar sample from Madgraph: [[http://atlaswww.hep.anl.gov/hepsim/info.php?item=15 | ttbar_mg5]].  Find the URL location of the analysis script ("ttbar_mg5.py") located at the bottom of this page. Then copy the URL link of the file *.py using the right mouse button ("Copy URL Location"). Let us make a calculation of differential ttbar cross section. +In this example, we will run a Python script that downloads data from URL into the computer memory  and runs it in a batch mode. First, you will need an analysis code from HepSim. Look at ttbar sample from Madgraph: [[http://atlaswww.hep.anl.gov/hepsim/info.php?item=15|ttbar_mg5]].  Find the URL location of the analysis script ("ttbar_mg5.py") located at the bottom of this page. Then copy the URL link of the file *.py using the right mouse button ("Copy URL Location"). Let us make a calculation of differential ttbar cross section. 
  
 Here is how to process the analysis using  [[http://atlaswww.hep.anl.gov/asc/jas4pp | Jas4pp]]: Here is how to process the analysis using  [[http://atlaswww.hep.anl.gov/asc/jas4pp | Jas4pp]]:
Line 45: Line 44:
 Look at the "example" directory of the Jas4pp installation. It has a several examples of how to process the ProMC files. Look at the "example" directory of the Jas4pp installation. It has a several examples of how to process the ProMC files.
  
-Similarly, you can use a more complex [[http://jwork.org/dmelt/ | DataMelt]]:+Similarly, you can use a more complex [[https://datamelt.org|DataMelt]]:
 <code bash> <code bash>
 wget -O dmelt.zip http://jwork.org/dmelt/download/current.php                        # get DataMelt wget -O dmelt.zip http://jwork.org/dmelt/download/current.php                        # get DataMelt
Line 59: Line 58:
 </code> </code>
  
-If you want to see a pop-up canvas with the output histogram on your screen, change the line "c1.visible(False)" to "c1.visible()" and comment out  "sys.exit(0)" at the very end of the "ttbar_mg5.py" macro. You can change the output format from "SVG" to "PDF", "EPS" or "PNG". Look at the [[http://jwork.org/dmelt/api/doc.php/jhplot/package-summary | Java API]].+If you want to see a pop-up canvas with the output histogram on your screen, change the line "c1.visible(False)" to "c1.visible()" and comment out  "sys.exit(0)" at the very end of the "ttbar_mg5.py" macro. You can change the output format from "SVG" to "PDF", "EPS" or "PNG". Look at the [[http://datamelt.org/api/doc.php/jhplot/package-summary | Java API]].
  
-===== Method IIRunning in batch mode after downloading ProMC files ====+ 
 +====== Using Java WebStart ====== 
 + 
 + 
 +Many "Info" pages of HepSim have Jython (Python) scripts for validation and analysisOne can run such scripts from the web browsers using the Java Web Start technology. Click the "Launch" button. You will see an editor. Then click the "Run" button to process events. 
 + 
 +To use Java Web Start, you should configure Java permissions: For Linux/Mac, run "ControlPanel", go to the "Security" tab and add "http://atlaswww.hep.anl.gov" to the exception list. For Windows, find "Java Control Panel" and do the same. Read [[https://www.java.com/en/download/help/java_blocked.xml|Why are Java applications blocked by your security settings]]. In addition, if you are Mac user, you should allow execution of programs outside Mac App Store.  
 + 
 + 
 +======  Downloaded ProMC files ====== 
  
 The above approach depends on network availability at the time when you do the analysis. The above approach depends on network availability at the time when you do the analysis.
Line 83: Line 91:
  
 Similarly,  you can use  [[http://atlaswww.hep.anl.gov/asc/jas4pp | Jas4pp]]. Similarly,  you can use  [[http://atlaswww.hep.anl.gov/asc/jas4pp | Jas4pp]].
-===== Method III. Running in a GUI mode  ====+ 
 +======  Running in a GUI mode ====== 
  
 You can perform short validation analysis using an editor as: You can perform short validation analysis using an editor as:
Line 108: Line 117:
 It will open the Python script for editing. Next, run this  script by clicking the image of green running man on the status bar (or press [F8]). It will open the Python script for editing. Next, run this  script by clicking the image of green running man on the status bar (or press [F8]).
  
-===== Method IV. Running in a GUI mode using URL dialog  ====+====== Using GUI URL dialogue ====== 
  
- +If you use DMelt, you can run this code using a more conventional editor:
- +
-If you use DMelt, you can run this code using +
-a more conventional editor:+
  
 <code bash> <code bash>
Line 185: Line 191:
  
 <hidden> <hidden>
-{{:etaphi.png|Eta-Phi}}+{{:hepsim:etaphi.png|Eta-Phi}}
 </hidden> </hidden>
  
Line 191: Line 197:
  
 <hidden> <hidden>
-{{:3dview.png| 3D view}}+{{:hepsim:3dview.png| 3D view}}
 </hidden> </hidden>
  
Line 197: Line 203:
  
 <hidden> <hidden>
-{{:view3d.py| Python code to show event in 3D}}+{{:hepsim:view3d.py| Python code to show event in 3D}}
 </hidden> </hidden>
  
Line 218: Line 224:
 </code> </code>
  
- +Click the event number ('left pannel"and then look at "Event info" It shows the integer values (idata) that encode the PDF uncertainties, while the float array ("fdata") shows other information. The first element in the float array is the weight of the event. The particle information is shown as usual (but without mother ID etc.). 
-On the left panel, click on the event and then look at "Event info" It shows the integer values (idata) that encode the PDF uncertainties, while the float array ("fdata") shows other information. The first element in the float array is the weight of the event. The particle information is shown as usual (but without mother ID etc.). +
  
 <hidden> <hidden>
Line 235: Line 240:
 </code> </code>
  
-Alternatively, open this script in the DMelt editor and press run (or [F8]).+Alternatively, open this script in the DataMelt editor and press run (or [F8]).
  
 NLO event record includes 4-momenta of particles and event weights (double values). In addition, deviations form central weights are included as an array of integer values as: NLO event record includes 4-momenta of particles and event weights (double values). In addition, deviations form central weights are included as an array of integer values as:
  
-{{:screenshot-26.png?300}}+{{:hepsim:screenshot-26.png?300}}
  
 You can calculate differential cross sections using online files using this example: You can calculate differential cross sections using online files using this example:
Line 251: Line 256:
 </code> </code>
  
-This example runs "higgsjet_gamgam_mcfm.py" code using online files and creates  a Higgs differential cross section with PDF uncertainties. +This example runs "higgsjet_gamgam_mcfm.py" code using online files and creates  a Higgs differential cross section with PDF uncertainties. We use DataMelt to do the calculations (after updating one jar file). You can also use ROOT/C++ to do the same.
-We use DMelt to do the calculations (after updating one jar file). You can also use ROOT/C++ to do the same.+
  
  
Line 294: Line 298:
 For a longer description, read the [[http://atlaswww.hep.anl.gov/asc/promc/ | ProMC manual]]. For a longer description, read the [[http://atlaswww.hep.anl.gov/asc/promc/ | ProMC manual]].
  
-For C++/ROOT, you can use {{:promc_root_example.tgz| this C++/ROOT example package}}.+For C++/ROOT, you can use {{:hepsim:promc_root_example.tgz| this C++/ROOT example package}}.
 Untar it and compile using "make". This will produce "promc2root" executable. It reads Untar it and compile using "make". This will produce "promc2root" executable. It reads
 all ProMC files in a given directory and fills ROOT histograms with cross sections.  all ProMC files in a given directory and fills ROOT histograms with cross sections. 
Line 304: Line 308:
      
  
-Please look at HepSim [[:usage_truth|programming tutorials]] on how to design Jython scripts. +Please look at HepSim [[:hepsim:usage_truth|programming tutorials]] on how to design Jython scripts. 
-Please refer [[asc:promc| ProMC web page]] on how to read/write ProMC files.+Please refer [[https://atlaswww.hep.anl.gov/asc/promc/| ProMC web page]] on how to read/write ProMC files.
  
 Also, there is a simple example showing how to read Monte Carlo files from HepSim in a loop, Also, there is a simple example showing how to read Monte Carlo files from HepSim in a loop,
Line 334: Line 338:
 ====== Converting to LCIO ====== ====== Converting to LCIO ======
  
-ProMC files can be converted to LCIO files for full detector simulations.  This is an example of such conversion (it requires Java installed):+ProMC files can be converted to LCIO or STDHEP  
 +files for full detector simulations.  See [[hepsim:dev_full|LCIO/STDHEP section]] for detail. 
  
 +Note that the converters are included inside the ProMC package (see the directory "examples"). Here is an example:
 +
 +<hidden>
 <code bash> <code bash>
 wget http://atlaswww.hep.anl.gov/asc/promc/download/current.php -O ProMC.tgz wget http://atlaswww.hep.anl.gov/asc/promc/download/current.php -O ProMC.tgz
Line 344: Line 352:
 java promc2lcio file.promc file.slcio java promc2lcio file.promc file.slcio
 </code> </code>
-The last commends creates  file.slcio with "MCparticle" container. +</hidden> 
 + 
 +The last command creates  file.slcio with the "MCParticle" container. 
  
  
Line 373: Line 383:
  
 Many scripts of HepSim create SVG images and a cross platform  Many scripts of HepSim create SVG images and a cross platform 
-[[http://jwork.org/dmelt/wikidoc/doku.php?id=man:io:crossplatform | JDAT data format based on HBook]]. In order to convert JDAT files into CPython or ROOT object, read the data using xml.dom. This is a conversion to the CPython:+[[https://handwiki.org/wiki/DMelt:IO/8_Cross_Paltform_IO | JDAT data format based on HBook]]. In order to convert JDAT files into CPython or ROOT object, read the data using xml.dom. This is a conversion to the CPython:
  
 <hidden> <hidden>
 <code python> <code python>
-!/usr/local/bin/python+#!/usr/local/bin/python
 # Convert jdat to the standard Python # Convert jdat to the standard Python
 # This can be used for converting data to pyROOT  # This can be used for converting data to pyROOT