Skip to content

Expand regrowing options#1870

Open
brownd1978 wants to merge 4 commits into
Mu2e:mainfrom
brownd1978:refreco
Open

Expand regrowing options#1870
brownd1978 wants to merge 4 commits into
Mu2e:mainfrom
brownd1978:refreco

Conversation

@brownd1978

Copy link
Copy Markdown
Collaborator

This PR adds the ability to regrow a Ptr list (selection) of LoopHelix KalSeeds, and to deep-copy the associated KalSeedMCs, to allow regrowing only selected tracks. If this feature is generally useful it could be added to regrowKinematicLine as well. Or perhaps it's time to merge these into a single module.

I also started moving some regrowing fcl into Offline prolog.

@brownd1978 brownd1978 requested a review from bonventre July 2, 2026 05:36
@FNALbuild

Copy link
Copy Markdown
Collaborator

Hi @brownd1978,
You have proposed changes to files in these packages:

  • Mu2eKinKal
  • TrkReco

which require these tests: build.

@Mu2e/fnalbuild-users, @Mu2e/write have access to CI actions on main.

⌛ The following tests have been triggered for f8fceca: build (Build queue - API unavailable)

About FNALbuild. Code review on Mu2e/Offline.

@FNALbuild

Copy link
Copy Markdown
Collaborator

☀️ The build tests passed at f8fceca.

Test Result Details
test with Command did not list any other PRs to include
merge Merged f8fceca at 3d84f93
build (prof) Log file. Build time: 04 min 15 sec
ceSimReco Log file.
g4test_03MT Log file.
transportOnly Log file.
POT Log file.
g4study Log file.
cosmicSimReco Log file.
cosmicOffSpill Log file.
ceSteps Log file.
ceDigi Log file.
muDauSteps Log file.
ceMix Log file.
rootOverlaps Log file.
g4surfaceCheck Log file.
trigger Log file.
check_cmake Log file.
FIXME, TODO TODO (0) FIXME (0) in 2 files
clang-tidy ➡️ 4 errors 32 warnings
whitespace check no whitespace errors found

N.B. These results were obtained from a build of this Pull Request at f8fceca after being merged into the base branch at 3d84f93.

For more information, please check the job page here.
Build artifacts are deleted after 5 days. If this is not desired, select Keep this build forever on the job page.

@brownd1978

Copy link
Copy Markdown
Collaborator Author

@FNALbuild run build test

@FNALbuild

Copy link
Copy Markdown
Collaborator

⌛ The following tests have been triggered for 7870183: build (Build queue - API unavailable)

@FNALbuild

Copy link
Copy Markdown
Collaborator

☀️ The build tests passed at 7870183.

Test Result Details
test with Command did not list any other PRs to include
merge Merged 7870183 at 704459c
build (prof) Log file. Build time: 04 min 34 sec
ceSimReco Log file.
g4test_03MT Log file.
transportOnly Log file.
POT Log file.
g4study Log file.
cosmicSimReco Log file.
cosmicOffSpill Log file.
ceSteps Log file.
ceDigi Log file.
muDauSteps Log file.
ceMix Log file.
rootOverlaps Log file.
g4surfaceCheck Log file.
trigger Log file.
check_cmake Log file.
FIXME, TODO TODO (0) FIXME (0) in 2 files
clang-tidy ➡️ 4 errors 38 warnings
whitespace check no whitespace errors found

N.B. These results were obtained from a build of this Pull Request at 7870183 after being merged into the base branch at 704459c.

For more information, please check the job page here.
Build artifacts are deleted after 5 days. If this is not desired, select Keep this build forever on the job page.

@oksuzian

oksuzian commented Jul 6, 2026

Copy link
Copy Markdown
Collaborator

🔴 Bugs

1. mom selection compares against wrong initial value → best-momentum pair never selected correctly
In SelectReflections_module.cc, the value seed is std::numeric_limits<double>::max(), but the mom branch now looks for the maximum momentum (>). Since no real momentum exceeds max(), the mom case can never update ibest past 0.

double value = std::numeric_limits<double>::max();   // ok for the "min" cases
...
if(selbest_ == mom && std::get<2>(match) > value){     // never true: nothing > max()
  ibest = imatch;
  value = std::get<2>(match);
} else if(selbest_ == deltat && std::get<3>(match) < value){
...
} else if(selbest_ == nactive && std::get<5>(match) > value){  // same bug: never > max()
  ibest = imatch;
  value = std::get<5>(match);
}

The two "maximize" branches (mom, nactive) need to start from lowest()/0, while the two "minimize" branches (deltat, deltap) need max(). As written, a single shared value initialized to max() breaks both maximize cases — so SelectBestPair : 3 (the new default in prolog.fcl) will always pick the first match, not the one with the most active hits.

2. Missing else chains the comparisons incorrectly
Because the four conditions are if / else if, only one can fire per match — that's fine — but combined with the shared value bug above, switching between metrics is unsafe. Recommend one value per metric or an early switch on selbest_ before the loop.

🟡 Correctness / robustness

3. Linear MC-assns lookup is O(N²)
The old code indexed MC assns by position ((*ksmca_H)[iseed]). The new code scans the entire KalSeedMCAssns for every seed:

for(auto ksmci= ksmca.begin(); ksmci != ksmca.end(); ++ksmci){
  if(ksmci->first == kseedptr){ ksmcai = ksmci; break; }
}

Correct given the Ptr-based approach, but O(seeds × assns). Fine for small collections; worth a comment noting the tradeoff.

4. mayConsume used for required products
kseedcol_T_, kseedptrcol_T_, and cccol_T_ are now built with mayConsume even when the collection is present. Since exactly one seed collection is always required (enforced at runtime), consumes would be more accurate for the branch that's actually configured and improves ART's dependency tracking.

5. getValidHandle on KalSeedPtrCollection copies the whole collection
kseedptrs = *kseedptr_H; copies the Ptr vector. Minor, but a const auto& in the has_kseedptrcol_ branch (mirroring the has_kseedcol_ branch) would avoid the copy — though the two branches build kseedptrs differently, so this needs a small refactor.

🟢 Style / nits

  • Whitespace-only churn: several prolog.fcl hunks (the SaveDomains/SaveTrajectory re-indentation, removed # comment lines) are pure formatting and inflate the diff. Not blocking, but noise for reviewers.
  • clang-tidy: the build reports 4 errors, 38 warnings (log). Non-blocking per Mu2e convention (:arrow_right:), but worth confirming none are newly introduced by this PR (it was 4 errors / 32 warnings before the latest push).

@brownd1978

Copy link
Copy Markdown
Collaborator Author

AI comments response:
1: fixed
2: NA
3: Unavoidable side effect of Assns not supporting a Ptr-based lookup
4: fixed
5: unavoidable

@brownd1978

Copy link
Copy Markdown
Collaborator Author

@FNALbuild run build test

@FNALbuild

Copy link
Copy Markdown
Collaborator

⌛ The following tests have been triggered for c5f5a7b: build (Build queue - API unavailable)

@FNALbuild

Copy link
Copy Markdown
Collaborator

☀️ The build tests passed at c5f5a7b.

Test Result Details
test with Command did not list any other PRs to include
merge Merged c5f5a7b at 704459c
build (prof) Log file. Build time: 04 min 28 sec
ceSimReco Log file.
g4test_03MT Log file.
transportOnly Log file.
POT Log file.
g4study Log file.
cosmicSimReco Log file.
cosmicOffSpill Log file.
ceSteps Log file.
ceDigi Log file.
muDauSteps Log file.
ceMix Log file.
rootOverlaps Log file.
g4surfaceCheck Log file.
trigger Log file.
check_cmake Log file.
FIXME, TODO TODO (0) FIXME (0) in 2 files
clang-tidy ➡️ 4 errors 38 warnings
whitespace check no whitespace errors found

N.B. These results were obtained from a build of this Pull Request at c5f5a7b after being merged into the base branch at 704459c.

For more information, please check the job page here.
Build artifacts are deleted after 5 days. If this is not desired, select Keep this build forever on the job page.

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.

3 participants