ATLAS Offline Software
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
CalculateHighPtTerm.pT
pT
Definition:
ICHEP2016/CalculateHighPtTerm.py:57
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition:
AthMsgStreamMacros.h:31
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
SG::ReadHandle
Definition:
StoreGate/StoreGate/ReadHandle.h:70
ReadxAOD::m_trackSelectionTool
ToolHandle< InDet::IInDetTrackSelectionTool > m_trackSelectionTool
Tool handle for the track selection tool.
Definition:
ReadxAOD.h:40
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition:
AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
ReadxAOD::ReadxAOD
ReadxAOD(const std::string &name, ISvcLocator *pSvcLocator)
Definition:
ReadxAOD.cxx:7
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition:
AthReentrantAlgorithm.h:83
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition:
AthMsgStreamMacros.h:33
ReadxAOD.h
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition:
PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
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
ReadxAOD::m_trackKey
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_trackKey
Read handle for the offline object container - set to muons by default.
Definition:
ReadxAOD.h:38
ReadxAOD::execute
virtual StatusCode execute(const EventContext &ctx) const override
Definition:
ReadxAOD.cxx:25
name
std::string name
Definition:
Control/AthContainers/Root/debug.cxx:221
ReadxAOD::initialize
virtual StatusCode initialize() override
Definition:
ReadxAOD.cxx:11
ActsTrk::to_string
std::string to_string(const DetectorType &type)
Definition:
GeometryDefs.h:34
ReadxAOD::finalize
virtual StatusCode finalize() override
Definition:
ReadxAOD.cxx:49
xAOD::track
@ track
Definition:
TrackingPrimitives.h:512
xAOD::TrackParticle_v1
Class describing a TrackParticle.
Definition:
TrackParticle_v1.h:43
ReadxAOD::m_cut
Gaudi::Property< float > m_cut
pT cut in MeV
Definition:
ReadxAOD.h:36
Generated on Thu Nov 7 2024 21:24:34 for ATLAS Offline Software by
1.8.18