ATLAS Offline Software
Loading...
Searching...
No Matches
ReadxAOD.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
5#include "ReadxAOD.h"
6
7ReadxAOD::ReadxAOD(const std::string &name, ISvcLocator *pSvcLocator)
8 : AthReentrantAlgorithm(name, pSvcLocator) {
9}
10
12
13 // Initialise the data handles
14 ATH_CHECK(m_trackKey.initialize());
15 // Initialise the tool handles
17
18 // Initialise the counters
21
22 return StatusCode::SUCCESS;
23}
24
25StatusCode ReadxAOD::execute(const EventContext& ctx) const {
26
27 // Get the particle containers requested
28 // EventContext is for multi-threading
30 if( ! tracks.isValid() ) {
31 ATH_MSG_ERROR ("Couldn't retrieve xAOD::TrackParticles with key: " << m_trackKey.key() );
32 return StatusCode::FAILURE;
33 }
34
35 // Loop over the tracks, select those passing selections, put into bins for final print-out
36 for ( const xAOD::TrackParticle* track : *tracks) {
37 if (m_trackSelectionTool->accept(*track)) {
38 float pT = track->pt();
39 if (pT <= m_cut) ++m_nTracksBelow;
40 if (pT > m_cut) ++m_nTracksAbove;
41 }
42 }
43
44 return StatusCode::SUCCESS;
45
46}
47
48// Print the contents of the map
49StatusCode ReadxAOD::finalize() {
50 ATH_MSG_INFO("=======================");
51 ATH_MSG_INFO("SUMMARY OF TRACK COUNTS");
52 ATH_MSG_INFO("=======================");
53 ATH_MSG_INFO("Number of tracks below the cut: " << std::to_string(m_nTracksBelow));
54 ATH_MSG_INFO("Number of tracks above the cut: " << std::to_string(m_nTracksAbove));
55
56 return StatusCode::SUCCESS;
57}
58
59
60
61
62
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
An algorithm that can be simultaneously executed in multiple threads.
std::atomic< unsigned int > m_nTracksBelow
Counter for tracks that have pT below the cut.
Definition ReadxAOD.h:31
std::atomic< unsigned int > m_nTracksAbove
Counter for tracks that have pT above the cut.
Definition ReadxAOD.h:33
virtual StatusCode execute(const EventContext &ctx) const override
Definition ReadxAOD.cxx:25
ToolHandle< InDet::IInDetTrackSelectionTool > m_trackSelectionTool
Tool handle for the track selection tool.
Definition ReadxAOD.h:40
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_trackKey
Read handle for the offline object container - set to ID tracks by default.
Definition ReadxAOD.h:38
virtual StatusCode initialize() override
Definition ReadxAOD.cxx:11
ReadxAOD(const std::string &name, ISvcLocator *pSvcLocator)
Definition ReadxAOD.cxx:7
virtual StatusCode finalize() override
Definition ReadxAOD.cxx:49
Gaudi::Property< float > m_cut
pT cut in MeV
Definition ReadxAOD.h:36
virtual bool isValid() override final
Can the handle be successfully dereferenced?
TrackParticle_v1 TrackParticle
Reference the current persistent version: