ATLAS Offline Software
Loading...
Searching...
No Matches
Trk::VertexMapper Class Reference

The vertex mapper transforms vertices from global coordinates into the local coordinate frame of the closest sensitive surface. More...

#include <VertexMapper.h>

Inheritance diagram for Trk::VertexMapper:
Collaboration diagram for Trk::VertexMapper:

Public Member Functions

 VertexMapper (const std::string &, const std::string &, const IInterface *)
 AlgTool like constructor.
MappedVertex mapToLocal (const Amg::Vector3D &vertex) const
 Record the vertex into the local frame of the closest module.
void handle (const Incident &inc)
 Handle the incident from the incident service.
ServiceHandle< StoreGateSvc > & evtStore ()
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
const ServiceHandle< StoreGateSvc > & detStore () const
 The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
virtual StatusCode sysInitialize () override
 Perform system initialization for an algorithm.
virtual StatusCode sysStart () override
 Handle START transition.
virtual std::vector< Gaudi::DataHandle * > inputHandles () const override
 Return this algorithm's input handles.
virtual std::vector< Gaudi::DataHandle * > outputHandles () const override
 Return this algorithm's output handles.
Gaudi::Details::PropertyBase & declareProperty (Gaudi::Property< T, V, H > &t)
void updateVHKA (Gaudi::Details::PropertyBase &)
MsgStream & msg () const
bool msgLvl (const MSG::Level lvl) const
 DeclareInterfaceID (IVertexMapper, 1, 0)
 Creates the InterfaceID and interfaceID() method.

Protected Member Functions

void renounceArray (SG::VarHandleKeyArray &handlesArray)
 remove all handles from I/O resolution
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce (T &h)
void extraDeps_update_handler (Gaudi::Details::PropertyBase &ExtraDeps)
 Add StoreName to extra input/output deps as needed.

Private Types

typedef ServiceHandle< StoreGateSvcStoreGateSvc_t

Private Member Functions

StatusCode updateTrackingGeometry () const
 < retrieve TrackingGeometry
const TrackingGeometrytrackingGeometry () const
 retrieve the tracking geometry
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey>

Private Attributes

const TrackingGeometrym_trackingGeometry = nullptr
 the tracking geometry owned by the navigator
Gaudi::Property< std::string > m_trackingGeometryName
StoreGateSvc_t m_evtStore
 Pointer to StoreGate (event store by default).
StoreGateSvc_t m_detStore
 Pointer to StoreGate (detector store by default).
std::vector< SG::VarHandleKeyArray * > m_vhka
bool m_varHandleArraysDeclared

Detailed Description

The vertex mapper transforms vertices from global coordinates into the local coordinate frame of the closest sensitive surface.

Todo
add option to also map onto non-sensitive layers
Author
Andre.nosp@m.as.S.nosp@m.alzbu.nosp@m.rger.nosp@m.@cern.nosp@m..ch

Definition at line 41 of file VertexMapper.h.

Member Typedef Documentation

◆ StoreGateSvc_t

typedef ServiceHandle<StoreGateSvc> AthCommonDataStore< AthCommonMsg< AlgTool > >::StoreGateSvc_t
privateinherited

Definition at line 388 of file AthCommonDataStore.h.

Constructor & Destructor Documentation

◆ VertexMapper()

Trk::VertexMapper::VertexMapper ( const std::string & t,
const std::string & n,
const IInterface * p )

AlgTool like constructor.

Definition at line 16 of file VertexMapper.cxx.

17: AthAlgTool(t,n,p)
18{
19 declareInterface<IVertexMapper>(this);
20}
AthAlgTool()
Default constructor:

Member Function Documentation

◆ declareGaudiProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< AlgTool > >::declareGaudiProperty ( Gaudi::Property< T, V, H > & hndl,
const SG::VarHandleKeyType &  )
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleKey>

Definition at line 156 of file AthCommonDataStore.h.

158 {
160 hndl.value(),
161 hndl.documentation());
162
163 }
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)

◆ DeclareInterfaceID()

Trk::IVertexMapper::DeclareInterfaceID ( IVertexMapper ,
1 ,
0  )
inherited

Creates the InterfaceID and interfaceID() method.

◆ declareProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( Gaudi::Property< T, V, H > & t)
inlineinherited

Definition at line 145 of file AthCommonDataStore.h.

145 {
146 typedef typename SG::HandleClassifier<T>::type htype;
148 }
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>

◆ detStore()

const ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< AlgTool > >::detStore ( ) const
inlineinherited

The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 95 of file AthCommonDataStore.h.

◆ evtStore()

ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore ( )
inlineinherited

The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 85 of file AthCommonDataStore.h.

◆ extraDeps_update_handler()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::extraDeps_update_handler ( Gaudi::Details::PropertyBase & ExtraDeps)
protectedinherited

Add StoreName to extra input/output deps as needed.

use the logic of the VarHandleKey to parse the DataObjID keys supplied via the ExtraInputs and ExtraOuputs Properties to add the StoreName if it's not explicitly given

◆ handle()

void Trk::VertexMapper::handle ( const Incident & inc)

Handle the incident from the incident service.

◆ inputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< AlgTool > >::inputHandles ( ) const
overridevirtualinherited

Return this algorithm's input handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ mapToLocal()

Trk::MappedVertex Trk::VertexMapper::mapToLocal ( const Amg::Vector3D & vertex) const
virtual

Record the vertex into the local frame of the closest module.

Implements Trk::IVertexMapper.

Definition at line 32 of file VertexMapper.cxx.

32 {
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}
virtual std::span< T *const > arrayObjects()=0
Return all objects of the Array non-const we can still modify the T.
const TrackingVolume * lowestTrackingVolume(const Amg::Vector3D &gp) const
return the lowest tracking Volume
const LayerArray * confinedLayers() const
Return the subLayer array.
const TrackingGeometry & trackingGeometry() const
retrieve the tracking geometry
Eigen::Matrix< double, 3, 1 > Vector3D
BinnedArray< Layer > LayerArray
simply for the eye

◆ msg()

MsgStream & AthCommonMsg< AlgTool >::msg ( ) const
inlineinherited

Definition at line 24 of file AthCommonMsg.h.

24 {
25 return this->msgStream();
26 }

◆ msgLvl()

bool AthCommonMsg< AlgTool >::msgLvl ( const MSG::Level lvl) const
inlineinherited

Definition at line 30 of file AthCommonMsg.h.

30 {
31 return this->msgLevel(lvl);
32 }

◆ outputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< AlgTool > >::outputHandles ( ) const
overridevirtualinherited

Return this algorithm's output handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ renounce()

std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > AthCommonDataStore< AthCommonMsg< AlgTool > >::renounce ( T & h)
inlineprotectedinherited

Definition at line 380 of file AthCommonDataStore.h.

381 {
382 h.renounce();
384 }
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce(T &h)

◆ renounceArray()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::renounceArray ( SG::VarHandleKeyArray & handlesArray)
inlineprotectedinherited

remove all handles from I/O resolution

Definition at line 364 of file AthCommonDataStore.h.

364 {
366 }

◆ sysInitialize()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysInitialize ( )
overridevirtualinherited

Perform system initialization for an algorithm.

We override this to declare all the elements of handle key arrays at the end of initialization. See comments on updateVHKA.

Reimplemented in asg::AsgMetadataTool, AthCheckedComponent< AthAlgTool >, and AthCheckedComponent<::AthAlgTool >.

◆ sysStart()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysStart ( )
overridevirtualinherited

Handle START transition.

We override this in order to make sure that conditions handle keys can cache a pointer to the conditions container.

◆ trackingGeometry()

const Trk::TrackingGeometry & Trk::VertexMapper::trackingGeometry ( ) const
inlineprivate

retrieve the tracking geometry

Definition at line 72 of file VertexMapper.h.

72 {
73 if (!m_trackingGeometry && updateTrackingGeometry().isFailure()){
74 ATH_MSG_FATAL("Could not load TrackingGeometry with name '" << m_trackingGeometryName << "'. Aborting." );
75 throw GaudiException("VertexMapper", "Problem with TrackingGeometry loading.", StatusCode::FAILURE);
76 }
77 return (*m_trackingGeometry);
78 }
#define ATH_MSG_FATAL(x)
const TrackingGeometry * m_trackingGeometry
the tracking geometry owned by the navigator
Gaudi::Property< std::string > m_trackingGeometryName
StatusCode updateTrackingGeometry() const
< retrieve TrackingGeometry

◆ updateTrackingGeometry()

StatusCode Trk::VertexMapper::updateTrackingGeometry ( ) const
private

< retrieve TrackingGeometry

update the tracking geometry return and retrieve

Definition at line 22 of file VertexMapper.cxx.

22 {
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}
#define ATH_MSG_ERROR(x)
const ServiceHandle< StoreGateSvc > & detStore() const

◆ updateVHKA()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::updateVHKA ( Gaudi::Details::PropertyBase & )
inlineinherited

Definition at line 308 of file AthCommonDataStore.h.

308 {
309 // debug() << "updateVHKA for property " << p.name() << " " << p.toString()
310 // << " size: " << m_vhka.size() << endmsg;
311 for (auto &a : m_vhka) {
313 for (auto k : keys) {
314 k->setOwner(this);
315 }
316 }
317 }
std::vector< SG::VarHandleKeyArray * > m_vhka

Member Data Documentation

◆ m_detStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_detStore
privateinherited

Pointer to StoreGate (detector store by default).

Definition at line 393 of file AthCommonDataStore.h.

◆ m_evtStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_evtStore
privateinherited

Pointer to StoreGate (event store by default).

Definition at line 390 of file AthCommonDataStore.h.

◆ m_trackingGeometry

const TrackingGeometry* Trk::VertexMapper::m_trackingGeometry = nullptr
mutableprivate

the tracking geometry owned by the navigator

Definition at line 65 of file VertexMapper.h.

◆ m_trackingGeometryName

Gaudi::Property<std::string> Trk::VertexMapper::m_trackingGeometryName
private
Initial value:
{this, "TrackingGeometry", "AtlasTrackingGeometry",
"Name of the TrackingGeometry as given in Detector Store"}

Definition at line 66 of file VertexMapper.h.

67 {this, "TrackingGeometry", "AtlasTrackingGeometry",
68 "Name of the TrackingGeometry as given in Detector Store"};

◆ m_varHandleArraysDeclared

bool AthCommonDataStore< AthCommonMsg< AlgTool > >::m_varHandleArraysDeclared
privateinherited

Definition at line 399 of file AthCommonDataStore.h.

◆ m_vhka

std::vector<SG::VarHandleKeyArray*> AthCommonDataStore< AthCommonMsg< AlgTool > >::m_vhka
privateinherited

Definition at line 398 of file AthCommonDataStore.h.


The documentation for this class was generated from the following files: