30 {
31 ATH_MSG_DEBUG(
"Building track from candidate with " << candidate.layerIntersections.size() <<
" layers ");
32
33 std::vector<MuonLayerIntersection> layerIntersections = candidate.layerIntersections;
35 [](const MuonLayerIntersection& lay1, const MuonLayerIntersection& lay2) {
36 auto getDistance = [](const MuonLayerIntersection& layerIntersection) {
37 if (layerIntersection.intersection.trackParameters.get() == nullptr) return 1e9;
38 return layerIntersection.intersection.trackParameters->position().mag();
39 };
41 });
42
43
44 std::vector<const Trk::MeasurementBase*> measurements;
45 int intersec = 0;
47 for (const MuonLayerIntersection& layerIntersection : layerIntersections) {
48 intersec++;
50 << layerIntersection.intersection.trackParameters->position().perp() << " z "
51 << layerIntersection.intersection.trackParameters->position().z() << " distance to IP "
52 << layerIntersection.intersection.trackParameters->position().mag());
53 ATH_MSG_VERBOSE(
" segment surface center perp " << layerIntersection.segment->associatedSurface().center().perp() <<
" z "
54 << layerIntersection.segment->associatedSurface().center().z() << " nr of msts "
55 << layerIntersection.segment->containedMeasurements().size());
57
58
59
60
61
62 std::vector<const Trk::MeasurementBase*> containedMeasurements = layerIntersection.segment->containedMeasurements();
63 for (const Trk::MeasurementBase* mit : containedMeasurements) {
64
66 const Trk::RIO_OnTrack* rio = dynamic_cast<const Trk::RIO_OnTrack*>(mit);
67 if (rio)
69 else {
70 const Trk::CompetingRIOsOnTrack* crio = dynamic_cast<const Trk::CompetingRIOsOnTrack*>(mit);
71 if (crio)
73 else
74 continue;
75 }
76
77 if (!id.is_valid()) continue;
78
80
82 isEndcap = true;
83 } else {
85 }
87
90 } else {
91 isLarge = true;
92 }
93 }
94
96
99 }
100
101 measurements.insert(measurements.end(), containedMeasurements.begin(), containedMeasurements.end());
102 }
103
104
105
106 if (candidate.layerIntersections.size() == 2 &&
isSmall && isLarge) {
109 const Muon::MuonSegment* seg1 = candidate.layerIntersections.at(0).segment.get();
110 const Muon::MuonSegment* seg2 = candidate.layerIntersections.at(1).segment.get();
112 seg2 = candidate.layerIntersections.at(0).segment.get();
113 seg1 = candidate.layerIntersections.at(1).segment.get();
114 }
121 break;
122 }
123 }
124
125 if (!found) break;
126 }
127 if (found) {
128 ATH_MSG_DEBUG(
"S/L overlap where one segment contains the other, don't use");
129 return std::unique_ptr<Trk::Track>();
130 }
131 }
132 }
133
134
135
136 bool reorderAllMeasurements = false;
137 if (
isSmall && isLarge) reorderAllMeasurements =
true;
138 if (isEndcap &&
isBarrel) reorderAllMeasurements =
false;
139
141
144 }
145
147
148 ATH_MSG_DEBUG(
"Extracted hits from candidate: " << measurements.size());
149 std::unique_ptr<Trk::Track> refittedTrack{
m_trackFitter->indetExtension(ctx, idTrack, measurements)};
150 if (refittedTrack) {
152 }
153 return refittedTrack;
154 }
#define ATH_MSG_VERBOSE(x)
virtual const RIO_OnTrack & rioOnTrack(unsigned int) const =0
returns the RIO_OnTrack (also known as ROT) objects depending on the integer.
Identifier identify() const
return the identifier -extends MeasurementBase
const std::vector< const Trk::MeasurementBase * > & containedMeasurements() const
returns the vector of Trk::MeasurementBase objects
bool isSmall(const ChIndex index)
Returns true if the chamber index is in a small sector.
bool isBarrel(const ChIndex index)
Returns true if the chamber index points to a barrel chamber.
double getDistance(const xAOD::Vertex *vtx1, const xAOD::Vertex *vtx2)
void stable_sort(DataModel_detail::iterator< DVL > beg, DataModel_detail::iterator< DVL > end)
Specialization of stable_sort for DataVector/List.