hepsim:usage_analysis
Differences
This shows you the differences between two versions of the page.
— | hepsim:usage_analysis [2024/07/01 21:25] (current) – created - external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | {{indexmenu_n> | ||
+ | [[: | ||
+ | |||
+ | ====== Analysis Primer ====== | ||
+ | |||
+ | |||
+ | This analysis tutorial covers Python codding on the Java platform (Jython). Look at the [[https:// | ||
+ | For C++/ROOT, please refer [[https:// | ||
+ | |||
+ | To ensure platform independence and a possibility to run programs using web browsers [(Cross-platform validation and analysis environment for particle physics, S.V. Chekanov, I. Pogrebnyak, D. Wilbern, arXiv: | ||
+ | Look at several links: | ||
+ | |||
+ | * [[http:// | ||
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | |||
+ | See [[http:// | ||
+ | |||
+ | The example codes on this page can be run using several options: | ||
+ | |||
+ | * Using Java web start from the browser. | ||
+ | * " | ||
+ | * " | ||
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | |||
+ | |||
+ | ====== Accessing data ====== | ||
+ | |||
+ | Here is a simple example to make a list of files using the data URL: | ||
+ | |||
+ | <code python> | ||
+ | from hepsim import HepSim | ||
+ | url=" | ||
+ | flist=HepSim.getList(url) | ||
+ | print flist | ||
+ | </ | ||
+ | |||
+ | If you do not know URL, you can use the dataset name or URL of the info page of this dataset: | ||
+ | |||
+ | <code python> | ||
+ | from hepsim import HepSim | ||
+ | url=HepSim.urlRedirector(" | ||
+ | flist=HepSim.getList(url) | ||
+ | print flist | ||
+ | </ | ||
+ | |||
+ | Note that you can find URL list of datasets using the standard Python. | ||
+ | |||
+ | <code python> | ||
+ | name=" | ||
+ | hepsim_server=" | ||
+ | import urllib2 | ||
+ | response = urllib2.urlopen(hepsim_server+'/ | ||
+ | html = response.read() | ||
+ | response.close() | ||
+ | html=html.split(";" | ||
+ | print html # print a list of URL locations | ||
+ | </ | ||
+ | |||
+ | If ProMC files were downloaded to the local file system, one can build the file list as: | ||
+ | |||
+ | <code python> | ||
+ | from jhplot.utils import FileList | ||
+ | flist=FileList.get(" | ||
+ | print flist | ||
+ | </ | ||
+ | |||
+ | Here " | ||
+ | |||
+ | Often, the output list contains multiple files generated with different pT or mass ranges. For example, a group of files generated with minimum pT=1000 GeV have names *_pt1000_*.py, | ||
+ | |||
+ | <code python> | ||
+ | xmin=HepSim.getRanges(flist," | ||
+ | </ | ||
+ | This methods takes file list, and identify pT ranges given between the strings " | ||
+ | |||
+ | ====== Using ProMC files ====== | ||
+ | |||
+ | |||
+ | ===== Reading the file header ===== | ||
+ | |||
+ | To read data from a ProMC file, you will need these statements: | ||
+ | |||
+ | <code python> | ||
+ | from proto import FileMC | ||
+ | f=FileMC(" | ||
+ | des=f.getDescription() | ||
+ | header = f.getHeader() | ||
+ | un=float(header.getMomentumUnit()) | ||
+ | lunit=float(header.getLengthUnit()) # conversion length units | ||
+ | </ | ||
+ | |||
+ | The latter | ||
+ | to double values. The values are typically around 1000-10000, depending on importance of representing low-momentum with a better precision. | ||
+ | The header file also stores some additional information. Look at Java API | ||
+ | |||
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | |||
+ | |||
+ | ===== Reading the event records ===== | ||
+ | |||
+ | |||
+ | <code python> | ||
+ | from proto import FileMC | ||
+ | f=FileMC(" | ||
+ | header = f.getHeader() | ||
+ | un=float(header.getMomentumUnit()) | ||
+ | lunit=float(header.getLengthUnit()) # conversion length units | ||
+ | for i in range(f.size()): | ||
+ | eve = f.read(i) | ||
+ | pa = eve.getParticles() | ||
+ | </ | ||
+ | |||
+ | Look at Java API of the ProMCEvent class: | ||
+ | |||
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | |||
+ | Here is the Java API for " | ||
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | |||
+ | In the above example, " | ||
+ | |||
+ | <code python> | ||
+ | from proto import FileMC | ||
+ | from hephysics.particle import LParticle | ||
+ | f=FileMC(" | ||
+ | header = f.getHeader() | ||
+ | un=float(header.getMomentumUnit()) | ||
+ | lunit=float(header.getLengthUnit()) # conversion length units | ||
+ | for i in range(f.size()): | ||
+ | eve = f.read(i) | ||
+ | pa = eve.getParticles() | ||
+ | for j in range(pa.getPxCount()): | ||
+ | | ||
+ | | ||
+ | | ||
+ | e= pa.getEnergy(j)/ | ||
+ | m= pa.getMass(j)/ | ||
+ | | ||
+ | </ | ||
+ | To access the PDG status code, us " | ||
+ | Here are the methods to retrieve information from the event records on a particle at a position j: | ||
+ | |||
+ | * **pa.getPdgId(j)** - get PDG id (int) | ||
+ | * **pa.getStatus(j)** - get status information (int) | ||
+ | * **pa.getPx(j), | ||
+ | * **pa.getX(j), | ||
+ | * **pa.getMass(j)** - get mass (in int64 varint) | ||
+ | * **pa.getMother1(j), | ||
+ | * **pa.getDaughter1(j), | ||
+ | * **pa.getBarcode(j)** - get barcode (int, in filled) | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | Look at the API of the Lorentz-particle class: | ||
+ | |||
+ | * [[http:// | ||
+ | * [[http:// | ||
+ | |||
+ | In addition, you can build an ArrayList with particles using a convenient class [[http:// | ||
+ | Also, when possible, use the method " | ||
+ | |||
+ | <code python> | ||
+ | from proto import FileMC | ||
+ | from hephysics.hepsim import PromcUtil | ||
+ | f=FileMC(" | ||
+ | header = f.getHeader() | ||
+ | un=float(header.getMomentumUnit()) | ||
+ | lunit=float(header.getLengthUnit()) # conversion length units | ||
+ | for i in range(f.size()): | ||
+ | eve = f.read(i) | ||
+ | pa = eve.getParticles() | ||
+ | par=PromcUtil.getParticleDList(f.getHeader(), | ||
+ | print "Nr of final-state particles=", | ||
+ | </ | ||
+ | The above example fills a list with all stable particles, without any cuts on pT and Eta (2 second arguments). | ||
+ | |||
+ | The next example creates [[http:// | ||
+ | <code python> | ||
+ | from proto import FileMC | ||
+ | from hephysics.hepsim import PromcUtil | ||
+ | f=FileMC(" | ||
+ | header = f.getHeader() | ||
+ | un=float(header.getMomentumUnit()) | ||
+ | lunit=float(header.getLengthUnit()) # conversion length units | ||
+ | for i in range(f.size()): | ||
+ | eve = f.read(i) | ||
+ | pa = eve.getParticles() | ||
+ | for j in range(pa.getPxCount()): | ||
+ | | ||
+ | | ||
+ | </ | ||
+ | |||
+ | |||
+ | |||
+ | In this example, we fill a list with all stable particles (status " | ||
+ | The object " | ||
+ | |||
+ | Finality, let us extend the above example: we will create anti-kT jets using the list " | ||
+ | <code python> | ||
+ | from proto import FileMC | ||
+ | from hephysics.hepsim import PromcUtil | ||
+ | from hephysics.jet import JetN2 | ||
+ | |||
+ | ktjet=JetN2(0.5," | ||
+ | print ktjet.info() | ||
+ | |||
+ | f=FileMC(" | ||
+ | header = f.getHeader() | ||
+ | un=float(header.getMomentumUnit()) | ||
+ | lunit=float(header.getLengthUnit()) # conversion length units | ||
+ | for i in range(f.size()): | ||
+ | eve = f.read(i) | ||
+ | pa = eve.getParticles() | ||
+ | par=PromcUtil.getParticleDList(f.getHeader(), | ||
+ | ktjet.buildJets(par) | ||
+ | jets=ktjet.getJetsSorted() | ||
+ | if (len(jets)> | ||
+ | print "pT of a leading jet =", | ||
+ | </ | ||
+ | To build anti-kT jets, we use [[http:// | ||
+ | The description of this algorithm is given in [[http:// | ||
+ | It is a similar to FastJet N*N algorithm and typically shows | ||
+ | a performance similar to the C++ analogue. Tests indicate that the JetN2 clustering algorithm is about twice slower that C++, but by a factor 20 faster than the traditional N^3 jet clustering algorithms. You can find benchmarking results in [[https:// | ||
+ | Look at a typical example of jet clustering in the [[http:// | ||
+ | |||
+ | ===== Event statistics ===== | ||
+ | |||
+ | Before closing ProMC file, you may need to access event statistics, cross sections and errors on cross sections. | ||
+ | |||
+ | <code python> | ||
+ | from proto import FileMC | ||
+ | f=FileMC(" | ||
+ | stat = f.getStat() | ||
+ | cross=stat.getCrossSectionAccumulated() | ||
+ | error=stat.getCrossSectionErrorAccumulated() # error on accumulated cross section in pb | ||
+ | print "Cross section:", | ||
+ | f.close() | ||
+ | </ | ||
+ | |||
+ | Look at the API: | ||
+ | |||
+ | * [[http:// | ||
+ | * [[http:// | ||
+ | |||
+ | |||
+ | |||
+ | ====== Using ProIO files ====== | ||
+ | |||
+ | ProIO files have their own API (https:// | ||
+ | It is at early stage of development. You can look at example of how to use ProIO here [http:// | ||
+ | |||
+ | ====== Using ROOT files ====== | ||
+ | |||
+ | ROOT files are used to store Delphes fast simulations. | ||
+ | To analyses ROOT files, either use ROOT (see Delphes manual) or the [[https:// | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | ====== Plots and histograms ====== | ||
+ | |||
+ | HepSim uses histogram packages supported by DataMelt (and implemented using JAIDA and FreeHep). | ||
+ | |||
+ | Here are a few most common classes: | ||
+ | |||
+ | * [[http:// | ||
+ | * [[http:// | ||
+ | * [[http:// | ||
+ | * [[http:// | ||
+ | |||
+ | The main canvas to show histograms [[http:// | ||
+ | |||
+ | Usually, plots are saved in the vector-graphics SVG format. They can be converted on Linux to EPS as: | ||
+ | <code bash> | ||
+ | inkscape --without-gui --export-eps output.eps input.svg | ||
+ | </ | ||
+ | However, one can also save images in PDF or EPS using the corresponding file extensions for the " | ||
+ | |||
+ | In addition, data are saved in the form of XML (with the extension " | ||
+ | For example, one can read such files and create histograms or data objects as: | ||
+ | |||
+ | <code python> | ||
+ | from jhplot.io import HBook | ||
+ | hb = HBook(" | ||
+ | print hb.getKeys() | ||
+ | p1=hb.get(" | ||
+ | print p1.toString() | ||
+ | </ | ||
+ | The object p1 belongs to the class [[https:// | ||
+ | |||
+ | |||
+ | ====== HepSim API ====== | ||
+ | |||
+ | |||
+ | All HepSim | ||
+ | stored inside ProMC data files: | ||
+ | |||
+ | ===== Histograms and plots ===== | ||
+ | |||
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | |||
+ | See also other math and graphics classes in the [[https:// | ||
+ | |||
+ | ===== Lorentz particles and Jets ===== | ||
+ | |||
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | | ||
+ | | ||
+ | Java implementation of the longitudinally invariant kT and anti-kT clustering algorithms uses the E-scheme to combine particles (p1+p2) and Eta-Phi space (not Rapidity-Phi). Also, Cambridge/ | ||
+ | |||
+ | |||
+ | You can build the standard kt-jets using [[https:// | ||
+ | [[https:// | ||
+ | |||
+ | ===== Working with ProMC files ===== | ||
+ | |||
+ | Also, look at the ProMC Java API that is used to store data: | ||
+ | |||
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | |||
+ | |||
+ | It is simplified compared to full MC simulations, | ||
+ | information on event weights and uncertainties. | ||
+ | |||
+ | The project uses the community edition of [[https:// | ||
+ | |||
+ | |||
+ | |||
+ | ====== GROOT API ====== | ||
+ | |||
+ | In addition, this tool supports GRoot histograms and canvases (see [[https:// | ||
+ | to use this package for PyROOT users. | ||
+ | You can find the Java API of this package in [[https:// | ||
+ | |||
+ | |||
+ | The following histograms are available: | ||
+ | |||
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | |||
+ | They can be plotted on the [[https:// | ||
+ | |||
+ | |||
+ | --- // |