From 1395fed44429c29be18da9734ee22cd950c91c10 Mon Sep 17 00:00:00 2001 From: Rob Mina Date: Fri, 13 Nov 2026 07:58:22 -0600 Subject: [PATCH] Update documentation and example for TrkCrvMatch projections. --- doc/branches.md | 3 ++- inc/TrkCrvInfo.hh | 2 +- inc/TrkCrvTrueXingInfoMC.hh | 2 +- inc/TrkCrvXingInfo.hh | 5 +++-- utils/trkcrv_example.py | 16 +++++++++------- 5 files changed, 16 insertions(+), 12 deletions(-) diff --git a/doc/branches.md b/doc/branches.md index 9a03218..0037755 100644 --- a/doc/branches.md +++ b/doc/branches.md @@ -71,11 +71,12 @@ Reco files made with the association in Production's reco paths already hold the ```crv``` has one element per track. The other branches hold, per track, a vector of CRV sector crossings (```crvxings```, with the per-layer probe) or of associated clusters (```crvcands```). ```crvcands.crvcoinc``` is the index of the cluster in ```crvcoincs```; ```crvcandsmc``` and ```crvxingsmc``` are parallel to ```crvcands``` and ```crvxings```. See ```utils/trkcrv_example.py```. +```crvxings.inbounds``` tells the crossings the extrapolation found (true) from projections (false): a straight-line track that crosses no CRV sector is projected onto the extended plane of each sector holding one of its candidates. Use ```inbounds```, not ```nxings > 0```, to select tracks that reach a CRV sector. Candidates from projections run to larger chi2 than those from extrapolated crossings, on which the error model was tuned. | branch | structure | explanation | leaf information | |--------|-----------|-------------|------------------| | trkcrv | Vector branch | track-CRV association summary of one track, from Offline TrkCrvMatch| [see TrkCrvInfo.hh](../inc/TrkCrvInfo.hh) -| trkcrvxings | Vector-of-vector branch | one CRV sector crossing of a track's extrapolation, with the layer probe of that sector| [see TrkCrvXingInfo.hh](../inc/TrkCrvXingInfo.hh) +| trkcrvxings | Vector-of-vector branch | one CRV sector crossing of a track's extrapolation (inbounds), or a projection onto a sector's extended plane for a straight-line track that crosses none, with the layer probe of that sector| [see TrkCrvXingInfo.hh](../inc/TrkCrvXingInfo.hh) | trkcrvcands | Vector-of-vector branch | one CRV coincidence cluster associated with a track (candidates ordered geometric by chi2, then time-only)| [see TrkCrvCandInfo.hh](../inc/TrkCrvCandInfo.hh) | trkcrvcandsmc | Vector-of-vector branch | truth of one track-CRV candidate, parallel to crvcands| [see TrkCrvCandInfoMC.hh](../inc/TrkCrvCandInfoMC.hh) | trkcrvxingsmc | Vector-of-vector branch | truth of one reco CRV crossing, parallel to crvxings| [see TrkCrvXingInfoMC.hh](../inc/TrkCrvXingInfoMC.hh) diff --git a/inc/TrkCrvInfo.hh b/inc/TrkCrvInfo.hh index 192531d..588df58 100644 --- a/inc/TrkCrvInfo.hh +++ b/inc/TrkCrvInfo.hh @@ -8,7 +8,7 @@ namespace mu2e { struct TrkCrvInfo { bool matched = false; // a TrkCrvMatch record exists for this track (false: the other leaves are defaults) - int nxings = 0; // CRV sector crossings of the track's extrapolation (entries of crvxings) + int nxings = 0; // entries of crvxings: the extrapolation's CRV crossings, or projections (inbounds false) for a line track with none int ncands = 0; // associated CRV coincidence clusters (entries of crvcands) int ngeom = 0; // candidates kept by the geometric test int bestgeom = -1; // index into crvcands of the lowest-chi2 geometric candidate, -1 if none diff --git a/inc/TrkCrvTrueXingInfoMC.hh b/inc/TrkCrvTrueXingInfoMC.hh index 961710b..8920ca4 100644 --- a/inc/TrkCrvTrueXingInfoMC.hh +++ b/inc/TrkCrvTrueXingInfoMC.hh @@ -26,7 +26,7 @@ namespace mu2e XYZVectorF deppos; // energy-weighted position of those deposits, detector frame (mm) int crvcoinc = -1; // index into crvcoincs of the cluster with most energy from the particle in this sector, -1 if none or not in that collection int cand = -1; // index into crvcands of that cluster, -1 if it is not a candidate - int recoxing = -1; // index into crvxings of the reco crossing of this sector, -1 if not extrapolated there + int recoxing = -1; // index into crvxings of the reco crossing of this sector (a projection if not inbounds), -1 if none void reset() { *this = TrkCrvTrueXingInfoMC(); } }; diff --git a/inc/TrkCrvXingInfo.hh b/inc/TrkCrvXingInfo.hh index ae29c84..6e32f00 100644 --- a/inc/TrkCrvXingInfo.hh +++ b/inc/TrkCrvXingInfo.hh @@ -1,5 +1,6 @@ // -// TrkCrvXingInfo: one CRV sector crossing of a track's extrapolation, with the layer probe of that sector +// TrkCrvXingInfo: one CRV sector crossing of a track's extrapolation, or, for a straight-line track that crosses no +// sector, its projection onto a sector's extended plane (inbounds false); with the layer probe of that sector // #ifndef TrkCrvXingInfo_HH #define TrkCrvXingInfo_HH @@ -22,7 +23,7 @@ namespace mu2e float sigt = 0; // track time error (ns) float mom = 0; // track momentum at the crossing (MeV/c) float momerr = 0; // its error (MeV/c) - bool inbounds = false; // crossing inside the sector rectangle + bool inbounds = false; // crossing inside the sector rectangle (found by the extrapolation); false: a projection, whose candidates run to larger chi2 float dedgeu = 0; // distance inside the sector edge along the bars (mm), negative outside float dedgev = 0; // distance inside the sector edge across the bars (mm), negative outside float edgesig = 0; // edge distance in units of the track error diff --git a/utils/trkcrv_example.py b/utils/trkcrv_example.py index 529a706..391732e 100644 --- a/utils/trkcrv_example.py +++ b/utils/trkcrv_example.py @@ -3,7 +3,8 @@ For a track branch (e.g. "trk") configured with trkCrvMatchTags, the ntuple holds, per track: crv one TrkCrvInfo: counts, bestgeom / besttime indices into crvcands, reference times - crvxings TrkCrvXingInfo per CRV sector crossing of the extrapolation, with the 4-layer probe + crvxings TrkCrvXingInfo per CRV sector crossing of the extrapolation (inbounds), or, for a straight-line track + that crosses no sector, per projection onto a sector's extended plane (not inbounds), with the 4-layer probe crvcands TrkCrvCandInfo per associated CRV cluster: residuals, chi2, flags, and crvcoinc, the index into crvcoincs and, with MC, crvcandsmc (parallel to crvcands), crvxingsmc (parallel to crvxings) and crvtruexingsmc. @@ -80,11 +81,12 @@ def main(): matched = leaf(a, crv, "matched") bestgeom = leaf(a, crv, "bestgeom") ntracks = int(ak.sum(ak.num(matched, axis=1))) - nxing = leaf(a, crv, "nxings") - has_xing = nxing > 0 + inbounds = leaf(a, xings, "inbounds") # [event][track][xing] + has_xing = ak.any(inbounds, axis=2) # crosses a CRV sector (not nxings > 0: projections) + has_proj = ak.any(~inbounds, axis=2) # a line track that crosses none, projected has_geom = bestgeom >= 0 - print("tracks %d, with a TrkCrvMatch record %d, crossing the CRV %d, with a geometric candidate %d" - % (ntracks, ak.sum(matched), ak.sum(has_xing), ak.sum(has_geom))) + print("tracks %d, with a TrkCrvMatch record %d, crossing the CRV %d, projected only %d, with a geometric candidate %d" + % (ntracks, ak.sum(matched), ak.sum(has_xing), ak.sum(has_proj), ak.sum(has_geom))) best_dv = pick(leaf(a, cands, "dv"), bestgeom) best_dtxing = pick(leaf(a, cands, "dtxing"), bestgeom) best_chi2 = pick(leaf(a, cands, "chi2"), bestgeom) @@ -125,8 +127,8 @@ def main(): print("tracks with a time candidate at 0 < dtref < 150 ns: %d" % ak.sum(in_window)) # --- 4. layer probe ------------------------------------------------------------------------------------------- - pbar = leaf(a, xings, "probe_bar") # [event][track][xing][layer] - pdbar = leaf(a, xings, "probe_dbar") + pbar = leaf(a, xings, "probe_bar")[inbounds] # [event][track][xing][layer], crossed sectors only + pdbar = leaf(a, xings, "probe_dbar")[inbounds] predicted = pbar >= 0 found = predicted & (pdbar != 127) pred_per_layer = np.array([ak.sum(predicted[..., L]) for L in range(4)])