ATLAS Offline Software
Loading...
Searching...
No Matches
TrigMissingETHypoAlg.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3*/
5
6#include "Gaudi/Property.h"
9
10using namespace TrigCompositeUtils;
12
14 ISvcLocator* pSvcLocator ) :
15 ::HypoBase( name, pSvcLocator ) {}
16
17
19
20 CHECK( m_hypoTools.retrieve() );
21 CHECK( m_metKey.initialize() );
22 return StatusCode::SUCCESS;
23}
24
25StatusCode TrigMissingETHypoAlg::execute( const EventContext& context ) const {
26 ATH_MSG_DEBUG ( "Executing " << name() << "..." );
27
28 // read in the met container
29 auto h_met = SG::makeHandle(m_metKey, context );
30 ATH_MSG_DEBUG("Retrieving MET from: " << h_met.key());
31 ATH_CHECK(h_met.isValid());
32 const TrigMissingETContainer* metContainer = h_met.get();
33
34 ATH_MSG_DEBUG("The MET value is " << round(std::hypot((*metContainer)[0]->ex(), (*metContainer)[0]->ey())/1000.0 ));
35
36 // read in the previous Decisions made before running this hypo Alg.
37 auto h_prevDecisions = SG::makeHandle(decisionInput(), context );
38 if( not h_prevDecisions.isValid() ) {//implicit
39 ATH_MSG_ERROR( "No implicit RH for previous decisions "<< decisionInput().key()<<". Check the input decisions key?" );
40 return StatusCode::FAILURE;
41 }
42 ATH_MSG_DEBUG( "Decisions being read from " << decisionInput().key() );
43 ATH_MSG_DEBUG( "Running with "<< h_prevDecisions->size() <<" implicit ReadHandles for previous decisions");
44 auto prevDecisions = h_prevDecisions.get();
45
46 // Make a new Decisions container which will contain the new Decision object created by this hypo.
47 // (Creating a single output as executing on a single MET value)
49 DecisionContainer* newDecisions = outputHandle.ptr();
50
51 // Make trigger decisions and save to "newDecisions"
52 ATH_CHECK(decide(metContainer, newDecisions, prevDecisions, context));
53
54 // Common debug printing
56
57 return StatusCode::SUCCESS;
58}
59
60
61
64 const DecisionContainer* oldDecisions,
65 const EventContext& context) const{
66
67 ATH_MSG_DEBUG("Executing decide() of " << name() );
68 if (oldDecisions->size() != 1) {
69 ATH_MSG_ERROR("TrigMissingETHypoAlg requires there to be exactly one previous Decision object, but found " << oldDecisions->size());
70 return StatusCode::FAILURE;
71 }
72 const Decision* previousDecision = oldDecisions->at(0);
73
74 if (metContainer->size()==0){
75 ATH_MSG_ERROR("There are no TrigEFMissingET objects in the MET container" );
76 return StatusCode::FAILURE;
77 } else if (metContainer->size()>1) {
78 ATH_MSG_ERROR("There is more than one TrigEFMissingET object in the MET container");
79 return StatusCode::FAILURE;
80 }
81
82 // Create output Decision object, link it to prevDecision & its "feature"
83 auto newDecision = TrigCompositeUtils::newDecisionIn(newDecisions, previousDecision, hypoAlgNodeName(), context);
85 newDecision->setObjectLink<xAOD::TrigMissingETContainer>(featureString(), metElementLink);
86
87 // Get set of active chains
88 const TrigCompositeUtils::DecisionIDContainer previousDecisionIDs{
89 TrigCompositeUtils::decisionIDs(previousDecision).begin(),
90 TrigCompositeUtils::decisionIDs(previousDecision).end()
91 };
92
93 //bool allPassed = true;
94 for (const auto& tool: m_hypoTools) {
95 auto decisionId = tool->getId();
96 ATH_MSG_DEBUG( "About to decide for " << tool->name() );
97 if (TrigCompositeUtils::passed(decisionId.numeric(), previousDecisionIDs)){
98 ATH_MSG_DEBUG("Passed previous trigger step");
99 bool pass;
100 ATH_CHECK(tool->decide(metContainer, pass));
101 if (pass) {
102 ATH_MSG_DEBUG("Passed " << tool->name() );
103 TrigCompositeUtils::addDecisionID(decisionId, newDecision);
104 } else ATH_MSG_DEBUG("Didn't pass " << tool->name() );
105 } else ATH_MSG_DEBUG("Didn't pass previous trigger step");
106 }
107
108 return StatusCode::SUCCESS;
109}
110
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_DEBUG(x)
#define CHECK(...)
Evaluate an expression and check for errors.
const T * get(size_type n) const
Access an element, as an rvalue.
const T * at(size_type n) const
Access an element, as an rvalue.
size_type size() const noexcept
Returns the number of elements in the collection.
const SG::ReadHandleKey< TrigCompositeUtils::DecisionContainer > & decisionInput() const
methods for derived classes to access handles of the base class input other read/write handles may be...
Definition HypoBase.cxx:18
const SG::WriteHandleKey< TrigCompositeUtils::DecisionContainer > & decisionOutput() const
methods for derived classes to access handles of the base class output other read/write handles may b...
Definition HypoBase.cxx:22
StatusCode hypoBaseOutputProcessing(SG::WriteHandle< TrigCompositeUtils::DecisionContainer > &outputHandle, MSG::Level lvl=MSG::DEBUG) const
Base class function to be called once slice specific code has finished. Handles debug printing and va...
Definition HypoBase.cxx:35
HypoBase(const std::string &name, ISvcLocator *pSvcLocator)
constructor, to be called by sub-class constructors
Definition HypoBase.cxx:12
pointer_type ptr()
Dereference the pointer.
virtual StatusCode execute(const EventContext &context) const override
TrigMissingETHypoAlg(const std::string &name, ISvcLocator *pSvcLocator)
virtual StatusCode initialize() override
StatusCode decide(const xAOD::TrigMissingETContainer *metContainer, TrigCompositeUtils::DecisionContainer *newDecisions, const TrigCompositeUtils::DecisionContainer *oldDecisions, const EventContext &context) const
ToolHandleArray< ITrigMissingETHypoTool > m_hypoTools
SG::ReadHandleKey< xAOD::TrigMissingETContainer > m_metKey
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Decision * newDecisionIn(DecisionContainer *dc, const std::string &name)
Helper method to create a Decision object, place it in the container and return a pointer to it.
const std::string & featureString()
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
SG::WriteHandle< DecisionContainer > createAndStore(const SG::WriteHandleKey< DecisionContainer > &key, const EventContext &ctx)
Creates and right away records the DecisionContainer with the key.
const std::string & hypoAlgNodeName()
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.
TrigMissingETContainer_v1 TrigMissingETContainer
DataVector of TrigMissingET - the current version.