ATLAS Offline Software
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"
8 #include "StoreGate/ReadHandle.h"
9 
10 namespace 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 
25 CLHEP::HepLorentzVector *MatchingBkgVertexPositioner::generate(
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
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
SG::ReadHandle::cptr
const_pointer_type cptr()
Dereference the pointer.
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
Simulation::MatchingBkgVertexPositioner::generate
CLHEP::HepLorentzVector * generate(const EventContext &ctx) const override final
Definition: MatchingBkgVertexPositioner.cxx:25
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
Simulation::MatchingBkgVertexPositioner::initialize
StatusCode initialize() override final
Definition: MatchingBkgVertexPositioner.cxx:17
Simulation::MatchingBkgVertexPositioner::m_vertexContainerKey
SG::ReadHandleKey< xAOD::VertexContainer > m_vertexContainerKey
Definition: MatchingBkgVertexPositioner.h:38
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
beamspotman.n
n
Definition: beamspotman.py:731
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
xAOD::VxType::PriVtx
@ PriVtx
Primary vertex.
Definition: TrackingPrimitives.h:571
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
MatchingBkgVertexPositioner.h
xAOD::Vertex_v1
Class describing a Vertex.
Definition: Vertex_v1.h:42
Simulation
Definition: BeamEffectsAlg.cxx:21
ReadHandle.h
Handle class for reading from StoreGate.
Simulation::MatchingBkgVertexPositioner::MatchingBkgVertexPositioner
MatchingBkgVertexPositioner(const std::string &t, const std::string &n, const IInterface *p)
Definition: MatchingBkgVertexPositioner.cxx:12