707 {
708
709 std::vector<std::unique_ptr<const Trk::TrackStateOnSurface>>
states;
710 std::set<IdentifierHash> newMdtHashes;
711 std::set<IdentifierHash> newRpcHashes;
712 std::set<IdentifierHash> newTgcHashes;
713 std::set<IdentifierHash> newCscHashes;
714
715 std::set<IdentifierHash> newMMHashes;
716 std::set<IdentifierHash> newsTgcHashes;
717 if (addMdt) {
718 ATH_MSG_DEBUG(
"Adding Missing MDT chambers: regions " <<
data.mdtPerStation.size());
719 std::vector<const MdtPrepDataCollection*> newmcols;
720 for (
const auto& chit :
data.mdtPerStation) {
722 std::vector<const MdtPrepDataCollection*>
cols;
724 std::map<int, std::vector<const MdtPrepData*>> mdtPrds;
725 std::unique_ptr<const Trk::TrackParameters> exParsFirst;
727 std::unique_ptr<const Trk::TrackParameters> exPars{
reachableDetEl(ctx, track, *mit->front()->detectorElement())};
728 if (exPars) {
731 << " sector " << sector);
732 newmcols.emplace_back(mit);
733 std::vector<const MdtPrepData*>& col = mdtPrds[sector];
734 col.insert(col.end(), mit->begin(), mit->end());
735 if (!exParsFirst) exParsFirst.swap(exPars);
736
737 } else {
739 << mit->identifyHash());
740 }
741 }
742 std::vector<const MdtPrepData*>* prds = nullptr;
743 std::map<int, std::vector<const MdtPrepData*>>::iterator sectorIt = mdtPrds.begin();
744 if (mdtPrds.empty()) {
746 } else if (mdtPrds.size() == 1) {
747 prds = §orIt->second;
748 } else {
749 IMuonHitSummaryTool::CompactSummary hitSummary =
m_hitSummaryTool->summary(track);
750 ATH_MSG_VERBOSE(
"Multiple sectors selected, using main sector: " << hitSummary.mainSector);
751 std::map<int, std::vector<const MdtPrepData*>>::iterator
pos = mdtPrds.find(hitSummary.mainSector);
752 if (pos != mdtPrds.end())
754 else {
755 ATH_MSG_DEBUG(
"Failed to find prds in main sector: " << hitSummary.mainSector);
756 }
757 }
758 if (prds && exParsFirst) {
759 std::unique_ptr<Trk::SegmentCollection> segments =
m_seededSegmentFinder->find(ctx, *exParsFirst, *prds);
760 if (segments) {
761 if (!segments->empty())
ATH_MSG_DEBUG(
"found segments " << segments->size());
762
764 std::unique_ptr<const Trk::TrackParameters> bestSegmentPars;
765 for (Trk::Segment* tseg : *segments) {
767
772 continue;
773 } else {
775 }
776 std::unique_ptr<const Trk::TrackParameters> segPars{
m_extrapolator->extrapolateDirectly(
778 if (segPars) {
780 Trk::LocalDirection
locDir;
784 if (std::abs(dangleYZ) < 0.05) {
785 bestSegment = mseg;
786 bestSegmentPars.swap(segPars);
787 }
788 } else {
790 }
791 }
792 if (bestSegment) {
794 std::unique_ptr<Trk::TrackParameters> hitPars{
m_extrapolator->extrapolateDirectly(
796 if (hitPars) {
797 std::bitset<Trk::TrackStateOnSurface::NumberOfTrackStateOnSurfaceTypes> typePattern;
799 Trk::TrackStateOnSurface* tsos =
800 new Trk::TrackStateOnSurface(hit->uniqueClone(), std::move(hitPars), nullptr, typePattern);
801 states.emplace_back(tsos);
802 const MdtDriftCircleOnTrack* mdt = dynamic_cast<const MdtDriftCircleOnTrack*>(hit);
804 } else {
806 }
807 }
808 }
809 }
810 }
811 }
812 data.mdtCols = std::move(newmcols);
813 } else {
814 unsigned int nstates =
states.size();
815 {
817 std::vector<const RpcPrepDataCollection*> newtcols;
819 std::unique_ptr<const Trk::TrackParameters> exPars{
reachableDetEl(ctx, track, *(rit)->front()->detectorElement())};
820 if (exPars) {
821 newtcols.emplace_back(rit);
822 Identifier detElId =
m_idHelperSvc->detElId(rit->identify());
823 std::set<Identifier> layIds;
825 if (
states.size() != nstates) {
827 newRpcHashes.insert(rit->identifyHash());
828 }
829 }
830 }
831 data.rpcCols = std::move(newtcols);
832 }
833 {
835 std::vector<const TgcPrepDataCollection*> newtcols;
837 std::unique_ptr<const Trk::TrackParameters> exPars{
reachableDetEl(ctx, track, *(tgcit)->front()->detectorElement())};
838 if (exPars) {
839 newtcols.emplace_back(tgcit);
840 Identifier detElId =
m_idHelperSvc->detElId(tgcit->identify());
841 std::set<Identifier> layIds;
843 if (
states.size() != nstates) {
845 newTgcHashes.insert(tgcit->identifyHash());
846 }
847 }
848 }
849 data.tgcCols = std::move(newtcols);
850 }
851
853 std::vector<const CscPrepDataCollection*> newccols;
855 std::unique_ptr<const Trk::TrackParameters> exPars{
reachableDetEl(ctx, track, *(cit)->front()->detectorElement())};
856 if (exPars) {
857 newccols.push_back(cit);
859 std::set<Identifier> layIds;
861 if (
states.size() != nstates) {
864 }
865 }
866 }
867 data.cscCols = std::move(newccols);
868
872 std::vector<const sTgcPrepDataCollection*> newstcols;
873 ATH_MSG_DEBUG(
" extractsTgcPrdCols data.stgcCols.size() " <<
data.stgcCols.size());
875 std::unique_ptr<const Trk::TrackParameters> exPars{
reachableDetEl(ctx, track, *(stgcit)->front()->detectorElement())};
876 if (exPars) {
877 newstcols.push_back(stgcit);
878 Identifier detElId =
m_idHelperSvc->detElId(stgcit->identify());
879 std::set<Identifier> layIds;
882 if (
states.size() != nstates) {
884 newsTgcHashes.insert(stgcit->identifyHash());
885 }
886 }
887 }
888 data.stgcCols = std::move(newstcols);
889 }
890
894 std::vector<const MMPrepDataCollection*> newmcols;
896 std::unique_ptr<const Trk::TrackParameters> exPars{
reachableDetEl(ctx, track, *mit->front()->detectorElement())};
897 if (exPars) {
898 newmcols.push_back(mit);
899 Identifier detElId =
m_idHelperSvc->detElId(mit->identify());
900 std::set<Identifier> layIds;
903 if (
states.size() != nstates) {
905 newMMHashes.insert(mit->identifyHash());
906 }
907 }
908 }
909 data.mmCols = std::move(newmcols);
910 }
911 }
914
916 if (!oldStates) {
918 return nullptr;
919 }
920
922 for (
const Trk::TrackStateOnSurface* tsit : *oldStates)
states.emplace_back(tsit->clone());
923
926 auto trackStateOnSurfaces = std::make_unique<Trk::TrackStates>();
927 trackStateOnSurfaces->reserve(
states.size());
928 for (std::unique_ptr<const Trk::TrackStateOnSurface>& sorted : states) { trackStateOnSurfaces->push_back(
sorted.release()); }
930 std::unique_ptr<Trk::Track> newTrack = std::make_unique<Trk::Track>(
track.info(), std::move(trackStateOnSurfaces),
931 track.fitQuality() ?
track.fitQuality()->uniqueClone() :
nullptr);
932 std::unique_ptr<Trk::Track> refittedTrack;
935 else
937 if (refittedTrack) {
939
940
941 data.mdtTrack.insert(newMdtHashes.begin(), newMdtHashes.end());
942 data.rpcTrack.insert(newRpcHashes.begin(), newRpcHashes.end());
943 data.tgcTrack.insert(newTgcHashes.begin(), newTgcHashes.end());
944 data.cscTrack.insert(newCscHashes.begin(), newCscHashes.end());
945
946 data.stgcTrack.insert(newsTgcHashes.begin(), newsTgcHashes.end());
947 data.mmTrack.insert(newMMHashes.begin(), newMMHashes.end());
948 }
949 return refittedTrack;
950 }
951 return nullptr;
952 }
#define ATH_MSG_WARNING(x)
char data[hepevt_bytes_allocation_ATLAS]
MuonSegment_v1 MuonSegment
Reference the current persistent version:
size_type size() const noexcept
Returns the number of elements in the collection.
IdentifierHash collectionHash() const
Returns the hashID of the PRD collection.
const Trk::LocalDirection & localDirection() const
local direction
virtual const Trk::PlaneSurface & associatedSurface() const override final
returns the surface for the local to global transformation
virtual Identifier identify() const override final
virtual IdentifierHash identifyHash() const override final
double angleYZ() const
access method for angle of local YZ projection
const LocalParameters & localParameters() const
Interface method to get the LocalParameters.
void globalToLocalDirection(const Amg::Vector3D &glodir, Trk::LocalDirection &locdir) const
This method transforms the global direction to a local direction wrt the plane.
const std::vector< const Trk::MeasurementBase * > & containedMeasurements() const
returns the vector of Trk::MeasurementBase objects
@ Measurement
This is a measurement, and will at least contain a Trk::MeasurementBase.
std::vector< typename R::value_type > sorted(const R &r, PROJ proj={})
Helper function to create a sorted vector from an unsorted range.
const std::string & chName(ChIndex index)
convert ChIndex into a string
MuonPrepDataCollection< CscPrepData > CscPrepDataCollection
MuonPrepDataCollection< TgcPrepData > TgcPrepDataCollection
MuonPrepDataCollection< MMPrepData > MMPrepDataCollection
MuonPrepDataCollection< MdtPrepData > MdtPrepDataCollection
MuonPrepDataCollection< RpcPrepData > RpcPrepDataCollection
MuonPrepDataCollection< sTgcPrepData > sTgcPrepDataCollection
DataVector< const Trk::TrackStateOnSurface > TrackStates
void stable_sort(DataModel_detail::iterator< DVL > beg, DataModel_detail::iterator< DVL > end)
Specialization of stable_sort for DataVector/List.