ATLAS Offline Software
Loading...
Searching...
No Matches
TestHypoTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3*/
4#include "TestHypoTool.h"
6
7using namespace TrigCompositeUtils;
8
9
10namespace HLTTest {
11
12 TestHypoTool::TestHypoTool( const std::string& type,
13 const std::string& name,
14 const IInterface* parent ) :
15 ITestHypoTool( name ),
16 AthAlgTool( type, name, parent )
17 {
19 }
20
22
24 ATH_MSG_INFO( "Initializing " << name() << "..." );
25
26 ATH_MSG_DEBUG("Configured to require chain " << m_decisionId );
27 ATH_MSG_DEBUG("Link name is "<<m_linkName.value());
28 ATH_MSG_DEBUG("threshold="<<m_threshold);
29 ATH_MSG_DEBUG("property="<<m_property);
30 return StatusCode::SUCCESS;
31 }
32
33 StatusCode TestHypoTool::decide( DecisionContainer* decisions ) const {
34 ATH_MSG_DEBUG( "Add decisionIDs to " << decisions->size() <<" output decisions" );
35 size_t counter = 0;
36 for ( const auto d: *decisions ) {
37 //get previous decisions
38 std::vector<ElementLink<DecisionContainer>> inputLinks = getLinkToPrevious(d);
39 ATH_MSG_DEBUG("Decision "<< counter <<": Got "<<inputLinks.size()<<" input decisions");
40 for (const auto& previousDecisions: inputLinks){
41
43 TrigCompositeUtils::decisionIDs( *previousDecisions, objDecisions );
44
45 ATH_MSG_DEBUG("Number of decision-IDs for input "<< counter <<" is: " << objDecisions.size() );
46
47 if ( TrigCompositeUtils::passed( m_decisionId.numeric(), objDecisions ) ) {
48 const auto feature = d->objectLink<xAOD::TrigCompositeContainer>( "feature" );
49 if ( not feature.isValid() ) {
50 ATH_MSG_ERROR( " Can not find reference to the object from the decision" );
51 return StatusCode::FAILURE;
52 }
53 const float v = (*feature)->getDetail<float>( m_property );
54 if ( v > m_threshold ) { // actual cut will be more complex of course
55 ATH_MSG_DEBUG( m_threshold << " passed by value: " << v << ". Adding "<< m_decisionId <<" to output" );
57 } else {
58 ATH_MSG_DEBUG( m_threshold << " not passed by value " << v );
59 }
60
61 } else {
62 ATH_MSG_DEBUG("No Input decisions matched");
63 }
64 counter++;
65 }
66 }
67 return StatusCode::SUCCESS;
68 }
69
70
72 ATH_MSG_INFO( "Finalizing " << name() << "..." );
73 return StatusCode::SUCCESS;
74 }
75
76} //> end namespace HLTTest
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
ITestHypoTool(const std::string &name)
HLT::Identifier m_decisionId
StringProperty m_linkName
StatusCode initialize() override
StatusCode decide(DecisionContainer *decisions) const override
method invoked to work out the decisions per object
TestHypoTool(const std::string &type, const std::string &name, const IInterface *parent)
Gaudi::Property< float > m_threshold
StringProperty m_property
StatusCode finalize() override
static HLT::Identifier fromToolName(const std::string &tname)
const std::vector< ElementLink< DecisionContainer > > getLinkToPrevious(const Decision *d)
returns links to previous decision object 'seed'
bool passed(DecisionID id, const DecisionIDContainer &idSet)
checks if required decision ID is in the set of IDs in the container
std::set< DecisionID > DecisionIDContainer
void addDecisionID(DecisionID id, Decision *d)
Appends the decision (given as ID) to the decision object.
void decisionIDs(const Decision *d, DecisionIDContainer &destination)
Extracts DecisionIDs stored in the Decision object.
TrigCompositeContainer_v1 TrigCompositeContainer
Declare the latest version of the container.