170 {
171
172
173
174
175
176
177
178
179 int imeas = 0;
181
182 for (
const auto *iterTSOS : *
track.trackStateOnSurfaces()) {
183
187 bool hasID = false;
188 if (iterTSOS->measurementOnTrack() != nullptr
189 && iterTSOS->measurementOnTrack()->associatedSurface().associatedDetectorElement() != nullptr
190 && iterTSOS->measurementOnTrack()->associatedSurface().associatedDetectorElement()->identify() != 0) {
191 id = iterTSOS->measurementOnTrack()->associatedSurface().associatedDetectorElement()->identify();
192 hasID = true;
193 } else if (iterTSOS->trackParameters() != nullptr
194 && iterTSOS->trackParameters()->associatedSurface().associatedDetectorElement() != nullptr
195 && iterTSOS->trackParameters()->associatedSurface().associatedDetectorElement()->identify() != 0) {
196 id = iterTSOS->trackParameters()->associatedSurface().associatedDetectorElement()->identify();
197 hasID = true;
198 }
199
201
202 mapOfHits.insert(std::pair<const Identifier, const Trk::TrackStateOnSurface*>(id,iterTSOS));
204 ++imeas;
205 if (!iterTSOS->trackParameters() &&
m_warning<10) {
207 ATH_MSG_WARNING(
"No track parameters available for state of type measurement");
210 }
211 }
212
213 if (
m_cosmic && !firstsipar && iterTSOS->trackParameters()) firstsipar=iterTSOS->trackParameters();
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 << " Si measurement");
219 }
220 } else {
221 if (iterTSOS->trackParameters()) {
222 ATH_MSG_VERBOSE(
"TSOS pos: " << iterTSOS->trackParameters()->position()
223 <<
" r: " << sqrt(
pow(iterTSOS->trackParameters()->position().x(),2)
224 +
pow(iterTSOS->trackParameters()->position().y(),2))
225 << " TRT measurement");
226 }
227 }
228 }
229 }
230
231 ATH_MSG_DEBUG(
"Number of Si hits + outliers on original track: " << mapOfHits.size() <<
" , hits only: " << imeas);
234 mapOfHits.clear();
235 return false;
236 }
237
238
239 std::unique_ptr<const Trk::TrackParameters> startParameters;
240
241
242
244
245
246 const Trk::TrackingGeometry* trackingGeometry =
m_extrapolator->trackingGeometry();
247
248 const Trk::TrackingVolume* sctVolume = trackingGeometry->
trackingVolume(
"InDet::Detectors::SCT::Barrel");
249
250 const Trk::CylinderSurface* sctCylinder = nullptr;
253 sctCylinder= static_cast<const Trk::CylinderSurface*> (sctSurface);
254 }
255 if (!sctCylinder) {
256 ATH_MSG_ERROR (
"cast to CylinderSurface failed, should never happen !");
257 return false;
258 }
259
260
261 if (firstsipar) {
262
265 }
266
267
268 if (!startParameters) {
269 ATH_MSG_DEBUG(
"no start parameters on SCT cylinder, try TRT ec disc");
270
271
272 const Trk::DiscSurface* trtDisc=nullptr;
273
275 const Trk::TrackingVolume* trtVolume = trackingGeometry->
trackingVolume(
"InDet::Detectors::TRT::NegativeEndcap");
278 trtDisc = static_cast<const Trk::DiscSurface*> (trtSurface);
279 }
280 } else {
281 const Trk::TrackingVolume* trtVolume = trackingGeometry->
trackingVolume(
"InDet::Detectors::TRT::PositiveEndcap");
284 trtDisc = static_cast<const Trk::DiscSurface*> (trtSurface);
285 }
286 }
287
288 if (trtDisc) {
289
292 }
293 }
294 } else {
295
296 if (
track.perigeeParameters()) {
297 startParameters.reset(
track.perigeeParameters()->clone());
298 }
else if (
track.trackParameters()->front()) {
300
301 startParameters =
303 *(
track.trackParameters()->front()),
304 Trk::PerigeeSurface(),
306 false,
307 partHyp);
308 }
309 }
310
311 if (!startParameters) {
312 ATH_MSG_DEBUG(
"No start point obtained, hole search not performed.");
313 mapOfHits.clear();
314 return false;
315 }
316
317 bool foundFirst = false;
318
319
321 ATH_MSG_DEBUG(
"We are looking for an extended list of holes, so add eventual holes before first hits");
322 foundFirst = true;
323 }
324
326 const Trk::Surface* surf = nullptr;
327 bool hasID = false;
328
329
331
332
333
335 while (iterTSOS!=
track.trackStateOnSurfaces()->end()
338 ++iterTSOS;
339 }
340 }
341
343 <<
" r: " << sqrt(
pow(startParameters->position().x(),2)
344 +
pow(startParameters->position().y(),2)));
345
346 int measno=0;
347 int nmeas=(
int)
track.measurementsOnTrack()->size();
348 for (; iterTSOS!=
track.trackStateOnSurfaces()->
end();++iterTSOS) {
350
354 hasID=false;
355 per=nullptr;
360 }
361 }
362 if ((*iterTSOS)->measurementOnTrack() != nullptr
363 && (*iterTSOS)->measurementOnTrack()->associatedSurface().associatedDetectorElement() != nullptr
364 && (*iterTSOS)->measurementOnTrack()->associatedSurface().associatedDetectorElement()->identify() != 0) {
365 id = (*iterTSOS)->measurementOnTrack()->associatedSurface().associatedDetectorElement()->identify();
366 surf = &(*iterTSOS)->measurementOnTrack()->associatedSurface();
367 hasID = true;
368 } else if ((*iterTSOS)->trackParameters() != nullptr
369 && (*iterTSOS)->trackParameters()->associatedSurface().associatedDetectorElement() != nullptr
370 && (*iterTSOS)->trackParameters()->associatedSurface().associatedDetectorElement()->identify() != 0) {
371 id = (*iterTSOS)->trackParameters()->associatedSurface().associatedDetectorElement()->identify();
372 surf = &((*iterTSOS)->trackParameters()->associatedSurface());
373 hasID = true;
375 surf=&((*iterTSOS)->trackParameters()->associatedSurface());
376 }
377
378
380
382
383
384
385 if(std::abs(startParameters->position().z())>5000.){
386 ATH_MSG_DEBUG(
"Pathological track parameter well outside of tracking detector");
387 ATH_MSG_DEBUG(
"Propagator might have issue with this, discarding");
389 continue;
390 }
391
392 std::vector<std::unique_ptr<Trk::TrackParameters> > paramList =
394 *startParameters,
395 *surf,
397 false, partHyp);
398
399 if (paramList.empty()) {
401 continue;
402 }
403
404 ATH_MSG_VERBOSE(
"Number of parameters in this step: " << paramList.size());
405
406
407 for (std::unique_ptr<Trk::TrackParameters>& thisParameters : paramList) {
408 ATH_MSG_VERBOSE(
"extrapolated pos: " << thisParameters->position() <<
" r: " <<
409 sqrt(
pow(thisParameters->position().x(),2)+
pow(thisParameters->position().y(),2)));
410
411
413 if ((thisParameters->associatedSurface()).associatedDetectorElement() != nullptr &&
414 (thisParameters->associatedSurface()).associatedDetectorElement()->identify() != 0) {
415 id2 = (thisParameters->associatedSurface()).associatedDetectorElement()->identify();
416 } else {
419 startParameters = std::move(thisParameters);
420 }
421 continue;
422 }
423
424
426 ATH_MSG_VERBOSE(
"Surface is not Pixel or SCT, stop loop over parameters in this step");
427
428
430 startParameters = std::move(thisParameters);
431 }
433 else break;
434 }
435
436
437 std::map<const Identifier, const Trk::TrackStateOnSurface*>::iterator iTSOS = mapOfHits.find(
id2);
438
439 if (iTSOS == mapOfHits.end() && !foundFirst) {
440 ATH_MSG_VERBOSE(
"Si surface before first Si measurement, skip it and continue");
441 continue;
442 }
443
444
445 if (iTSOS != mapOfHits.end()) {
448 foundFirst = true;
449 }
450
451
452 if (iTSOS->second->trackParameters()) {
454 startParameters.reset( iTSOS->second->trackParameters()->clone());
455 } else {
457 startParameters.reset(thisParameters->clone());
458 }
459 }
460
461
462 std::pair<const Trk::TrackParameters*,const bool> trackparampair (thisParameters.release(),true);
463 if (mapOfPredictions.insert(std::pair<
const Identifier, std::pair<const Trk::TrackParameters*,const bool> >(
id2,trackparampair)).second) {
465 } else {
467 delete trackparampair.first;
468 trackparampair.first=nullptr;
469 }
470 }
471
474 break;
475 }
476
477 }
478 }
480 if (measno==nmeas) break;
481 }
482
483
484
485
486
488 ATH_MSG_DEBUG(
"Search for dead modules after the last Si measurement");
490
491 auto cylinderBounds = std::make_shared<Trk::CylinderVolumeBounds>(560, 2750);
492
493 Trk::Volume* boundaryVol = new Trk::Volume(nullptr, cylinderBounds);
494
495
496 std::vector<std::unique_ptr<Trk::TrackParameters> > paramList =
498 *startParameters,
500 false, partHyp,
501 boundaryVol);
502 if (paramList.empty()) {
503 ATH_MSG_VERBOSE(
"--> Did not manage to extrapolate to another surface, break loop");
504 } else {
505 ATH_MSG_VERBOSE(
"Number of parameters in this step: " << paramList.size());
506
507
508 for (std::unique_ptr<Trk::TrackParameters>& thisParameter : paramList) {
509
511 if (thisParameter->associatedSurface().associatedDetectorElement() != nullptr &&
512 thisParameter->associatedSurface().associatedDetectorElement()->identify() != 0) {
513 id2 = thisParameter->associatedSurface().associatedDetectorElement()->identify();
514
515
517 ATH_MSG_VERBOSE(
"Surface is not Pixel or SCT, stop loop over parameters in this step");
518 break;
519 }
520
521
522
523 std::pair<Trk::TrackParameters*, const bool> trackparampair(
525 if (mapOfPredictions
526 .insert(std::pair<const Identifier, std::pair<const Trk::TrackParameters*, const bool>>(
527 id2, trackparampair))
528 .second) {
529 thisParameter.reset(trackparampair.first->clone());
531 } else {
532 thisParameter.reset(trackparampair.first);
534 }
535 } else {
537 }
538
539
540 startParameters = std::move(thisParameter);
541 }
542 }
543
544
545 delete boundaryVol;
546 boundaryVol = nullptr;
547
548 }
549
550 ATH_MSG_DEBUG(
"Number of Predictions found: " << mapOfPredictions.size());
551 return true;
552
553}
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
constexpr int pow(int base, int exp) noexcept
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.
ParametersT< TrackParametersDim, Charged, PerigeeSurface > Perigee