psana.event¶
Event is the object yielded by run.events() and step.events(). It holds
the dgrams of one event (one per stream; missing ones are None) and gives
access to the event's timestamp (64-bit: seconds in the upper 32 bits,
nanoseconds in the lower 32 bits), datetime(), service() (transition id)
and run(), which returns a small RunCtx (psana/psana/psexp/run_ctx.py),
not the full Run. Detector data are read through detector objects
(det.raw.calib(evt)), not from the event directly.
service() returns (env() >> 24) & 0xF of the first dgram that has
env(), through psana.utils.first_service. That function raises
RuntimeError unless the value is between 1 and 13. Transition id 0 is
ClearReadout in both TransitionId and the C++ enum (see
XTC2 data format), so a dgram with that id makes
service() raise instead of returning 0.
See DataSource, Run and the event loop.
psana.event ¶
Define Event, the object that holds the dgrams making up one event.
Entries in the dgram list can be None when a dgram is missing from the event.
DrpClassContainer ¶
DrpClassContainer()
Bases: object
Empty placeholder class.
Its __init__ body is pass and it defines no other members.
Event ¶
Event(dgrams, run=None, proxy_evt=None)
Event holds list of dgrams
timestamp
property
¶
timestamp
Timestamp of the first dgram in the event that provides one.
Delegates to psana.utils.first_timestamp, which skips None dgrams and raises RuntimeError
if no dgram has a timestamp. timestamp_diff and datetime treat the upper 32 bits as
seconds and the lower 32 bits as nanoseconds.
env
property
¶
env
Value of env() of the first dgram that provides it.
Delegates to psana.utils.first_env, which skips None dgrams and raises RuntimeError if no
dgram can provide env().
next ¶
next()
Return the next dgram of this event and advance the iterator position.
The returned entry can be None for a missing dgram.
Raises:
| Type | Description |
|---|---|
StopIteration
|
When all dgrams have been returned. |
timestamp_diff ¶
timestamp_diff(ts)
Subtract the given timestamp from the event timestamp and return the difference in nanoseconds.
A timestamp packs seconds in its upper 32 bits and nanoseconds in its lower 32 bits, so both parts of each timestamp are converted to a total number of nanoseconds before subtracting.
run ¶
run()
Return the run object given as run when the event was created, or None if none was given.
service ¶
service()
Return the service code of the event.
Delegates to psana.utils.first_service, which returns (env() >> 24) & 0xF of the first
valid dgram and raises RuntimeError if that value is outside 1..13 or no dgram provides
env().
keepraw ¶
keepraw()
Return the keepraw bit of the event.
Returns:
| Type | Description |
|---|---|
int or None
|
Bit 22 of |
get_offsets_and_sizes ¶
get_offsets_and_sizes()
Return the offset and size of every dgram in the event.
Returns:
| Type | Description |
|---|---|
ndarray
|
int64 array of shape (number of dgrams, 2); row i is |
get_offset_and_size ¶
get_offset_and_size(i)
Returns value of offset and size stored in smdinfo event * For other event, return 0 of offset and size of the dgram for size.
datetime ¶
datetime()
Return the event timestamp as a datetime.datetime.
Adds the seconds (upper 32 bits) and the nanoseconds (lower 32 bits, divided by 1000 to give microseconds) to the epoch 1990-01-01 00:00:00. The result is a naive datetime (no time zone).
set_destination ¶
set_destination(dest)
Sets destination (bigdata core rank no.) where this event should be sent to.
Destination only works in parallel mode with only one EvenBuilder core (PS_EB_NODES=1). The valid range of destination is from 1 to the number of available bigdata cores.
EndOfBatch ¶
EndOfBatch()
Returns a list of integrating detectors whose batch ends at this event
Single integrating detector: defaulted to [intg_det] Multiple integrating detectors (future feature): we probably need another flag to identify which integrating detector(s) marks the end of this batch.