ATLAS Offline Software
Loading...
Searching...
No Matches
EMVertexBuilder.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3*/
4
5/***************************************************************************
6
7EMVertexBuilder.cxx - Description
8-------------------
9begin : 11-03-2011
10authors : Kerstin Tackmann, Bruno Lenzi
11email : kerstin.tackmann@cern.ch, Bruno.Lenzi@cern.ch
12changes :
13 Nov 2011 (KT) Initial version
14 Mar 2014 (BL) xAOD migration, creates both double and single track vertices
15
16***************************************************************************/
17
18#include "EMVertexBuilder.h"
19
20#include "GaudiKernel/EventContext.h"
27#include "GeoPrimitives/GeoPrimitives.h" // Amg::Vector3D
28
29EMVertexBuilder::EMVertexBuilder(const std::string& name,
30 ISvcLocator* pSvcLocator)
31 : AthReentrantAlgorithm(name, pSvcLocator)
32{
33}
34
36
37 ATH_MSG_DEBUG( "Initializing " << name() << "...");
38
41
42 // Get the ID VertexFinderTool
43 ATH_CHECK( m_vertexFinderTool.retrieve());
44 // Retrieve EMExtrapolationTool
46
47 return StatusCode::SUCCESS;
48}
49
51 return StatusCode::SUCCESS;
52}
53
54StatusCode EMVertexBuilder::execute(const EventContext& ctx) const
55{
56
57 //retrieve TrackParticleContainer
59
60 // check for serial running only, remove in MT
61 ATH_CHECK(TPCol.isValid());
62
63 std::pair<xAOD::VertexContainer*, xAOD::VertexAuxContainer*> verticesPair =
64 m_vertexFinderTool->findVertex(ctx,TPCol.cptr());
65
66 if (!verticesPair.first || !verticesPair.second){
67 ATH_MSG_ERROR("Null pointer to conversion container");
68 return StatusCode::SUCCESS;
69 }
70
72
73 ATH_CHECK(vertices.record(std::unique_ptr<xAOD::VertexContainer>(verticesPair.first),
74 std::unique_ptr<xAOD::VertexAuxContainer>(verticesPair.second)));
75
76 ATH_MSG_DEBUG("New conversion container size: " << vertices->size());
77
78 // Remove vertices with radii above m_maxRadius
79 xAOD::VertexContainer::iterator itVtx = vertices->begin();
80 xAOD::VertexContainer::iterator itVtxEnd = vertices->end();
81
82 while (itVtx != itVtxEnd){
83 xAOD::Vertex* vertex = *itVtx;
84
85 Amg::Vector3D momentum(0., 0., 0.);
86 for (unsigned int i = 0; i < vertex->nTrackParticles(); ++i){
87 momentum += m_EMExtrapolationTool->getMomentumAtVertex(ctx,*vertex, i);
88 }
89
90 static const SG::AuxElement::Accessor<float> accPx("px");
91 static const SG::AuxElement::Accessor<float> accPy("py");
92 static const SG::AuxElement::Accessor<float> accPz("pz");
93 accPx(*vertex) = momentum.x();
94 accPy(*vertex) = momentum.y();
95 accPz(*vertex) = momentum.z();
96
98 const bool vxDoubleTRT = (convType == xAOD::EgammaParameters::doubleTRT);
99 const bool vxSingleTRT = (convType == xAOD::EgammaParameters::singleTRT);
100
101 if ((vxDoubleTRT && momentum.perp() < m_minPtCut_DoubleTrack) ||
102 (vxSingleTRT && momentum.perp() < m_minPtCut_SingleTrack) ||
103 ((*itVtx)->position().perp() > m_maxRadius)) {
104
105 itVtx = vertices->erase(itVtx);
106 itVtxEnd = vertices->end();
107 } else {
108 // Decorate the vertices with the momentum at the conversion point and
109 // etaAtCalo, phiAtCalo (extrapolate each vertex)
110 float etaAtCalo = -9999.;
111 float phiAtCalo = -9999.;
112
113 if (!m_EMExtrapolationTool->getEtaPhiAtCalo(
114 ctx, vertex, &etaAtCalo, &phiAtCalo)) {
115 ATH_MSG_DEBUG("getEtaPhiAtCalo failed!");
116 }
117
118 static const SG::AuxElement::Accessor<float> accetaAtCalo("etaAtCalo");
119 static const SG::AuxElement::Accessor<float> accphiAtCalo("phiAtCalo");
120 accetaAtCalo(*vertex) = etaAtCalo;
121 accphiAtCalo(*vertex) = phiAtCalo;
122
123 ++itVtx;
124 }
125 }
126
127 return StatusCode::SUCCESS;
128}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_DEBUG(x)
Handle class for reading from StoreGate.
Handle class for recording to StoreGate.
An algorithm that can be simultaneously executed in multiple threads.
DataModel_detail::iterator< DataVector > iterator
Definition DataVector.h:842
ToolHandle< IEMExtrapolationTools > m_EMExtrapolationTool
EMExtrapolationTool.
virtual StatusCode finalize() override final
SG::WriteHandleKey< xAOD::VertexContainer > m_outputConversionContainerKey
conversion container output name
virtual StatusCode execute(const EventContext &ctx) const override final
EMVertexBuilder(const std::string &name, ISvcLocator *pSvcLocator)
Gaudi::Property< float > m_minPtCut_SingleTrack
ToolHandle< InDet::IVertexFinder > m_vertexFinderTool
Tool to find vertices (creates double-track conversions)
virtual StatusCode initialize() override final
Gaudi::Property< float > m_maxRadius
Maximum radius accepted for conversion vertices.
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_inputTrackParticleContainerKey
TrackParticle container input name.
Gaudi::Property< float > m_minPtCut_DoubleTrack
Minimum Pt, less than that TRT track are pileup for double/single track conversion.
SG::Accessor< T, ALLOC > Accessor
Definition AuxElement.h:572
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.
Eigen::Matrix< double, 3, 1 > Vector3D
xAOD::EgammaParameters::ConversionType conversionType(const xAOD::Photon *ph)
return the photon conversion type (see EgammaEnums)
@ doubleTRT
two tracks, none with Si hits (TRT only)
@ singleTRT
one track only, no Si hits (TRT only)
Vertex_v1 Vertex
Define the latest version of the vertex class.