39 {
40
43
46
47 ATH_CHECK(muonCandidates.
record(std::make_unique<MuonCandidateCollection>()));
49
50 const InDet::BeamSpotData*
beamSpot{
nullptr};
52
54 unsigned int ntracks = 0;
55
56
58
59 std::vector<track_link> trackLinks;
60
61 unsigned int index = -1;
62
65
66 if (!
track->track()) {
68 continue;
69 }
70 const Trk::Track& msTrack = *
track->track();
71
75
76 std::unique_ptr<Trk::Track> standaloneTrack;
79 } else {
81 }
82
83 if (standaloneTrack) {
84
85 if (standaloneTrack->fitQuality()->doubleNumberDoF() == 0) {
86 standaloneTrack.reset();
88 } else {
89 double mschi2 = 2.5;
92
93 if (standaloneTrack->fitQuality()->chiSquared() / standaloneTrack->fitQuality()->doubleNumberDoF() > 1000 * mschi2) {
94 standaloneTrack.reset();
95 ATH_MSG_DEBUG(
"extrapolated track has a degraded fit, don't use it");
96 }
97 }
98 }
99 if (standaloneTrack) {
100 standaloneTrack->info().setParticleHypothesis(
Trk::muon);
103 <<
m_printer->print(*standaloneTrack) << std::endl
104 <<
m_printer->printStations(*standaloneTrack));
105 ++ntracks;
106 if (!standaloneTrack->perigeeParameters()) {
108 } else if (!standaloneTrack->perigeeParameters()->covariance()) {
109 ATH_MSG_WARNING(
" Track with perigee without covariance " << (*standaloneTrack));
110 }
111 trackLinks.emplace_back(std::move(standaloneTrack), index, true);
112 } else {
113
114
115
116 bool skipTrack = true;
117 const Trk::MuonTrackSummary* msMuonTrackSummary = nullptr;
118 std::unique_ptr<Trk::TrackSummary> msTrackSummary;
119
122 msMuonTrackSummary = msTrackSummary->muonTrackSummary();
123 } else{
125 }
127 using namespace Muon::MuonStationIndex;
128 if ((chs.isMdt() &&
m_idHelperSvc->stationIndex(chs.chamberId()) != StIndex::EM) ||
130 skipTrack = false;
131 break;
132 }
133 }
134 if (!skipTrack) {
135 trackLinks.emplace_back(std::make_unique<Trk::Track>(msTrack), index, false);
136 }
137 }
138 }
141 extrapTracks->reserve(trackLinks.size());
142 for (const track_link& link : trackLinks) {
143 extrapTracks->push_back(
link.track.get());
144 }
145 ATH_MSG_DEBUG(
"Finished back-tracking, total number of successfull fits " << ntracks);
146
147
149
150 ATH_MSG_DEBUG(
"Finished ambiguity solving: " << extrapTracks->size() <<
" track(s) in -> " << resolvedTracks->size()
151 << " track(s) out");
152
155
156
157 for (const Trk::Track* track : *resolvedTracks) {
158 std::vector<track_link>::iterator tLink = std::ranges::find_if(trackLinks,
159 [&track](const track_link& link) {
161 });
162
163 if (tLink == trackLinks.end()) {
164 ATH_MSG_WARNING(
"Unable to find internal link between MS and SA tracks!");
165 continue;
166 }
167
168 std::unique_ptr<MuonCombined::MuonCandidate> muon_candidate{};
169 ElementLink<xAOD::TrackParticleContainer> MS_TrkLink{*muonTrackParticles, tLink->container_index, ctx};
170 if (tLink->extp_succeed) {
171 msOnlyTracks->push_back(std::move(tLink->track));
172 ElementLink<TrackCollection> saLink(*msOnlyTracks, msOnlyTracks->size() - 1, ctx);
173 muon_candidate = std::make_unique<MuonCombined::MuonCandidate>(MS_TrkLink, saLink,
174 msOnlyTracks->size() - 1);
175
176 } else {
177
178 muon_candidate = std::make_unique<MuonCombined::MuonCandidate>(MS_TrkLink);
179 }
181 if (segments) {
182 std::vector<const Muon::MuonSegment*> assoc_segs;
184 muon_candidate->setSegments(std::move(assoc_segs));
185 }
186 muonCandidates->push_back(std::move(muon_candidate));
187 }
188 return StatusCode::SUCCESS;
189}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
size_type size() const noexcept
Returns the number of elements in the collection.
SG::WriteHandleKey< MuonCandidateCollection > m_candidateCollectionName
ToolHandle< Muon::IMuonTrackExtrapolationTool > m_trackExtrapolationTool
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_muonTrackParticleLocation
ToolHandle< Trk::ITrackAmbiguityProcessorTool > m_ambiguityProcessor
PublicToolHandle< MuonCombined::IMuonTrackToSegmentAssociationTool > m_trackSegmentAssociationTool
SG::ReadCondHandleKey< InDet::BeamSpotData > m_beamSpotKey
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
ToolHandle< Trk::IExtendedTrackSummaryTool > m_trackSummaryTool
ToolHandle< Rec::ICombinedMuonTrackBuilder > m_trackBuilder
Gaudi::Property< unsigned int > m_extrapolationStrategy
SG::WriteHandleKey< TrackCollection > m_msOnlyTracks
PublicToolHandle< Muon::MuonEDMPrinterTool > m_printer
SG::ReadHandleKey< Trk::SegmentCollection > m_segmentKey
Retrieve the segment container to perform the segment association offline.
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
double chiSquared() const
returns the of the overall track fit
double doubleNumberDoF() const
returns the number of degrees of freedom of the overall track or vertex fit as double
const std::vector< ChamberHitSummary > & chamberHitSummary() const
access to the vector of chamber hit summaries on the track
@ MuidStandAlone
MuidStandalone.
const MuonTrackSummary * muonTrackSummary() const
returns a pointer to the MuonTrackSummary if available
const Trk::TrackSummary * trackSummary() const
Returns a pointer to the const Trk::TrackSummary owned by this const track (could be nullptr).
const FitQuality * fitQuality() const
return a pointer to the fit quality const-overload
std::string toString(const Translation3D &translation, int precision=4)
GeoPrimitvesToStringConverter.
pointer & link(pointer p) const
Return a reference to the link for an element.
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
const T * get(const ReadCondHandleKey< T > &key, const EventContext &ctx)
Convenience function to retrieve an object given a ReadCondHandleKey.
DataVector< Trk::Segment > SegmentCollection
AthConfigFlags beamSpot(AthConfigFlags flags, str instanceName, str recoMode)
TrackParticle_v1 TrackParticle
Reference the current persistent version:
TrackParticleContainer_v1 TrackParticleContainer
Definition of the current "TrackParticle container version".