Skip to content
Snippets Groups Projects
Commit 4b1b8b0b authored by Stewart Martin-Haugh's avatar Stewart Martin-Haugh
Browse files

Merge branch 'master-trig-decisionhandling-base-classes' into 'master'

Master trig decisionhandling base classes

See merge request atlas/athena!9963
parents 7c6214b4 95a08b1c
No related branches found
No related tags found
No related merge requests found
/*
Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
*/
#ifndef DECISIONHANDLING_HYPOBASE_H
#define DECISIONHANDLING_HYPOBASE_H 1
#include "DecisionHandling/TrigCompositeUtils.h"
#include "AthenaBaseComps/AthAlgorithm.h"
#include "AthenaBaseComps/AthReentrantAlgorithm.h"
#include "StoreGate/ReadHandleKeyArray.h"
class HypoBase : public ::AthReentrantAlgorithm {
/**
* @class HypoBase
* @brief Hypothesis algorithms take the output of reco algorithms and the decision from the preceeding InputMaker, to produce a new decision.
This is a base class for HLT Hypos to reduce boilerplate and enforce the common naming scheme for decision handle keys. Derived classes will have to add specific reco data read & write keys to suit their purpose.
**/
public:
/// constructor, to be called by sub-class constructors
HypoBase( const std::string& name, ISvcLocator* pSvcLocator );
/// destructor
virtual ~HypoBase();
/// initialise this base class and renounce input decision key handles
StatusCode initialize() override;
/// execute to be implemented in derived clas
virtual StatusCode execute_r(const EventContext&) const = 0;
//StatusCode execute(){};
virtual StatusCode finalize() = 0;
/// special method for initialisation of derived classes, to be implemented by them, called from base class initialize
virtual StatusCode subInitialize()= 0;
protected:
/// methods for derived classes to access handles of the base class input and output decisions; other read/write handles may be implemented by derived classes
const SG::ReadHandleKey<TrigCompositeUtils::DecisionContainer>& decisionInput() const;
const SG::WriteHandleKey<TrigCompositeUtils::DecisionContainer>& decisionOutput() const;
private:
/// input decisions, will be implicit (renounced).
SG::ReadHandleKey<TrigCompositeUtils::DecisionContainer> m_input { this, "previousDecisions", "InputDecision", "Input Decision (implicit)" };
/// output decisions
SG::WriteHandleKey<TrigCompositeUtils::DecisionContainer> m_output { this, "Output", "OutputDecision", "Ouput Decision" };
// for future implementation: ToolHandleArray<ITestHypoTool> m_tools { this, "HypoTools", {}, "Hypo tools" };
};
#endif // DECISIONHANDLING_HYPOBASE_H
/*
Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
*/
#include "DecisionHandling/HypoBase.h"
HypoBase::HypoBase( const std::string& name, ISvcLocator* pSvcLocator )
: ::AthReentrantAlgorithm( name, pSvcLocator ) {}
HypoBase::~HypoBase() {}
const SG::ReadHandleKey<TrigCompositeUtils::DecisionContainer>& HypoBase::decisionInput() const{
return m_input;
}
const SG::WriteHandleKey<TrigCompositeUtils::DecisionContainer>& HypoBase::decisionOutput() const{
return m_output;
}
StatusCode HypoBase::initialize() {
CHECK( m_input.initialize() );
renounce(m_input); // make inputs implicit, i.e. not required by scheduler
ATH_MSG_DEBUG("Will consume implicit decision: " << m_input.key() );
CHECK( m_output.initialize() );
ATH_MSG_DEBUG(" and produce decision: " << m_output.key() );
// initialise sub class
CHECK ( subInitialize() );
return StatusCode::SUCCESS;
}
......@@ -19,7 +19,8 @@ StatusCode InputMakerBase::initialize() {
for (auto& input: m_inputs){
ATH_MSG_DEBUG( " "<<input.key() );
}
ATH_MSG_DEBUG(" and produce decisions: " << m_outputs );
CHECK( m_outputs.initialize() );
ATH_MSG_DEBUG(" and produce decisions: ");
for (auto& output: m_outputs){
ATH_MSG_DEBUG( " "<<output.key() );
}
......
......@@ -5,45 +5,31 @@
// TrigUpgradeTest includes
#include "TestHypoAlg.h"
namespace HLTTest {
TestHypoAlg::TestHypoAlg( const std::string& name,
ISvcLocator* pSvcLocator ) :
::AthReentrantAlgorithm( name, pSvcLocator ) {}
TestHypoAlg::TestHypoAlg( const std::string& name, ISvcLocator* pSvcLocator )
: ::HypoBase( name, pSvcLocator ) {}
TestHypoAlg::~TestHypoAlg() {}
StatusCode TestHypoAlg::initialize() {
StatusCode TestHypoAlg::subInitialize() {
ATH_MSG_INFO ("Initializing " << name() << "...");
CHECK( m_output.initialize() );
CHECK( m_recoInput.initialize() );
CHECK( m_previousDecisions.initialize() );
renounce(m_previousDecisions);
ATH_MSG_DEBUG("Will consume implicit previous decisions "<< m_previousDecisions.key());
// for (auto& input: m_previousDecisions){
//ATH_MSG_DEBUG(" "<<input.key());
//}
CHECK( m_tools.retrieve() );
return StatusCode::SUCCESS;
}
StatusCode TestHypoAlg::finalize() {
ATH_MSG_INFO( "Finalizing " << name() << "..." );
return StatusCode::SUCCESS;
}
StatusCode TestHypoAlg::execute_r( const EventContext& context ) const {
ATH_MSG_DEBUG( "Executing " << name() << "..." );
auto previousDecisionsHandle = SG::makeHandle( m_previousDecisions, context );
auto previousDecisionsHandle = SG::makeHandle( decisionInput(), context );
if( not previousDecisionsHandle.isValid() ) {//implicit
ATH_MSG_DEBUG( "No implicit RH for previous decisions "<< m_previousDecisions.key()<<": is this expected?" );
ATH_MSG_DEBUG( "No implicit RH for previous decisions "<< decisionInput().key()<<": is this expected?" );
return StatusCode::SUCCESS;
}
......@@ -95,7 +81,7 @@ namespace HLTTest {
auto d = newDecisionIn(decisions.get());
d->setObjectLink( "feature", ElementLink<xAOD::TrigCompositeContainer>(m_recoInput.key(), counter) );// feature used by the Tool
d->setObjectLink( "initialRoI", featurelink );// this is used by the InputMaker
d->setObjectLink( "previousDecisions", ElementLink<DecisionContainer>(m_previousDecisions.key(), pos) );// link to previous decision object
d->setObjectLink( "previousDecisions", ElementLink<DecisionContainer>(decisionInput().key(), pos) );// link to previous decision object
}
else{
ATH_MSG_ERROR( " Can not find reference to previous decision from feature " + m_linkName.value() + " from reco object " << counter );
......@@ -112,7 +98,7 @@ namespace HLTTest {
}
}
auto outputHandle = SG::makeHandle(m_output, context);
auto outputHandle = SG::makeHandle(decisionOutput(), context);
CHECK( outputHandle.record(std::move(decisions), std::move(aux) ) );
ATH_MSG_DEBUG( "Exiting with "<< outputHandle->size() <<" decisions");
......
......@@ -6,7 +6,7 @@
#include <string>
#include "AthenaBaseComps/AthReentrantAlgorithm.h"
#include "DecisionHandling/HypoBase.h"
#include "xAODTrigger/TrigCompositeContainer.h"
#include "DecisionHandling/TrigCompositeUtils.h"
#include "TrigSteeringEvent/TrigRoiDescriptorCollection.h"
......@@ -20,33 +20,25 @@ namespace HLTTest {
using namespace TrigCompositeUtils;
class TestHypoAlg : public ::AthReentrantAlgorithm
class TestHypoAlg : public ::HypoBase
{
public:
TestHypoAlg( const std::string& name, ISvcLocator* pSvcLocator );
virtual ~TestHypoAlg();
StatusCode initialize() override;
virtual StatusCode execute_r( const EventContext& context ) const override;
StatusCode finalize() override;
StatusCode subInitialize() override;
virtual StatusCode execute_r( const EventContext& context ) const override;
StatusCode finalize() override;
private:
typedef TrigRoiDescriptor FeatureOBJ;
typedef TrigRoiDescriptorCollection FeatureContainer;
// the DecisionContainer read/write handle keys are in the base class, called previousDecisions and Output
TestHypoAlg();
ToolHandleArray<ITestHypoTool> m_tools { this, "HypoTools", {}, "Hypo tools" };
SG::ReadHandleKey<xAOD::TrigCompositeContainer> m_recoInput { this, "Input", "Input", "Key for reco input"};
SG::ReadHandleKey <DecisionContainer> m_previousDecisions { this, "previousDecisions", "previousDecisions", "Key for decisions per RoI" };
SG::WriteHandleKey<DecisionContainer> m_output { this, "Output", "Output", "Key for decision output"};
StringProperty m_linkName {this, "LinkName", "initialRoI", "name of the link to the features in the decision, e.g. 'feature', 'initialRoI'"};
};
......
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