35{
36
37 SG::ReadHandle<xAOD::TruthEventContainer> importedTruthEvents{
m_eventsKey, ctx};
38 if (!importedTruthEvents.
isValid()) {
40 return StatusCode::FAILURE;
41 }
42
43
44 SG::WriteHandle<xAOD::TruthVertexContainer> writeHandleVtx{
m_outVtxKey, ctx};
45 ATH_CHECK(writeHandleVtx.
record(std::make_unique<xAOD::TruthVertexContainer>(),
46 std::make_unique<xAOD::TruthVertexAuxContainer>()));
49
50
51 for (const auto * event : *importedTruthEvents){
52
53 if (!event) continue;
54
56
57 if (!old_vert &&
event->nTruthVertices()>0){
58 old_vert = event->truthVertex(0);
59 }
60 if (old_vert){
61
62
64 newVertexCollection->
push_back( xTruthVertex );
65
68 xTruthVertex->
setX(old_vert->x());
69 xTruthVertex->
setY(old_vert->y());
70 xTruthVertex->
setZ(old_vert->z());
71 xTruthVertex->
setT(old_vert->t());
72 } else {
73 ATH_MSG_WARNING(
"No signal vertex or vertices associated to an input event!");
74 }
75 }
76 return StatusCode::SUCCESS;
77}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
value_type push_back(value_type pElem)
Add an element to the end of the collection.
SG::WriteHandleKey< xAOD::TruthVertexContainer > m_outVtxKey
Output collection name.
SG::ReadHandleKey< xAOD::TruthEventContainer > m_eventsKey
Input event collection (navigates to the vertices)
virtual bool isValid() override final
Can the handle be successfully dereferenced?
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
pointer_type ptr()
Dereference the pointer.
void setStatus(int value)
Set the vertex status.
void setZ(float value)
Set the vertex's longitudinal distance from the origin.
void setUid(int value)
Set the vertex unique ID.
void setT(float value)
Set the vertex time.
void setX(float value)
Set the x displacement of the vertex.
void setY(float value)
Set the y displacement of the vertex.
TruthVertex_v1 TruthVertex
Typedef to implementation.
TruthVertexContainer_v1 TruthVertexContainer
Declare the latest version of the truth vertex container.