Skip to content

[WIP] Prototype TruthInfo graph for truth history navigation and association studies#50913

Closed
felicepantaleo wants to merge 53 commits into
cms-sw:masterfrom
felicepantaleo:truthGraph_17_0_0_pre1
Closed

[WIP] Prototype TruthInfo graph for truth history navigation and association studies#50913
felicepantaleo wants to merge 53 commits into
cms-sw:masterfrom
felicepantaleo:truthGraph_17_0_0_pre1

Conversation

@felicepantaleo

Copy link
Copy Markdown
Contributor

This draft PR collects the ongoing TruthInfo graph developments being worked on during the 20th Patatrack hackathon.

The goal is to prototype a common truth-history representation in CMSSW, combining generator-level and simulation-level information into graph-based data structures that can be navigated through a physics-oriented API.

This PR is intentionally opened as a draft so that the working group can collaborate in a single place during the hackathon.

This development explores two related layers:

  • a compact raw TruthGraph, built from existing CMS truth products such as HepMC, SimTrack, and SimVertex;
  • a higher-level logical truth::Graph, exposing particles, vertices, payload, and navigation methods.

The long-term goal is to provide a stable abstraction for truth navigation and truth-reco association, avoiding the need for downstream reconstruction and validation code to directly depend on the internal structure of several low-level truth collections.

Hackathon work area

This PR is meant as the shared development branch for the working group at the ongoing 20th Patatrack hackathon.

Status

This is a prototype and not yet intended as a final interface.

The main purpose of this draft PR is to collect ideas, code, tests, and validation feedback in a common place during the hackathon. The implementation and API are expected to evolve substantially before this can become a stable CMSSW interface.

@cmsbuild

cmsbuild commented May 11, 2026

Copy link
Copy Markdown
Contributor

cms-bot internal usage

@cmsbuild

Copy link
Copy Markdown
Contributor

+code-checks

Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-50913/49282

  • Found files with invalid states:
    • PhysicsTools/TruthInfo/src/BuildFile.xml:

@cmsbuild

Copy link
Copy Markdown
Contributor

+code-checks

Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-50913/49283

  • Found files with invalid states:
    • PhysicsTools/TruthInfo/src/BuildFile.xml:

@cmsbuild

Copy link
Copy Markdown
Contributor

Pull request #50913 was updated.

@cmsbuild

Copy link
Copy Markdown
Contributor

-code-checks

Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-50913/49286

  • Found files with invalid states:
    • PhysicsTools/TruthInfo/src/BuildFile.xml:

Code check has found code style and quality issues which could be resolved by applying following patch(s)

@cmsbuild

Copy link
Copy Markdown
Contributor

+code-checks

Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-50913/49287

  • Found files with invalid states:
    • PhysicsTools/TruthInfo/src/BuildFile.xml:

@cmsbuild

Copy link
Copy Markdown
Contributor

Pull request #50913 was updated.

felicepantaleo and others added 15 commits June 13, 2026 07:29
…ch SimVertex dumps

Vertex time normalization (cm, ns):
- SimVertex position().t() is stored in seconds and HepMC GenVertex time is
  c*t in mm; previously only x/y/z were converted (mm->cm) while t was left
  raw, so GEN and SIM times were incomparable (and SimVertex t printed as 0).
- TruthLogicalGraphProducer now converts GEN t (mm/c -> ns) and SIM t (s -> ns)
  so VertexData.position is consistently (cm, ns).
- Re-enable the t term in compatibleVertexPositions; GEN/SIM primary vertices
  now agree to ~1e-5 ns and merge correctly.

Raw SimVertex -> GenVertex provenance connection:
- New TruthGraph::simVtxToGen association (SimVertex node -> GenVertex node),
  derived from primary SimTracks (production SimVertex <-> GenParticle
  production GenVertex). Conflicts are logged. Emitted as SimToGen edges.
- TruthGraphProducer fills it and reports simVtxToGenVertexLinks.

Dumper enrichment:
- TruthGraphDumper now fetches the SimVertexContainer and annotates SimVertex
  nodes with position (cm,ns), vertexId, processType, parentTrackId, noParent,
  eventId (bx/evtInBx) and the associated GenVertex_nodeId.
- TruthLogicalGraphDumper vertex labels use a 4D (x,y,z,t) formatter.

Also fix a stale GEN/SIM vertex-merge debug print that used px()/py()/pz()
and a misleading message.

format
…ch tracker simhits to particles

New NanoAOD flat tables:
- PFRecHitFlatTableProducer: barrel/forward calorimeter PFRecHits (ECAL/HBHE/HF/HO).
  Positions are recomputed from CaloGeometry via the detId because
  PFRecHit::position()/positionREP() read a non-persisted CaloCellGeometry and
  segfault on rechits read back from a file. The offline (RECO) PFRecHit
  collections are empty in the test sample, so the HLT-tier collections are used.
- TrackerSimHitFlatTableProducer: tracker PSimHits with global positions from the
  TrackerGeometry, plus trackId/pdgId/energyLoss/tof/pabs/processType.

Tracker simhits in the truth matching:
- LogicalGraphHitIndex/Builder gain a separate tracker-hit channel (direct and
  subgraph), filled from PSimHit::trackId() in TruthLogicalGraphHitIndexProducer.
- TruthLogicalGraphDumper reports per-particle tracker simhit counts and energy.

Test config wires both tables into the path and uses the ideal tracker geometry
(applyAlignment=False) so no alignment conditions are needed standalone.
@cmsbuild

Copy link
Copy Markdown
Contributor

+code-checks

Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-50913/49758

@cmsbuild

Copy link
Copy Markdown
Contributor

Pull request #50913 was updated.

…odes, pile-up provenance, heavy-flavor seeding and jet-origin navigation
…ssociation

Per reco track, match to a Branch via shared tracker hits (PSimHit-based hit
index) and to a TrackingParticle via ClusterTPAssociation, and check both point
to the same truth particle. Agreement 96-100% across ZMM/TTbar/SingleE.
Adds a tracker-channel unit test for BranchHitAssociator.
Prepend an 'Original author: Felice Pantaleo (CERN) <felice.pantaleo@cern.ch>'
header to every source file created for the MC-truth-graph prototype, and add a
prominent under-heavy-development / not-open-to-external-contributions notice
(Phase-2 only) at the top of the README.

Also fix two latent warnings surfaced by the full recompile: a dangling
reference to the temporary Particle from Branch::root() in BranchSelector, and a
memcpy into the non-trivial EncodedEventId in Branch::decodeEventId.
Diagnostic EDAnalyzer auditing the raw TruthGraph and logical truth::Graph for
strange topologies: many-particle vertices, particles with multiple parents or
multiple production vertices, cycles (the graphs must be DAGs), and disconnected
components. Aggregates per job with worst-case examples carrying pdgId/status.
Used to characterize and regression-test graph-construction changes.
…ertex merge

A merged GEN+SIM particle now takes its production vertex from the GEN side (the
immediate GenParticle's production GenVertex, via the faithful genpartIndex link),
dropping the redundant SimTrack production edge to the shared Geant4 beam vertex.
This replaces mergeGenSimVerticesByPosition, which collapsed the spatially
coincident GEN/SIM vertex cluster at the primary into one mega-vertex and induced
DAG cycles. Removes that postprocessor step and its two config parameters.

Verified with the topology checker on all 8 library samples: cycles 5->0,
multi-production particles ->0, logical vertex out-degree from ~600-900 down to
the physical hadronization scale, no orphan fragments; raw graph unchanged. All
cppunit tests pass; code-format and code-checks clean.
@cmsbuild

Copy link
Copy Markdown
Contributor

-code-checks

Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-50913/49760

Code check has found code style and quality issues which could be resolved by applying following patch(s)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants