654 if (not fitResult.ok()) {
658 std::unique_ptr<Trk::Track> newtrack =
nullptr;
661 const auto& acts_track = fitResult.value();
662 auto finalTrajectory = std::make_unique<Trk::TrackStates>();
665 int numberOfDeadPixel = 0;
666 int numberOfDeadSCT = 0;
668 std::vector<std::unique_ptr<const Acts::BoundTrackParameters>>
671 tracks.trackStateContainer().visitBackwards(
672 acts_track.tipIndex(), [&](
const auto& state) ->
void {
675 auto flag = state.typeFlags();
676 const auto* associatedDetEl =
677 state.referenceSurface().associatedDetectorElement();
678 if (not associatedDetEl) {
682 const auto* actsElement =
684 if (not actsElement) {
688 const auto* upstreamDetEl = actsElement->upstreamDetectorElement();
689 if (not upstreamDetEl) {
697 const auto* trkDetElem =
699 if (not trkDetElem) {
705 <<
static_cast<std::underlying_type_t<Trk::DetectorElemType>
>(
706 trkDetElem->detectorType()));
709 const auto* detElem =
717 std::bitset<Trk::TrackStateOnSurface::NumberOfTrackStateOnSurfaceTypes>
719 std::unique_ptr<Trk::TrackParameters> parm;
722 if (
flag.test(Acts::TrackStateFlag::HoleFlag)) {
724 const Acts::BoundTrackParameters actsParam(
725 state.referenceSurface().getSharedPtr(), state.smoothed(),
726 state.smoothedCovariance(), acts_track.particleHypothesis());
728 actsParam, tgContext);
733 "Check if this is a hole, a dead sensors or a state outside the "
736 if (detElem->isPixel()) {
738 }
else if (detElem->isSCT()) {
748 }
else if (
flag.test(Acts::TrackStateFlag::OutlierFlag)) {
750 const Acts::BoundTrackParameters actsParam(
751 state.referenceSurface().getSharedPtr(), state.smoothed(),
752 state.smoothedCovariance(), acts_track.particleHypothesis());
754 actsParam, tgContext);
759 const Acts::BoundTrackParameters actsParam(
760 state.referenceSurface().getSharedPtr(), state.smoothed(),
761 state.smoothedCovariance(), acts_track.particleHypothesis());
763 actsSmoothedParam.push_back(
764 std::make_unique<const Acts::BoundTrackParameters>(
765 Acts::BoundTrackParameters(actsParam)));
767 actsParam, tgContext);
771 std::unique_ptr<Trk::MeasurementBase> measState;
772 if (state.hasUncalibratedSourceLink() && !SourceLinkType) {
774 state.getUncalibratedSourceLink().template get<ATLASSourceLink>();
777 }
else if (state.hasUncalibratedSourceLink() && SourceLinkType) {
780 auto sl = state.getUncalibratedSourceLink()
781 .template get<PRDSourceLinkGX2F>()
785 const IdentifierHash idHash = sl->detectorElement()->identifyHash();
786 int dim = state.calibratedSize();
787 std::unique_ptr<Trk::RIO_OnTrack> rot;
795 rot = std::make_unique<InDet::SCT_ClusterOnTrack>(
798 state.template calibrated<1>()[0],
Trk::loc1)),
799 state.template calibratedCovariance<1>(), idHash);
800 }
else if (
dim == 2) {
807 "Dimension is 2 but we need SCT_Cluster for this "
811 rot = std::make_unique<InDet::SCT_ClusterOnTrack>(
814 state.template calibrated<1>()[0],
Trk::loc1)),
815 state.template calibratedCovariance<1>(), idHash);
817 rot = std::make_unique<InDet::PixelClusterOnTrack>(
820 state.template calibratedCovariance<2>(), idHash);
823 throw std::domain_error(
"Cannot handle measurement dim>2");
828 double nDoF = state.calibratedSize();
832 std::move(parm),
nullptr, typePattern);
836 "State successfully created, adding it to the trajectory");
837 finalTrajectory->insert(finalTrajectory->begin(), perState);
842 const Acts::BoundTrackParameters actsPer(
843 acts_track.referenceSurface().getSharedPtr(), acts_track.parameters(),
844 acts_track.covariance(), acts_track.particleHypothesis());
845 std::unique_ptr<Trk::TrackParameters> per =
848 std::bitset<Trk::TrackStateOnSurface::NumberOfTrackStateOnSurfaceTypes>
852 nullptr, std::move(per),
nullptr, typePattern);
854 finalTrajectory->insert(finalTrajectory->begin(), perState);
862 newtrack = std::make_unique<Trk::Track>(newInfo, std::move(finalTrajectory),