Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Next revision Both sides next revision | ||
fcs:fccee:tutorial [2023/04/10 14:35] hepsim17 [Using files from HepSim] |
fcs:fccee:tutorial [2023/05/24 13:21] hepsim17 [Data streaming] |
||
---|---|---|---|
Line 69: | Line 69: | ||
</ | </ | ||
- | ====== Validation | + | ===== Validation ===== |
Now we know a lot about this files. Let's make a simple code to run over 10,000 events (2 files) and draw some useful histograms. | Now we know a lot about this files. Let's make a simple code to run over 10,000 events (2 files) and draw some useful histograms. | ||
Line 105: | Line 105: | ||
cross=0; nev=0; | cross=0; nev=0; | ||
for m in range(Nfiles): | for m in range(Nfiles): | ||
- | | + | |
| | ||
| | ||
Line 123: | Line 123: | ||
| | ||
| | ||
- | e= pa.getEnergy(j)/ | + | e= pa.getEnergy(j)/ |
mass= pa.getMass(j)/ | mass= pa.getMass(j)/ | ||
| | ||
Line 169: | Line 169: | ||
# h1.toTable() | # h1.toTable() | ||
- | l1=HLabel(" | + | l1=HLabel(" |
l1.setFont(Font(" | l1.setFont(Font(" | ||
c1.add(l1) | c1.add(l1) | ||
- | l2=HLabel(" | + | c1.cd(1, |
- | l2.setColor(Color.gray) | + | |
- | l2.setFont(Font(" | + | |
- | c1.add(l2) | + | |
- | # plot rapidity | + | |
- | c1.cd(1,2) | + | |
c1.setNameX(" | c1.setNameX(" | ||
c1.setNameY(" | c1.setNameY(" | ||
Line 215: | Line 210: | ||
{{: | {{: | ||
+ | |||
+ | |||
+ | ===== Data streaming ===== | ||
+ | |||
+ | One can also analyze truth-level files using data streaming, i.e. without downloading the actual input files. | ||
+ | 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+" | ||
+ | # | ||
+ | # | ||
+ | </ | ||
+ | </ | ||
===== Preparation for fast simulation ===== | ===== Preparation for fast simulation ===== | ||
Line 300: | Line 412: | ||
</ | </ | ||
- | This script creates the output file in the directory " | + | This script creates the output file in the directory " |
<code bash> | <code bash> | ||
Line 328: | Line 440: | ||
The output file will be data/ | The output file will be data/ | ||
- | ===== Full simulation ===== | + | |
+ | ===== Full simulation | ||
For full simulations, | For full simulations, | ||
Read the README of this simple tool. | Read the README of this simple tool. | ||
+ | |||
+ | The C++ version of the ProMC package can also convert files to HEPMC2 and LHEF. Look at the directories: | ||
+ | |||
+ | < | ||
+ | cd $PROMC/ | ||
+ | cd $PROMC/ | ||
+ | </ | ||
+ | |||
+ | 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. | ||
+ | |||
===== Some outreach | ===== Some outreach | ||
- | If you are a student who has never seen a typical e+e- event in real life, you may use this simple tool to display and view e+e- events. Here we will explore | + | If you are a student who has never seen a typical e+e- event in real life, you may use this simple tool to display and view e+e- events. Here we will explore |
+ | |||
+ | Unlike the tutorial discussed above, this example | ||
<code bash> | <code bash> |