fcs:fccee:tutorial
Differences
This shows you the differences between two versions of the page.
— | fcs:fccee:tutorial [2024/07/01 21:25] (current) – created - external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== FCC-ee tutorial using HepSim files ====== | ||
+ | |||
+ | Here is mini-tutorial explaining how to use Monte Carlo truth-level files from the HepSim for the FCC-ee studies. The setup of the computer environment is described in [[fcs: | ||
+ | |||
+ | |||
+ | ====== FCC-ee tutorial ====== | ||
+ | |||
+ | See [[https:// | ||
+ | |||
+ | |||
+ | |||
+ | ===== Using files from HepSim | ||
+ | |||
+ | This part of the tutorial does not use any C++ specific libraries and can be done on any computers with Java installed. | ||
+ | <code bash> | ||
+ | java -version | ||
+ | </ | ||
+ | |||
+ | Typically, it will tell openjdk version " | ||
+ | |||
+ | <code bash> | ||
+ | bash # | ||
+ | wget https:// | ||
+ | source hs-toolkit/ | ||
+ | </ | ||
+ | |||
+ | Let's look at a few events: Z-> Z H, where Z-> nunu, and H decays to bbar. The CM energy is 250 GeV. The sample is described in https:// | ||
+ | |||
+ | First, print all files with Higgs processes: | ||
+ | |||
+ | <code bash> | ||
+ | hs-find higgs | ||
+ | </ | ||
+ | |||
+ | Then grab the file with H to bbar at e+e-: | ||
+ | |||
+ | <code bash> | ||
+ | hs-ls gev250ee_pythia8_zhiggs_nunubbar | ||
+ | </ | ||
+ | |||
+ | Let's download 10 files (in 2 threads): | ||
+ | |||
+ | <code bash> | ||
+ | hs-get gev250ee_pythia8_zhiggs_nunubbar data 2 10 | ||
+ | </ | ||
+ | |||
+ | We should have 10 files in the directory " | ||
+ | |||
+ | <code bash> | ||
+ | hs-info | ||
+ | </ | ||
+ | |||
+ | Do you want to print 1st event? Do this: | ||
+ | |||
+ | <code bash> | ||
+ | hs-info data/ | ||
+ | </ | ||
+ | |||
+ | Want to examine the log file? Do this: | ||
+ | |||
+ | <code bash> | ||
+ | hs-log | ||
+ | </ | ||
+ | |||
+ | Let's study each event in the GUI mode (needs X-session!). Start this GUI and click each event number using the left panel. | ||
+ | |||
+ | <code bash> | ||
+ | hs-view | ||
+ | </ | ||
+ | |||
+ | ===== 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. | ||
+ | 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: | ||
+ | |||
+ | <hidden Click here to show the Python/ | ||
+ | < | ||
+ | # Part of =HepMC= : https:// | ||
+ | # S.Chekanov (ANL) | ||
+ | from java.lang import * | ||
+ | from proto import FileMC | ||
+ | from java.util import ArrayList | ||
+ | from hep.physics.vec import BasicHepLorentzVector | ||
+ | from jhplot.utils import FileList | ||
+ | from java.awt import Color,Font | ||
+ | from jhplot import | ||
+ | from jhplot.io import HBook | ||
+ | from hephysics.particle import LParticle | ||
+ | from hep.physics.jet import DurhamJetFinder, | ||
+ | from hepsim import HepSim | ||
+ | import sys | ||
+ | |||
+ | Nfiles=2 # 2 files to process for checking | ||
+ | flist=FileList.get(" | ||
+ | print "Found " | ||
+ | |||
+ | fjet=DurhamJetFinder(0.05) # DurhamJet with y_cut=0.05 | ||
+ | # | ||
+ | |||
+ | h1= H1D(" | ||
+ | # | ||
+ | h2= H1D(" | ||
+ | h3= H1D(" | ||
+ | |||
+ | cross=0; nev=0; | ||
+ | for m in range(Nfiles): | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | if m==0: | ||
+ | print "ProMC v=", | ||
+ | for i in range(file.size()): | ||
+ | nev=nev+1 | ||
+ | if (nev%500==0): | ||
+ | eve = file.read(i) | ||
+ | pa = eve.getParticles() | ||
+ | ve = eve.getEvent() | ||
+ | particles=ArrayList() # list of particles | ||
+ | for j in range(pa.getPxCount()): | ||
+ | if (pa.getStatus(j)==1): | ||
+ | | ||
+ | | ||
+ | | ||
+ | e= pa.getEnergy(j)/ | ||
+ | mass= pa.getMass(j)/ | ||
+ | | ||
+ | if (apdg==12 or apdg==14 or apdg==16): continue # no neutrino | ||
+ | | ||
+ | | ||
+ | fjet.setEvent(particles) | ||
+ | jets=[] # make a new list with jets | ||
+ | for j in range(fjet.njets()): | ||
+ | # print " | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | if (len(jets)> | ||
+ | jets[0].add(jets[1]) | ||
+ | h3.fill(jets[0].calcMass() ) | ||
+ | |||
+ | stat = file.getStat() | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | lumi=nev/ | ||
+ | print " | ||
+ | print "Total cross section (pb)=", | ||
+ | c1 = HPlot(" | ||
+ | c1.visible(True) | ||
+ | # c1.setAutoRange() | ||
+ | # c1.setLogScale(1, | ||
+ | c1.setMarginLeft(100) | ||
+ | c1.setNameX(" | ||
+ | c1.setNameY(" | ||
+ | c1.setRange(0, | ||
+ | |||
+ | Z=h1.getDividedByBinWidth() | ||
+ | Z.scale(1.0/ | ||
+ | xsec1=P1D(Z) | ||
+ | xsec1.setErr(1) | ||
+ | xsec1.setColor(Color.blue) | ||
+ | c1.draw(Z) | ||
+ | # h1.toTable() | ||
+ | |||
+ | l1=HLabel(" | ||
+ | l1.setFont(Font(" | ||
+ | c1.add(l1) | ||
+ | c1.cd(1,2) # plot rapidity | ||
+ | c1.setNameX(" | ||
+ | c1.setNameY(" | ||
+ | c1.setMarginLeft(100) | ||
+ | c1.setAutoRange() | ||
+ | c1.setRangeX(-5, | ||
+ | c1.draw(h2) | ||
+ | |||
+ | # plot invariant mass | ||
+ | c1.cd(1,3) | ||
+ | c1.setNameX(" | ||
+ | c1.setNameY(" | ||
+ | c1.setMarginLeft(100) | ||
+ | c1.setAutoRange() | ||
+ | c1.setRangeX(100, | ||
+ | c1.draw(h3) | ||
+ | |||
+ | # create file/image using name of the file | ||
+ | name=" | ||
+ | if len(sys.argv[0])> | ||
+ | file=HBook(name+" | ||
+ | file.write(xsec1) | ||
+ | file.close() | ||
+ | c1.export(name+" | ||
+ | # xsec.toFile(name+" | ||
+ | # sys.exit(0) | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | Copy the code shown below to a file " | ||
+ | |||
+ | < | ||
+ | hs-run validatation.py | ||
+ | </ | ||
+ | |||
+ | It will create the image with jets and a Higgs peak for 2-jet mass. | ||
+ | |||
+ | {{: | ||
+ | |||
+ | |||
+ | ===== 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 ===== | ||
+ | |||
+ | For fast simulations we need to install the C++ ProMC library. After it is installed, the compiled Delphes program can start using the ProMC files natively. | ||
+ | Let's take this package from https:// | ||
+ | |||
+ | |||
+ | Use the key4hep setup with gcc11. It will also link the ROOT libraries: | ||
+ | |||
+ | <code bash> | ||
+ | source / | ||
+ | </ | ||
+ | |||
+ | If ( / | ||
+ | |||
+ | <code bash> | ||
+ | source / | ||
+ | </ | ||
+ | |||
+ | Then install ProMC (currently it is an external package): | ||
+ | |||
+ | <code bash> | ||
+ | wget http:// | ||
+ | tar -zvxf ProMC.tgz | ||
+ | cd ProMC | ||
+ | ./ | ||
+ | ./ | ||
+ | source lib/ | ||
+ | </ | ||
+ | |||
+ | After the installation, | ||
+ | |||
+ | <code bash> | ||
+ | echo $PROMC/bin | ||
+ | </ | ||
+ | |||
+ | This package will be used for fast simulation. In addition, you can perform various transformation of the event records. For example, move your data to ROOT: | ||
+ | |||
+ | |||
+ | <code bash> | ||
+ | cd $PROMC/ | ||
+ | make # creates converter promc2root | ||
+ | cd ../ | ||
+ | $PROMC/ | ||
+ | </ | ||
+ | Note some system picks the native "zlib library" | ||
+ | |||
+ | The last command will create ROOT files with the tree " | ||
+ | |||
+ | {{ : | ||
+ | |||
+ | Similarly, one can do transformation oto the popular text formats: | ||
+ | |||
+ | <code bash> | ||
+ | $PROMC/ | ||
+ | $PROMC/ | ||
+ | </ | ||
+ | |||
+ | The same directory " | ||
+ | |||
+ | |||
+ | ===== Creating Pythia8 events ===== | ||
+ | |||
+ | In this example, instead of downloading files with e+e- events, we will generate Pythia8 events at the truth level. We create 100k events at 250 GeV CM energy with all Higgs processes. Then we will force H to decay to 2 b jets. | ||
+ | |||
+ | (1) Step 1. Get the package: | ||
+ | |||
+ | <code bash> | ||
+ | wget https:// | ||
+ | tar -zvxf package_ee.tgz | ||
+ | </ | ||
+ | |||
+ | (2) Compile the program. The steering card is located in " | ||
+ | |||
+ | <code bash> | ||
+ | cd package_ee | ||
+ | make | ||
+ | </ | ||
+ | |||
+ | (3) Run the Pythioa8 events using the supplied bash script. | ||
+ | |||
+ | <code bash> | ||
+ | ./ | ||
+ | </ | ||
+ | |||
+ | This script creates the output file in the directory " | ||
+ | |||
+ | <code bash> | ||
+ | cd out | ||
+ | promc_browser gev250ee_higgs_bbar_001.promc | ||
+ | </ | ||
+ | ===== Fast simulation ===== | ||
+ | |||
+ | To perform fast simulation, install Delphes using the standard steps: | ||
+ | |||
+ | <code bash> | ||
+ | wget http:// | ||
+ | tar -zxf Delphes-3.5.0.tar.gz | ||
+ | cd Delphes-3.5.0 | ||
+ | make | ||
+ | </ | ||
+ | On some systems, the compilation may fail if the ZLIB library is already present, i.e. the error will be " | ||
+ | |||
+ | The last line of the compilation should have " | ||
+ | |||
+ | <code bash> | ||
+ | cd .. | ||
+ | ./ | ||
+ | data/ | ||
+ | data/ | ||
+ | </ | ||
+ | |||
+ | The output file will be data/ | ||
+ | |||
+ | ===== Full simulation and file conversions ===== | ||
+ | |||
+ | For full simulations, | ||
+ | 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 | ||
+ | |||
+ | 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 only requires a personal Linux/ | ||
+ | |||
+ | <code bash> | ||
+ | wget https:// | ||
+ | tar -zvxf jas4pp-1.7.tgz | ||
+ | cd jas4pp | ||
+ | wget https:// | ||
+ | jaspp pythia6_higgs_zz_4l_0001_pandora.slcio | ||
+ | </ | ||
+ | |||
+ | You will see an editor. Use the left panel and expand " | ||
+ | |||
+ | You can also display very busy events with H-> bbar if you will download files from [[https:// | ||
+ | |||
+ | |||
+ | {{ : | ||
+ | |||
+ | You can explore various detector components, data collections etc. Use File-> | ||
+ | |||
+ | --- // | ||
fcs/fccee/tutorial.txt · Last modified: 2024/07/01 21:25 by 127.0.0.1