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

#include <VertexMergingTool.h>

Inheritance diagram for Trk::VertexMergingTool:
Collaboration diagram for Trk::VertexMergingTool:

Public Member Functions

StatusCode initialize () override
 VertexMergingTool (const std::string &t, const std::string &n, const IInterface *p)
 constructor
virtual ~VertexMergingTool ()
 destructor
virtual std::pair< xAOD::VertexContainer *, xAOD::VertexAuxContainer * > mergeVertexContainer (const xAOD::VertexContainer &MyVxCont) const override
 Merging.
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

Static Public Member Functions

static const InterfaceID & interfaceID ()
 AlgTool interface methods.

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

bool checkCompatibility (const xAOD::Vertex *vx1, const xAOD::Vertex *vx2) const
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey>

Private Attributes

SG::ReadCondHandleKey< InDet::BeamSpotDatam_beamSpotKey { this, "BeamSpotKey", "BeamSpotData", "SG key for beam spot" }
ToolHandle< Trk::IVertexFitterm_iVertexFitter
bool m_useBeamConstraint
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

Author
Maria Ilaria Besana, June 2014

Changes:

David Shope david.nosp@m..ric.nosp@m.hard..nosp@m.shop.nosp@m.e@cer.nosp@m.n.ch (2016-04-26)

EDM Migration to xAOD - remove method using VxCandidate

Definition at line 41 of file Tracking/TrkVertexFitter/TrkVertexTools/TrkVertexTools/VertexMergingTool.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

◆ VertexMergingTool()

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

constructor

Definition at line 13 of file Tracking/TrkVertexFitter/TrkVertexTools/src/VertexMergingTool.cxx.

14 : AthAlgTool ( t,n,p ),
15 m_iVertexFitter("Trk::AdaptiveVertexFitter"),
17 {
18 declareInterface<IVertexMergingTool> ( this );
19 declareProperty("VertexFitterTool", m_iVertexFitter);
20 declareProperty("useBeamConstraint",m_useBeamConstraint);
21 }
AthAlgTool()
Default constructor:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)

◆ ~VertexMergingTool()

Trk::VertexMergingTool::~VertexMergingTool ( )
virtualdefault

destructor

Member Function Documentation

◆ checkCompatibility()

bool Trk::VertexMergingTool::checkCompatibility ( const xAOD::Vertex * vx1,
const xAOD::Vertex * vx2 ) const
private

Definition at line 127 of file Tracking/TrkVertexFitter/TrkVertexTools/src/VertexMergingTool.cxx.

127 {
128
129 double z1 = vx1->z();
130 double z2 = vx2->z();
131
132 double err2_z1 = vx1->covariancePosition()(Trk::z, Trk::z);
133 double err2_z2 = vx2->covariancePosition()(Trk::z, Trk::z);
134
135 double sigmaZ = (fabs(z1-z2))/(sqrt(err2_z1+err2_z2));
136
137 ATH_MSG_DEBUG("z1 = " << z1 << ", z2 = " << z2 << ", error = " << sqrt( err2_z1+err2_z2 ) );
138
139 return sigmaZ<3;
140 }
#define ATH_MSG_DEBUG(x)
float z() const
Returns the z position.
@ z
global position (cartesian)
Definition ParamDefs.h:57

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

◆ 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

◆ initialize()

StatusCode Trk::VertexMergingTool::initialize ( )
override

Definition at line 27 of file Tracking/TrkVertexFitter/TrkVertexTools/src/VertexMergingTool.cxx.

28 {
29
30 if ( m_iVertexFitter.retrieve().isFailure() ) {
31 msg(MSG::ERROR) << "Failed to retrieve tool " << m_iVertexFitter << endmsg;
32 return StatusCode::FAILURE;
33 }
34
35 ATH_CHECK(m_beamSpotKey.initialize());
36
37 ATH_MSG_DEBUG("Re-merging tool initialization successful");
38 return StatusCode::SUCCESS;
39 }
#define endmsg
#define ATH_CHECK
Evaluate an expression and check for errors.
MsgStream & msg() const

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

◆ interfaceID()

const InterfaceID & Trk::IVertexMergingTool::interfaceID ( )
inlinestaticinherited

AlgTool interface methods.

Definition at line 49 of file Tracking/TrkVertexFitter/TrkVertexFitterInterfaces/TrkVertexFitterInterfaces/IVertexMergingTool.h.

49{ return IID_IVertexMergingTool; };
static const InterfaceID IID_IVertexMergingTool("IVertexMergingTool", 1, 0)

◆ mergeVertexContainer()

std::pair< xAOD::VertexContainer *, xAOD::VertexAuxContainer * > Trk::VertexMergingTool::mergeVertexContainer ( const xAOD::VertexContainer & MyVxCont) const
overridevirtual

Merging.

EndOfInitialize.

Implements Trk::IVertexMergingTool.

Definition at line 42 of file Tracking/TrkVertexFitter/TrkVertexTools/src/VertexMergingTool.cxx.

43 {
44
45 ATH_MSG_DEBUG("Run vertex remerging");
46
47 //if beamspot constraint was requested, get it now
48 xAOD::Vertex theconstraint;
50 SG::ReadCondHandle<InDet::BeamSpotData> beamSpotHandle { m_beamSpotKey };
51 if(not beamSpotHandle.isValid()) ATH_MSG_ERROR("Cannot Retrieve " << m_beamSpotKey.key() );
52 theconstraint = xAOD::Vertex(); // Default constructor creates a private store
53 theconstraint.setPosition( beamSpotHandle->beamVtx().position() );
54 theconstraint.setCovariancePosition( beamSpotHandle->beamVtx().covariancePosition() );
55 theconstraint.setFitQuality( beamSpotHandle->beamVtx().fitQuality().chiSquared(), beamSpotHandle->beamVtx().fitQuality().doubleNumberDoF() );
56 }
57
58 //new output containers to be filled
59 xAOD::VertexContainer *NewContainer = new xAOD::VertexContainer();
61 NewContainer->setStore( auxNewContainer );
62
63 //add remerged flags to all
64 std::vector<bool> remerged( MyVxCont.size(), false );
65
66 xAOD::VertexContainer::const_iterator beginIter = MyVxCont.begin();
67 xAOD::VertexContainer::const_iterator endIter = MyVxCont.end();
68 unsigned int Ni=0;
69 for(xAOD::VertexContainer::const_iterator i = beginIter; i!=endIter; ++i) {
70 xAOD::Vertex * vx = new xAOD::Vertex( **i );
71
72 if( vx->vertexType() == xAOD::VxType::NoVtx ) { //dummy vertex -- just add a copy
73 NewContainer->push_back( vx );
74 } else if( !remerged[Ni] ) { //skip vertices already merged into another
75
76 unsigned int Nj = Ni+1;
77 for(xAOD::VertexContainer::const_iterator j=i+1; j!=endIter; ++j ) {
78 const xAOD::Vertex * mergeCand = (*j);
79 if( mergeCand->vertexType() != xAOD::VxType::NoVtx && !remerged[Nj] ) {
80 //not dummy and not already merged into earlier vertex, so consider it as merging candidate
81 if( checkCompatibility( vx, mergeCand ) ) {
82
83 //get all the track particles to fit
84 std::vector<const xAOD::TrackParticle*> combinedTracks;
85 for(size_t t=0; t<vx->nTrackParticles(); ++t) {
86 combinedTracks.push_back( vx->trackParticle(t) );
87 }
88 for(size_t t=0; t<mergeCand->nTrackParticles(); ++t) {
89 combinedTracks.push_back( mergeCand->trackParticle(t) );
90 }
91
92 //call the fitter -> using xAOD::TrackParticle it should set the track links for us
93 xAOD::Vertex * mergedVtx = nullptr;
95 mergedVtx = m_iVertexFitter->fit( combinedTracks, theconstraint );
96 } else {
97 //no interface for no constraint and no starting point, so use starting point of original vertex
98 const Amg::Vector3D& start( vx->position() );
99 mergedVtx = m_iVertexFitter->fit( combinedTracks, start );
100 }
101
102 //CHECK MERGING IS GOOD?
103 // flag as remerged
104 ATH_MSG_DEBUG("Merge vertices " << Ni << " and " << Nj);
105 remerged[Nj] = true;
106 remerged[Ni] = true;
107 //delete copy of first vertex and then overwrite with merged vertex
108 delete vx;
109 vx = mergedVtx;
110 }
111 }
112
113 Nj++;
114 } //loop over j
115
116 //whether we merged or not, can add vx to the container
117 NewContainer->push_back( vx );
118
119 } //end if vtx[Ni] is not remerged
120 Ni++;
121 }
122
123 return std::make_pair( NewContainer, auxNewContainer );
124
125 }
#define ATH_MSG_ERROR(x)
DataModel_detail::const_iterator< DataVector > const_iterator
Definition DataVector.h:838
value_type push_back(value_type pElem)
Add an element to the end of the collection.
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
size_type size() const noexcept
Returns the number of elements in the collection.
bool checkCompatibility(const xAOD::Vertex *vx1, const xAOD::Vertex *vx2) const
size_t nTrackParticles() const
Get the number of tracks associated with this vertex.
void setCovariancePosition(const AmgSymMatrix(3)&covariancePosition)
Sets the vertex covariance matrix.
const TrackParticle * trackParticle(size_t i) const
Get the pointer to a given track that was used in vertex reco.
void setPosition(const Amg::Vector3D &position)
Sets the 3-position.
VxType::VertexType vertexType() const
The type of the vertex.
void setFitQuality(float chiSquared, float numberDoF)
Set the 'Fit Quality' information.
const Amg::Vector3D & position() const
Returns the 3-pos.
Eigen::Matrix< double, 3, 1 > Vector3D
@ NoVtx
Dummy vertex. TrackParticle was not used in vertex fit.
VertexAuxContainer_v1 VertexAuxContainer
Definition of the current jet auxiliary container.
VertexContainer_v1 VertexContainer
Definition of the current "Vertex container version".
Vertex_v1 Vertex
Define the latest version of the vertex class.

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

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

SG::ReadCondHandleKey<InDet::BeamSpotData> Trk::VertexMergingTool::m_beamSpotKey { this, "BeamSpotKey", "BeamSpotData", "SG key for beam spot" }
private

Definition at line 64 of file Tracking/TrkVertexFitter/TrkVertexTools/TrkVertexTools/VertexMergingTool.h.

64{ this, "BeamSpotKey", "BeamSpotData", "SG key for beam spot" };

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

ToolHandle< Trk::IVertexFitter > Trk::VertexMergingTool::m_iVertexFitter
private

◆ m_useBeamConstraint

bool Trk::VertexMergingTool::m_useBeamConstraint
private

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