8 #include "Acts/Surfaces/Surface.hpp"
9 #include "Acts/Surfaces/PerigeeSurface.hpp"
23 const auto *actsElement =
dynamic_cast<const ActsDetectorElement *
>(surface.associatedDetectorElement());
35 ISvcLocator *pSvcLocator)
57 return StatusCode::SUCCESS;
70 std::unique_ptr<::TrackCollection> trackCollection = std::make_unique<::TrackCollection>();
79 return StatusCode::SUCCESS;
83 const Acts::GeometryContext &tgContext,
88 for (
const typename ActsTrk::TrackContainer::ConstTrackProxy
track : tracks)
90 const auto lastMeasurementIndex =
track.tipIndex();
91 auto finalTrajectory = std::make_unique<Trk::TrackStates>();
93 int numberOfDeadPixel = 0;
94 int numberOfDeadSCT = 0;
98 std::vector<std::unique_ptr<const Acts::BoundTrackParameters>> actsSmoothedParam;
99 tracks.trackStateContainer().visitBackwards(
100 lastMeasurementIndex,
101 [
this, &tgContext, &
track, &finalTrajectory, &actsSmoothedParam, &numberOfDeadPixel, &numberOfDeadSCT](
const typename ActsTrk::TrackStateBackend::ConstTrackStateProxy &state) ->
void
104 if (!state.hasReferenceSurface() || !state.referenceSurface().associatedDetectorElement())
109 auto flag = state.typeFlags();
110 std::bitset<Trk::TrackStateOnSurface::NumberOfTrackStateOnSurfaceTypes> typePattern;
111 std::unique_ptr<Trk::TrackParameters> parm;
114 if (
flag.test(Acts::TrackStateFlag::HoleFlag))
116 const Acts::BoundTrackParameters actsParam = track.createParametersFromState(state);
117 parm = m_ATLASConverterTool->actsTrackParametersToTrkParameters(actsParam, tgContext);
118 auto boundaryCheck = m_boundaryCheckTool->boundaryCheck(*parm);
121 if (boundaryCheck == Trk::BoundaryCheckResult::DeadElement)
123 auto *detElem = actsToDetElem(state.referenceSurface());
128 if (detElem->isPixel())
132 else if (detElem->isSCT())
146 else if (
flag.test(Acts::TrackStateFlag::OutlierFlag))
148 const Acts::BoundTrackParameters actsParam = track.createParametersFromState(state);
149 parm = m_ATLASConverterTool->actsTrackParametersToTrkParameters(actsParam, tgContext);
150 typePattern.set(Trk::TrackStateOnSurface::Outlier);
155 const Acts::BoundTrackParameters actsParam = track.createParametersFromState(state);
158 actsSmoothedParam.push_back(std::make_unique<const Acts::BoundTrackParameters>(Acts::BoundTrackParameters(actsParam)));
159 parm = m_ATLASConverterTool->actsTrackParametersToTrkParameters(actsParam, tgContext);
160 typePattern.set(Trk::TrackStateOnSurface::Measurement);
163 std::unique_ptr<Trk::MeasurementBase> measState;
164 if (state.hasUncalibratedSourceLink())
167 auto sl = state.getUncalibratedSourceLink().template get<ATLASUncalibSourceLink>();
168 assert( sl != nullptr);
169 const xAOD::UncalibratedMeasurement &uncalibMeas = getUncalibratedMeasurement(sl);
170 measState = makeRIO_OnTrack(uncalibMeas, *parm);
171 ATH_MSG_DEBUG(
"Successfully used ATLASUncalibratedSourceLink");
172 } catch (
const std::bad_any_cast& ){
173 ATH_MSG_DEBUG(
"Not an ATLASUncalibSourceLink, trying ATLASSourceLink");
174 auto sl = state.getUncalibratedSourceLink().template get<ATLASSourceLink>();
175 assert( sl !=
nullptr );
176 measState.reset(sl->clone());
182 double nDoF = state.calibratedSize();
185 std::move(measState),
191 finalTrajectory->insert(finalTrajectory->begin(), perState);
195 const Acts::BoundTrackParameters actsPer(
track.referenceSurface().getSharedPtr(),
200 std::unique_ptr<Trk::TrackParameters> per = m_ATLASConverterTool->actsTrackParametersToTrkParameters(actsPer, tgContext);
201 std::bitset<Trk::TrackStateOnSurface::NumberOfTrackStateOnSurfaceTypes> typePattern;
207 finalTrajectory->insert(finalTrajectory->begin(), perState);
213 auto newtrack = std::make_unique<Trk::Track>(newInfo, std::move(finalTrajectory),
nullptr);
215 if (!newtrack->trackSummary())
217 newtrack->setTrackSummary(std::make_unique<Trk::TrackSummary>());
225 m_trkSummaryTool->updateTrackSummary(ctx, *newtrack,
true);
226 tracksContainer.push_back(std::move(newtrack));
229 return StatusCode::SUCCESS;
242 if (not pixcl or not pixelLinkAcc.
isAvailable(*pixcl))
244 ATH_MSG_DEBUG(
"no pixelClusterLink for cluster associated to measurement");
248 auto pix = *pixelLinkAcc(*pixcl);
249 if (m_RotCreatorTool.empty())
257 ATH_MSG_DEBUG(
"create InDet::PixelClusterOnTrack without correction");
258 return std::make_unique<InDet::PixelClusterOnTrack>(
pix,
262 pix->globalPosition(),
272 if (not stripcl or not stripLinkAcc.
isAvailable(*stripcl))
274 ATH_MSG_WARNING(
"no sctClusterLink for clusters associated to measurement");
278 auto sct = *stripLinkAcc(*stripcl);
279 if (m_RotCreatorTool.empty())
287 ATH_MSG_DEBUG(
"create InDet::SCT_ClusterOnTrack without correction");
288 return std::make_unique<InDet::SCT_ClusterOnTrack>(sct,
292 sct->globalPosition(),
299 ATH_MSG_WARNING(
"xAOD::UncalibratedMeasurement is neither xAOD::PixelCluster nor xAOD::StripCluster");
303 ATH_MSG_DEBUG(
"use Trk::RIO_OnTrackCreator::correct to create corrected Trk::RIO_OnTrack");
304 assert(!m_RotCreatorTool.empty());
305 assert(rio !=
nullptr);
306 return std::unique_ptr<Trk::MeasurementBase>(m_RotCreatorTool->correct(*rio, parm, Gaudi::Hive::currentContext()));