Package: proio
proio for PythonProio is an event-oriented streaming data format based on Google'sprotocol
buffers(protobuf).  Proio
aims to add event structure and additional compression to protobuf in a way
that supports event data model serialization in medium- and high-energy
physics.  Additionally, proiosupports self-descriptive data,is stream compatible,is language agnostic,and brings along many advantages of protobuf, including forward/backward
compatibility.For detailed information on the proio format and introductory information on
the software implementations, please seeDOI
10.1016/j.cpc.2019.03.018.  This
work was inspired and influenced byLCIO,
ProMC (Sergei Chekanov), and EicMC (Alexander Kiselev)Also see themain proio repositoryfor
additional information information.APIThe API documentation is generated using Sphinx, and can be foundhere.InstallationPy-proio is maintained onpypi.  The
proio package can be installed viapip:pipinstall--user--upgradeproioIf you run into trouble importing proio, force upgrade the two dependencies
which areprotobufandlz4.For information on what versions of Python are supported, please see theTravis CI page.Building the packageIf you need to build the package (instead of just installing from pypi as
described above), you can do so with the fairly standardsetup.py.
In this case, you need to have the Protobuf compiler (protoc) installed.
Withpip:pythonsetup.pycleanbuild_py
pipinstall--user--upgrade., or if you want to just build a source package:pythonsetup.pycleanbuild_pysdist, or if you want to build a wheel package:pythonsetup.pycleanbdist_wheel.  Note that thebuild_pycommand is responsible for generating the Protobuf
code withprotoc, and needs to be called explicitly in the pip and source
package case.ExamplesManipulating data model objects (EIC Particle)importproioimportproio.model.eicasmodeltest_filename='test_file.proio'withproio.Writer(test_filename)aswriter:event=proio.Event()parent=model.Particle()parent.pdg=443parent.p.x=1parent.mass=3.097parent_id=event.add_entry('Particle',parent)child1=model.Particle()child1.pdg=11child1.vertex.x=0.5child1.mass=0.000511child1.charge=-1child2=model.Particle()child2.pdg=-11child2.vertex.x=0.5child2.mass=0.000511child2.charge=1child_ids=event.add_entries('Particle',child1,child2)forIDinchild_ids:event.tag_entry(ID,'GenStable')parent.child.extend(child_ids)child1.parent.append(parent_id)child2.parent.append(parent_id)print(event)writer.push(event)Iterating events in a fileimportproio# the model does not need to be imported when reading since proio# is self-descriptive!test_filename='test_file.proio'n_events=0withproio.Reader(test_filename)asreader:foreventinreader:print('========== EVENT '+str(n_events)+' ==========')print(event)n_events+=1print(n_events)Event inspection by tagimportproioimportproio.model.eicasmodeltest_filename='test_file.proio'withproio.Writer(test_filename)aswriter:event=proio.Event()parent=model.Particle()parent.pdg=443parent_id=event.add_entry('Particle',parent)child1=model.Particle()child1.pdg=11child2=model.Particle()child2.pdg=-11child_ids=event.add_entries('Particle',child1,child2)forIDinchild_ids:event.tag_entry(ID,'GenStable')parent.child.extend(child_ids)child1.parent.append(parent_id)child2.parent.append(parent_id)writer.push(event)withproio.Reader(test_filename)asreader:foreventinreader:parts=event.tagged_entries('Particle')print('%iparticle(s)...'%len(parts))foriinrange(0,len(parts)):part=event.get_entry(parts[i])print('%i. PDG Code:%i'%(i,part.pdg))print('%ichildren...'%len(part.child))forjinrange(0,len(part.child)):print('%i. PDG Code:%i'%(j,event.get_entry(part.child[j]).pdg))