8 #include "Acts/Surfaces/Surface.hpp"
9 #include "Acts/Surfaces/PerigeeSurface.hpp"
23 const auto *actsElement =
dynamic_cast<const ActsDetectorElement *
>(surface.associatedDetectorElement());
51 return StatusCode::SUCCESS;
64 std::unique_ptr<::TrackCollection> trackCollection = std::make_unique<::TrackCollection>();
73 return StatusCode::SUCCESS;
77 const Acts::GeometryContext &tgContext,
82 for (
const typename ActsTrk::TrackContainer::ConstTrackProxy
track : tracks)
84 const auto lastMeasurementIndex =
track.tipIndex();
85 auto finalTrajectory = std::make_unique<Trk::TrackStates>();
87 int numberOfDeadPixel = 0;
88 int numberOfDeadSCT = 0;
92 std::vector<std::unique_ptr<const Acts::BoundTrackParameters>> actsSmoothedParam;
93 tracks.trackStateContainer().visitBackwards(
95 [
this, &tgContext, &
track, &finalTrajectory, &actsSmoothedParam, &numberOfDeadPixel, &numberOfDeadSCT](
const typename ActsTrk::TrackStateBackend::ConstTrackStateProxy &state) ->
void
98 if (!state.hasReferenceSurface() || !state.referenceSurface().associatedDetectorElement())
103 auto flag = state.typeFlags();
104 std::bitset<Trk::TrackStateOnSurface::NumberOfTrackStateOnSurfaceTypes> typePattern;
105 std::unique_ptr<Trk::TrackParameters> parm;
108 if (
flag.test(Acts::TrackStateFlag::HoleFlag))
110 const Acts::BoundTrackParameters actsParam = track.createParametersFromState(state);
111 parm = m_ATLASConverterTool->actsTrackParametersToTrkParameters(actsParam, tgContext);
112 auto boundaryCheck = m_boundaryCheckTool->boundaryCheck(*parm);
115 if (boundaryCheck == Trk::BoundaryCheckResult::DeadElement)
117 auto *detElem = actsToDetElem(state.referenceSurface());
122 if (detElem->isPixel())
126 else if (detElem->isSCT())
140 else if (
flag.test(Acts::TrackStateFlag::OutlierFlag))
142 const Acts::BoundTrackParameters actsParam = track.createParametersFromState(state);
143 parm = m_ATLASConverterTool->actsTrackParametersToTrkParameters(actsParam, tgContext);
144 typePattern.set(Trk::TrackStateOnSurface::Outlier);
149 const Acts::BoundTrackParameters actsParam = track.createParametersFromState(state);
152 actsSmoothedParam.push_back(std::make_unique<const Acts::BoundTrackParameters>(Acts::BoundTrackParameters(actsParam)));
153 parm = m_ATLASConverterTool->actsTrackParametersToTrkParameters(actsParam, tgContext);
154 typePattern.set(Trk::TrackStateOnSurface::Measurement);
157 std::unique_ptr<Trk::MeasurementBase> measState;
158 if (state.hasUncalibratedSourceLink())
161 auto sl = state.getUncalibratedSourceLink().template get<ATLASUncalibSourceLink>();
162 assert( sl != nullptr);
163 const xAOD::UncalibratedMeasurement &uncalibMeas = getUncalibratedMeasurement(sl);
164 measState = makeRIO_OnTrack(uncalibMeas, *parm);
165 ATH_MSG_DEBUG(
"Successfully used ATLASUncalibratedSourceLink");
166 } catch (
const std::bad_any_cast& ){
167 ATH_MSG_DEBUG(
"Not an ATLASUncalibSourceLink, trying ATLASSourceLink");
168 auto sl = state.getUncalibratedSourceLink().template get<ATLASSourceLink>();
169 assert( sl !=
nullptr );
170 measState.reset(sl->clone());
176 double nDoF = state.calibratedSize();
179 std::move(measState),
185 finalTrajectory->insert(finalTrajectory->begin(), perState);
189 const Acts::BoundTrackParameters actsPer(
track.referenceSurface().getSharedPtr(),
194 std::unique_ptr<Trk::TrackParameters> per = m_ATLASConverterTool->actsTrackParametersToTrkParameters(actsPer, tgContext);
195 std::bitset<Trk::TrackStateOnSurface::NumberOfTrackStateOnSurfaceTypes> typePattern;
201 finalTrajectory->insert(finalTrajectory->begin(), perState);
207 auto newtrack = std::make_unique<Trk::Track>(newInfo, std::move(finalTrajectory),
nullptr);
209 if (!newtrack->trackSummary())
211 newtrack->setTrackSummary(std::make_unique<Trk::TrackSummary>());
219 m_trkSummaryTool->updateTrackSummary(ctx, *newtrack,
true);
220 tracksContainer.push_back(std::move(newtrack));
223 return StatusCode::SUCCESS;
236 if (not pixcl or not pixelLinkAcc.
isAvailable(*pixcl))
238 ATH_MSG_DEBUG(
"no pixelClusterLink for cluster associated to measurement");
242 auto pix = *pixelLinkAcc(*pixcl);
243 if (m_RotCreatorTool.empty())
251 ATH_MSG_DEBUG(
"create InDet::PixelClusterOnTrack without correction");
252 return std::make_unique<InDet::PixelClusterOnTrack>(
pix,
256 pix->globalPosition(),
266 if (not stripcl or not stripLinkAcc.
isAvailable(*stripcl))
268 ATH_MSG_WARNING(
"no sctClusterLink for clusters associated to measurement");
272 auto sct = *stripLinkAcc(*stripcl);
273 if (m_RotCreatorTool.empty())
281 ATH_MSG_DEBUG(
"create InDet::SCT_ClusterOnTrack without correction");
282 return std::make_unique<InDet::SCT_ClusterOnTrack>(sct,
286 sct->globalPosition(),
293 ATH_MSG_WARNING(
"xAOD::UncalibratedMeasurement is neither xAOD::PixelCluster nor xAOD::StripCluster");
297 ATH_MSG_DEBUG(
"use Trk::RIO_OnTrackCreator::correct to create corrected Trk::RIO_OnTrack");
298 assert(!m_RotCreatorTool.empty());
299 assert(rio !=
nullptr);
300 return std::unique_ptr<Trk::MeasurementBase>(m_RotCreatorTool->correct(*rio, parm, Gaudi::Hive::currentContext()));