ATLAS Offline Software
Loading...
Searching...
No Matches
TrigHIEventShapeHypoAlg.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4
6
7#include "Gaudi/Property.h"
10
12 ISvcLocator* pSvcLocator) :
13 ::HypoBase(name, pSvcLocator) {}
14
15
17 ATH_CHECK(m_hypoTools.retrieve());
18 ATH_CHECK(m_esKey.initialize());
19 return StatusCode::SUCCESS;
20}
21
22StatusCode TrigHIEventShapeHypoAlg::execute(const EventContext& context) const {
23 ATH_MSG_DEBUG ("Executing " << name() << "...");
24
25 // Retrieve the HI event shape container
26 auto esHandle = SG::makeHandle(m_esKey, context);
27 ATH_CHECK(esHandle.isValid());
28 ATH_MSG_DEBUG("Retrieving HI event shape container using key: " << esHandle.key());
29 const xAOD::HIEventShapeContainer* eventShapeContainer = esHandle.get();
30
31 // Retrieve the previous Decisions made before running this hypo
32 auto prevDecisionsHandle = SG::makeHandle(decisionInput(), context);
33 ATH_CHECK(prevDecisionsHandle.isValid());
34 ATH_MSG_DEBUG("Running with " << prevDecisionsHandle->size() << " implicit ReadHandles for previous decisions");
35 const TrigCompositeUtils::DecisionContainer* prevDecisions = prevDecisionsHandle.get();
36
37 // Make a new Decisions container which will contain the new Decision object created by this hypo
39 TrigCompositeUtils::DecisionContainer* newDecisions = decisionOutputHandle.ptr();
40
41 // Make trigger decisions and save to "newDecisions"
42 ATH_CHECK(decide(eventShapeContainer, newDecisions, prevDecisions, context));
43
44 // Common debug printing
45 ATH_CHECK(hypoBaseOutputProcessing(decisionOutputHandle));
46
47 return StatusCode::SUCCESS;
48}
49
50
53 const TrigCompositeUtils::DecisionContainer* oldDecisions,
54 const EventContext& context) const {
55
56 ATH_MSG_DEBUG("Executing decide() of " << name());
57 if (oldDecisions->size() != 1) {
58 ATH_MSG_ERROR("TrigHIEventShapeHypoAlg requires there to be exactly one previous Decision object, but found " << oldDecisions->size());
59 return StatusCode::FAILURE;
60 }
61 const TrigCompositeUtils::Decision* previousDecision = oldDecisions->at(0);
62
63 if (eventShapeContainer->size()==0) {
64 ATH_MSG_ERROR("There are no HIEventShape objects in the container");
65 return StatusCode::FAILURE;
66 }
67
68 // Create output Decision object, link it to prevDecision and its "feature"
69 auto newDecision = TrigCompositeUtils::newDecisionIn(newDecisions, previousDecision, TrigCompositeUtils::hypoAlgNodeName(), context);
70 ElementLink<xAOD::HIEventShapeContainer> esElementLink = ElementLink<xAOD::HIEventShapeContainer>(*eventShapeContainer, /*index*/ 0);
71 newDecision->setObjectLink<xAOD::HIEventShapeContainer>(TrigCompositeUtils::featureString(), esElementLink);
72
73 // Get set of active chains
74 const TrigCompositeUtils::DecisionIDContainer previousDecisionIDs{
75 TrigCompositeUtils::decisionIDs(previousDecision).begin(),
76 TrigCompositeUtils::decisionIDs(previousDecision).end()
77 };
78
79 for (const auto& tool: m_hypoTools) {
80 ATH_MSG_DEBUG("About to decide for " << tool->name());
81
82 auto decisionId = tool->getId();
83 if (TrigCompositeUtils::passed(decisionId.numeric(), previousDecisionIDs)) {
84 ATH_MSG_DEBUG("Passed previous trigger step");
85
86 bool pass;
87 ATH_CHECK(tool->decide(eventShapeContainer, pass));
88
89 if (pass) {
90 ATH_MSG_DEBUG("Passed " << tool->name());
91 TrigCompositeUtils::addDecisionID(decisionId, newDecision);
92 }
93 else {
94 ATH_MSG_DEBUG("Didn't pass " << tool->name());
95 }
96 }
97 else {
98 ATH_MSG_DEBUG("Didn't pass previous trigger step");
99 }
100 }
101
102 return StatusCode::SUCCESS;
103}
104
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_DEBUG(x)
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 initialize() override
ToolHandleArray< ITrigHIEventShapeHypoTool > m_hypoTools
TrigHIEventShapeHypoAlg(const std::string &name, ISvcLocator *pSvcLocator)
SG::ReadHandleKey< xAOD::HIEventShapeContainer > m_esKey
virtual StatusCode execute(const EventContext &context) const override
StatusCode decide(const xAOD::HIEventShapeContainer *eventShapeContainer, TrigCompositeUtils::DecisionContainer *newDecisions, const TrigCompositeUtils::DecisionContainer *oldDecisions, const EventContext &context) const
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.
HIEventShapeContainer_v2 HIEventShapeContainer
Define the latest version of the container.