Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
fcs:fccee:tutorial [2023/04/11 19:49] hepsim17 [Validation] |
fcs:fccee:tutorial [2023/05/24 14:06] (current) hepsim17 [Data streaming] |
||
---|---|---|---|
Line 74: | Line 74: | ||
Click the tab below to see the code. This code may look rather long, but it does a lot: It reads the truth-level events, reconstructs jets, and makes plots of the pT (differential cross section), Rapidity distribution and the invariant mass of the 2 jets. It also saves the image in SVG file and an XML file for examination: | Click the tab below to see the code. This code may look rather long, but it does a lot: It reads the truth-level events, reconstructs jets, and makes plots of the pT (differential cross section), Rapidity distribution and the invariant mass of the 2 jets. It also saves the image in SVG file and an XML file for examination: | ||
- | < | + | < |
- | < | + | < |
# Part of =HepMC= : https:// | # Part of =HepMC= : https:// | ||
# S.Chekanov (ANL) | # S.Chekanov (ANL) | ||
Line 210: | Line 210: | ||
{{: | {{: | ||
+ | |||
+ | |||
+ | ===== Data streaming ===== | ||
+ | |||
+ | One can also analyze truth-level files using data streaming, i.e. without downloading the actual input files. | ||
+ | This example shows data for Higgs to bbar at 240 GeV e+e-. | ||
+ | Click the code shown below, save it as " | ||
+ | |||
+ | <hidden Click here to show the Python/ | ||
+ | <code python> | ||
+ | # illustration of how to make pT distribution in real time using data streaming | ||
+ | # S.Chekanov (ANL) | ||
+ | from java.awt import Color,Font | ||
+ | from java.lang import * | ||
+ | from proto import FileMC | ||
+ | from jhplot import HPlot, | ||
+ | from jhplot.utils import FileList | ||
+ | from hephysics.particle import LParticle | ||
+ | from hephysics.hepsim import PromcUtil | ||
+ | from hephysics.jet import JetN2 | ||
+ | from hepsim import HepSim | ||
+ | import sys, | ||
+ | |||
+ | TotalEvents=10000 | ||
+ | |||
+ | dataset=" | ||
+ | tag="" | ||
+ | url="" | ||
+ | NMax=0 | ||
+ | if len(sys.argv)> | ||
+ | | ||
+ | if (len(sys.argv)> | ||
+ | else: | ||
+ | | ||
+ | | ||
+ | | ||
+ | if len(flist)==0: | ||
+ | else: print " | ||
+ | |||
+ | # | ||
+ | h1= H1D(" | ||
+ | |||
+ | c1 = HPlot(" | ||
+ | c1.visible(True) | ||
+ | c1.setAutoRange(True) | ||
+ | c1.setMarginLeft(90) | ||
+ | c1.setLegend(0) | ||
+ | |||
+ | cross=0; nev=0; | ||
+ | for m in range(Nfiles): | ||
+ | | ||
+ | print " | ||
+ | | ||
+ | | ||
+ | | ||
+ | if m==0: | ||
+ | print "ProMC v=", | ||
+ | if (nev> | ||
+ | for i in range(file.size()): | ||
+ | if (nev> | ||
+ | nev=nev+1 | ||
+ | if (nev%1000==0): | ||
+ | if (Nfiles==1): | ||
+ | | ||
+ | print " | ||
+ | c1.clearData() | ||
+ | # | ||
+ | # | ||
+ | c1.draw(h1) | ||
+ | print " | ||
+ | eve = file.read(i) | ||
+ | pa = eve.getParticles() | ||
+ | nt=0; xsum=0; | ||
+ | darkpi={} | ||
+ | #print " " | ||
+ | for j in range(pa.getPxCount()): | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | stat = file.getStat() | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | # show final cross section | ||
+ | c1.clearData() | ||
+ | c1.clear() | ||
+ | # | ||
+ | # | ||
+ | c1.setRangeX(0, | ||
+ | c1.setMarginLeft(90) | ||
+ | c1.setNameX(" | ||
+ | c1.setNameY(" | ||
+ | |||
+ | c1.draw(h1) | ||
+ | print h1.getStat() | ||
+ | # | ||
+ | # | ||
+ | # | ||
+ | #c1.add(l1) | ||
+ | |||
+ | l2=HLabel(" | ||
+ | l2.setColor(Color.gray) | ||
+ | l2.setFont(Font(" | ||
+ | c1.add(l2) | ||
+ | |||
+ | # create file/image using name of the file | ||
+ | name=" | ||
+ | from jhplot.io import HBook | ||
+ | file=HBook(name+" | ||
+ | file.write(" | ||
+ | file.close() | ||
+ | c1.export(name+" | ||
+ | # | ||
+ | # | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | If you run this code as Jython script inside Jas4pp, you will see a histogram updated in real time: | ||
+ | |||
+ | {{ : | ||
+ | |||
+ | |||
+ | ===== Analysis of LCIO files ===== | ||
+ | |||
+ | Full example of how to analyse LCIO files is given in: https:// | ||
===== Preparation for fast simulation ===== | ===== Preparation for fast simulation ===== | ||
Line 338: | Line 465: | ||
The key4hep requires HEPMC3 format (not HEPMC2). Therefore, the current option is to convert PROMC to HEMC2 and then convert HEPMC3. Alternatively, | The key4hep requires HEPMC3 format (not HEPMC2). Therefore, the current option is to convert PROMC to HEMC2 and then convert HEPMC3. Alternatively, | ||
+ | First, get the script: | ||
+ | |||
+ | < | ||
+ | wget http:// | ||
+ | </ | ||
+ | |||
+ | Then use it like this: | ||
+ | |||
+ | < | ||
+ | $ source / | ||
+ | $ ./ | ||
+ | </ | ||
+ | |||
+ | |||
+ | You can specify the number of events in the file in the case the guess based on grepping < | ||
+ | If you specify ‘—stable’ only the stable particles (status == 1) are kept in the final file. | ||