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