ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Control
AthenaExamples
AthExBasics
src
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
7
ReadxAOD::ReadxAOD
(
const
std::string &name, ISvcLocator *pSvcLocator)
8
:
AthReentrantAlgorithm
(name, pSvcLocator) {
9
}
10
11
StatusCode
ReadxAOD::initialize
() {
12
13
// Initialise the data handles
14
ATH_CHECK
(
m_trackKey
.initialize());
15
// Initialise the tool handles
16
ATH_CHECK
(
m_trackSelectionTool
.retrieve());
17
18
// Initialise the counters
19
m_nTracksBelow
= 0;
20
m_nTracksAbove
= 0;
21
22
return
StatusCode::SUCCESS;
23
}
24
25
StatusCode
ReadxAOD::execute
(
const
EventContext& ctx)
const
{
26
27
// Get the particle containers requested
28
// EventContext is for multi-threading
29
SG::ReadHandle<xAOD::TrackParticleContainer>
tracks{
m_trackKey
, ctx};
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
49
StatusCode
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
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition
AthMsgStreamMacros.h:33
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition
AthMsgStreamMacros.h:31
ReadxAOD.h
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition
AthReentrantAlgorithm.h:74
ReadxAOD::m_nTracksBelow
std::atomic< unsigned int > m_nTracksBelow
Counter for tracks that have pT below the cut.
Definition
ReadxAOD.h:31
ReadxAOD::m_nTracksAbove
std::atomic< unsigned int > m_nTracksAbove
Counter for tracks that have pT above the cut.
Definition
ReadxAOD.h:33
ReadxAOD::execute
virtual StatusCode execute(const EventContext &ctx) const override
Definition
ReadxAOD.cxx:25
ReadxAOD::m_trackSelectionTool
ToolHandle< InDet::IInDetTrackSelectionTool > m_trackSelectionTool
Tool handle for the track selection tool.
Definition
ReadxAOD.h:40
ReadxAOD::m_trackKey
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_trackKey
Read handle for the offline object container - set to ID tracks by default.
Definition
ReadxAOD.h:38
ReadxAOD::initialize
virtual StatusCode initialize() override
Definition
ReadxAOD.cxx:11
ReadxAOD::ReadxAOD
ReadxAOD(const std::string &name, ISvcLocator *pSvcLocator)
Definition
ReadxAOD.cxx:7
ReadxAOD::finalize
virtual StatusCode finalize() override
Definition
ReadxAOD.cxx:49
ReadxAOD::m_cut
Gaudi::Property< float > m_cut
pT cut in MeV
Definition
ReadxAOD.h:36
SG::ReadHandle
Definition
StoreGate/StoreGate/ReadHandle.h:67
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
xAOD::TrackParticle
TrackParticle_v1 TrackParticle
Reference the current persistent version:
Definition
Event/xAOD/xAODTracking/xAODTracking/TrackParticle.h:13
Generated on
for ATLAS Offline Software by
1.17.0