ATLAS Offline Software
Loading...
Searching...
No Matches
WritexAOD.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
5#include "WritexAOD.h"
6
8
9 // Initialise the data handles
10 ATH_CHECK(m_trackKey.initialize());
11 ATH_CHECK(m_newKey.initialize());
12 // Initialise the tool handles
14
15 return StatusCode::SUCCESS;
16}
17
18StatusCode WritexAOD::execute(const EventContext &ctx) const {
19
20 // Get the particle containers requested
21 // EventContext is for multi-threading
23 if (!tracksIn.isValid()) {
24 ATH_MSG_ERROR("Couldn't retrieve xAOD::TrackParticles with key: "
25 << m_trackKey.key());
26 return StatusCode::FAILURE;
27 }
28
29 // Create the new container
30 // Note the creation of the aux container, for the data payload, in addition
31 // to the object container
34 tracksOut.record(std::make_unique<xAOD::TrackParticleContainer>(),
35 std::make_unique<xAOD::TrackParticleAuxContainer>()));
36
37 // Loop over the tracks, select those passing selections, push a copy into the
38 // output container
39 for (const xAOD::TrackParticle *track : *tracksIn) {
40 if (m_trackSelectionTool->accept(*track)) {
41 xAOD::TrackParticle* newTrack = tracksOut->push_back (std::make_unique<xAOD::TrackParticle>());
42 *newTrack = *track;
43 }
44 }
45
46 return StatusCode::SUCCESS;
47}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
virtual bool isValid() override final
Can the handle be successfully dereferenced?
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_trackKey
Read handle for the offline object container - set to tracks by default. **‍/.
Definition WritexAOD.h:30
SG::WriteHandleKey< xAOD::TrackParticleContainer > m_newKey
Read handle for the new track container **‍/.
Definition WritexAOD.h:32
virtual StatusCode initialize() override
Definition WritexAOD.cxx:7
virtual StatusCode execute(const EventContext &ctx) const override
Definition WritexAOD.cxx:18
ToolHandle< InDet::IInDetTrackSelectionTool > m_trackSelectionTool
Tool handle for the track selection tool *‍/.
Definition WritexAOD.h:34
TrackParticle_v1 TrackParticle
Reference the current persistent version: