ATLAS Offline Software
Loading...
Searching...
No Matches
Simulation::MatchingBkgVertexPositioner Class Reference

Returns a VertexShift based on what is given in the background input file. More...

#include <MatchingBkgVertexPositioner.h>

Inheritance diagram for Simulation::MatchingBkgVertexPositioner:
Collaboration diagram for Simulation::MatchingBkgVertexPositioner:

Public Member Functions

 MatchingBkgVertexPositioner (const std::string &t, const std::string &n, const IInterface *p)
virtual ~MatchingBkgVertexPositioner ()=default
StatusCode initialize () override final
CLHEP::HepLorentzVector * generate (const EventContext &ctx) const override final

Private Attributes

SG::ReadHandleKey< xAOD::VertexContainerm_vertexContainerKey
SG::ReadHandleKey< McEventCollectionm_mcEventKey

Detailed Description

Returns a VertexShift based on what is given in the background input file.

Definition at line 25 of file MatchingBkgVertexPositioner.h.

Constructor & Destructor Documentation

◆ MatchingBkgVertexPositioner()

Simulation::MatchingBkgVertexPositioner::MatchingBkgVertexPositioner ( const std::string & t,
const std::string & n,
const IInterface * p )

Definition at line 12 of file MatchingBkgVertexPositioner.cxx.

15 : base_class(t, n, p) {}

◆ ~MatchingBkgVertexPositioner()

virtual Simulation::MatchingBkgVertexPositioner::~MatchingBkgVertexPositioner ( )
virtualdefault

Member Function Documentation

◆ generate()

CLHEP::HepLorentzVector * Simulation::MatchingBkgVertexPositioner::generate ( const EventContext & ctx) const
finaloverride

Definition at line 35 of file MatchingBkgVertexPositioner.cxx.

36 {
37 // we can currently not reliably determine if the timing information is
38 // available
39 constexpr bool enableTime{false};
40 if(!m_vertexContainerKey.key().empty()) {
41 SG::ReadHandle<xAOD::VertexContainer> vertices(m_vertexContainerKey, ctx);
42 if (!vertices.isValid()) {
43 ATH_MSG_ERROR("Couldn't retrieve xAOD::VertexContainer with key: "
45 return nullptr;
46 }
47
48 for (const xAOD::Vertex *vx : *(vertices.cptr())) {
49 if (vx->vertexType() == xAOD::VxType::PriVtx) {
50 ATH_MSG_INFO("Using primary vertex with position and time: "
51 << vx->position().x() << " " << vx->position().y() << " "
52 << vx->position().z() << " "
53 << (enableTime && vx->hasValidTime() ? vx->time() : 0));
54 return new CLHEP::HepLorentzVector(
55 vx->position().x(), vx->position().y(), vx->position().z(),
56 enableTime && vx->hasValidTime() ? vx->time() : 0);
57 }
58 }
59
60 ATH_MSG_ERROR("No primary vertex found in xAOD::VertexContainer with key: "
62 return nullptr;
63 } else if (!m_mcEventKey.key().empty()) {
64 SG::ReadHandle<McEventCollection> mcEvent(m_mcEventKey, ctx);
65 for ( auto event: *mcEvent) {
66 for ( auto vertex: event->vertices()) {
67 const float x = vertex->position().x();
68 const float y = vertex->position().y();
69 const float z = vertex->position().z();
70
71 ATH_MSG_DEBUG("bkg gen vertex position " << vertex->position() << " " << vertex->particles_in_size());
72 return new CLHEP::HepLorentzVector(x, y, z, 0);
73 }
74 }
75 }
76 return nullptr;
77}
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_ERROR(x,...)
#define ATH_MSG_INFO(x,...)
#define y
#define x
#define z
SG::ReadHandleKey< McEventCollection > m_mcEventKey
SG::ReadHandleKey< xAOD::VertexContainer > m_vertexContainerKey
@ PriVtx
Primary vertex.
Vertex_v1 Vertex
Define the latest version of the vertex class.

◆ initialize()

StatusCode Simulation::MatchingBkgVertexPositioner::initialize ( )
finaloverride

Definition at line 17 of file MatchingBkgVertexPositioner.cxx.

17 {
18 ATH_MSG_VERBOSE("Initializing ...");
19
22
23 if ( m_vertexContainerKey.key().empty() && m_mcEventKey.key().empty()) {
24 ATH_MSG_ERROR("Both, vertex and McEventCollection keys are empty, no source of vertex position");
25 return StatusCode::FAILURE;
26 }
27 if ( !m_vertexContainerKey.key().empty() && !m_mcEventKey.key().empty()) {
28 ATH_MSG_ERROR("Both, vertex and McEventCollection keys are not empty, ambiguous source of vertex position");
29 return StatusCode::FAILURE;
30 }
31
32 return StatusCode::SUCCESS;
33}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x,...)

Member Data Documentation

◆ m_mcEventKey

SG::ReadHandleKey<McEventCollection> Simulation::MatchingBkgVertexPositioner::m_mcEventKey
private
Initial value:
{
this, "McEventCollectionName", "", "Use MC collection (typically Bkg_TruthEvent) as source of vertex position"}

Definition at line 41 of file MatchingBkgVertexPositioner.h.

41 {
42 this, "McEventCollectionName", "", "Use MC collection (typically Bkg_TruthEvent) as source of vertex position"};

◆ m_vertexContainerKey

SG::ReadHandleKey<xAOD::VertexContainer> Simulation::MatchingBkgVertexPositioner::m_vertexContainerKey
private
Initial value:
{
this, "PrimaryVertexContainerName", ""}

Definition at line 39 of file MatchingBkgVertexPositioner.h.

39 {
40 this, "PrimaryVertexContainerName", ""};

The documentation for this class was generated from the following files: