ATLAS Offline Software
Loading...
Searching...
No Matches
InDetSecVtxFinder.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4/***************************************************************************
5 InDetSecVtxFinder.cxx - Description
6 -------------------
7 begin : Nov 10, 2016
8 authors : Lianyou SHAN ( IHEP-Beijing ) Neža Ribarič (Lancaster university, UK)
9 email : shanly@mail.ihep.ac.cn, neza.ribaric@cern.ch
10 changes : Changed name from InDetInclusiveSecVtx, added the option to chose the vertexing tool (ISV,AMVF)
11 ***************************************************************************/
13
14
15// forward declares
16
17#include "xAODTracking/Vertex.h"
22// normal includes
25#include "GaudiKernel/EventContext.h"
26
27
28namespace InDet
29{
30
31 InDetSecVtxFinder::InDetSecVtxFinder ( const std::string &n, ISvcLocator *pSvcLoc ) : AthAlgorithm ( n, pSvcLoc ),
32 // for summary output at the end
35 {}
36
37
39 {
40 /* Get the VertexFinderTool */
42
44
45 ATH_CHECK(m_inputTrackParticles.initialize());
48
49 ATH_MSG_DEBUG("Initialization successful");
50
51 return StatusCode::SUCCESS;
52 }
53
54
55 StatusCode InDetSecVtxFinder::execute(const EventContext& ctx)
56 {
58
59
61
62 xAOD::VertexContainer* theXAODContainer = nullptr;
63 xAOD::VertexAuxContainer* theXAODAuxContainer = nullptr;
64 std::pair<xAOD::VertexContainer*,xAOD::VertexAuxContainer*> theXAODContainers
65 = std::make_pair( theXAODContainer, theXAODAuxContainer );
66
67 // retrieve the PRIMARY Vertex
68
70
71 if(vtxCont.isValid()){
72 const xAOD::Vertex *privtx = static_cast< const xAOD::Vertex * >( *(vtxCont->begin()) );
73 static const SG::ConstAccessor<float> zAcc ("z");
74 if( privtx->vertexType() != xAOD::VxType::PriVtx || privtx->nTrackParticles() < 2 || !zAcc.isAvailable(*privtx)){
75 ATH_MSG_WARNING(" Illed Primary vertex, keeping privtx_z0 = 0 ");
76 }
77 else{
78 m_AdaptiveMultiVertexFinderTool->setPrimaryVertexPosition( privtx->position().x(), privtx->position().y(), privtx->position().z());
79 }
80 }
81
82 else{
83 ATH_MSG_WARNING("couldn't retrieve Primary vertex, keeping privtx_z0 = 0 ");
84 }
85
86 std::unique_ptr<Trk::VxSecVertexInfo> foundVrts;
88 ATH_CHECK(trackParticleCollection.isValid());
89 theXAODContainers = m_AdaptiveMultiVertexFinderTool->findVertex ( trackParticleCollection.cptr());
90
91 // now re-merge and resort the vertex container and store to SG
92 xAOD::VertexContainer* myVertexContainer = nullptr;
93 xAOD::VertexAuxContainer* myVertexAuxContainer = nullptr;
94 std::pair<xAOD::VertexContainer*, xAOD::VertexAuxContainer*> myVxContainers = std::make_pair( myVertexContainer, myVertexAuxContainer );
95 ATH_MSG_DEBUG("Vertexing done, sorting the vertex container");
96 if (theXAODContainers.first) {
97 //sort xAOD::Vertex container
98
99 myVxContainers.first = theXAODContainers.first;
100 myVxContainers.second = theXAODContainers.second;
101
102 if (myVxContainers.first == 0) {
103 ATH_MSG_WARNING("Vertex container has no associated store.");
104
105 return StatusCode::SUCCESS;
106 }
107
108 if (not myVxContainers.first->hasStore()) {
109 ATH_MSG_WARNING("Vertex container has no associated store.");
110
111 return StatusCode::SUCCESS;
112 }
113
114 ATH_MSG_DEBUG("Successfully reconstructed " << myVxContainers.first->size()-1 << " vertices (excluding dummy)");
115 m_totalNumVerticesWithoutDummy += (myVxContainers.first->size()-1);
116
117 }
118
119 ATH_CHECK(outputVertices.record(std::unique_ptr<xAOD::VertexContainer>(myVxContainers.first),std::unique_ptr<xAOD::VertexAuxContainer>(myVxContainers.second)));
120
121
122 ATH_MSG_DEBUG( "Recorded Vertices with key: " << m_outputSecondaryVertices.key() );
123
124 return StatusCode::SUCCESS;
125 }
126
128 {
129 ATH_MSG_DEBUG("Summary from Secondary Vertex Finder (InnerDetector/InDetRecAlgs/InDetSecVtxFinder)");
130 ATH_MSG_DEBUG("=== " << m_totalNumVerticesWithoutDummy << " vertices recoed in " << m_numEventsProcessed << " events (excluding dummy).");
131
132 if (m_numEventsProcessed!=0) {
133 ATH_MSG_DEBUG( "=== " << double(m_totalNumVerticesWithoutDummy)/double(m_numEventsProcessed) << " vertices per event (excluding dummy).");
134 }
135
136 return StatusCode::SUCCESS;
137 }
138
139} // end namespace InDet
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
Helper class to provide constant type-safe access to aux data.
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_inputTrackParticles
unsigned int m_totalNumVerticesWithoutDummy
ToolHandle< InDet::IAdaptiveMultiSecVertexFinder > m_AdaptiveMultiVertexFinderTool
SG::WriteHandleKey< xAOD::VertexContainer > m_outputSecondaryVertices
SG::ReadHandleKey< xAOD::VertexContainer > m_inputPrimaryVertices
InDetSecVtxFinder(const std::string &name, ISvcLocator *pSvcLocator)
StatusCode execute(const EventContext &ctx)
Execute method.
Helper class to provide constant type-safe access to aux data.
bool isAvailable(const ELT &e) const
Test to see if this variable exists in the store.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
const_pointer_type cptr()
Dereference the pointer.
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
size_t nTrackParticles() const
Get the number of tracks associated with this vertex.
VxType::VertexType vertexType() const
The type of the vertex.
const Amg::Vector3D & position() const
Returns the 3-pos.
Primary Vertex Finder.
@ PriVtx
Primary vertex.
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.