Skip to content

feat: add typed event data pipeline with loader registry#801

Open
remo-lab wants to merge 1 commit intoHSF:mainfrom
remo-lab:feat/typed-event-data-pipeline
Open

feat: add typed event data pipeline with loader registry#801
remo-lab wants to merge 1 commit intoHSF:mainfrom
remo-lab:feat/typed-event-data-pipeline

Conversation

@remo-lab
Copy link
Contributor

Summary

PhoenixLoader.loadObjectTypes() was 290 lines of if/else chains. Adding a new object type meant editing core code, and experiment loaders had to override the entire method just to add one custom type. Replaced it with a declarative registry. Also added proper TypeScript interfaces for event data and fixed a bug in Edm4hepJsonLoader where getRunNumber() and getEventNumber() had inverted logic.

Changes

  • src/lib/types/event-data.ts (new) - TypeScript interfaces for TrackParams, JetParams, CaloClusterParams, etc.
  • src/loaders/object-type-registry.ts (new) - ObjectTypeConfig registry and default configs
  • src/loaders/phoenix-loader.ts - Replaced 290-line if/else with 60-line registry loop
  • src/loaders/event-data-loader.ts - Added types to interface methods
  • src/loaders/cms-loader.ts - Uses getObjectTypeConfigs() override instead of overriding loadObjectTypes()
  • src/loaders/edm4hep-json-loader.ts - Fixed inverted logic in getRunNumber() / getEventNumber()
  • src/event-display.ts - Typed eventsData and related methods
  • src/index.ts - Export new types and registry

Testing

  • yarn tsc:build --noEmit passes with zero errors
  • All 170 existing tests pass
  • Manually loaded Phoenix JSON events - all object types render correctly
  • Manually loaded EDM4hep JSON - run/event numbers display correctly now
  • Verified CMS .ig file loading still works with MuonChambers via registry extension

Notes

Skipped decorator-based registration - adds complexity for minimal benefit. The explicit registry is simpler and easier to debug.

@remo-lab
Copy link
Contributor Author

Hi @EdwardMoyse ,This PR replaces the 290-line if/else chain in PhoenixLoader with a registry-based approach. Much easier to extend now - experiments can add custom object types without overriding the entire load method.

Also fixed a bug in Edm4hepJsonLoader where getRunNumber() and getEventNumber() were returning the wrong values (inverted null checks).

All tests pass and I manually verified with Phoenix JSON, EDM4hep, and CMS .ig files.would appreciate a review whenever you have time!

Signed-off-by: remo-lab <remopanda7@gmail.com>
@remo-lab remo-lab force-pushed the feat/typed-event-data-pipeline branch from 4da6609 to 901707a Compare February 12, 2026 21:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant