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.
virtual ~VertexMapper ()
 Virtual destructor.
StatusCode initialize ()
 AlgTool initialize method.
StatusCode finalize ()
 AlgTool finalize method.
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
 the tracking geometry owned by the navigator
std::string m_trackingGeometryName
 Name of the TrackingGeometry as given in Detector Store.
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 m_trackingGeometry(nullptr),
19 m_trackingGeometryName("AtlasTrackingGeometry")
20{
21 declareInterface<IVertexMapper>(this);
22
23 // The TrackingGeometry
24 declareProperty("TrackingGeometry" , m_trackingGeometryName);
25
26
27}
AthAlgTool()
Default constructor:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
std::string m_trackingGeometryName
Name of the TrackingGeometry as given in Detector Store.
const TrackingGeometry * m_trackingGeometry
the tracking geometry owned by the navigator

◆ ~VertexMapper()

Trk::VertexMapper::~VertexMapper ( )
virtualdefault

Virtual destructor.

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 }

◆ 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

◆ finalize()

StatusCode Trk::VertexMapper::finalize ( )

AlgTool finalize method.

Definition at line 43 of file VertexMapper.cxx.

44{
45 ATH_MSG_INFO( "finalize() successful" );
46 return StatusCode::SUCCESS;
47}
#define ATH_MSG_INFO(x)

◆ handle()

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

Handle the incident from the incident service.

◆ initialize()

StatusCode Trk::VertexMapper::initialize ( )

AlgTool initialize method.

Definition at line 35 of file VertexMapper.cxx.

36{
37
38
39 return StatusCode::SUCCESS;
40}

◆ 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 60 of file VertexMapper.cxx.

60 {
61
62 // first find the volume where you are in
63 const Trk::TrackingVolume* mVolume = trackingGeometry().lowestTrackingVolume(vertex);
64 // we have a volume, so go on
65 if (mVolume){
66 // from the volume, get all the layers
67 const Trk::LayerArray* mLayerArray = mVolume->confinedLayers();
68 // and check if we have confined layers
69 if (mLayerArray){
70 // extract all the layers with sensitive surfaces
71 std::span<Trk::Layer const * const> mLayerObjects = mLayerArray->arrayObjects();
72 std::vector<const Trk::Layer*> mSensitiveLayers;
73 // loop over for the extraction - and check if they have a sub surface array
74 for (const auto & mLayer : mLayerObjects){
75 if (mLayer->surfaceArray()){
76 // remember this layer
77 mSensitiveLayers.push_back(mLayer);
78 }
79 }
80 // now find out the closest - if you have layers to test
81 if (!mSensitiveLayers.empty()){
82 // prepare the book keepint
83 double mDistance = 10e10;
84 const Layer* mLayer = nullptr;
85 Amg::Vector3D mPosition(0.,0.,0.);
86 Amg::Vector3D mDirection(0.,0.,0.);
87 // loop over the test layers
88 for (auto& sLayer : mSensitiveLayers) {
89 // find out the optimal association :
90 // - for cylinders we want to radially hit the layer
91 // - for disks we want to move along z
92 mDirection = Amg::Vector3D(
93 (sLayer->surfaceRepresentation().type() ==
95 ? Amg::Vector3D(vertex.x(), vertex.y(), 0.)
96 : Amg::Vector3D(0., 0., 1.))
97 .unit();
98 // now intersect the layer
99 Intersection sIntersection = sLayer->surfaceRepresentation().straightLineIntersection(vertex,mDirection,false,false);
100 // check if valid
101 if (sIntersection.valid){
102 // record the new closest distance and remember the layer
103 double currentDistance = fabs(sIntersection.pathLength);
104 if ( currentDistance < mDistance ){
105 // assign the new closest distance
106 mDistance = currentDistance;
107 mLayer = sLayer;
108 mPosition = sIntersection.position;
109 }
110 }
111 } // loop over layers done
112
113 // continue if you have found a good layer
114 if (mLayer) {
115 // let's find the assoicated surfaces using the overlap descriptor
116 std::vector<SurfaceIntersection> testSurfaces;
117 // get the main target surface
118 const Surface* mSurface = mLayer->subSurface(mPosition);
119 // we have more than one test surface
120 if (mSurface && mLayer->overlapDescriptor()){
121 // get the reachable surfaces, the target surface will be added
122 mLayer->overlapDescriptor()->reachableSurfaces(testSurfaces, *mSurface, vertex, mDirection);
123 // let's loop over the provided surfaces, intersect them and take the closest
124 mDistance = 10e10;
125 for (auto& tSurface : testSurfaces){
126 // intersect
127 Intersection tsfInter = tSurface.object->straightLineIntersection(vertex,mDirection,false,false);
128 // check if the intersection is valid and the maxPathLength has not been exceeded
129 if (tsfInter.valid && tsfInter.pathLength < mDistance ){
130 // change the mDistance and remember the surface
131 mDistance = tsfInter.pathLength;
132 mSurface = tSurface.object;
133 }
134 }
135 }
136 // now collect all the other surfaces from the compatible surface call
137 if (mSurface){
138 // we have a surface, do the final transformation into the surface frame
139 Amg::Vector3D mLocPosition = mSurface->transform().inverse()*vertex;
140 // everything is set -> return
141 return Trk::MappedVertex(mLocPosition,*mSurface,*mLayer,*mVolume);
142 }
143 }
144 }
145 }
146 }
147 // did not succeed return an invalid solution
148 return {};
149}
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 >, AthCheckedComponent<::AthAlgTool >, and DerivationFramework::CfAthAlgTool.

◆ 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 79 of file VertexMapper.h.

79 {
80 if (!m_trackingGeometry && updateTrackingGeometry().isFailure()){
81 ATH_MSG_FATAL("Could not load TrackingGeometry with name '" << m_trackingGeometryName << "'. Aborting." );
82 throw GaudiException("VertexMapper", "Problem with TrackingGeometry loading.", StatusCode::FAILURE);
83 }
84 return (*m_trackingGeometry);
85 }
#define ATH_MSG_FATAL(x)
StatusCode updateTrackingGeometry() const
< retrieve TrackingGeometry

◆ updateTrackingGeometry()

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

< retrieve TrackingGeometry

update the tracking geometry return and retrieve

Definition at line 50 of file VertexMapper.cxx.

50 {
51 // retrieve the TrackingGeometry from the detector store
53 ATH_MSG_ERROR("Could not retrieve the tracking geometry. Bailing out.");
54 return StatusCode::FAILURE;
55 }
56 return StatusCode::SUCCESS;
57}
#define ATH_MSG_ERROR(x)
const ServiceHandle< StoreGateSvc > & detStore() const
retrieve(aClass, aKey=None)
Definition PyKernel.py:110

◆ 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
mutableprivate

the tracking geometry owned by the navigator

Definition at line 74 of file VertexMapper.h.

◆ m_trackingGeometryName

std::string Trk::VertexMapper::m_trackingGeometryName
private

Name of the TrackingGeometry as given in Detector Store.

Definition at line 75 of file VertexMapper.h.

◆ 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: