92 {
93
94
95 std::map<size_t, std::vector<std::shared_ptr<const FPGATrackSimHit>>> strip_hits;
96 std::map<size_t, std::vector<std::shared_ptr<const FPGATrackSimHit>>> inner_spacepoints;
97 std::map<size_t, std::vector<std::shared_ptr<const FPGATrackSimHit>>> outer_spacepoints;
98
100
102
105 continue;
106 }
107 }
109 continue;
110 }
111
112
113 std::vector<std::shared_ptr<const FPGATrackSimHit>> strip_hits_in;
114 std::vector<std::shared_ptr<const FPGATrackSimHit>> spacepoints_in;
115 const std::vector<std::shared_ptr<const FPGATrackSimHit>> hits_in = initial_road.
getHits(layer);
116 for (auto& hit : hits_in) {
118 spacepoints_in.push_back(hit);
119 } else {
120 strip_hits_in.push_back(hit);
121 }
122 }
123
124
125 std::vector<std::shared_ptr<const FPGATrackSimHit>> strip_hits_out;
126 std::vector<std::shared_ptr<const FPGATrackSimHit>> spacepoints_out;
127 const std::vector<std::shared_ptr<const FPGATrackSimHit>> hits_out = initial_road.
getHits(layer + 1);
128 for (auto& hit : hits_out) {
130 spacepoints_out.push_back(hit);
131 } else {
132 strip_hits_out.push_back(hit);
133 }
134 }
135
136
137
138
139
140
141
142 std::vector<std::shared_ptr<const FPGATrackSimHit>> new_sp_in;
143 std::vector<std::shared_ptr<const FPGATrackSimHit>> new_sp_out;
144 unsigned num_unique =
findUnique(spacepoints_in, spacepoints_out, strip_hits_in, strip_hits_out, new_sp_in, new_sp_out);
145
146 if (num_unique > 0) {
147
149
150
151 ATH_MSG_DEBUG(
"Found inconsistent number of spacepoints in road with x = " << initial_road.
getXBin() <<
", y = " << initial_road.
getYBin() <<
": spacepoints_in = " << spacepoints_in <<
", spacepoints_out = " << spacepoints_out);
152
153
154 spacepoints_in = std::move(new_sp_in);
155 spacepoints_out = std::move(new_sp_out);
156
157
158 std::vector<std::shared_ptr<const FPGATrackSimHit>> new_all_in = spacepoints_in;
159 new_all_in.insert(std::end(new_all_in), std::begin(strip_hits_in), std::end(strip_hits_in));
160 initial_road.
setHits(layer, std::move(new_all_in));
161
162 std::vector<std::shared_ptr<const FPGATrackSimHit>> new_all_out = spacepoints_out;
163 new_all_out.insert(std::end(new_all_out), std::begin(strip_hits_out), std::end(strip_hits_out));
164 initial_road.
setHits(layer + 1, std::move(new_all_out));
165 }
166
167
168 inner_spacepoints.emplace(layer, spacepoints_in);
169 outer_spacepoints.emplace(layer+1, spacepoints_out);
170 if (spacepoints_in.size() != spacepoints_out.size()) {
171 ATH_MSG_WARNING(
"Handling of unique spacepoints failed, " << spacepoints_in.size() <<
" != " << spacepoints_out.size());
172 return false;
173 }
174
175
177 strip_hits_in.clear();
178 strip_hits_out.clear();
179 }
180 strip_hits.emplace(layer, strip_hits_in);
181 strip_hits.emplace(layer + 1, strip_hits_out);
182
184 }
185
186
187 std::vector<FPGATrackSimRoad> working_roads;
188 FPGATrackSimRoad new_road(initial_road);
189 working_roads.push_back(new_road);
190
191
192 for (auto& entry : inner_spacepoints) {
194
195
196 std::vector<std::shared_ptr<const FPGATrackSimHit>> strip_hits_in = strip_hits[
layer];
197 std::vector<std::shared_ptr<const FPGATrackSimHit>> strip_hits_out = strip_hits[
layer + 1];
198
199 ATH_MSG_DEBUG(
"Road (x = " << new_road.getXBin() <<
", y = " << new_road.getYBin() <<
") has merged spacepoints: " <<
entry.second.size() <<
", unpaired inner hits: " << strip_hits_in.size() <<
", unpaired outer hits: " << strip_hits_out.size());
200
201
202
203 if ((strip_hits_in.size() > 0 &&
entry.second.size() > 0) ||
204 (strip_hits_out.size() > 0 &&
entry.second.size() > 0)) {
205
206
207 int wildcard_layer = -1;
208 if (strip_hits_in.size() == 0 || strip_hits_out.size() == 0) {
209 std::unique_ptr<FPGATrackSimHit> wcHit = std::make_unique<FPGATrackSimHit>();
212 if (strip_hits_in.size() == 0) {
213 wildcard_layer =
layer;
214 wcHit->setLayer(wildcard_layer);
215 strip_hits_in.push_back(std::move(wcHit));
216 } else {
217 wildcard_layer =
layer + 1;
218 wcHit->setLayer(wildcard_layer);
219 strip_hits_out.push_back(std::move(wcHit));
220 }
221 }
222
223
224
225 unsigned num_working = working_roads.size();
226 for (
unsigned i = 0;
i < num_working;
i++) {
227
228 FPGATrackSimRoad strips_only(working_roads[i]);
229 FPGATrackSimRoad spacepoints_only(working_roads[i]);
230
231
232 strips_only.setHits(layer, std::vector<std::shared_ptr<const FPGATrackSimHit>>(strip_hits_in));
233 strips_only.setHits(layer + 1, std::vector<std::shared_ptr<const FPGATrackSimHit>>(strip_hits_out));
234 spacepoints_only.setHits(layer, std::vector<std::shared_ptr<const FPGATrackSimHit>>(
entry.second));
235 spacepoints_only.setHits(layer + 1, std::vector<std::shared_ptr<const FPGATrackSimHit>>(outer_spacepoints[layer + 1]));
236
237
238
239 if (wildcard_layer != -1) {
241 wc_layers |= (0x1 << wildcard_layer);
242 strips_only.setWCLayers(wc_layers);
243
245 hit_layers -= (0x1 << wildcard_layer);
246 if (strips_only.getHitLayers() < (unsigned)(0x1 << wildcard_layer)) {
247 ATH_MSG_WARNING(
"Found weird problem: current layers is " << strips_only.getHitLayers() <<
", adding wildcard in layer " << wildcard_layer);
248 }
249 strips_only.setHitLayers(hit_layers);
250 }
251
252
253
254
255 working_roads[
i] = std::move(spacepoints_only);
257 working_roads.push_back(std::move(strips_only));
258 }
259 }
260 }
261 }
262
263 ATH_MSG_DEBUG(
"Created " << working_roads.size() <<
" new roads in spacepoint road filter.");
264
265
266 for (auto road : working_roads) {
267 unsigned numSpacePlusPixel =
setSector(road);
268 ATH_MSG_DEBUG(
"This road has sector = " << road.getSector() <<
" and q/pt = " << road.getX() <<
", x = " << road.getY());
269 ATH_MSG_DEBUG(
"numSpacePlusPixel = " << numSpacePlusPixel <<
", nhitlayers = " << road.getNHitLayers());
270
271
273 continue;
274 }
275
276
278 continue;
279 }
280
282 }
283
285}
#define ATH_MSG_WARNING(x)
void setHits(std::vector< std::vector< std::shared_ptr< const FPGATrackSimHit > > > &&hits)