403 if (not fitResult.ok())
406 std::unique_ptr<Trk::Track> newtrack =
nullptr;
408 const auto& acts_track = fitResult.value();
409 auto finalTrajectory = std::make_unique<Trk::TrackStates>();
411 int numberOfDeadPixel = 0;
412 int numberOfDeadSCT = 0;
414 std::vector<std::unique_ptr<const Acts::BoundTrackParameters>> actsSmoothedParam;
416 tracks.trackStateContainer().visitBackwards(acts_track.tipIndex(),
417 [&] (
const auto &state) ->
void
420 auto flag = state.typeFlags();
421 const auto* associatedDetEl = state.referenceSurface().associatedDetectorElement();
422 if (not associatedDetEl)
425 const auto* actsElement = dynamic_cast<const ActsDetectorElement*>(associatedDetEl);
429 const auto* upstreamDetEl = actsElement->upstreamDetectorElement();
430 if (not upstreamDetEl)
433 ATH_MSG_VERBOSE(
"Try casting to TRT for if");
434 if (dynamic_cast<const InDetDD::TRT_BaseElement*>(upstreamDetEl))
437 const auto* trkDetElem = dynamic_cast<const Trk::TrkDetElementBase*>(upstreamDetEl);
441 ATH_MSG_VERBOSE(
"trkDetElem type: " << static_cast<std::underlying_type_t<Trk::DetectorElemType>>(trkDetElem->detectorType()));
443 ATH_MSG_VERBOSE(
"Try casting to SiDetectorElement");
444 const auto* detElem = dynamic_cast<const InDetDD::SiDetectorElement*>(upstreamDetEl);
447 ATH_MSG_VERBOSE(
"detElem = " << detElem);
450 std::bitset<Trk::TrackStateOnSurface::NumberOfTrackStateOnSurfaceTypes> typePattern;
451 std::unique_ptr<Trk::TrackParameters> parm;
454 if (flag.test(Acts::TrackStateFlag::HoleFlag)){
455 ATH_MSG_VERBOSE(
"State is a hole (no associated measurement), use predicted parameters");
456 const Acts::BoundTrackParameters actsParam(state.referenceSurface().getSharedPtr(),
458 state.predictedCovariance(),
459 acts_track.particleHypothesis());
460 parm = m_ATLASConverterTool->actsTrackParametersToTrkParameters(actsParam, tgContext);
461 auto boundaryCheck = m_boundaryCheckTool->boundaryCheck(*parm);
463 ATH_MSG_VERBOSE(
"Check if this is a hole, a dead sensors or a state outside the sensor boundary");
464 if(boundaryCheck == Trk::BoundaryCheckResult::DeadElement){
465 if (detElem->isPixel()) {
468 else if (detElem->isSCT()) {
473 } else if (boundaryCheck != Trk::BoundaryCheckResult::Candidate){
477 typePattern.set(Trk::TrackStateOnSurface::Hole);
480 else if (
flag.test(Acts::TrackStateFlag::OutlierFlag) or not state.hasSmoothed()) {
481 ATH_MSG_VERBOSE(
"The state was tagged as an outlier or was missed in the reverse filtering, use filtered parameters");
482 const Acts::BoundTrackParameters actsParam(state.referenceSurface().getSharedPtr(),
484 state.filteredCovariance(),
485 acts_track.particleHypothesis());
486 parm = m_ATLASConverterTool->actsTrackParametersToTrkParameters(actsParam, tgContext);
487 typePattern.set(Trk::TrackStateOnSurface::Outlier);
491 ATH_MSG_VERBOSE(
"The state is a measurement state, use smoothed parameters");
493 const Acts::BoundTrackParameters actsParam(state.referenceSurface().getSharedPtr(),
495 state.smoothedCovariance(),
496 acts_track.particleHypothesis());
498 actsSmoothedParam.push_back(std::make_unique<const Acts::BoundTrackParameters>(Acts::BoundTrackParameters(actsParam)));
499 parm = m_ATLASConverterTool->actsTrackParametersToTrkParameters(actsParam, tgContext);
500 typePattern.set(Trk::TrackStateOnSurface::Measurement);
503 std::unique_ptr<Trk::MeasurementBase> measState;
504 if (state.hasUncalibratedSourceLink()){
505 auto sl = state.getUncalibratedSourceLink().template get<ATLASSourceLink>();
507 measState = sl->uniqueClone();
509 double nDoF = state.calibratedSize();
514 ATH_MSG_VERBOSE(
"State succesfully creates, adding it to the trajectory");
515 finalTrajectory->insert(finalTrajectory->begin(), perState);
520 const Acts::BoundTrackParameters actsPer(acts_track.referenceSurface().getSharedPtr(),
521 acts_track.parameters(),
522 acts_track.covariance(),
523 acts_track.particleHypothesis());
524 std::unique_ptr<Trk::TrackParameters> per =
m_ATLASConverterTool->actsTrackParametersToTrkParameters(actsPer, tgContext);
525 std::bitset<Trk::TrackStateOnSurface::NumberOfTrackStateOnSurfaceTypes> typePattern;
528 if (perState) finalTrajectory->insert(finalTrajectory->begin(), perState);
533 newtrack = std::make_unique<Trk::Track>(newInfo, std::move(finalTrajectory),
nullptr);