42 {
44 unsigned int ntracks = 0;
45
46 SG::ReadCondHandle<InDet::BeamSpotData> beamSpotHandle{
m_beamSpotKey, ctx};
47 if (!beamSpotHandle.
isValid()) {
49 return;
50 }
51
52 ATH_MSG_DEBUG(
"Beamspot position bs_x=" << beamSpotHandle->beamPos());
53
54 std::vector<track_link> trackLinks;
55
56 unsigned int index = -1;
57
58 for (const auto* track : tracks) {
60
61 if (!
track->trackLink().isValid() || !
track->track()) {
63 continue;
64 }
65 const Trk::Track& msTrack = *
track->track();
66
70 std::unique_ptr<Trk::Track> standaloneTrack;
72 standaloneTrack =
m_trackBuilder->standaloneFit(ctx, msTrack, beamSpotHandle->beamPos(),
nullptr);
73 } else {
75 }
76 if (standaloneTrack) {
77
78 if (standaloneTrack->fitQuality()->doubleNumberDoF() == 0) {
79 standaloneTrack.reset();
81 } else {
82 double mschi2 = 2.5;
85
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");
89 }
90 }
91 }
92 if (standaloneTrack) {
93 standaloneTrack->info().setParticleHypothesis(
Trk::muon);
96 <<
m_printer->print(*standaloneTrack) << std::endl
97 <<
m_printer->printStations(*standaloneTrack));
98 ++ntracks;
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);
104 } else {
105
106
107
108 bool skipTrack = true;
109 const Trk::MuonTrackSummary* msMuonTrackSummary = nullptr;
110 std::unique_ptr<Trk::TrackSummary> msTrackSummary;
111
114 msMuonTrackSummary = msTrackSummary->muonTrackSummary();
115 } else
118 using namespace Muon::MuonStationIndex;
119 if ((chs.isMdt() &&
m_idHelperSvc->stationIndex(chs.chamberId()) != StIndex::EM) ||
121 skipTrack = false;
122 break;
123 }
124 }
125 if (!skipTrack) { trackLinks.emplace_back(std::make_unique<Trk::Track>(msTrack), index, false); }
126 }
127 }
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);
133
134
135 std::unique_ptr<const TrackCollection> resolvedTracks(
m_ambiguityProcessor->process(extrapTracks.get()));
136
137 ATH_MSG_DEBUG(
"Finished ambiguity solving: " << extrapTracks->size() <<
" track(s) in -> " << resolvedTracks->size()
138 << " track(s) out");
139
142 SG::ReadHandle<Trk::SegmentCollection> readHandle{
m_segmentKey, ctx};
145 } else
146 segments = readHandle.
cptr();
147 }
148
149
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; });
153
154 if (tLink == trackLinks.end()) {
155 ATH_MSG_WARNING(
"Unable to find internal link between MS and SA tracks!");
156 continue;
157 }
158
159 std::unique_ptr<MuonCandidate> muon_candidate;
160 ElementLink<xAOD::TrackParticleContainer> MS_TrkLink{tracks, tLink->container_index, ctx};
161 if (tLink->extp_succeed) {
162 outputTracks.
push_back(std::move(tLink->track));
163 ElementLink<TrackCollection> saLink(outputTracks, outputTracks.
size() - 1, ctx);
164 muon_candidate = std::make_unique<MuonCandidate>(MS_TrkLink, saLink, outputTracks.
size() - 1);
165
166 } else {
167
168 muon_candidate = std::make_unique<MuonCandidate>(MS_TrkLink);
169 }
172 if (segments) {
173 std::vector<const Muon::MuonSegment*> assoc_segs;
175 muon_candidate->setSegments(std::move(assoc_segs));
176 }
177
179 }
180 }
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
value_type push_back(value_type pElem)
Add an element to the end of the collection.
size_type size() const noexcept
Returns the number of elements in the collection.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
const_pointer_type cptr()
Dereference the pointer.
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
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
DataVector< Trk::Segment > SegmentCollection