ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Simulation
BeamEffects
src
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
5
#include "
MatchingBkgVertexPositioner.h
"
6
7
#include "CLHEP/Vector/LorentzVector.h"
8
#include "
StoreGate/ReadHandle.h
"
9
10
namespace
Simulation
{
11
12
MatchingBkgVertexPositioner::MatchingBkgVertexPositioner
(
const
std::string &t,
13
const
std::string &n,
14
const
IInterface *p)
15
: base_class(t, n, p) {}
16
17
StatusCode
MatchingBkgVertexPositioner::initialize
() {
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
31
SG::ReadHandle<xAOD::VertexContainer>
vertices(
m_vertexContainerKey
, ctx);
32
if
(!vertices.
isValid
()) {
33
ATH_MSG_ERROR
(
"Couldn't retrieve xAOD::VertexContainer with key: "
34
<<
m_vertexContainerKey
);
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: "
51
<<
m_vertexContainerKey
);
52
return
nullptr
;
53
}
54
55
}
// namespace Simulation
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition
AthMsgStreamMacros.h:33
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition
AthMsgStreamMacros.h:31
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition
AthMsgStreamMacros.h:28
MatchingBkgVertexPositioner.h
ReadHandle.h
Handle class for reading from StoreGate.
SG::ReadHandle
Definition
StoreGate/StoreGate/ReadHandle.h:67
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
SG::ReadHandle::cptr
const_pointer_type cptr()
Dereference the pointer.
Simulation::MatchingBkgVertexPositioner::MatchingBkgVertexPositioner
MatchingBkgVertexPositioner(const std::string &t, const std::string &n, const IInterface *p)
Definition
MatchingBkgVertexPositioner.cxx:12
Simulation::MatchingBkgVertexPositioner::m_vertexContainerKey
SG::ReadHandleKey< xAOD::VertexContainer > m_vertexContainerKey
Definition
MatchingBkgVertexPositioner.h:38
Simulation::MatchingBkgVertexPositioner::initialize
StatusCode initialize() override final
Definition
MatchingBkgVertexPositioner.cxx:17
Simulation::MatchingBkgVertexPositioner::generate
CLHEP::HepLorentzVector * generate(const EventContext &ctx) const override final
Definition
MatchingBkgVertexPositioner.cxx:25
Simulation
Definition
BeamEffectsAlg.cxx:21
xAOD::VxType::PriVtx
@ PriVtx
Primary vertex.
Definition
TrackingPrimitives.h:590
xAOD::Vertex
Vertex_v1 Vertex
Define the latest version of the vertex class.
Definition
Event/xAOD/xAODTracking/xAODTracking/Vertex.h:16
Generated on
for ATLAS Offline Software by
1.17.0