Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
hepsim:jas4pp [2021/02/17 00:10] hepsim17 [Jas4pp description] |
hepsim:jas4pp [2021/02/17 16:15] hepsim17 [Reading ROOT files] |
||
---|---|---|---|
Line 46: | Line 46: | ||
* Visualization of reconstructed events using Wired4 display | * Visualization of reconstructed events using Wired4 display | ||
- | You can find more details in [[https:// | + | You can find more details in [[https:// |
Line 318: | Line 318: | ||
The script that call these browsers | The script that call these browsers | ||
+ | |||
+ | To read ROOT files from Delphes simulations, | ||
+ | [[https:// | ||
+ | getFloat, getDouble, getInt, and getBool. But first, explore the Delphes ROOT file using the browser shown above. | ||
+ | |||
+ | Here is an example that uses high-level classes to read transverse momentum (PT) and pseudorapidity (ETA) of Monte Carlo particles: | ||
+ | |||
+ | |||
+ | <hidden Click here to show a Python code to read Delphes files> | ||
+ | <code python> | ||
+ | from hep.io.root import RootFileReader | ||
+ | from rootio import * | ||
+ | |||
+ | reader = RootFileReader(" | ||
+ | tree = reader.get(" | ||
+ | maxevents=tree.getEntries() | ||
+ | branches=tree.getBranches() | ||
+ | print "Nr of events=", | ||
+ | print "Nr of branches=", | ||
+ | print " | ||
+ | for l in xrange( branches.size() | ||
+ | print " | ||
+ | |||
+ | particles=tree.getBranch(" | ||
+ | |||
+ | ptEvents=Delphes.getFloat(particles," | ||
+ | etaEvents=Delphes.getFloat(particles," | ||
+ | |||
+ | from jhplot import * | ||
+ | h1 = H1D(" | ||
+ | h2 = H1D(" | ||
+ | for i in xrange(tree.getEntries()): | ||
+ | | ||
+ | for j in xrange(len(pt)): | ||
+ | | ||
+ | | ||
+ | c=HPlot(" | ||
+ | c.visible() | ||
+ | c.setAutoRange() | ||
+ | c.draw(h1) | ||
+ | |||
+ | c.cd(2,1) | ||
+ | c.setAutoRange() | ||
+ | c.draw(h2) | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | {{: | ||
+ | |||
+ | <note warning> | ||
====== Using GUI mode ====== | ====== Using GUI mode ====== |