Skip to content

SV study: --full-output writes V0s with the raw clusters of their prongs - #16277

Open
matthias-kleiner wants to merge 2 commits into
AliceO2Group:devfrom
matthias-kleiner:sv-full-output-pr
Open

matthias-kleiner wants to merge 2 commits into
AliceO2Group:devfrom
matthias-kleiner:sv-full-output-pr

Conversation

@matthias-kleiner

@matthias-kleiner matthias-kleiner commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

New option o2-sv-study-workflow --full-output. It selects K0s, Λ / anti-Λ and photon conversions among the V0 finder's V0s and writes them to o2_v0s_full.root (one entry per TF) with everything needed to refit their prongs offline. The new data format DataFormatsGlobalTracking/TrackV0Extended.h follows TrackCosmicsExtended.h: each V0 is self-contained, with its two prongs, each with its raw TPC clusters (plus the reconstruction's sharing-map byte), ITS compact clusters and patterns, the matched TOF cluster and the TRD tracklets; the reconstruction's track parameters, times and TOF match; the assigned primary vertex and the selection variables. Per TF it also stores the TPC transformation info, the TPC occupancy map and the TF ID. With MC input the file also carries the MC truth, since the kinematics are not kept in MC productions: per prong its PDG code, momentum and production point, per V0 the common mother of the prongs if they come from its displaced decay or conversion (label, PDG code, momentum, production point, its own mother and whether it comes from the generator; beam particles, hadronic interactions in material and prompt decays excluded). Without readable MC files the labels are written without truth (one warning); the MC events are released after each TF. On a Pb-Pb MC TF: 93 % of the K0s and 81 % of the photons are true, decay radius true vs reconstructed 0.10 cm for K0s.

Selection and downsampling are configurable (svFullOutput.*, V0FullOutputParams.h). Defaults: K0s / Λ with 5 < r < 35 cm; far K0s / Λ (both legs without ITS, up to 250 cm) with their own cuts; photons with the O2Physics Armenteros ellipse. Downsampling per class flat in V0 pT with a cap per TF and log-pT bin (svFullOutput.maxPerBin*): cap >= 1 keeps at most int(cap) V0s (weight candidates / kept; default 5, i.e. at most 440 V0s per TF besides the rare far ones); cap < 1 keeps each V0 with probability cap / candidates (weight candidates / cap), for a full reconstruction pass (about one V0 per TF and class with caps of 0.05-0.08). The random numbers come from the TF and the prong tracks, so the sample does not depend on the V0 finder's threads. calib-workflow.sh: CALIB_ASYNC_EXTRACTV0S=1 runs the extraction in the reconstruction chain (--disable-study-tree skips svStudy.root). The V0 finder's indices are enough (production default, svertexer.createFullV0s=false): the selected V0s are refitted with the finder's fitter and settings and are the finder's V0s (see below). With svertexer.createFullV0s=true the refit is skipped.

Also changed in the existing study device: its V0 refit (--refit, or when the finder sends no full V0s) now prepares TPC-only prongs as the V0 finder does (shifted in z to the vertex time, VDriftHelper); before, they were fitted at their own time0. On a Pb-Pb MC TF the refit now reproduces the finder's V0s bit-identically (336 / 336). This changes svStudy.root in refit mode for V0s with TPC-only prongs.

Why. V0s with a known mass and a common displaced vertex constrain the alignment and the TPC distortion corrections (common-vertex and mass constraints in the global alignment; re-transforming the clusters with a new TPC map and checking the mass). That needs the raw clusters, which the reconstruction output does not keep. The TPC refit reproduces the reconstruction only if the sharing map and the occupancy map are stored too: without the sharing map the TPC-only V0 mass moves by up to 15 MeV.

Test. Pb-Pb MC (1 TF): the prongs refitted from the stored clusters equal the refit from the original clusters to the bit (653 / 653); the downsampling keeps min(cap, candidates) per class and pT bin, and the weights add up exactly to the selected numbers. Pb-Pb data, run 568041: 3000 TFs extracted in the reconstruction chain via CALIB_ASYNC_EXTRACTV0S (same code without downsampling): about 1400 V0s and 3.6–3.9 MB per TF (unbinned TPC residuals of the same run: 81.7 MB per TF). With the default downsampling (run 568663, 22 kHz, 10 TFs): 203 V0s and 0.59 MB per TF instead of 1564 V0s and 3.97 MB. With the caps for a full pass (K0s 0.08, Λ 0.05, photons 0.05, far 0.03; 50 CTFs = 2349 TFs): 2.9 V0s and 13 kB per TF (about 1 K0s, 0.5 Λ, 0.5 anti-Λ, 0.9 photons).

Effect on production. Nothing changes unless --full-output / CALIB_ASYNC_EXTRACTV0S is set; the existing study tree is unchanged except in refit mode (see above). When enabled, the writer only reads and no setting of the reconstruction changes, so the AOD does not change. CPU (Pb-Pb data, 22 kHz, 50 CTFs = 2349 TFs, full-pass caps): the extraction runs as a separate process next to the chain and needs about a quarter of the V0 finder's CPU, the same with the finder's indices only (25.9 %) as with its full V0s (25.3 %).

Indices vs full V0s (Pb-Pb data, run 568663, same 50 CTFs = 2349 TFs, full-pass caps): 6880 = 6880 V0s, all the same V0s, 6859 identical in every stored value; the other 21 have identical fits and differ only in cosPA2 and in a weight, both from the wrong cosPA of the finder's cascade copies fixed in the second commit.

Second commit (SVertexer). With svertexer.createFullV0s, the copy of a V0 that the finder adds for a cascade at another primary vertex got its cosPA from V0::getX()/getY(), i.e. from the coordinates in the V0's sector frame, combined with the global position of the vertex. It now uses the global V0 position. Only the full V0 output is affected; the indices, the fits and the AOD are unchanged. Pb-Pb MC TF with the cascade finder: 2 of 1782 V0s are such copies, their cosPA changes from -0.83 / -0.23 to 0.93 / 0.99, nothing else changes.

Review. The code was reviewed by Claude Fable 5.2 in four rounds (two of the whole commit, two of the MC truth); all findings were addressed (among them the refit of TPC-only prongs above, a thread-independent sampling, the ITS staggering flag in the chain, the definition of a true V0 and the handling of missing MC files).

Armenteros-Podolanski plot of the written V0s (Pb-Pb, run 568663): without downsampling (left) and with the full-pass caps (right; far K0s black, far Λ magenta).

v0_armenteros_pr

V0 pT per class: without downsampling (black), with the full-pass caps (filled, flat in log pT), and weighted (open, reproduces the spectrum).

v0_ptflat_pr

🤖 Generated with Claude Code

o2-sv-study-workflow --full-output selects K0s, Lambda, anti-Lambda and
photon conversions among the V0 finder's V0s and writes them, with
everything needed to refit their prongs offline, to o2_v0s_full.root
(one entry per TF). New data format DataFormatsGlobalTracking/
TrackV0Extended.h, built like TrackCosmicsExtended.h:
- per V0: its two prongs, each with its raw TPC clusters (plus the
  sharing-map byte), ITS compact clusters and patterns, the matched TOF
  cluster and the TRD tracklets; the track parameters, times and TOF
  match of the reconstruction; the assigned primary vertex; selection
  variables and the downsampling weight
- per TF: the TPC transformation info, the TPC occupancy map, the TF ID
- with MC input also the MC truth of each prong and of the V0 (common
  mother of the prongs: PDG code, momentum, production point, its
  mother), as the kinematics are not kept in MC productions

Selection and downsampling (svFullOutput.*, V0FullOutputParams.h): cuts
per class, far K0s / Lambda (beyond maxR, both legs without ITS) with
their own cuts; flat in log V0 pT per class with a cap per TF and pT
bin. Caps >= 1 keep at most int(cap) V0s, caps < 1 keep each V0 with
probability cap / candidates (for full passes); the weights restore the
spectrum. Random numbers from the TF and the prong tracks.

Existing study device: the V0 refit (--refit, or when the finder does
not send full V0s) now prepares TPC-only prongs as the V0 finder does
(shifted to the vertex time, drift from VDriftHelper), so it reproduces
the finder's V0s; svStudy.root changes in refit mode for such V0s.
New option --disable-study-tree.

calib-workflow.sh: CALIB_ASYNC_EXTRACTV0S=1 runs the extraction in the
reconstruction chain (with svertexer.createFullV0s=true the V0s are not
refitted).

Code review: two rounds by Claude Fable 5.2; all findings addressed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@matthias-kleiner
matthias-kleiner requested review from a team and shahor02 as code owners December 3, 2026 17:25
…ition

With svertexer.createFullV0s, the copy of a V0 that the finder adds for a
cascade at another primary vertex got its cosPA from V0::getX()/getY(),
i.e. from the coordinates in the V0's sector frame, combined with the
global position of the vertex. The cosPA of these copies was wrong
(e.g. -0.83 instead of 0.93). Use the global position of the V0
(getXYZGlo). Only the full V0 output (createFullV0s=true) is affected;
the V0 indices, the fits and the AOD are unchanged.

Test: Pb-Pb MC TF with the cascade finder: 2 of 1782 V0s are such copies;
their cosPA changes from -0.83 / -0.23 to 0.93 / 0.99, nothing else changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant