ATLAS Offline Software
Loading...
Searching...
No Matches
VertexMapper.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
6// VertexMapper.cxx, (c) ATLAS Detector software
8
9// Trk include
13
14
15// constructor
16Trk::VertexMapper::VertexMapper(const std::string& t, const std::string& n, const IInterface* p)
17: AthAlgTool(t,n,p)
18{
19 declareInterface<IVertexMapper>(this);
20}
21
23 // retrieve the TrackingGeometry from the detector store
24 if (detStore()->retrieve(m_trackingGeometry, m_trackingGeometryName).isFailure()){
25 ATH_MSG_ERROR("Could not retrieve the tracking geometry. Bailing out.");
26 return StatusCode::FAILURE;
27 }
28 return StatusCode::SUCCESS;
29}
30
33
34 // first find the volume where you are in
35 const Trk::TrackingVolume* mVolume = trackingGeometry().lowestTrackingVolume(vertex);
36 // we have a volume, so go on
37 if (mVolume){
38 // from the volume, get all the layers
39 const Trk::LayerArray* mLayerArray = mVolume->confinedLayers();
40 // and check if we have confined layers
41 if (mLayerArray){
42 // extract all the layers with sensitive surfaces
43 std::span<Trk::Layer const * const> mLayerObjects = mLayerArray->arrayObjects();
44 std::vector<const Trk::Layer*> mSensitiveLayers;
45 // loop over for the extraction - and check if they have a sub surface array
46 for (const auto & mLayer : mLayerObjects){
47 if (mLayer->surfaceArray()){
48 // remember this layer
49 mSensitiveLayers.push_back(mLayer);
50 }
51 }
52 // now find out the closest - if you have layers to test
53 if (!mSensitiveLayers.empty()){
54 // prepare the book keepint
55 double mDistance = 10e10;
56 const Layer* mLayer = nullptr;
57 Amg::Vector3D mPosition(0.,0.,0.);
58 Amg::Vector3D mDirection(0.,0.,0.);
59 // loop over the test layers
60 for (auto& sLayer : mSensitiveLayers) {
61 // find out the optimal association :
62 // - for cylinders we want to radially hit the layer
63 // - for disks we want to move along z
64 mDirection = Amg::Vector3D(
65 (sLayer->surfaceRepresentation().type() ==
67 ? Amg::Vector3D(vertex.x(), vertex.y(), 0.)
68 : Amg::Vector3D(0., 0., 1.))
69 .unit();
70 // now intersect the layer
71 Intersection sIntersection = sLayer->surfaceRepresentation().straightLineIntersection(vertex,mDirection,false,false);
72 // check if valid
73 if (sIntersection.valid){
74 // record the new closest distance and remember the layer
75 double currentDistance = fabs(sIntersection.pathLength);
76 if ( currentDistance < mDistance ){
77 // assign the new closest distance
78 mDistance = currentDistance;
79 mLayer = sLayer;
80 mPosition = sIntersection.position;
81 }
82 }
83 } // loop over layers done
84
85 // continue if you have found a good layer
86 if (mLayer) {
87 // let's find the assoicated surfaces using the overlap descriptor
88 std::vector<SurfaceIntersection> testSurfaces;
89 // get the main target surface
90 const Surface* mSurface = mLayer->subSurface(mPosition);
91 // we have more than one test surface
92 if (mSurface && mLayer->overlapDescriptor()){
93 // get the reachable surfaces, the target surface will be added
94 mLayer->overlapDescriptor()->reachableSurfaces(testSurfaces, *mSurface, vertex, mDirection);
95 // let's loop over the provided surfaces, intersect them and take the closest
96 mDistance = 10e10;
97 for (auto& tSurface : testSurfaces){
98 // intersect
99 Intersection tsfInter = tSurface.object->straightLineIntersection(vertex,mDirection,false,false);
100 // check if the intersection is valid and the maxPathLength has not been exceeded
101 if (tsfInter.valid && tsfInter.pathLength < mDistance ){
102 // change the mDistance and remember the surface
103 mDistance = tsfInter.pathLength;
104 mSurface = tSurface.object;
105 }
106 }
107 }
108 // now collect all the other surfaces from the compatible surface call
109 if (mSurface){
110 // we have a surface, do the final transformation into the surface frame
111 Amg::Vector3D mLocPosition = mSurface->transform().inverse()*vertex;
112 // everything is set -> return
113 return Trk::MappedVertex(mLocPosition,*mSurface,*mLayer,*mVolume);
114 }
115 }
116 }
117 }
118 }
119 // did not succeed return an invalid solution
120 return {};
121}
122
#define ATH_MSG_ERROR(x)
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
const ServiceHandle< StoreGateSvc > & detStore() const
virtual std::span< T *const > arrayObjects()=0
Return all objects of the Array non-const we can still modify the T.
Base Class for a Detector Layer in the Tracking realm.
Definition Layer.h:72
const OverlapDescriptor * overlapDescriptor() const
gettint hte overlap descriptor
const Surface * subSurface(const Amg::Vector3D &gp) const
If no subSurface array is defined or no subSurface can be found to the given Amg::Vector3D,...
Definition Layer.cxx:107
virtual bool reachableSurfaces(std::vector< SurfaceIntersection > &cSurfaces, const Trk::Surface &sf, const Amg::Vector3D &pos, const Amg::Vector3D &dir) const =0
get the compatible surfaces
Abstract Base Class for tracking surfaces.
Definition Surface.h:79
const Amg::Transform3D & transform() const
Returns HepGeom::Transform3D by reference.
Full Volume description used in Tracking, it inherits from Volume to get the geometrical structure,...
const LayerArray * confinedLayers() const
Return the subLayer array.
const TrackingGeometry & trackingGeometry() const
retrieve the tracking geometry
MappedVertex mapToLocal(const Amg::Vector3D &vertex) const
Record the vertex into the local frame of the closest module.
const TrackingGeometry * m_trackingGeometry
the tracking geometry owned by the navigator
Gaudi::Property< std::string > m_trackingGeometryName
VertexMapper(const std::string &, const std::string &, const IInterface *)
AlgTool like constructor.
StatusCode updateTrackingGeometry() const
< retrieve TrackingGeometry
Eigen::Matrix< double, 3, 1 > Vector3D
BinnedArray< Layer > LayerArray
simply for the eye
Amg::Vector3D position