ATLAS Offline Software
TruthVertexPrinterAlg.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).
5 
6 // Framework include(s).
9 
10 // EDM include(s).
12 
13 // System include(s).
14 #include <iomanip>
15 #include <sstream>
16 
17 namespace xAODReader {
18 
20 
21  // Initialize the handle.
22  ATH_CHECK(m_key.initialize());
23 
24  // Return gracefully.
25  return StatusCode::SUCCESS;
26 }
27 
28 StatusCode TruthVertexPrinterAlg::execute(const EventContext& ctx) const {
29 
30  // Print a header.
32  "----------------------------------------------------------------------"
33  "-");
34  ANA_MSG_INFO(" \"" << m_key.key() << "\"");
36  "----------------------------------------------------------------------"
37  "-");
39  " uniqueID | status | x | y | z | t "
40  " ");
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::TruthVertex* vertex : *container) {\
50 
51  // Construct a string with code copied from xAODTruthReader.
52  std::ostringstream ss;
53  ss.width(9);
54  ss << HepMC::uniqueID(vertex) << " | ";
55  ss.width(5);
56  ss << HepMC::status(vertex) << " | ";
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 << vertex->x() << " | ";
62  ss.width(9);
63  ss.precision(2);
64  ss << vertex->y() << " | ";
65  ss.width(9);
66  ss.precision(2);
67  ss << vertex->z() << " | ";
68  ss.width(9);
69  ss.precision(2);
70  ss << vertex->t();
71 
72  // Properly print the constructed string.
73  ANA_MSG_INFO(" " << ss.str());
74  }
75 
76  // Print a footer.
78  "----------------------------------------------------------------------"
79  "-");
80 
81  // Return gracefully.
82  return StatusCode::SUCCESS;
83 }
84 
85 } // namespace xAODReader
PowhegControl_ttHplus_NLO.ss
ss
Definition: PowhegControl_ttHplus_NLO.py:83
TruthVertexPrinterAlg.h
xAODReader::TruthVertexPrinterAlg::initialize
virtual StatusCode initialize() override
Function initialising the algorithm.
Definition: TruthVertexPrinterAlg.cxx:19
xAODReader::TruthVertexPrinterAlg::execute
virtual StatusCode execute(const EventContext &ctx) const override
Function executing the algorithm.
Definition: TruthVertexPrinterAlg.cxx:28
SG::makeHandle
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Definition: ReadCondHandle.h:274
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ANA_MSG_INFO
#define ANA_MSG_INFO(xmsg)
Macro printing info messages.
Definition: Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:290
HepMC::uniqueID
int uniqueID(const T &p)
Definition: MagicNumbers.h:116
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
xAOD::TruthVertex_v1
Class describing a truth vertex in the MC record.
Definition: TruthVertex_v1.h:37
MagicNumbers.h
ReadHandle.h
Handle class for reading from StoreGate.
xAODReader::TruthVertexPrinterAlg::m_key
SG::ReadHandleKey< xAOD::TruthVertexContainer > m_key
The key of the truth vertex container to print.
Definition: TruthVertexPrinterAlg.h:32
Trk::vertex
@ vertex
Definition: MeasurementType.h:21
HepMC::status
int status(const T &p)
Definition: MagicNumbers.h:143
TruthParticle.h
xAODReader
Definition: BTaggingReader.cxx:21