ATLAS Offline Software
Loading...
Searching...
No Matches
TrackParametersAtPV.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// Author: Tomoe Kishimoto (Tomoe.Kishimoto@cern.ch)
6// Wrapper around the passSelection() method of xAOD egamma
7// Writes result to SG for later selection by string parser
8
10
13
14#include <string>
15
16// Athena initialize and finalize
18{
19 if (m_collTrackKey.key().empty() || m_collVertexKey.key().empty()) {
20 ATH_MSG_ERROR("No selection variables for the TrackParametersAtPV tool!");
21 return StatusCode::FAILURE;
22 }
23 ATH_CHECK( m_collTrackKey.initialize() );
24 ATH_CHECK( m_collVertexKey.initialize() );
25 ATH_CHECK( m_trackZ0PVDecoKey.initialize() );
26
27 ATH_MSG_VERBOSE("initialize() ...");
28 return StatusCode::SUCCESS;
29}
30
31// Augmentation
32StatusCode DerivationFramework::TrackParametersAtPV::addBranches(const EventContext& ctx) const
33{
35
36 // Get Primary vertex
38 if(!vertices.isValid()) {
39 ATH_MSG_ERROR ("Couldn't retrieve VertexContainer with key: " << m_collVertexKey.key());
40 return StatusCode::FAILURE;
41 }
42
43 const xAOD::Vertex* pv(nullptr);
44 for (const xAOD::Vertex* vx : *vertices) {
45 if (vx->vertexType() == xAOD::VxType::PriVtx) {
46 pv = vx;
47 break;
48 }
49 }
50
51 // Get the track container
53 if(!tracks.isValid()) {
54 ATH_MSG_ERROR ("Couldn't retrieve TrackParticleContainer with key: " << m_collTrackKey.key());
55 return StatusCode::FAILURE;
56 }
57
58 // Get track z0 w.r.t PV
59 for (const auto *trackIt : *tracks) {
60 track_z0_PV(*trackIt) = pv ? trackIt->z0() + trackIt->vz() - pv->z() : 999.;
61 }
62
63 return StatusCode::SUCCESS;
64}
65
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_VERBOSE(x)
Handle class for reading from StoreGate.
Handle class for adding a decoration to an object.
SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > m_trackZ0PVDecoKey
SG::ReadHandleKey< xAOD::VertexContainer > m_collVertexKey
virtual StatusCode initialize() override final
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_collTrackKey
virtual StatusCode addBranches(const EventContext &ctx) const override final
Check that the current event passes this filter.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
Handle class for adding a decoration to an object.
@ PriVtx
Primary vertex.
Vertex_v1 Vertex
Define the latest version of the vertex class.