Reading usr data of eventsΒΆ

To access the usr data of events, use the .usr property which behaves like a dictionary and returns lazyarray, compatible to the numpy.array interface. The available keys can be accessed either as attributes or via a dictionary lookup:

import km3io as ki
from km3net_testdata import data_path

First, pass a filename to the OfflineReader class to open the file. Note that only some meta information is read into memory.

r = ki.OfflineReader(data_path("offline/usr-sample.root"))

Accessing the usr fields:

print(r.events.usr_names.tolist())

Out:

[['RecoQuality', 'RecoNDF', 'CoC', 'ToT', 'ChargeAbove', 'ChargeBelow', 'ChargeRatio', 'DeltaPosZ', 'FirstPartPosZ', 'LastPartPosZ', 'NSnapHits', 'NTrigHits', 'NTrigDOMs', 'NTrigLines', 'NSpeedVetoHits', 'NGeometryVetoHits', 'ClassficationScore'], ['RecoQuality', 'RecoNDF', 'CoC', 'ToT', 'ChargeAbove', 'ChargeBelow', 'ChargeRatio', 'DeltaPosZ', 'FirstPartPosZ', 'LastPartPosZ', 'NSnapHits', 'NTrigHits', 'NTrigDOMs', 'NTrigLines', 'NSpeedVetoHits', 'NGeometryVetoHits', 'ClassficationScore'], ['RecoQuality', 'RecoNDF', 'CoC', 'ToT', 'ChargeAbove', 'ChargeBelow', 'ChargeRatio', 'DeltaPosZ', 'FirstPartPosZ', 'LastPartPosZ', 'NSnapHits', 'NTrigHits', 'NTrigDOMs', 'NTrigLines', 'NSpeedVetoHits', 'NGeometryVetoHits', 'ClassficationScore']]

to access data of a specific key:

print(ki.tools.usr(r.events, "DeltaPosZ"))

Out:

[37.5, -10.3, 13.7]

Total running time of the script: ( 0 minutes 2.217 seconds)

Estimated memory usage: 109 MB

Gallery generated by Sphinx-Gallery