k4bench.analysis.event_source¶
k4bench.analysis.event_source ¶
What went into a run's events: event_source.json.gz.
One file per run, shared by all its configurations, since every configuration
of a run processes the same events. It holds, entry by entry, the generator
particles of each event and, for a job that reads a file (reconstruction on a
frozen simulated input), what that file's collections hold. The per-event
costs (:mod:k4bench.analysis.components, the timing plugins' files) can then
be set against what each event is.
Where it comes from
:func:record_event_source reads a podio file with uproot: a ddsim benchmark's
own output file after its first run, a k4run benchmark's input file before its
first run. Its origin says how it was made:
recorded: by the benchmark, from the run's own file;backfill-verified: later, from the very file the run read, matched by its checksum;backfill-inferred: later, from a file that should hold the same generator particles, e.g. another detector's simulation of the same sample.
Its source names the file, its checksum when one was taken, the
configuration whose output it is (simulation only) and the entries read:
events of them from first_entry.
Which event is which
The entries are those the job processed, in order: entry i is the i-th
event the job's profiling counted (G4Event ID in simulation,
EventContext::evt() in reconstruction), as a job reads its input from its
first entry on. The EventHeader's event and run numbers of each entry are kept
beside them (None for an entry without one) but are not the key.
The generator particles
The particles of the generator record (generatorStatus not 0)
(:data:GENERATOR_COLUMNS), floats to six significant digits; edm4hep's
units: GeV, mm, and the elementary charge. What transport made of them
(simulatorStatus, end points) is not kept: it depends on the detector, so
it would differ between the configurations sharing the file. Neither is the
record wholly the generator's: simulation boosts it by the crossing angle its
steering sets, and the products of a decay the generator assigned but Geant4
performs (a b hadron's, say) start where and as transport left the parent, so
in Z→bb̄ about 1% of the particles, all born off the interaction point, differ
slightly from detector to detector.
EventSource
dataclass
¶
EventSource(origin: str, file: str, sha256: str | None, label: str | None, first_entry: int, events: int, event_numbers: tuple[int | None, ...] | None, run_numbers: tuple[int | None, ...] | None, offsets: ndarray, columns: Mapping[str, ndarray], input_counts: DataFrame, input_energies: DataFrame)
What went into a run's events, read back from event_source.json.gz.
particles ¶
Every field of :data:PARTICLE_FIELDS per generator particle: its
columns and what follows from them. A quantity undefined for a
particle (eta along the beam axis, abs_cos_theta at rest) is
NaN.
Source code in k4bench/analysis/event_source.py
load_event_source ¶
load_event_source(run_dir: str | Path) -> EventSource | None
The event_source.json.gz of run_dir, or None when it has none.
Raises ValueError for an unsupported or malformed file.
Source code in k4bench/analysis/event_source.py
read_event_source ¶
read_event_source(path: Path) -> EventSource
The event source in path; ValueError for an unsupported
schema_version or a malformed file.
Source code in k4bench/analysis/event_source.py
record_event_source ¶
record_event_source(out_path: Path, source_file: Path, *, n_events: int, origin: str = 'recorded', label: str | None = None, input_content: bool = False, checksum: bool = False) -> bool
Write what went into the first n_events events of the podio source_file to out_path: their generator particles and, with input_content, what the file's collections hold in each; with checksum, the file's sha256. label names the configuration whose output the file is. Whether it was written: a failure is warned about and costs only this file, never the run.
Source code in k4bench/analysis/event_source.py
describe_source ¶
describe_source(source_file: Path, *, n_events: int, origin: str = 'recorded', label: str | None = None, input_content: bool = False, checksum: bool = False) -> dict
The event_source.json.gz record of source_file's first
n_events events; see :func:record_event_source.