Skip to content

reading in every Nth event from a file #287

Answered by jpivarski
calebmiller asked this question in Q&A
Discussion options

You must be logged in to vote

Any array in Python can use a slice syntax like this:

array[::10]

The above will take event 0, event 10, event 20, etc. (If you wanted event 9, 19, 29, etc., then you can do array[9::10]. That would agree better with eventId % 10 if the eventId started with 1 instead of 0.)

There's no way to avoid reading all the events before applying this prescale because contiguous events have to be read together (due to the columnar structure of a ROOT TBranch), but this will get you every 10th event after they've been read.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@calebmiller
Comment options

Answer selected by calebmiller
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants