def push_get1(comp): buf = io.BytesIO(b'') with proio.Writer(fileobj=buf) as writer: writer.set_compression(comp) eventsOut = [] event = proio.Event() event.add_entries('MCParticle', prolcio.MCParticle(), prolcio.MCParticle()) event.add_entries('TrackerHits', prolcio.SimTrackerHit(), prolcio.SimTrackerHit()) writer.push(event) eventsOut.append(event) event = proio.Event() event.add_entries('TrackerHits', prolcio.SimTrackerHit(), prolcio.SimTrackerHit()) writer.push(event) eventsOut.append(event) buf.seek(0, 0) with proio.Reader(fileobj=buf) as reader: for i in range(0, len(eventsOut)): event = reader.__next__() assert event != None assert event.__str__() == eventsOut[i].__str__()
def push_seek_skip_get1(comp): buf = io.BytesIO(b'') with proio.Writer(fileobj = buf) as writer: writer.set_compression(comp) eventsOut = [] event = proio.Event() event.add_entries( 'Hit1', prolcio.MCParticle(), prolcio.MCParticle() ) writer.push(event) eventsOut.append(event) event = proio.Event() event.add_entries( 'Hit2', prolcio.SimTrackerHit(), prolcio.SimTrackerHit() ) writer.push(event) eventsOut.append(event) writer.flush() event = proio.Event() event.add_entries( 'Hit3', prolcio.SimTrackerHit(), prolcio.SimTrackerHit() ) writer.push(event) eventsOut.append(event) buf.seek(0, 0) with proio.Reader(fileobj = buf) as reader: event = reader.next() assert event != None assert event.__str__() == eventsOut[0].__str__() reader.seek_to_start() reader.skip(2) event = reader.next() assert event != None assert event.__str__() == eventsOut[2].__str__()