ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Event
xAOD
xAODTruthCnv
Root
TruthParticlePrinterAlg.cxx
Go to the documentation of this file.
1
// Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
2
3
// Local include(s).
4
#include "
xAODTruthCnv/TruthParticlePrinterAlg.h
"
5
6
// Framework include(s).
7
#include "
AsgDataHandles/ReadHandle.h
"
8
#include "
TruthUtils/MagicNumbers.h
"
9
10
// EDM include(s).
11
#include "
xAODTruth/TruthVertex.h
"
12
13
// System include(s).
14
#include <iomanip>
15
#include <sstream>
16
17
namespace
xAODReader
{
18
19
StatusCode
TruthParticlePrinterAlg::initialize
() {
20
21
// Initialize the handle.
22
ATH_CHECK
(
m_key
.initialize());
23
24
// Return gracefully.
25
return
StatusCode::SUCCESS;
26
}
27
28
StatusCode
TruthParticlePrinterAlg::execute
(
const
EventContext& ctx)
const
{
29
30
// Print a header.
31
ANA_MSG_INFO
(
32
"------------------------------------------------------------------------"
33
"-----------------------"
);
34
ANA_MSG_INFO
(
" \""
<<
m_key
.key() <<
"\""
);
35
ANA_MSG_INFO
(
36
"------------------------------------------------------------------------"
37
"-----------------------"
);
38
ANA_MSG_INFO
(
39
" uniqueID | pdgId | pt | eta | phi | e "
40
"| status | decayVtxID"
);
41
ANA_MSG_INFO
(
42
"------------------------------------------------------------------------"
43
"-----------------------"
);
44
45
// Access the input container.
46
auto
container =
SG::makeHandle
(
m_key
, ctx);
47
48
// Print the particles one by one.
49
for
(
const
xAOD::TruthParticle
* particle : *container) {
50
51
// Construct a string with code copied from xAODTruthReader.
52
std::ostringstream
ss
;
53
ss
.width(9);
54
ss
<<
HepMC::uniqueID
(particle) <<
" | "
;
55
ss
.width(9);
56
ss
<< particle->pdgId() <<
" | "
;
57
ss
.width(9);
58
ss
.precision(2);
59
ss
.setf(std::ios::scientific, std::ios::floatfield);
60
ss
.setf(std::ios_base::showpos);
61
ss
<< particle->pt() <<
" | "
;
62
ss
.width(9);
63
ss
.precision(2);
64
ss
<< particle->eta() <<
" | "
;
65
ss
.width(9);
66
ss
.precision(2);
67
ss
<< particle->phi() <<
" | "
;
68
ss
.width(9);
69
ss
.precision(2);
70
ss
<< particle->e() <<
" | "
;
71
ss
.setf(std::ios::fmtflags(0), std::ios::floatfield);
72
ss
.unsetf(std::ios_base::showpos);
73
ss
.width(3);
74
ss
<< particle->status() <<
" | "
;
75
if
(particle->hasDecayVtx() &&
76
(
HepMC::uniqueID
(particle->decayVtx()) !=
HepMC::UNDEFINED_ID
)) {
77
ss
.width(9);
78
ss
<<
HepMC::uniqueID
(particle->decayVtx());
79
}
else
{
80
ss
<<
" n/a"
;
81
}
82
83
// Properly print the constructed string.
84
ANA_MSG_INFO
(
" "
<<
ss
.str());
85
}
86
87
// Print a footer.
88
ANA_MSG_INFO
(
89
"------------------------------------------------------------------------"
90
"-----------------------"
);
91
92
// Return gracefully.
93
return
StatusCode::SUCCESS;
94
}
95
96
}
// namespace xAODReader
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ReadHandle.h
Handle class for reading from StoreGate.
ANA_MSG_INFO
#define ANA_MSG_INFO(xmsg)
Macro printing info messages.
Definition
Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:290
ss
static Double_t ss
Definition
LArPhysWaveHECTool.cxx:37
MagicNumbers.h
TruthParticlePrinterAlg.h
TruthVertex.h
xAODReader::TruthParticlePrinterAlg::m_key
SG::ReadHandleKey< xAOD::TruthParticleContainer > m_key
The key of the truth particle container to print.
Definition
TruthParticlePrinterAlg.h:32
xAODReader::TruthParticlePrinterAlg::initialize
virtual StatusCode initialize() override
Function initialising the algorithm.
Definition
TruthParticlePrinterAlg.cxx:19
xAODReader::TruthParticlePrinterAlg::execute
virtual StatusCode execute(const EventContext &ctx) const override
Function executing the algorithm.
Definition
TruthParticlePrinterAlg.cxx:28
HepMC::uniqueID
int uniqueID(const T &p)
Definition
MagicNumbers.h:89
HepMC::UNDEFINED_ID
constexpr int UNDEFINED_ID
Definition
MagicNumbers.h:57
SG::makeHandle
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Definition
ReadCondHandle.h:269
xAODReader
Definition
EventDuplicateFinderAlg.cxx:12
xAOD::TruthParticle
TruthParticle_v1 TruthParticle
Typedef to implementation.
Definition
Event/xAOD/xAODTruth/xAODTruth/TruthParticle.h:15
Generated on
for ATLAS Offline Software by
1.17.0