163 {
164
165
166
167
168
169
170
171
172 int imeas = 0;
174
175 for (
const auto *iterTSOS : *
track.trackStateOnSurfaces()) {
176
180 bool hasID = false;
181 if (iterTSOS->measurementOnTrack() != nullptr
182 && iterTSOS->measurementOnTrack()->associatedSurface().associatedDetectorElement() != nullptr
183 && iterTSOS->measurementOnTrack()->associatedSurface().associatedDetectorElement()->identify() != 0) {
184 id = iterTSOS->measurementOnTrack()->associatedSurface().associatedDetectorElement()->identify();
185 hasID = true;
186 } else if (iterTSOS->trackParameters() != nullptr
187 && iterTSOS->trackParameters()->associatedSurface().associatedDetectorElement() != nullptr
188 && iterTSOS->trackParameters()->associatedSurface().associatedDetectorElement()->identify() != 0) {
189 id = iterTSOS->trackParameters()->associatedSurface().associatedDetectorElement()->identify();
190 hasID = true;
191 }
192
194
195 mapOfHits.insert(std::pair<const Identifier, const Trk::TrackStateOnSurface*>(id,iterTSOS));
197 ++imeas;
198 if (!iterTSOS->trackParameters() &&
m_warning<10) {
200 ATH_MSG_WARNING(
"No track parameters available for state of type measurement");
203 }
204 }
205
206 if (
m_cosmic && !firstsipar && iterTSOS->trackParameters()) firstsipar=iterTSOS->trackParameters();
207 if (iterTSOS->trackParameters()) {
208 ATH_MSG_VERBOSE(
"TSOS pos: " << iterTSOS->trackParameters()->position()
209 <<
" r: " << sqrt(
pow(iterTSOS->trackParameters()->position().x(),2)
210 +
pow(iterTSOS->trackParameters()->position().y(),2))
211 << " Si measurement");
212 }
213 } else {
214 if (iterTSOS->trackParameters()) {
215 ATH_MSG_VERBOSE(
"TSOS pos: " << iterTSOS->trackParameters()->position()
216 <<
" r: " << sqrt(
pow(iterTSOS->trackParameters()->position().x(),2)
217 +
pow(iterTSOS->trackParameters()->position().y(),2))
218 << " TRT measurement");
219 }
220 }
221 }
222 }
223
224 ATH_MSG_DEBUG(
"Number of Si hits + outliers on original track: " << mapOfHits.size() <<
" , hits only: " << imeas);
227 mapOfHits.clear();
228 return false;
229 }
230
231
232 std::unique_ptr<const Trk::TrackParameters> startParameters;
233
234
235
237
238
239 const Trk::TrackingGeometry* trackingGeometry =
m_extrapolator->trackingGeometry();
240
241 const Trk::TrackingVolume* sctVolume = trackingGeometry->
trackingVolume(
"InDet::Detectors::SCT::Barrel");
242
243 const Trk::CylinderSurface* sctCylinder = nullptr;
246 sctCylinder= static_cast<const Trk::CylinderSurface*> (sctSurface);
247 }
248 if (!sctCylinder) {
249 ATH_MSG_ERROR (
"cast to CylinderSurface failed, should never happen !");
250 return false;
251 }
252
253
254 if (firstsipar) {
255
258 }
259
260
261 if (!startParameters) {
262 ATH_MSG_DEBUG(
"no start parameters on SCT cylinder, try TRT ec disc");
263
264
265 const Trk::DiscSurface* trtDisc=nullptr;
266
268 const Trk::TrackingVolume* trtVolume = trackingGeometry->
trackingVolume(
"InDet::Detectors::TRT::NegativeEndcap");
271 trtDisc = static_cast<const Trk::DiscSurface*> (trtSurface);
272 }
273 } else {
274 const Trk::TrackingVolume* trtVolume = trackingGeometry->
trackingVolume(
"InDet::Detectors::TRT::PositiveEndcap");
277 trtDisc = static_cast<const Trk::DiscSurface*> (trtSurface);
278 }
279 }
280
281 if (trtDisc) {
282
285 }
286 }
287 } else {
288
289 if (
track.perigeeParameters()) {
290 startParameters.reset(
track.perigeeParameters()->clone());
291 }
else if (
track.trackParameters()->front()) {
293
294 startParameters =
296 *(
track.trackParameters()->front()),
297 Trk::PerigeeSurface(),
299 false,
300 partHyp);
301 }
302 }
303
304 if (!startParameters) {
305 ATH_MSG_DEBUG(
"No start point obtained, hole search not performed.");
306 mapOfHits.clear();
307 return false;
308 }
309
310 bool foundFirst = false;
311
312
314 ATH_MSG_DEBUG(
"We are looking for an extended list of holes, so add eventual holes before first hits");
315 foundFirst = true;
316 }
317
319 const Trk::Surface* surf = nullptr;
320 bool hasID = false;
321
322
324
325
326
328 while (iterTSOS!=
track.trackStateOnSurfaces()->end()
331 ++iterTSOS;
332 }
333 }
334
336 <<
" r: " << sqrt(
pow(startParameters->position().x(),2)
337 +
pow(startParameters->position().y(),2)));
338
339 int measno=0;
340 int nmeas=(
int)
track.measurementsOnTrack()->size();
341 for (; iterTSOS!=
track.trackStateOnSurfaces()->
end();++iterTSOS) {
343
347 hasID=false;
348 per=nullptr;
353 }
354 }
355 if ((*iterTSOS)->measurementOnTrack() != nullptr
356 && (*iterTSOS)->measurementOnTrack()->associatedSurface().associatedDetectorElement() != nullptr
357 && (*iterTSOS)->measurementOnTrack()->associatedSurface().associatedDetectorElement()->identify() != 0) {
358 id = (*iterTSOS)->measurementOnTrack()->associatedSurface().associatedDetectorElement()->identify();
359 surf = &(*iterTSOS)->measurementOnTrack()->associatedSurface();
360 hasID = true;
361 } else if ((*iterTSOS)->trackParameters() != nullptr
362 && (*iterTSOS)->trackParameters()->associatedSurface().associatedDetectorElement() != nullptr
363 && (*iterTSOS)->trackParameters()->associatedSurface().associatedDetectorElement()->identify() != 0) {
364 id = (*iterTSOS)->trackParameters()->associatedSurface().associatedDetectorElement()->identify();
365 surf = &((*iterTSOS)->trackParameters()->associatedSurface());
366 hasID = true;
368 surf=&((*iterTSOS)->trackParameters()->associatedSurface());
369 }
370
371
373
375
376
377
378 if(std::abs(startParameters->position().z())>5000.){
379 ATH_MSG_DEBUG(
"Pathological track parameter well outside of tracking detector");
380 ATH_MSG_DEBUG(
"Propagator might have issue with this, discarding");
382 continue;
383 }
384
385 std::vector<std::unique_ptr<Trk::TrackParameters> > paramList =
387 *startParameters,
388 *surf,
390 false, partHyp);
391
392 if (paramList.empty()) {
394 continue;
395 }
396
397 ATH_MSG_VERBOSE(
"Number of parameters in this step: " << paramList.size());
398
399
400 for (std::unique_ptr<Trk::TrackParameters>& thisParameters : paramList) {
401 ATH_MSG_VERBOSE(
"extrapolated pos: " << thisParameters->position() <<
" r: " <<
402 sqrt(
pow(thisParameters->position().x(),2)+
pow(thisParameters->position().y(),2)));
403
404
405 Identifier id2;
406 if ((thisParameters->associatedSurface()).associatedDetectorElement() != nullptr &&
407 (thisParameters->associatedSurface()).associatedDetectorElement()->identify() != 0) {
408 id2 = (thisParameters->associatedSurface()).associatedDetectorElement()->identify();
409 } else {
412 startParameters = std::move(thisParameters);
413 }
414 continue;
415 }
416
417
419 ATH_MSG_VERBOSE(
"Surface is not Pixel or SCT, stop loop over parameters in this step");
420
421
423 startParameters = std::move(thisParameters);
424 }
426 else break;
427 }
428
429
430 std::map<const Identifier, const Trk::TrackStateOnSurface*>::iterator iTSOS = mapOfHits.find(id2);
431
432 if (iTSOS == mapOfHits.end() && !foundFirst) {
433 ATH_MSG_VERBOSE(
"Si surface before first Si measurement, skip it and continue");
434 continue;
435 }
436
437
438 if (iTSOS != mapOfHits.end()) {
441 foundFirst = true;
442 }
443
444
445 if (iTSOS->second->trackParameters()) {
447 startParameters.reset( iTSOS->second->trackParameters()->clone());
448 } else {
450 startParameters.reset(thisParameters->clone());
451 }
452 }
453
454
455 std::pair<const Trk::TrackParameters*,const bool> trackparampair (thisParameters.release(),true);
456 if (mapOfPredictions.insert(std::pair<const Identifier, std::pair<const Trk::TrackParameters*,const bool> >(id2,trackparampair)).second) {
458 } else {
460 delete trackparampair.first;
461 trackparampair.first=nullptr;
462 }
463 }
464
467 break;
468 }
469
470 }
471 }
473 if (measno==nmeas) break;
474 }
475
476
477
478
479
481 ATH_MSG_DEBUG(
"Search for dead modules after the last Si measurement");
483
484 auto cylinderBounds = std::make_shared<Trk::CylinderVolumeBounds>(560, 2750);
485
486 Trk::Volume* boundaryVol = new Trk::Volume(nullptr, cylinderBounds);
487
488
489 std::vector<std::unique_ptr<Trk::TrackParameters> > paramList =
491 *startParameters,
493 false, partHyp,
494 boundaryVol);
495 if (paramList.empty()) {
496 ATH_MSG_VERBOSE(
"--> Did not manage to extrapolate to another surface, break loop");
497 } else {
498 ATH_MSG_VERBOSE(
"Number of parameters in this step: " << paramList.size());
499
500
501 for (std::unique_ptr<Trk::TrackParameters>& thisParameter : paramList) {
502
503 Identifier id2;
504 if (thisParameter->associatedSurface().associatedDetectorElement() != nullptr &&
505 thisParameter->associatedSurface().associatedDetectorElement()->identify() != 0) {
506 id2 = thisParameter->associatedSurface().associatedDetectorElement()->identify();
507
508
510 ATH_MSG_VERBOSE(
"Surface is not Pixel or SCT, stop loop over parameters in this step");
511 break;
512 }
513
514
515
516 std::pair<Trk::TrackParameters*, const bool> trackparampair(
518 if (mapOfPredictions
519 .
insert(std::pair<
const Identifier, std::pair<const Trk::TrackParameters*, const bool>>(
520 id2, trackparampair))
521 .second) {
522 thisParameter.reset(trackparampair.first->clone());
524 } else {
525 thisParameter.reset(trackparampair.first);
527 }
528 } else {
530 }
531
532
533 startParameters = std::move(thisParameter);
534 }
535 }
536
537
538 delete boundaryVol;
539 boundaryVol = nullptr;
540
541 }
542
543 ATH_MSG_DEBUG(
"Number of Predictions found: " << mapOfPredictions.size());
544 return true;
545
546}
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
DataModel_detail::const_iterator< DataVector > const_iterator
virtual const Surface & associatedSurface() const override=0
Access to the Surface associated to the Parameters.
virtual constexpr SurfaceType type() const =0
Returns the Surface type to avoid dynamic casts.
@ Measurement
This is a measurement, and will at least contain a Trk::MeasurementBase.
@ Perigee
This represents a perigee, and so will contain a Perigee object only.
@ Outlier
This TSoS contains an outlier, that is, it contains a MeasurementBase/RIO_OnTrack which was not used ...
const TrackingVolume * trackingVolume(const std::string &name) const
return the tracking Volume by name, 0 if it doesn't exist
std::vector< std::shared_ptr< BoundarySurface< TrackingVolume > > > & boundarySurfaces()
Method to return the BoundarySurfaces.
ConcurrentBitset & insert(bit_t bit, bit_t new_nbits=0)
Set a bit to 1.
ParametersT< TrackParametersDim, Charged, PerigeeSurface > Perigee