162 std::map<const Identifier, const Trk::TrackStateOnSurface*>& mapOfHits,
163 std::map<
const Identifier, std::pair<const Trk::TrackParameters*,const bool> >& mapOfPredictions)
const {
175 for (
const auto *iterTSOS : *track.trackStateOnSurfaces()) {
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();
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();
195 mapOfHits.insert(std::pair<const Identifier, const Trk::TrackStateOnSurface*>(
id,iterTSOS));
198 if (!iterTSOS->trackParameters() &&
m_warning<10) {
200 ATH_MSG_WARNING(
"No track parameters available for state of type measurement");
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");
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");
224 ATH_MSG_DEBUG(
"Number of Si hits + outliers on original track: " << mapOfHits.size() <<
" , hits only: " << imeas);
232 std::unique_ptr<const Trk::TrackParameters> startParameters;
249 ATH_MSG_ERROR (
"cast to CylinderSurface failed, should never happen !");
261 if (!startParameters) {
262 ATH_MSG_DEBUG(
"no start parameters on SCT cylinder, try TRT ec disc");
289 if (track.perigeeParameters()) {
290 startParameters.reset( track.perigeeParameters()->clone());
291 }
else if (track.trackParameters()->front()) {
296 *(track.trackParameters()->front()),
304 if (!startParameters) {
305 ATH_MSG_DEBUG(
"No start point obtained, hole search not performed.");
310 bool foundFirst =
false;
314 ATH_MSG_DEBUG(
"We are looking for an extended list of holes, so add eventual holes before first hits");
328 while (iterTSOS!=track.trackStateOnSurfaces()->end()
336 <<
" r: " << sqrt(pow(startParameters->position().x(),2)
337 +pow(startParameters->position().y(),2)));
340 int nmeas=(int)track.measurementsOnTrack()->size();
341 for (; iterTSOS!=track.trackStateOnSurfaces()->end();++iterTSOS) {
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();
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());
368 surf=&((*iterTSOS)->trackParameters()->associatedSurface());
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");
385 std::vector<std::unique_ptr<Trk::TrackParameters> > paramList =
392 if (paramList.empty()) {
397 ATH_MSG_VERBOSE(
"Number of parameters in this step: " << paramList.size());
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)));
406 if ((thisParameters->associatedSurface()).associatedDetectorElement() !=
nullptr &&
407 (thisParameters->associatedSurface()).associatedDetectorElement()->identify() != 0) {
408 id2 = (thisParameters->associatedSurface()).associatedDetectorElement()->identify();
412 startParameters = std::move(thisParameters);
419 ATH_MSG_VERBOSE(
"Surface is not Pixel or SCT, stop loop over parameters in this step");
423 startParameters = std::move(thisParameters);
430 std::map<const Identifier, const Trk::TrackStateOnSurface*>::iterator iTSOS = mapOfHits.find(id2);
432 if (iTSOS == mapOfHits.end() && !foundFirst) {
433 ATH_MSG_VERBOSE(
"Si surface before first Si measurement, skip it and continue");
438 if (iTSOS != mapOfHits.end()) {
445 if (iTSOS->second->trackParameters()) {
447 startParameters.reset( iTSOS->second->trackParameters()->clone());
450 startParameters.reset(thisParameters->clone());
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) {
460 delete trackparampair.first;
461 trackparampair.first=
nullptr;
473 if (measno==nmeas)
break;
481 ATH_MSG_DEBUG(
"Search for dead modules after the last Si measurement");
484 auto cylinderBounds = std::make_shared<Trk::CylinderVolumeBounds>(560, 2750);
489 std::vector<std::unique_ptr<Trk::TrackParameters> > paramList =
495 if (paramList.empty()) {
496 ATH_MSG_VERBOSE(
"--> Did not manage to extrapolate to another surface, break loop");
498 ATH_MSG_VERBOSE(
"Number of parameters in this step: " << paramList.size());
501 for (std::unique_ptr<Trk::TrackParameters>& thisParameter : paramList) {
504 if (thisParameter->associatedSurface().associatedDetectorElement() !=
nullptr &&
505 thisParameter->associatedSurface().associatedDetectorElement()->identify() != 0) {
506 id2 = thisParameter->associatedSurface().associatedDetectorElement()->identify();
510 ATH_MSG_VERBOSE(
"Surface is not Pixel or SCT, stop loop over parameters in this step");
516 std::pair<Trk::TrackParameters*, const bool> trackparampair(
519 .insert(std::pair<
const Identifier, std::pair<const Trk::TrackParameters*, const bool>>(
520 id2, trackparampair))
522 thisParameter.reset(trackparampair.first->clone());
525 thisParameter.reset(trackparampair.first);
533 startParameters = std::move(thisParameter);
539 boundaryVol =
nullptr;
543 ATH_MSG_DEBUG(
"Number of Predictions found: " << mapOfPredictions.size());
550 std::map<
const Identifier, std::pair<const Trk::TrackParameters*, const bool> >& mapOfPredictions,
551 std::vector<int>* information,
552 std::vector<const Trk::TrackStateOnSurface*>* listOfHoles)
const {
564 unsigned int foundTSOS = 0;
565 int PixelHoles = 0, SctHoles = 0, SctDoubleHoles = 0, PixelDead=0, SctDead=0;
566 std::set<Identifier> SctHoleIds;
569 ATH_MSG_DEBUG(
"Number of hits+outliers: " << mapOfHits.size() <<
" and predicted parameters:" << mapOfPredictions.size());
571 for (std::map<
const Identifier,std::pair<const Trk::TrackParameters*,const bool> >
::const_iterator it = mapOfPredictions.begin();
572 it != mapOfPredictions.end(); ++it) {
579 std::map<const Identifier, const Trk::TrackStateOnSurface*>::iterator iTSOS = mapOfHits.find(
id);
581 if (iTSOS == mapOfHits.end()) {
586 ATH_MSG_VERBOSE(
"Found element is a dead pixel module, add it to the list and continue");
590 ATH_MSG_VERBOSE(
"Found element is a dead SCT module, add it to the list and continue");
604 if (((it->second).second)) {
606 ATH_MSG_VERBOSE(
"Found element is a Pixel hole, add it to the list and continue");
609 ATH_MSG_VERBOSE(
"Found element is a SCT hole, add it to the list and continue");
617 ATH_MSG_ERROR (
"cast to SiDetectorElement failed, should never happen !");
623 if (SctHoleIds.find(otherId) != SctHoleIds.end()) {
628 SctHoleIds.insert(
id);
632 if (listOfHoles) listOfHoles->push_back(
createHoleTSOS(nextParameters));
641 ATH_MSG_VERBOSE(
"Found TSOS is an outlier, not a hole, skip it and continue");
643 mapOfHits.erase(iTSOS);
651 mapOfHits.erase(iTSOS);
657 << PixelHoles <<
" Pixel holes, "
658 << SctHoles <<
" Sct holes, "
659 << SctDoubleHoles <<
" Double holes");
661 if (listOfHoles)
ATH_MSG_DEBUG(
"==> Size of listOfHoles: " << listOfHoles->size());
663 if (!mapOfHits.empty()) {
664 int ioutliers = 0, imeasurements = 0;
665 for (std::map<const Identifier, const Trk::TrackStateOnSurface*>::const_iterator iter = mapOfHits.begin();
666 iter != mapOfHits.end(); ++iter) {
672 if (imeasurements > 0) {
673 if (PixelHoles+SctHoles+SctDoubleHoles > 0) {
674 ATH_MSG_DEBUG(
"Not all measurements found, but holes. Left measurements: "
675 << imeasurements <<
" outliers: " << ioutliers <<
" found: " << foundTSOS
676 <<
" Pixel holes: " << PixelHoles <<
" Sct holes: " << SctHoles
677 <<
" Double holes: " << SctDoubleHoles);
679 ATH_MSG_DEBUG(
"Problem ? Not all measurements found. Left measurements: "
680 << imeasurements <<
" outliers: " << ioutliers <<
" found: " << foundTSOS);