Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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
12  // Initialise the tool handles
13  ATH_CHECK(m_trackSelectionTool.retrieve());
14 
15  return StatusCode::SUCCESS;
16 }
17 
18 StatusCode 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
33  ATH_CHECK(
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 }
WritexAOD::execute
virtual StatusCode execute(const EventContext &ctx) const override
Definition: WritexAOD.cxx:18
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:67
WritexAOD::m_trackSelectionTool
ToolHandle< InDet::IInDetTrackSelectionTool > m_trackSelectionTool
Tool handle for the track selection tool *‍/.
Definition: WritexAOD.h:34
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
WritexAOD::m_newKey
SG::WriteHandleKey< xAOD::TrackParticleContainer > m_newKey
Read handle for the new track container **‍/.
Definition: WritexAOD.h:32
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
WritexAOD.h
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
WritexAOD::m_trackKey
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_trackKey
Read handle for the offline object container - set to tracks by default. **‍/.
Definition: WritexAOD.h:30
WritexAOD::initialize
virtual StatusCode initialize() override
Definition: WritexAOD.cxx:7
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:73
xAOD::track
@ track
Definition: TrackingPrimitives.h:513
xAOD::TrackParticle_v1
Class describing a TrackParticle.
Definition: TrackParticle_v1.h:43