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
56 {
58
59 const EventContext& ctx = Gaudi::Hive::currentContext();
60
62
63 xAOD::VertexContainer* theXAODContainer = nullptr;
64 xAOD::VertexAuxContainer* theXAODAuxContainer = nullptr;
65 std::pair<xAOD::VertexContainer*,xAOD::VertexAuxContainer*> theXAODContainers
66 = std::make_pair( theXAODContainer, theXAODAuxContainer );
67
68 // retrieve the PRIMARY Vertex
69
71
72 if(vtxCont.isValid()){
73 const xAOD::Vertex *privtx = static_cast< const xAOD::Vertex * >( *(vtxCont->begin()) );
74 static const SG::ConstAccessor<float> zAcc ("z");
75 if( privtx->vertexType() != xAOD::VxType::PriVtx || privtx->nTrackParticles() < 2 || !zAcc.isAvailable(*privtx)){
76 ATH_MSG_WARNING(" Illed Primary vertex, keeping privtx_z0 = 0 ");
77 }
78 else{
79 m_AdaptiveMultiVertexFinderTool->setPrimaryVertexPosition( privtx->position().x(), privtx->position().y(), privtx->position().z());
80 }
81 }
82
83 else{
84 ATH_MSG_WARNING("couldn't retrieve Primary vertex, keeping privtx_z0 = 0 ");
85 }
86
87 std::unique_ptr<Trk::VxSecVertexInfo> foundVrts;
89 ATH_CHECK(trackParticleCollection.isValid());
90 theXAODContainers = m_AdaptiveMultiVertexFinderTool->findVertex ( trackParticleCollection.cptr());
91
92 // now re-merge and resort the vertex container and store to SG
93 xAOD::VertexContainer* myVertexContainer = nullptr;
94 xAOD::VertexAuxContainer* myVertexAuxContainer = nullptr;
95 std::pair<xAOD::VertexContainer*, xAOD::VertexAuxContainer*> myVxContainers = std::make_pair( myVertexContainer, myVertexAuxContainer );
96 ATH_MSG_DEBUG("Vertexing done, sorting the vertex container");
97 if (theXAODContainers.first) {
98 //sort xAOD::Vertex container
99
100 myVxContainers.first = theXAODContainers.first;
101 myVxContainers.second = theXAODContainers.second;
102
103 if (myVxContainers.first == 0) {
104 ATH_MSG_WARNING("Vertex container has no associated store.");
105
106 return StatusCode::SUCCESS;
107 }
108
109 if (not myVxContainers.first->hasStore()) {
110 ATH_MSG_WARNING("Vertex container has no associated store.");
111
112 return StatusCode::SUCCESS;
113 }
114
115 ATH_MSG_DEBUG("Successfully reconstructed " << myVxContainers.first->size()-1 << " vertices (excluding dummy)");
116 m_totalNumVerticesWithoutDummy += (myVxContainers.first->size()-1);
117
118 }
119
120 ATH_CHECK(outputVertices.record(std::unique_ptr<xAOD::VertexContainer>(myVxContainers.first),std::unique_ptr<xAOD::VertexAuxContainer>(myVxContainers.second)));
121
122
123 ATH_MSG_DEBUG( "Recorded Vertices with key: " << m_outputSecondaryVertices.key() );
124
125 return StatusCode::SUCCESS;
126 }
127
129 {
130 ATH_MSG_DEBUG("Summary from Secondary Vertex Finder (InnerDetector/InDetRecAlgs/InDetSecVtxFinder)");
131 ATH_MSG_DEBUG("=== " << m_totalNumVerticesWithoutDummy << " vertices recoed in " << m_numEventsProcessed << " events (excluding dummy).");
132
133 if (m_numEventsProcessed!=0) {
134 ATH_MSG_DEBUG( "=== " << double(m_totalNumVerticesWithoutDummy)/double(m_numEventsProcessed) << " vertices per event (excluding dummy).");
135 }
136
137 return StatusCode::SUCCESS;
138 }
139
140} // 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 with parameters:
StatusCode execute()
Execute method without EventContext (deprecated).
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)
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.