Updates to DBSClusterer and FlgBkgHits#1762
Conversation
|
Hi @NamithaChitrazee,
which require these tests: build. @Mu2e/fnalbuild-users, @Mu2e/write have access to CI actions on main. ⌛ The following tests have been triggered for ea2d9aa: build (Build queue - API unavailable) |
|
☔ The build is failing at ea2d9aa.
N.B. These results were obtained from a build of this Pull Request at ea2d9aa after being merged into the base branch at e4c9d83. For more information, please check the job page here. |
|
Let me review this pull request in detail.Here's my review of PR #1762 — "Updates to DBSClusterer and FlgBkgHits". I've identified several categories of issues across the 7 changed files. 🔴 Bugs / Correctness Issues1. Copy-paste comment error in
|
| Severity | Issue | File |
|---|---|---|
| 🔴 Bug | kerasvars has 7 elements but model expects 8 inputs |
DBSClusterer.cc |
| 🔴 Bug | hitToClusterMap passed by value (writes are lost) |
FlagBkgHits_module.cc |
| 🔴 Bug | chcol_out->at(ich) out-of-bounds when filtering |
FlagBkgHits_module.cc |
| 🟠 Potential | mergeClusters declared but not defined (linker error) |
DBSClusterer.hh |
| 🟠 Potential | nNeighbors unsigned wrap-around risk |
DBSClusterer.cc |
| 🟡 Quality | Copy-paste comment //cluster time on _edep |
BkgCluster.hh |
| 🟡 Quality | Unused variables (npexp, fp, pgap) |
DBSClusterer.cc |
| 🟡 Quality | Unnecessary #include "TMath.h" and ConditionsHandle.hh |
Multiple |
| 🟡 Quality | Lots of commented-out code / debug std::cout |
Multiple |
| 🟡 Quality | Inconsistent indentation in classifyCluster |
DBSClusterer.cc |
The most critical issues are #2 (array size mismatch → undefined behavior), #3 (pass-by-value → silently broken map), and #4 (out-of-bounds when filtering is active). These should be fixed before merging.
|
@FNALbuild run build test |
|
|
@FNALbuild run build test |
|
⌛ The following tests have been triggered for 3282b56: build (Build queue - API unavailable) |
|
☀️ The build tests passed at 3282b56.
N.B. These results were obtained from a build of this Pull Request at 3282b56 after being merged into the base branch at b188c42. For more information, please check the job page here. |
|
I'll review this pull request by examining its details and the code changes.Here is my review of PR #1762 ("Updates to DBSClusterer and FlgBkgHits") in Mu2e/Offline. I've organized the findings by severity. 🔴 Bugs / Potential Correctness Issues1.
|
| Severity | Count | Key Concerns |
|---|---|---|
| 🔴 Bug/Correctness | 5 | Unsigned/signed mismatch in findNeighbors return, uninitialized kerasQ for small clusters, phi wrapping removed, countProton semantics, energysel flag meaning |
| 🟡 Quality | 5 | Commented-out code, brace style, broken dump(), unused 22K-line file, extra whitespace |
| 🟢 Good | 5 | Performance improvements, cleaner architecture, feature enablement |
The most critical items to address before merge are #1 (unsigned return narrowing), #3 (uninitialized kerasQ for small clusters), and #5 (phi wrapping removal). The unused TrainBkgDiagBDT.hxx file (#10) should also be clarified.
|
|
@FNALbuild run build test |
|
⌛ The following tests have been triggered for 22c023a: build (Build queue - API unavailable) |
|
📝 The HEAD of |
|
☀️ The build tests passed at 22c023a.
N.B. These results were obtained from a build of this Pull Request at 22c023a after being merged into the base branch at 1241ca2. For more information, please check the job page here. |
|
Let me review this pull request to find any issues.Here's my review of PR #1762 — "Updates to DBSClusterer and FlgBkgHits". I've identified several issues ranging from potential bugs to code quality concerns. 🔴 Bugs / Correctness IssuesMissing shiv.clear() in sub-level output path (FlagBkgHits_module.cc): fillStrawHitIndices(size_t, SHIV&, Level) appends via push_back without clearing — verified in ComboHit.cc:135-159. The old code called shiv.clear() each iteration; the new code removed it. Hit indices accumulate across iterations, producing duplicate ComboHits when the sub-level path is active. hit.time() vs hit.correctedTime() mismatch in MVA input (DBSClusterer.cc:classifyCluster): Time delta computed as hit.time() - cluster.time(), but cluster.time() derives from correctedTime(). time() returns raw TDC threshold crossing (_etime[_eend]), correctedTime() returns calibrated aggregate time (_time). The MVA feature is physically meaningless. 1. Incorrect use of
|
| Severity | Issue | File |
|---|---|---|
| 🔴 Bug | Hits flagged as energysel even when cluster isn't a proton candidate |
FlagBkgHits_module.cc |
| 🔴 Bug | Removed consistency checks / error handling silently | FlagBkgHits_module.cc |
| 🔴 Bug | shiv.clear() removed — potential stale data accumulation |
FlagBkgHits_module.cc |
| 🟠 Risk | Phi averaging without wrap-around handling | DBSClusterer.cc |
| 🟠 Risk | Small clusters get default kerasQ=0 instead of explicit sentinel |
DBSClusterer.cc |
| 🟡 Quality | Redundant forward declaration alongside full #include |
DBSClusterer.hh |
| 🟡 Quality | bkghitcol allocated unconditionally |
FlagBkgHits_module.cc |
| 🟡 Quality | and vs && style inconsistency |
FlagBkgHits_module.cc |
| 🟡 Quality | Commented-out code should be removed | FlagBkgHits_module.cc |
TrkHitReco/src/DBSClusterer.cc
Outdated
| float edep = chcol[idx].energyDep(); | ||
| XYZVectorF hitpos(chcol[idx].pos().x(), chcol[idx].pos().y(), chcol[idx].pos().z()); | ||
| cluster.addHitPosition(hitpos); | ||
| float dp = chcol[idx].phi(); |
There was a problem hiding this comment.
I agree with the AI that phi wrapping has to be handled correctly to deal with the weighted sum. Typically this is done by choosing 1 (arbitrary) wrapping (the 1st entry is typical), then enforcing that all subsequent entries have the same. Let me know if this is unclear.
brownd1978
left a comment
There was a problem hiding this comment.
Thanks for the fixes, the phi wrapping now all looks correct. Have you retrained since these fixes? I imagine it might have some impact.
Otherwise I have a few minor suggestions that don't affect the code quality, implement as you see fit.
TrkHitReco/src/FlagBkgHits_module.cc
Outdated
| void FlagBkgHits::classifyCluster(BkgClusterCollection& bkgccol, BkgClusterHitCollection& bkghitcol, StrawHitFlagCollection& chfcol, const ComboHitCollection& chcol) const | ||
| { | ||
| for (auto& cluster : bkgccol) { | ||
| for (size_t icl =0; icl < bkgccol.size(); ++icl) { |
There was a problem hiding this comment.
I suggest a range loop here as well: for (auto& cluster : bkgcol) {
TrkHitReco/src/FlagBkgHits_module.cc
Outdated
| if (std::find(bkgccol[icl].hits().begin(),bkgccol[icl].hits().end(),ich) != bkgccol[icl].hits().end()) return icl; | ||
| return -1; | ||
| int npc(0); | ||
| for (size_t icl=0; icl < bkgccol.size(); ++icl) { |
There was a problem hiding this comment.
I suggest using a range loop here too
|
@FNALbuild run build test |
|
⌛ The following tests have been triggered for 19b4105: build (Build queue - API unavailable) |
|
☀️ The build tests passed at 19b4105.
N.B. These results were obtained from a build of this Pull Request at 19b4105 after being merged into the base branch at c570352. For more information, please check the job page here. |
More small refinements will follow for this update.