21#include "Identifier/Identifier.h"
35 const IInterface* p) :
39 declareInterface<ITrackHoleSearchTool>(
this);
48 StatusCode
sc = AlgTool::initialize();
49 if (
sc.isFailure())
return sc;
57 return StatusCode::SUCCESS;
62 StatusCode
sc = AlgTool::finalize();
68 std::vector<int>& information,
70 std::vector<const Trk::TrackStateOnSurface*>* listOfHoles =
nullptr;
78 std::vector<const Trk::TrackStateOnSurface*>* listOfHoles =
new std::vector<const Trk::TrackStateOnSurface*>;
82 for (
const auto *listOfHole : *listOfHoles)
83 output->push_back(listOfHole);
86 listOfHoles =
nullptr;
93 std::vector<const Trk::TrackStateOnSurface*>* listOfHoles =
new std::vector<const Trk::TrackStateOnSurface*>;
97 listOfHoles =
nullptr;
111 std::vector<int>* information,
112 std::vector<const Trk::TrackStateOnSurface*>* listOfHoles,
127 std::map<const Identifier, const Trk::TrackStateOnSurface*> mapOfHits;
139 std::map<const Identifier, std::pair<const Trk::TrackParameters*,const bool> > mapOfPredictions;
142 Gaudi::Hive::currentContext(), track, partHyp, mapOfHits, mapOfPredictions);
148 ATH_MSG_DEBUG(
"List of hits not properly obtained, abort hole search.");
151 for (
auto & mapOfPrediction : mapOfPredictions) {
152 delete (mapOfPrediction.second).first;
153 (mapOfPrediction.second).first =
nullptr;
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);
698 std::bitset<Trk::TrackStateOnSurface::NumberOfTrackStateOnSurfaceTypes> typePattern;
706 std::vector<const Trk::TrackStateOnSurface*>* listOfHoles)
const {
707 auto trackTSOS = std::make_unique<Trk::TrackStates>();
717 ATH_MSG_DEBUG(
"No holes on track, copy input track to new track");
721 std::move(trackTSOS),
727 for (
const auto *listOfHole : *listOfHoles) {
728 trackTSOS->push_back(listOfHole);
742 if (fabs(perigee->parameters()[
Trk::qOverP]) > 0.002) {
749 trackTSOS->sort(CompFunc);
757 std::move(trackTSOS),
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_ERROR(x,...)
#define ATH_MSG_WARNING(x,...)
#define ATH_MSG_VERBOSE(x,...)
#define ATH_MSG_INFO(x,...)
This class provides an interface to generate or decode an identifier for the upper levels of the dete...
const ServiceHandle< StoreGateSvc > & detStore() const
DataModel_detail::const_iterator< DataVector > const_iterator
size_type size() const noexcept
Returns the number of elements in the collection.
Class to hold geometrical description of a silicon detector element.
const SiDetectorElement * otherSide() const
Useful for SCT only.
virtual Identifier identify() const override final
identifier of this detector element (inline)
Class for a CylinderSurface in the ATLAS detector.
Class for a DiscSurface in the ATLAS detector.
std::unique_ptr< FitQuality > uniqueClone() const
NVI uniqueClone.
const Amg::Vector3D & momentum() const
Access method for the momentum.
std::unique_ptr< ParametersBase< DIM, T > > uniqueClone() const
clone method for polymorphic deep copy returning unique_ptr; it is not overriden, but uses the existi...
virtual const Surface & associatedSurface() const =0
Access to the Surface associated to the Parameters.
Class describing the Line to which the Perigee refers to.
Abstract Base Class for tracking surfaces.
const TrkDetElementBase * associatedDetectorElement() const
return associated Detector Element
virtual constexpr SurfaceType type() const =0
Returns the Surface type to avoid dynamic casts.
Class providing comparison function, or relational definition, for sorting MeasurementBase objects.
represents the track state (measurement, material, fit parameters and quality) at a surface.
@ 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 ...
@ Hole
A hole on the track - this is defined in the following way.
const Trk::TrackStates * trackStateOnSurfaces() const
return a pointer to a const DataVector of const TrackStateOnSurfaces.
const TrackInfo & info() const
Returns a const ref to info of a const tracks.
const Perigee * perigeeParameters() const
return Perigee.
const FitQuality * fitQuality() const
return a pointer to the fit quality const-overload
The TrackingGeometry class is the owner of the constructed TrackingVolumes.
const TrackingVolume * trackingVolume(const std::string &name) const
return the tracking Volume by name, 0 if it doesn't exist
Full Volume description used in Tracking, it inherits from Volume to get the geometrical structure,...
std::vector< std::shared_ptr< BoundarySurface< TrackingVolume > > > & boundarySurfaces()
Method to return the BoundarySurfaces.
virtual Identifier identify() const =0
Identifier.
Base class for all volumes inside the tracking realm, it defines the interface for inherited Volume c...
DataVector< const Trk::TrackStateOnSurface > TrackStates
ParametersT< TrackParametersDim, Charged, PerigeeSurface > Perigee
@ OnEdge
within the sensitive area of an active element
@ DeadElement
outside the element
@ Insensitive
close to the edge of an active element
@ Outside
with the insensitive area of an active element
@ Error
within the nominally active area of a dead element
ParticleHypothesis
Enumeration for Particle hypothesis respecting the interaction with material.
ParametersBase< TrackParametersDim, Charged > TrackParameters
@ numberOfTRTHoles
number of TRT hits which pass the high threshold (only xenon counted) total number of TRT hits which ...
@ numberOfTRTDeadStraws
number of TRT tube hits
@ numberOfSCTHoles
number of Holes in both sides of a SCT module
@ numberOfSCTDeadSensors
number of TRT hits
@ numberOfPixelHoles
number of pixels which have a ganged ambiguity.
@ numberOfPixelDeadSensors
number of pixel hits with broad errors (width/sqrt(12))
void stable_sort(DataModel_detail::iterator< DVL > beg, DataModel_detail::iterator< DVL > end)
Specialization of stable_sort for DataVector/List.