44 unsigned int ntracks = 0;
47 if (!beamSpotHandle.
isValid()) {
52 ATH_MSG_DEBUG(
"Beamspot position bs_x=" << beamSpotHandle->beamPos());
54 std::vector<track_link> trackLinks;
56 unsigned int index = -1;
58 for (
const auto* track : tracks) {
61 if (!track->trackLink().isValid() || !track->track()) {
70 std::unique_ptr<Trk::Track> standaloneTrack;
72 standaloneTrack =
m_trackBuilder->standaloneFit(ctx, msTrack, beamSpotHandle->beamPos(),
nullptr);
76 if (standaloneTrack) {
78 if (standaloneTrack->fitQuality()->doubleNumberDoF() == 0) {
79 standaloneTrack.reset();
86 if (standaloneTrack->fitQuality()->chiSquared() / standaloneTrack->fitQuality()->doubleNumberDoF() > 1000 * mschi2) {
87 standaloneTrack.reset();
88 ATH_MSG_DEBUG(
"extrapolated track has a degraded fit, don't use it");
92 if (standaloneTrack) {
93 standaloneTrack->info().setParticleHypothesis(
Trk::muon);
96 <<
m_printer->print(*standaloneTrack) << std::endl
97 <<
m_printer->printStations(*standaloneTrack));
99 if (!standaloneTrack->perigeeParameters())
101 else if (!standaloneTrack->perigeeParameters()->covariance())
102 ATH_MSG_WARNING(
" Track with perigee without covariance " << (*standaloneTrack));
103 trackLinks.emplace_back(std::move(standaloneTrack),
index,
true);
108 bool skipTrack =
true;
110 std::unique_ptr<Trk::TrackSummary> msTrackSummary;
114 msMuonTrackSummary = msTrackSummary->muonTrackSummary();
119 if ((chs.isMdt() &&
m_idHelperSvc->stationIndex(chs.chamberId()) != StIndex::EM) ||
125 if (!skipTrack) { trackLinks.emplace_back(std::make_unique<Trk::Track>(msTrack),
index,
false); }
129 std::unique_ptr<TrackCollection> extrapTracks = std::make_unique<TrackCollection>(
SG::VIEW_ELEMENTS);
130 extrapTracks->reserve(trackLinks.size());
131 for (
const track_link& link : trackLinks) extrapTracks->push_back(link.track.get());
132 ATH_MSG_DEBUG(
"Finished back-tracking, total number of successfull fits " << ntracks);
135 std::unique_ptr<const TrackCollection> resolvedTracks(
m_ambiguityProcessor->process(extrapTracks.get()));
137 ATH_MSG_DEBUG(
"Finished ambiguity solving: " << extrapTracks->size() <<
" track(s) in -> " << resolvedTracks->size()
146 segments = readHandle.
cptr();
150 for (
const Trk::Track* track : *resolvedTracks) {
151 std::vector<track_link>::iterator tLink =
152 std::find_if(trackLinks.begin(), trackLinks.end(), [&track](
const track_link& link) { return link.track.get() == track; });
154 if (tLink == trackLinks.end()) {
155 ATH_MSG_WARNING(
"Unable to find internal link between MS and SA tracks!");
159 std::unique_ptr<MuonCandidate> muon_candidate;
161 if (tLink->extp_succeed) {
162 outputTracks.
push_back(std::move(tLink->track));
164 muon_candidate = std::make_unique<MuonCandidate>(MS_TrkLink, saLink, outputTracks.
size() - 1);
168 muon_candidate = std::make_unique<MuonCandidate>(MS_TrkLink);
173 std::vector<const Muon::MuonSegment*> assoc_segs;
175 muon_candidate->setSegments(std::move(assoc_segs));
178 outputCollection.push_back(std::move(muon_candidate));