Difference between revisions of "HOWTO read GlueX hddm data from a jupyter notebook"

From GlueXWiki
Jump to: navigation, search
Line 6: Line 6:
 
Below are some examples of jupyter notebooks that demonstrate this capability in a jupyter notebook on Google colab. To enable the same functionality on your desktop or portable device, the python modules can be installed using the familiar "pip install" command.
 
Below are some examples of jupyter notebooks that demonstrate this capability in a jupyter notebook on Google colab. To enable the same functionality on your desktop or portable device, the python modules can be installed using the familiar "pip install" command.
  
  $ pip install --user gluex.hddm_s
+
  $ python3 -m pip install --user gluex.hddm_s
  $ pip install --user gluex.hddm_r
+
  $ python3 -m pip install --user gluex.hddm_r
  
 
To demonstrate this capability in a jupyter environment, cut and paste the following block into a code cell within a freshly opened notebook. Running this cell produces a series of lines "found run 71000, event X000" where X increases from 1 to 40.
 
To demonstrate this capability in a jupyter environment, cut and paste the following block into a code cell within a freshly opened notebook. Running this cell produces a series of lines "found run 71000, event X000" where X increases from 1 to 40.
  
  !pip install gluex.hddm_s
+
  !python3 -m pip install --user gluex.hddm_s
 
  from gluex import hddm_s
 
  from gluex import hddm_s
 
  for rec in hddm_s.istream("root://nod25.phys.uconn.edu/Gluex/simulation" +
 
  for rec in hddm_s.istream("root://nod25.phys.uconn.edu/Gluex/simulation" +
Line 21: Line 21:
 
Here is a similar demonstration where the input data are in REST format instead of raw hits. Running this cell produces a similar output to what the above cell generates.
 
Here is a similar demonstration where the input data are in REST format instead of raw hits. Running this cell produces a similar output to what the above cell generates.
  
  !pip install gluex.hddm_r
+
  !python3 -m pip install --user gluex.hddm_r
 
  from gluex import hddm_r
 
  from gluex import hddm_r
 
  for rec in hddm_r.istream("root://nod25.phys.uconn.edu/Gluex/simulation" +
 
  for rec in hddm_r.istream("root://nod25.phys.uconn.edu/Gluex/simulation" +

Revision as of 15:07, 26 June 2024

Two public python modules are available for reading hddm event data into a python session on a jupyter notebook environment like https://colab.research.google.com.

  • gluex.hddm_s - python module for reading hddm_s events that encode raw hit information, either from simulation or real data converted from evio to hddm format.
  • gluex.hddm_r - python module for reading hddm_r events that encode reconstructed event information in REST format.

Below are some examples of jupyter notebooks that demonstrate this capability in a jupyter notebook on Google colab. To enable the same functionality on your desktop or portable device, the python modules can be installed using the familiar "pip install" command.

$ python3 -m pip install --user gluex.hddm_s
$ python3 -m pip install --user gluex.hddm_r

To demonstrate this capability in a jupyter environment, cut and paste the following block into a code cell within a freshly opened notebook. Running this cell produces a series of lines "found run 71000, event X000" where X increases from 1 to 40.

!python3 -m pip install --user gluex.hddm_s
from gluex import hddm_s
for rec in hddm_s.istream("root://nod25.phys.uconn.edu/Gluex/simulation" +
                          "/simsamples/particle_gun-v5.2.0/particle_gun001_019.hddm"):
   for pe in rec.getPhysicsEvents():
      if pe.eventNo % 1000 == 0:
         print(f"found run {pe.runNo}, event {pe.eventNo}")

Here is a similar demonstration where the input data are in REST format instead of raw hits. Running this cell produces a similar output to what the above cell generates.

!python3 -m pip install --user gluex.hddm_r
from gluex import hddm_r
for rec in hddm_r.istream("root://nod25.phys.uconn.edu/Gluex/simulation" +
                          "/simsamples/particle_gun-v5.2.0/particle_gun001_019_rest.hddm"):
   for pe in rec.getReconstructedPhysicsEvents():
      if pe.eventNo % 1000 == 0:
         print(f"found run {pe.runNo}, event {pe.eventNo}")