20 ATH_MSG_INFO(
"Intialized using ITrackVertexAssociationTool");
24 ATH_MSG_INFO(
"Intialized using custom track-vertex association");
25 return StatusCode::SUCCESS;
35 if(!handle_tracks.isValid()){
36 ATH_MSG_ERROR(
"Error retrieving TrackParticleContainer from evtStore: "
38 return StatusCode::FAILURE;
41 const auto *trackContainer = handle_tracks.cptr();
46 bool oneOwningContainer(
true);
47 for(
const auto *
const track : *trackContainer) {
48 if(track->container() != trackContainer->front()->container()) {
49 oneOwningContainer=
false;
53 if(!oneOwningContainer) {
54 ATH_MSG_ERROR(
"Track view container holds track from multiple owning containers.");
56 return StatusCode::FAILURE;
63 if(!handle_vert.isValid()){
64 ATH_MSG_ERROR(
"Error retrieving VertexContainer from evtStore: "
66 return StatusCode::FAILURE;
69 const auto *vertexContainer = handle_vert.cptr();
78 return StatusCode::FAILURE;
84 if(!handle_tva.record(std::move(tva))){
85 ATH_MSG_ERROR(
"Unable to write new TrackVertexAssociation to evtStore: "
87 return StatusCode::FAILURE;
91 ATH_MSG_DEBUG(
"Wrote new TrackVertexAssociation to evtStore: "
93 return StatusCode::SUCCESS;
99std::unique_ptr<jet::TrackVertexAssociation>
103 ATH_MSG_DEBUG(
"Building track-vertex association USING InDet tool. trk size="<< trackContainer->
size()
104 <<
" vtx size="<< vertexContainer->
size());
106 auto tva = std::make_unique<jet::TrackVertexAssociation>(trackContainer);
108 std::vector<const xAOD::Vertex*> vecVert;
109 vecVert.assign(vertexContainer->
begin(), vertexContainer->
end());
114 tva->associate( track, v );
121std::unique_ptr<jet::TrackVertexAssociation>
124 ATH_MSG_DEBUG(
"Building track-vertex association trk size="<< trackContainer->
size()
125 <<
" vtx size="<< vertexContainer->
size());
127 auto tva = std::make_unique<jet::TrackVertexAssociation>(trackContainer);
129 for (
size_t iTrack = 0; iTrack < trackContainer->
size(); ++iTrack)
134 const float transverseDistance = track->d0();
139 const float longitudinalDistance = track->z0()+track->vz();
141 double sinTheta = std::sin(track->theta());
144 size_t matchedIndex = 0;
145 bool foundMatch =
false;
146 for (
size_t iVertex = 0; iVertex < vertexContainer->
size(); ++iVertex)
150 double deltaz = longitudinalDistance - vertex->z();
163 matchedIndex = iVertex;
169 tva->associate(trackContainer->
at(iTrack),vertexContainer->
at(matchedIndex));
179std::unique_ptr<jet::TrackVertexAssociation>
182 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".