22 ATH_MSG_INFO(
"Intialized using ITrackVertexAssociationTool");
26 ATH_MSG_INFO(
"Intialized using custom track-vertex association");
27 return StatusCode::SUCCESS;
37 if(!handle_tracks.isValid()){
38 ATH_MSG_ERROR(
"Error retrieving TrackParticleContainer from evtStore: "
40 return StatusCode::FAILURE;
43 const auto *trackContainer = handle_tracks.cptr();
48 bool oneOwningContainer(
true);
49 for(
const auto *
const track : *trackContainer) {
50 if(track->container() != trackContainer->front()->container()) {
51 oneOwningContainer=
false;
55 if(!oneOwningContainer) {
56 ATH_MSG_ERROR(
"Track view container holds track from multiple owning containers.");
58 return StatusCode::FAILURE;
65 if(!handle_vert.isValid()){
66 ATH_MSG_ERROR(
"Error retrieving VertexContainer from evtStore: "
68 return StatusCode::FAILURE;
71 const auto *vertexContainer = handle_vert.cptr();
80 return StatusCode::FAILURE;
86 if(!handle_tva.record(std::move(tva))){
87 ATH_MSG_ERROR(
"Unable to write new TrackVertexAssociation to evtStore: "
89 return StatusCode::FAILURE;
93 ATH_MSG_DEBUG(
"Wrote new TrackVertexAssociation to evtStore: "
95 return StatusCode::SUCCESS;
101std::unique_ptr<jet::TrackVertexAssociation>
105 ATH_MSG_DEBUG(
"Building track-vertex association USING InDet tool. trk size="<< trackContainer->
size()
106 <<
" vtx size="<< vertexContainer->
size());
108 auto tva = std::make_unique<jet::TrackVertexAssociation>(trackContainer);
110 std::vector<const xAOD::Vertex*> vecVert;
111 vecVert.assign(vertexContainer->
begin(), vertexContainer->
end());
116 tva->associate( track, v );
123std::unique_ptr<jet::TrackVertexAssociation>
126 ATH_MSG_DEBUG(
"Building track-vertex association trk size="<< trackContainer->
size()
127 <<
" vtx size="<< vertexContainer->
size());
129 auto tva = std::make_unique<jet::TrackVertexAssociation>(trackContainer);
131 for (
size_t iTrack = 0; iTrack < trackContainer->
size(); ++iTrack)
136 const float transverseDistance = track->d0();
141 const float longitudinalDistance = track->z0()+track->vz();
143 double sinTheta = std::sin(track->theta());
146 size_t matchedIndex = 0;
147 bool foundMatch =
false;
148 for (
size_t iVertex = 0; iVertex < vertexContainer->
size(); ++iVertex)
152 double deltaz = longitudinalDistance - vertex->z();
165 matchedIndex = iVertex;
171 tva->associate(trackContainer->
at(iTrack),vertexContainer->
at(matchedIndex));
181std::unique_ptr<jet::TrackVertexAssociation>
184 bool useCustom)
const {
#define ATH_CHECK
Evaluate an expression and check for errors.
const xAOD::TrackParticleContainer * PTPC
const xAOD::VertexContainer * PVC
const T * at(size_type n) const
Access an element, as an rvalue.
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.
SG::ReadHandleKey< xAOD::VertexContainer > m_vertexContainer_key
StatusCode execute(const EventContext &ctx) const override
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_trackContainer_key
StatusCode initialize() override
Athena algorithm's Hooks.
std::unique_ptr< jet::TrackVertexAssociation > buildTrackVertexAssociation_custom(const xAOD::TrackParticleContainer *, const xAOD::VertexContainer *) const
std::unique_ptr< jet::TrackVertexAssociation > buildTrackVertexAssociation_withTool(const xAOD::TrackParticleContainer *, const xAOD::VertexContainer *) const
Gaudi::Property< float > m_longDistMax
Gaudi::Property< float > m_transDistMax
ToolHandle< CP::ITrackVertexAssociationTool > m_tvaTool
std::unique_ptr< jet::TrackVertexAssociation > makeTrackVertexAssociation(const xAOD::TrackParticleContainer *, const xAOD::VertexContainer *, bool useCustom) const
SG::WriteHandleKey< jet::TrackVertexAssociation > m_tva_key
Gaudi::Property< float > m_maxZ0SinTheta
@ OWN_ELEMENTS
this data object owns its elements
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
TrackParticle_v1 TrackParticle
Reference the current persistent version:
VertexContainer_v1 VertexContainer
Definition of the current "Vertex container version".
Vertex_v1 Vertex
Define the latest version of the vertex class.
TrackParticleContainer_v1 TrackParticleContainer
Definition of the current "TrackParticle container version".