ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Event
xAOD
xAODTrackingCnv
src
VertexCnvAlg.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
// Gaudi/Athena include(s):
6
#include "
AthenaKernel/errorcheck.h
"
7
8
// EDM include(s):
9
#include "
xAODTracking/VertexContainer.h
"
10
#include "
xAODTracking/VertexAuxContainer.h
"
11
#include "
VxVertex/VxContainer.h
"
12
#include "
VxVertex/VxTrackAtVertex.h
"
13
#include "
TrkTrackLink/ITrackLink.h
"
14
#include "
TrkParticleBase/LinkToTrackParticleBase.h
"
15
#include "
TrkLinks/LinkToXAODTrackParticle.h
"
16
#include "
TrkLinks/LinkToXAODNeutralParticle.h
"
17
// Local include(s):
18
#include "
VertexCnvAlg.h
"
19
20
namespace
xAODMaker
{
21
22
VertexCnvAlg::VertexCnvAlg
(
const
std::string& name,
23
ISvcLocator* svcLoc )
24
:
AthAlgorithm
( name, svcLoc ),
25
m_aod
(
"VxPrimaryCandidate"
),
26
m_xaodout
(
"PrimaryVertices"
)
27
{
28
29
declareProperty
(
"AODContainerName"
,
30
m_aod
);
31
declareProperty
(
"xAODContainerName"
,
32
m_xaodout
);
33
declareProperty
(
"TPContainerName"
,
34
m_TPContainerName
=
"InDetTrackParticles"
);
35
declareProperty
(
"NPContainerName"
,
36
m_NPContainerName
=
"VertexNeutralParticles"
);
37
}
38
39
StatusCode
VertexCnvAlg::initialize
() {
40
41
ATH_MSG_INFO
(
"Initializing"
);
42
ATH_MSG_INFO
(
"AODContainerName = "
<<
m_aod
.name() );
43
ATH_MSG_INFO
(
"xAODContainerName = "
<<
m_xaodout
.name() );
44
ATH_MSG_INFO
(
"TPContainerName = "
<<
m_TPContainerName
);
45
ATH_MSG_INFO
(
"NPContainerName = "
<<
m_NPContainerName
);
46
47
// Return gracefully:
48
return
StatusCode::SUCCESS;
49
}
50
51
StatusCode
VertexCnvAlg::execute
(
const
EventContext&
/*ctx*/
) {
52
// Retrieve the AOD vertexes:
53
54
if
(!
m_aod
.isValid()) {
55
ATH_MSG_DEBUG
(
"No VxContainer with key "
<<
m_aod
.name() <<
" found. Do nothing."
);
56
return
StatusCode::SUCCESS;
57
}
58
59
ATH_MSG_DEBUG
(
"Retrieved particles with key: "
<<
m_aod
.name() );
60
61
// Create the xAOD container and its auxiliary store:
62
63
m_xaodout
= std::make_unique<xAOD::VertexContainer>();
64
m_xauxout
= std::make_unique<xAOD::VertexAuxContainer>();
65
66
if
(!
m_xaodout
.isValid() || !
m_xauxout
.isValid()){
67
ATH_MSG_ERROR
(
"Problem creating "
<<
m_xaodout
.name() );
68
}
69
70
m_xaodout
->setStore( *
m_xauxout
);
71
72
73
// Create the xAOD objects:
74
auto
itr =
m_aod
->cbegin();
75
auto
end =
m_aod
->cend();
76
m_xaodout
->reserve(
m_aod
->size());
77
78
for
( ; itr != end; ++itr ) {
79
// Create the xAOD object:
80
xAOD::Vertex
* vertex =
new
xAOD::Vertex
();
81
m_xaodout
->push_back( vertex );
82
// Get & set the Position
83
const
Amg::Vector3D
& position = (*itr)->recVertex().position();
84
vertex->setPosition(position);
85
// Get & set the Covariance Position
86
const
AmgSymMatrix
(3)& covariance = (*itr)->recVertex().covariancePosition();
87
vertex->setCovariancePosition(covariance);
88
// Get & set the Fit quality
89
vertex->setFitQuality((*itr)->recVertex().fitQuality().chiSquared(),
static_cast<
float
>
((*itr)->recVertex().fitQuality().doubleNumberDoF ()));
90
//Type of the vertex
91
vertex->setVertexType((
xAOD::VxType::VertexType
)(*itr)->vertexType());
92
//Set Links
93
unsigned
int
VTAVsize = (*itr)->vxTrackAtVertex()->size();
94
for
(
unsigned
int
i = 0 ; i < VTAVsize ; ++i)
95
{
96
Trk::VxTrackAtVertex
* VTAV = (*((*itr)->vxTrackAtVertex()))[i];
97
Trk::ITrackLink
* trklink = VTAV->
trackOrParticleLink
();
98
Trk::LinkToTrackParticleBase
* linkToTrackPB =
dynamic_cast<
Trk::LinkToTrackParticleBase
*
>
(trklink);
99
if
(linkToTrackPB) {
100
ElementLink<xAOD::TrackParticleContainer>
newLink;
101
newLink.
resetWithKeyAndIndex
(
m_TPContainerName
, linkToTrackPB->index());
102
//Now set the newlink to the new xAOD vertex
103
vertex->addTrackAtVertex(newLink, VTAV->
vtxCompatibility
());
104
}
105
else
{
106
Trk::LinkToXAODNeutralParticle
* linkToTrackNP =
dynamic_cast<
Trk::LinkToXAODNeutralParticle
*
>
(trklink);
107
if
(linkToTrackNP) {
108
ElementLink<xAOD::NeutralParticleContainer>
newLink;
109
newLink.
resetWithKeyAndIndex
(
m_NPContainerName
, linkToTrackNP->index());
110
//Now set the newlink to the new xAOD vertex
111
vertex->addNeutralAtVertex(newLink, VTAV->
vtxCompatibility
());
112
}
113
else
{
114
ATH_MSG_DEBUG
(
"Cast of element link failed, skip this VxTrack/NeutralAtVertex !!!!!"
);
115
}
116
}
117
}
118
}
119
// Return gracefully:
120
return
StatusCode::SUCCESS;
121
}
//execute
122
123
}
// namespace xAODMaker
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition
AthMsgStreamMacros.h:33
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition
AthMsgStreamMacros.h:31
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
errorcheck.h
Helpers for checking error return status codes and reporting errors.
AmgSymMatrix
#define AmgSymMatrix(dim)
Definition
EventPrimitives.h:50
ITrackLink.h
LinkToTrackParticleBase.h
LinkToXAODNeutralParticle.h
LinkToXAODTrackParticle.h
VertexAuxContainer.h
VertexCnvAlg.h
VertexContainer.h
VxContainer.h
VxTrackAtVertex.h
AthAlgorithm::AthAlgorithm
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Definition
AthAlgorithm.cxx:10
AthCommonAlgorithm< Gaudi::Algorithm >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
Definition
AthCommonDataStore.h:145
ElementLink
ElementLink implementation for ROOT usage.
Definition
A/AthLinks/ElementLink.h:40
ElementLink::resetWithKeyAndIndex
void resetWithKeyAndIndex(const ID_type &key, index_type index, xAOD::TVirtualEvent *event=0)
Reset with storable key and element index (fast).
Trk::ITrackLink
An abstract class which is meant to represent an element link to the Trk::Track or Trk::TrackParticle...
Definition
ITrackLink.h:26
Trk::LinkToTrackParticleBase
Definition
LinkToTrackParticleBase.h:17
Trk::LinkToXAODNeutralParticle
Element link to XAOD NeutralParticle.
Definition
LinkToXAODNeutralParticle.h:32
Trk::VxTrackAtVertex
The VxTrackAtVertex is a common class for all present TrkVertexFitters The VxTrackAtVertex is designe...
Definition
VxTrackAtVertex.h:77
Trk::VxTrackAtVertex::vtxCompatibility
double vtxCompatibility(void) const
Information about fast compatibility estimation, to be given to the annealing.
Trk::VxTrackAtVertex::trackOrParticleLink
const ITrackLink * trackOrParticleLink(void) const
xAODMaker::VertexCnvAlg::VertexCnvAlg
VertexCnvAlg(const std::string &name, ISvcLocator *svcLoc)
Regular algorithm constructor.
Definition
VertexCnvAlg.cxx:22
xAODMaker::VertexCnvAlg::initialize
virtual StatusCode initialize()
Function initialising the algorithm.
Definition
VertexCnvAlg.cxx:39
xAODMaker::VertexCnvAlg::m_aod
SG::ReadHandle< VxContainer > m_aod
The key of the input Container.
Definition
VertexCnvAlg.h:41
xAODMaker::VertexCnvAlg::m_xauxout
SG::WriteHandle< xAOD::VertexAuxContainer > m_xauxout
Definition
VertexCnvAlg.h:45
xAODMaker::VertexCnvAlg::execute
virtual StatusCode execute(const EventContext &ctx)
Function executing the algorithm.
Definition
VertexCnvAlg.cxx:51
xAODMaker::VertexCnvAlg::m_xaodout
SG::WriteHandle< xAOD::VertexContainer > m_xaodout
The key for the output xAOD::Container.
Definition
VertexCnvAlg.h:44
xAODMaker::VertexCnvAlg::m_TPContainerName
std::string m_TPContainerName
The key for the track particle links Container.
Definition
VertexCnvAlg.h:48
xAODMaker::VertexCnvAlg::m_NPContainerName
std::string m_NPContainerName
The key for the neutral particle links Container.
Definition
VertexCnvAlg.h:50
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition
GeoPrimitives.h:47
xAODMaker
Definition
StoreGateSvc.h:70
xAOD::VxType::VertexType
VertexType
Vertex types.
Definition
TrackingPrimitives.h:588
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