ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
InnerDetector
InDetRecAlgs
InDetSecVtxFinder
src
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
***************************************************************************/
12
#include "
InDetSecVtxFinder/InDetSecVtxFinder.h
"
13
14
15
// forward declares
16
17
#include "
xAODTracking/Vertex.h
"
18
#include "
xAODTracking/VertexAuxContainer.h
"
19
#include "
xAODTracking/TrackParticle.h
"
20
#include "
xAODTracking/TrackParticleAuxContainer.h
"
21
#include "
VxSecVertex/VxSecVertexInfo.h
"
22
// normal includes
23
#include "
TrkParticleBase/TrackParticleBaseCollection.h
"
24
#include "
AthContainers/ConstAccessor.h
"
25
#include "GaudiKernel/EventContext.h"
26
27
28
namespace
InDet
29
{
30
31
InDetSecVtxFinder::InDetSecVtxFinder
(
const
std::string &n, ISvcLocator *pSvcLoc ) :
AthAlgorithm
( n, pSvcLoc ),
32
// for summary output at the end
33
m_numEventsProcessed
(0),
34
m_totalNumVerticesWithoutDummy
(0)
35
{}
36
37
38
StatusCode
InDetSecVtxFinder::initialize
()
39
{
40
/* Get the VertexFinderTool */
41
ATH_CHECK
(
m_AdaptiveMultiVertexFinderTool
.retrieve());
42
44
45
ATH_CHECK
(
m_inputTrackParticles
.initialize());
46
ATH_CHECK
(
m_outputSecondaryVertices
.initialize());
47
ATH_CHECK
(
m_inputPrimaryVertices
.initialize());
48
49
ATH_MSG_DEBUG
(
"Initialization successful"
);
50
51
return
StatusCode::SUCCESS;
52
}
53
54
55
StatusCode
InDetSecVtxFinder::execute
(
const
EventContext& ctx)
56
{
57
m_numEventsProcessed
++;
58
59
60
SG::WriteHandle<xAOD::VertexContainer>
outputVertices (
m_outputSecondaryVertices
, ctx);
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
69
SG::ReadHandle<xAOD::VertexContainer>
vtxCont(
m_inputPrimaryVertices
, ctx);
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;
87
SG::ReadHandle<xAOD::TrackParticleContainer>
trackParticleCollection(
m_inputTrackParticles
, ctx);
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
127
StatusCode
InDetSecVtxFinder::finalize
()
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
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition
AthMsgStreamMacros.h:32
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
ConstAccessor.h
Helper class to provide constant type-safe access to aux data.
TrackParticle.h
Vertex.h
InDetSecVtxFinder.h
TrackParticleAuxContainer.h
TrackParticleBaseCollection.h
VertexAuxContainer.h
VxSecVertexInfo.h
AthAlgorithm::AthAlgorithm
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Definition
AthAlgorithm.cxx:10
InDet::InDetSecVtxFinder::m_numEventsProcessed
unsigned int m_numEventsProcessed
Definition
InDetSecVtxFinder.h:50
InDet::InDetSecVtxFinder::m_inputTrackParticles
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_inputTrackParticles
Definition
InDetSecVtxFinder.h:43
InDet::InDetSecVtxFinder::finalize
StatusCode finalize()
Definition
InDetSecVtxFinder.cxx:127
InDet::InDetSecVtxFinder::m_totalNumVerticesWithoutDummy
unsigned int m_totalNumVerticesWithoutDummy
Definition
InDetSecVtxFinder.h:51
InDet::InDetSecVtxFinder::m_AdaptiveMultiVertexFinderTool
ToolHandle< InDet::IAdaptiveMultiSecVertexFinder > m_AdaptiveMultiVertexFinderTool
Definition
InDetSecVtxFinder.h:47
InDet::InDetSecVtxFinder::m_outputSecondaryVertices
SG::WriteHandleKey< xAOD::VertexContainer > m_outputSecondaryVertices
Definition
InDetSecVtxFinder.h:44
InDet::InDetSecVtxFinder::m_inputPrimaryVertices
SG::ReadHandleKey< xAOD::VertexContainer > m_inputPrimaryVertices
Definition
InDetSecVtxFinder.h:45
InDet::InDetSecVtxFinder::initialize
StatusCode initialize()
Definition
InDetSecVtxFinder.cxx:38
InDet::InDetSecVtxFinder::InDetSecVtxFinder
InDetSecVtxFinder(const std::string &name, ISvcLocator *pSvcLocator)
Definition
InDetSecVtxFinder.cxx:31
InDet::InDetSecVtxFinder::execute
StatusCode execute(const EventContext &ctx)
Execute method.
Definition
InDetSecVtxFinder.cxx:55
SG::ConstAccessor
Helper class to provide constant type-safe access to aux data.
Definition
ConstAccessor.h:55
SG::ConstAccessor::isAvailable
bool isAvailable(const ELT &e) const
Test to see if this variable exists in the store.
SG::ReadHandle
Definition
StoreGate/StoreGate/ReadHandle.h:67
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
SG::ReadHandle::cptr
const_pointer_type cptr()
Dereference the pointer.
SG::WriteHandle
Definition
StoreGate/StoreGate/WriteHandle.h:73
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
xAOD::Vertex_v1::nTrackParticles
size_t nTrackParticles() const
Get the number of tracks associated with this vertex.
Definition
Vertex_v1.cxx:292
xAOD::Vertex_v1::vertexType
VxType::VertexType vertexType() const
The type of the vertex.
xAOD::Vertex_v1::position
const Amg::Vector3D & position() const
Returns the 3-pos.
Definition
Vertex_v1.cxx:106
InDet
Primary Vertex Finder.
Definition
VP1ErrorUtils.h:36
xAOD::VxType::PriVtx
@ PriVtx
Primary vertex.
Definition
TrackingPrimitives.h:590
xAOD::VertexAuxContainer
VertexAuxContainer_v1 VertexAuxContainer
Definition of the current jet auxiliary container.
Definition
VertexAuxContainer.h:19
xAOD::VertexContainer
VertexContainer_v1 VertexContainer
Definition of the current "Vertex container version".
Definition
VertexContainer.h:14
xAOD::Vertex
Vertex_v1 Vertex
Define the latest version of the vertex class.
Definition
Event/xAOD/xAODTracking/xAODTracking/Vertex.h:16
Generated on
for ATLAS Offline Software by
1.17.0