Skip to content

Add GenFit2-based Track Fitting Functional#77

Open
andread3vita wants to merge 47 commits intokey4hep:mainfrom
andread3vita:PRtrackingPipeline
Open

Add GenFit2-based Track Fitting Functional#77
andread3vita wants to merge 47 commits intokey4hep:mainfrom
andread3vita:PRtrackingPipeline

Conversation

@andread3vita
Copy link
Copy Markdown
Contributor

@andread3vita andread3vita commented Feb 26, 2026

BEGINRELEASENOTES

  • Rename the track finder functional to align with the current coding style
  • Add GenFit interfaces to enable running the track fitter
  • Implement the GenFit-based track fitter
  • Implement PerfectTrackFinder
  • Add test for the track fitter

ENDRELEASENOTES

Hello! This PR includes the implementation of the track fitter using Genfit2.
See more info here.

TODO:

  • Remove debug_lvl and use the gaudi-friendly version of the OutputLevel -> DONE
  • Add functionality to filter hits based on their weights after the fit - DONE
  • Add multiple fitters -> DONE

andread3vita and others added 5 commits February 25, 2026 18:10
FIX comments and track finder test
FIX fit initialization

ADD fitter test

ADD README for fitter

FIX small fix

FIX hit ordering function for fitter

ADD comments

Remove compatibility with older Gaudi versions (key4hep#76)
Comment thread Tracking/components/GenfitTrackFitter.cpp Outdated
Comment thread Tracking/components/GenfitTrackFitter.cpp Outdated
Comment thread Tracking/components/GenfitTrackFitter.cpp Outdated
Comment thread Tracking/components/GenfitTrackFitter.cpp Outdated
Comment thread Tracking/components/GenfitTrackFitter.cpp Outdated
Comment thread Tracking/components/GenfitTrackFitter.cpp Outdated
Comment thread Tracking/components/GenfitTrackFitter.cpp Outdated
Comment thread Tracking/components/GenfitTrackFitter.cpp Outdated
Comment thread Tracking/components/GenfitTrackFitter.cpp Outdated
Comment thread Tracking/components/GenfitTrackFitter.cpp Outdated
Comment thread Tracking/components/GenfitTrackFitter.cpp Outdated
…NAME m_skip_background to m_skip_unmatchedTracks + COMMENT m_singleEvaluation
Comment thread Tracking/components/GenfitTrackFitter.cpp Outdated
Comment thread Tracking/components/GenfitTrackFitter.cpp Outdated
Comment thread Tracking/components/GenfitTrackFitter.cpp Outdated
Comment thread Tracking/components/GenfitTrackFitter.cpp Outdated
Comment thread Tracking/components/GenfitTrackFitter.cpp Outdated
Comment thread Tracking/components/GenfitTrackFitter.cpp Outdated
Comment thread Tracking/components/GenfitTrackFitter.cpp Outdated
Comment thread Tracking/components/GenfitTrackFitter.cpp Outdated
@SanghyunKo
Copy link
Copy Markdown
Collaborator

As there were quite a number of formatting issues, I ran the clang hook and pushed to the PR myself. I will start reviewing the PR based on the updated one. Next time, it'll be very helpful for reviewers if you can run the pre-commit in advance, especially for a big PR like this :) I'll come back soon with the real comments.

Copy link
Copy Markdown
Collaborator

@SanghyunKo SanghyunKo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Impressive amount of work! I made my first round of passes. Frankly, I'm not confident enough that I caught everything properly (or even that my comments were proper). I'd highly appreciate comments from others.

I think most of my comments are rather easy to address, except the ones in GenfitTrack.cpp; Personally I feel that we might need to iterate on GenfitTrack.cpp a couple of times more. Anyway, let's make it converge soon ;)

Comment thread Tracking/src/genfit_interfaces/GenfitField.cpp Outdated
Comment thread Tracking/src/genfit_interfaces/GenfitTrack.cpp Outdated
Comment on lines +637 to +650
points_Rz.emplace_back(R, z_coord);
}

double sumR = 0.0;
double sumZ = 0.0;
double sumRZ = 0.0;
double sumR2 = 0.0;

for (const auto& p : points_Rz) {
sumR += p.x;
sumZ += p.y;
sumRZ += p.x * p.y;
sumR2 += p.x * p.x;
}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you use Point2D_xy to store R & Z? It seems really confusing. You could use something else (e.g. std::pair) if you simply wanted to store the two doubles.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed by creating Point2D_Rz

Comment thread Tracking/src/genfit_interfaces/GenfitTrack.cpp
Comment thread Tracking/components/GenfitTrackFitter.cpp Outdated
Comment thread Tracking/src/genfit_interfaces/GenfitTrack.cpp Outdated
Comment thread Tracking/src/genfit_interfaces/GenfitTrack.cpp Outdated
Comment thread Tracking/src/genfit_interfaces/GenfitTrack.cpp Outdated
Comment on lines +56 to +58
const int layer = decoder->get(cellid, "layer");
const int superlayer = decoder->get(cellid, "superlayer");
const int nphi = decoder->get(cellid, "nphi");
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we 100% sure that all users of the SenseWireHit will use the same cell ID encoding scheme?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What can we do about this? What was the outcome of the discussion on the encoding scheme? As far as I understand, it will be difficult to use a single encoder for both silicon and gaseous detectors. However, would it be possible to adopt a common encoding scheme for all wire-based detectors?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we can't do anything with this, we should at least check whether the cell ID decoding string contains those substrings in advance (otherwise users will need to go to the DD4hep source code to figure out what the error is); probably the following would be a good place to put:
https://github.com/key4hep/k4RecTracker/pull/77/changes#diff-f5800e72dd2692318dbc3570ae10bfb8d5624fd746c72ae636095de982473dd2R155-R164

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment thread Tracking/src/genfit_interfaces/GenfitWireMeasurement.cpp
@andread3vita
Copy link
Copy Markdown
Contributor Author

@SanghyunKo I have implemented what we discussed. Let me know if there is something else I should implement/change.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants