Commit 9c3ced8e authored by Frank Winklmeier's avatar Frank Winklmeier
Browse files

DecisionObjectHandle: remove DataHandle inheritance

Remove the `DataHandle` inheritance of the various `DecisionObjectHandle`
classes and remove the internal caching of the decision object as the
ReadHandle(Key) already does its own caching.
parent ba6fef6e
/*
Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
*/
// Local include(s):
......@@ -21,52 +21,45 @@ namespace Trig {
DecisionObjectHandleStandalone::DecisionObjectHandleStandalone( SG::ReadHandleKey<xAOD::TrigDecision>* deckey,
SG::ReadHandleKey<xAOD::TrigNavigation>* navikey )
: m_deckey( deckey ), m_navikey( navikey ),
m_decision( nullptr ), m_navigation( nullptr ) {
: m_deckey( deckey ), m_navikey( navikey ) {
}
void DecisionObjectHandleStandalone::reset(bool) {
m_decision = nullptr;
m_navigation = nullptr;
invalidate();
return;
}
const xAOD::TrigDecision*
DecisionObjectHandleStandalone::getDecision() const {
if( ! m_decision && !m_deckey->empty() ) {
const EventContext& ctx = Gaudi::Hive::currentContext();
SG::ReadHandle<xAOD::TrigDecision> decisionReadHandle = SG::makeHandle(*m_deckey, ctx);
if( ! decisionReadHandle.isValid() ) {
[[maybe_unused]] static std::atomic<bool> warningPrinted =
[&]() { ATH_MSG_WARNING( "xAOD::TrigDecision is not available on the input" );
return true; }();
return nullptr;
}
m_decision = decisionReadHandle.ptr();
if( m_deckey->empty() ) return nullptr;
const EventContext& ctx = Gaudi::Hive::currentContext();
SG::ReadHandle<xAOD::TrigDecision> decisionReadHandle = SG::makeHandle(*m_deckey, ctx);
if( ! decisionReadHandle.isValid() ) {
[[maybe_unused]] static std::atomic<bool> warningPrinted =
[&]() { ATH_MSG_WARNING( "xAOD::TrigDecision is not available on the input" );
return true; }();
return nullptr;
}
return m_decision;
return decisionReadHandle.ptr();
}
const xAOD::TrigNavigation*
DecisionObjectHandleStandalone::getNavigation() const {
if( ! m_navigation && !m_navikey->empty() ) {
const EventContext& ctx = Gaudi::Hive::currentContext();
SG::ReadHandle<xAOD::TrigNavigation> navReadHandle = SG::makeHandle(*m_navikey, ctx);
if( ! navReadHandle.isValid() ) {
[[maybe_unused]] static std::atomic<bool> warningPrinted =
[&]() { ATH_MSG_WARNING( "xAOD::TrigNavigation is not available on the input" );
return true; }();
return nullptr;
}
m_navigation = navReadHandle.ptr();
if( m_navikey->empty() ) return nullptr;
const EventContext& ctx = Gaudi::Hive::currentContext();
SG::ReadHandle<xAOD::TrigNavigation> navReadHandle = SG::makeHandle(*m_navikey, ctx);
if( ! navReadHandle.isValid() ) {
[[maybe_unused]] static std::atomic<bool> warningPrinted =
[&]() { ATH_MSG_WARNING( "xAOD::TrigNavigation is not available on the input" );
return true; }();
return nullptr;
}
return m_navigation;
return navReadHandle.ptr();
}
} // namespace Trig
......@@ -15,7 +15,6 @@
#include "TrigDecisionTool/DecisionObjectHandle.h"
#include "TrigDecisionEvent/TrigDecision.h"
#include "StoreGate/DataHandle.h"
#include "StoreGate/ReadHandleKey.h"
#include <string>
......@@ -28,17 +27,15 @@ namespace Trig {
/**
* @brief Decision invalidator for Athena (really doing the job)
**/
class DecisionObjectHandleAthena : public DecisionObjectHandle<TrigDec::TrigDecision,TrigDec::TrigDecision>,
public DataHandle<TrigDec::TrigDecision>
class DecisionObjectHandleAthena : public DecisionObjectHandle<TrigDec::TrigDecision,TrigDec::TrigDecision>
{
public:
DecisionObjectHandleAthena( SG::ReadHandleKey<TrigDec::TrigDecision>* olddeckey );
virtual void reset (bool hard = false) override;
virtual void reset (bool hard = false);
virtual TrigDec::TrigDecision const * getDecision() const override;
virtual TrigDec::TrigDecision const * getNavigation() const override;
private:
SG::ReadHandleKey<TrigDec::TrigDecision>* m_oldDecKey;
mutable TrigDec::TrigDecision const * m_object;
SG::ReadHandleKey<TrigDec::TrigDecision>* m_oldDecKey;
};
}
#endif // TrigDecisionTool_DecisionObjectHandle_h
......
......@@ -12,7 +12,6 @@
#define TrigDecisionTool_DecisionObjectHandleEventInfo_h
#include <string>
#include "StoreGate/DataHandle.h"
#include "TrigDecisionTool/DecisionObjectHandle.h"
#include "EventInfo/EventInfo.h"
......@@ -26,17 +25,15 @@ namespace Trig {
/**
* @brief Decision invalidator for EventInfo (really doing the job)
**/
class DecisionObjectHandleEventInfo : public DecisionObjectHandle<TriggerInfo,void>,
public DataHandle<EventInfo>
class DecisionObjectHandleEventInfo : public DecisionObjectHandle<TriggerInfo,void>
{
public:
DecisionObjectHandleEventInfo( SG::ReadHandleKey<EventInfo>* oldEventInfoKey );
virtual void reset (bool hard = false) override;
virtual void reset (bool hard = false);
virtual TriggerInfo const * getDecision() const override;
virtual void const * getNavigation() const override;
private:
SG::ReadHandleKey<EventInfo>* m_oldEventInfoKey;
mutable EventInfo const * m_object;
};
}
......
......@@ -45,10 +45,6 @@ namespace Trig {
SG::ReadHandleKey<xAOD::TrigDecision>* m_deckey;
/// Key of the trigger navigation object in the event
SG::ReadHandleKey<xAOD::TrigNavigation>* m_navikey;
/// Cached pointer to the trigger decision object
mutable xAOD::TrigDecision const * m_decision;
/// Cached pointer to the trigger navigation object
mutable xAOD::TrigNavigation const * m_navigation;
}; // class DecisionObjectHandleStandalone
......
/*
Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
*/
#ifndef XAOD_ANALYSIS // Full Athena only
......@@ -10,35 +10,30 @@
using namespace Trig;
DecisionObjectHandleAthena::DecisionObjectHandleAthena( SG::ReadHandleKey<TrigDec::TrigDecision>* olddeckey )
: m_oldDecKey(olddeckey),
m_object(nullptr)
: m_oldDecKey(olddeckey)
{
}
TrigDec::TrigDecision const * DecisionObjectHandleAthena::getDecision() const {
if ( !m_object && !m_oldDecKey->empty() ) {
const EventContext& ctx = Gaudi::Hive::currentContext();
SG::ReadHandle<TrigDec::TrigDecision> oldDecisionReadHandle = SG::makeHandle(*m_oldDecKey, ctx);
if( ! oldDecisionReadHandle.isValid() ) {
[[maybe_unused]] static std::atomic<bool> warningPrinted =
[&]() { ATH_MSG_WARNING( "TrigDec::TrigDecision is not available on the input" );
return true; }();
return nullptr;
}
m_object = oldDecisionReadHandle.ptr();
if ( m_oldDecKey->empty() ) return nullptr;
const EventContext& ctx = Gaudi::Hive::currentContext();
SG::ReadHandle<TrigDec::TrigDecision> oldDecisionReadHandle = SG::makeHandle(*m_oldDecKey, ctx);
if( ! oldDecisionReadHandle.isValid() ) {
[[maybe_unused]] static std::atomic<bool> warningPrinted =
[&]() { ATH_MSG_WARNING( "TrigDec::TrigDecision is not available on the input" );
return true; }();
return nullptr;
}
return m_object;
return oldDecisionReadHandle.ptr();
}
TrigDec::TrigDecision const * DecisionObjectHandleAthena::getNavigation() const {
return getDecision();
}
void DecisionObjectHandleAthena::reset (bool hard) {
DataHandle<TrigDec::TrigDecision>::reset (hard);
m_object = nullptr;
void DecisionObjectHandleAthena::reset (bool) {
invalidate();
ATH_MSG_DEBUG("invalidated decision object");
}
......
/*
Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
*/
#ifndef XAOD_ANALYSIS // Full Athena only
......@@ -12,38 +12,32 @@
using namespace Trig;
DecisionObjectHandleEventInfo::DecisionObjectHandleEventInfo( SG::ReadHandleKey<EventInfo>* oldEventInfoKey )
: m_oldEventInfoKey(oldEventInfoKey),
m_object(nullptr)
: m_oldEventInfoKey(oldEventInfoKey)
{
}
TriggerInfo const * DecisionObjectHandleEventInfo::getDecision() const {
if ( !m_object && !m_oldEventInfoKey->empty() ) {
const EventContext& ctx = Gaudi::Hive::currentContext();
SG::ReadHandle<EventInfo> oldEventInfo = SG::makeHandle(*m_oldEventInfoKey, ctx);
if( ! oldEventInfo.isValid() ) {
static bool warningPrinted = false;
if( ! warningPrinted ) {
ATH_MSG_WARNING( "EventInfo is not available on the "
"input" );
warningPrinted = true;
}
return nullptr;
}
m_object = oldEventInfo.ptr();
if ( m_oldEventInfoKey->empty() ) return nullptr;
const EventContext& ctx = Gaudi::Hive::currentContext();
SG::ReadHandle<EventInfo> oldEventInfo = SG::makeHandle(*m_oldEventInfoKey, ctx);
if( ! oldEventInfo.isValid() ) {
[[maybe_unused]] static std::atomic<bool> warningPrinted =
[&]() { ATH_MSG_WARNING( "EventInfo is not available on the input" );
return true; }();
return nullptr;
}
return m_object->trigger_info();
return oldEventInfo->trigger_info();
}
void const * DecisionObjectHandleEventInfo::getNavigation() const {
ATH_MSG_ERROR("TDT configured with EventInfo object handle. It does not support navigation access!");
return nullptr;
}
void DecisionObjectHandleEventInfo::reset (bool hard) {
DataHandle<EventInfo>::reset (hard);
m_object = nullptr;
void DecisionObjectHandleEventInfo::reset (bool) {
invalidate();
ATH_MSG_DEBUG("invalidated decision object");
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment