ATLAS Offline Software
Loading...
Searching...
No Matches
MatchingBkgVertexPositioner.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
6
7#include "CLHEP/Vector/LorentzVector.h"
9
10namespace Simulation {
11
13 const std::string &n,
14 const IInterface *p)
15 : base_class(t, n, p) {}
16
18 ATH_MSG_VERBOSE("Initializing ...");
19
20 ATH_CHECK(m_vertexContainerKey.initialize());
21
22 return StatusCode::SUCCESS;
23}
24
26 const EventContext &ctx) const {
27 // we can currently not reliably determine if the timing information is
28 // available
29 bool enableTime{};
30
32 if (!vertices.isValid()) {
33 ATH_MSG_ERROR("Couldn't retrieve xAOD::VertexContainer with key: "
35 return nullptr;
36 }
37
38 for (const xAOD::Vertex *vx : *(vertices.cptr())) {
39 if (vx->vertexType() == xAOD::VxType::PriVtx) {
40 ATH_MSG_INFO("Using primary vertex with position and time: "
41 << vx->position().x() << " " << vx->position().y() << " "
42 << vx->position().z() << " "
43 << (enableTime && vx->hasValidTime() ? vx->time() : 0));
44 return new CLHEP::HepLorentzVector(
45 vx->position().x(), vx->position().y(), vx->position().z(),
46 enableTime && vx->hasValidTime() ? vx->time() : 0);
47 }
48 }
49
50 ATH_MSG_ERROR("No primary vertex found in xAOD::VertexContainer with key: "
52 return nullptr;
53}
54
55} // namespace Simulation
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_VERBOSE(x)
Handle class for reading from StoreGate.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
const_pointer_type cptr()
Dereference the pointer.
MatchingBkgVertexPositioner(const std::string &t, const std::string &n, const IInterface *p)
SG::ReadHandleKey< xAOD::VertexContainer > m_vertexContainerKey
CLHEP::HepLorentzVector * generate(const EventContext &ctx) const override final
@ PriVtx
Primary vertex.
Vertex_v1 Vertex
Define the latest version of the vertex class.