Skip to content
Snippets Groups Projects
Commit d3ad28ec authored by Tadej Novak's avatar Tadej Novak Committed by Vakhtang Tsulaia
Browse files

Make EventInfoTagBuilder reentrant

Make EventInfoTagBuilder reentrant
parent 36bb4a71
No related branches found
No related tags found
No related merge requests found
......@@ -51,29 +51,13 @@ StatusCode EventInfoAttListTool::initialize() {
}
/* Build attribute list from EventInfo object */
const AthenaAttributeList EventInfoAttListTool::getAttributeList(const xAOD::EventInfo& eventInfo) {
// Create attributeList with appropriate attributes
AthenaAttributeList eventTag( *m_attribListSpec );
StatusCode sc = this->eventTag (eventTag, eventInfo);
if (sc.isFailure()) {
ATH_MSG_WARNING("Unable to build Tag Fragments for the Event");
}
ATH_MSG_DEBUG("EventInfoAttListTool - getAttributeList() return success");
return eventTag;
}
/* Build attribute list from EventInfo object */
std::unique_ptr<AthenaAttributeList>
EventInfoAttListTool::getAttributeListPtr(const xAOD::EventInfo& eventInfo)
EventInfoAttListTool::getAttributeListPtr(const xAOD::EventInfo& eventInfo) const
{
// Create attributeList with appropriate attributes
auto eventTag = std::make_unique<AthenaAttributeList> ( *m_attribListSpec );
const coral::AttributeListSpecification& specRef = *m_attribListSpec;
auto eventTag = std::make_unique<AthenaAttributeList> ( specRef );
StatusCode sc = this->eventTag (*eventTag, eventInfo);
if (sc.isFailure()) {
......@@ -88,7 +72,7 @@ EventInfoAttListTool::getAttributeListPtr(const xAOD::EventInfo& eventInfo)
/** build the tag associate to the event information */
StatusCode EventInfoAttListTool::eventTag(AthenaAttributeList& eventTag,
const xAOD::EventInfo& eventInfo)
const xAOD::EventInfo& eventInfo) const
{
// Note: for any attribute added here, please confirm the corresponding EventInfo member being
// retained in DAOD smart slimming:
......
......@@ -37,21 +37,18 @@ public:
static const InterfaceID& interfaceID( ) { return IID_EventInfoAttListTool; };
/** Overriding initialize, finalize and execute */
StatusCode initialize() override;
StatusCode finalize() override;
virtual StatusCode initialize() override;
virtual StatusCode finalize() override;
// interface
bool isValid();
const coral::AttributeListSpecification& getAttributeSpecification();
const AthenaAttributeList getAttributeList(const xAOD::EventInfo& einfo);
std::unique_ptr<AthenaAttributeList> getAttributeListPtr(const xAOD::EventInfo& einfo);
bool isValid() const;
const coral::AttributeListSpecification& getAttributeSpecification() const;
std::unique_ptr<AthenaAttributeList> getAttributeListPtr(const xAOD::EventInfo& einfo) const;
protected:
/** the various components to build their own fragments of tag */
StatusCode eventTag (AthenaAttributeList& eventTagCol,
const xAOD::EventInfo& eventInfo);
StatusCode eventTag(AthenaAttributeList& eventTagCol, const xAOD::EventInfo& eventInfo) const;
coral::AttributeListSpecification* m_attribListSpec{};
......
/*
Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
*/
#include "EventInfoTagBuilder.h"
......@@ -7,6 +7,7 @@
#include <StoreGate/ReadHandle.h>
#include <StoreGate/WriteHandle.h>
StatusCode EventInfoTagBuilder::initialize()
{
ATH_MSG_DEBUG( "Initializing " << name() );
......@@ -26,11 +27,11 @@ StatusCode EventInfoTagBuilder::initialize()
}
StatusCode EventInfoTagBuilder::execute()
StatusCode EventInfoTagBuilder::execute(const EventContext &ctx) const
{
ATH_MSG_DEBUG( "Executing " << name() );
SG::ReadHandle<xAOD::EventInfo> h_evt(m_evtKey);
SG::ReadHandle<xAOD::EventInfo> h_evt(m_evtKey, ctx);
if (!h_evt.isValid()) {
ATH_MSG_ERROR("Did not find xAOD::EventInfo");
return StatusCode::FAILURE;
......@@ -42,7 +43,7 @@ StatusCode EventInfoTagBuilder::execute()
// Check whether to propagate
if (m_propInput) {
SG::ReadHandle<AthenaAttributeList> h_att(m_inputAttList);
SG::ReadHandle<AthenaAttributeList> h_att(m_inputAttList, ctx);
// Check if there is an input to propagate
if (h_att.isValid()) {
for (auto it = h_att->specification().begin();
......@@ -65,7 +66,7 @@ StatusCode EventInfoTagBuilder::execute()
} // propagate
/** record attribute list to SG */
SG::WriteHandle<AthenaAttributeList> wh(m_attributeListName);
SG::WriteHandle<AthenaAttributeList> wh(m_attributeListName, ctx);
ATH_CHECK( wh.record(std::move(attribList)) );
ATH_MSG_DEBUG( "Finished " << name() );
......
/*
Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
*/
#ifndef EVENTTAGALGS_EVENTINFOTAGBUILDER_H
......@@ -26,7 +26,7 @@ inclusion in an event tag database.
*/
#include <AthenaBaseComps/AthAlgorithm.h>
#include <AthenaBaseComps/AthReentrantAlgorithm.h>
#include <GaudiKernel/ToolHandle.h>
#include <PersistentDataModel/AthenaAttributeList.h>
#include <StoreGate/ReadHandleKey.h>
......@@ -35,22 +35,20 @@ inclusion in an event tag database.
#include "EventInfoAttListTool.h"
class EventInfoTagBuilder : public AthAlgorithm
class EventInfoTagBuilder : public AthReentrantAlgorithm
{
public:
/// Standard constructor.
using AthAlgorithm::AthAlgorithm;
using AthReentrantAlgorithm::AthReentrantAlgorithm;
/// Destructor.
~EventInfoTagBuilder() = default;
virtual StatusCode initialize() override;
virtual StatusCode execute() override;
virtual StatusCode execute(const EventContext &ctx) const override;
private:
/// Global Event Tag Tool
ToolHandle<EventInfoAttListTool> m_tool{this, "Tool", "EventInfoAttListTool/EventInfoAttListTool", "EventInfoAttListTool used"};
SG::ReadHandleKey<xAOD::EventInfo> m_evtKey{this, "EventInfoKey", "EventInfo", "xAOD::EventInfo ReadHandleKey"};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment