ATLAS Offline Software
Loading...
Searching...
No Matches
MlMuonDVtxHypoAlg.cxx
Go to the documentation of this file.
1/*
2Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
5#include "MlMuonDVtxHypoAlg.h"
6
8
9using namespace TrigCompositeUtils;
10
12{
13 ATH_CHECK(m_DVOutputKey.initialize());
14
15 ATH_CHECK(m_hypoTools.retrieve());
16 return StatusCode::SUCCESS;
17}
18
19StatusCode MlMuonDVtxHypoAlg::execute(const EventContext& ctx) const {
20 ATH_MSG_DEBUG ( "Executing " << name() << "..." );
21
22 // Obtain incoming Decision Objects (one per L1 muon ROI)
23 auto previousDecisionsHandle = SG::makeHandle( decisionInput(), ctx );
24 ATH_CHECK( previousDecisionsHandle.isValid() );
25 ATH_MSG_DEBUG("Running with "<<previousDecisionsHandle->size()<<" previous decisions");
26
27 // New output trigger decisions container
29 auto decisions = outputHandle.ptr();
30
31 if (previousDecisionsHandle->size() == 0) {
32 ATH_MSG_DEBUG( "No previous decision, nothing to do.");
33 return StatusCode::SUCCESS;
34 }
35
36 const xAOD::TrigCompositeContainer* dvOutput {nullptr};
37 ATH_CHECK(SG::get(dvOutput, m_DVOutputKey, ctx));
38
39 if (dvOutput->size() != 1) {
40 ATH_MSG_ERROR("One DV output expected, but " << dvOutput->size() << " found.");
41 return StatusCode::FAILURE;
42 }
43
44 // Creating a DecisionIDContainer to hold all active chain IDs
45 DecisionIDContainer chainIDs;
46
47 // Create new output decision object
48 Decision* newDecision = newDecisionIn(decisions, hypoAlgNodeName());
49
50 // Link the DV output to the new decision
51 newDecision->setObjectLink(featureString(),
53
54 // We have only one output decision (event level) and many inputs (L1 muon ROIs),
55 // so we link the new decision to all previous decisions (L1 muon ROIs)
56 for (const Decision* previousDecision : *previousDecisionsHandle) {
57 linkToPrevious(newDecision, previousDecision, ctx);
58 decisionIDs(previousDecision, chainIDs);
59 }
60
61 MlMuonDVtxHypoTool::Info info{newDecision,
62 dvOutput->front()->getDetail<float>("Score"),
63 std::move(chainIDs)};
64
65 for (const auto& hypoTool : m_hypoTools) {
66 ATH_CHECK(hypoTool->decide(info));
67 }
68
69 ATH_CHECK( hypoBaseOutputProcessing(outputHandle) );
70 return StatusCode::SUCCESS;
71}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_ERROR(x,...)
Handle class for reading a decoration on an object.
const T * front() const
Access the first element in the collection 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
virtual StatusCode execute(const EventContext &context) const override
virtual StatusCode initialize() override
SG::ReadHandleKey< xAOD::TrigCompositeContainer > m_DVOutputKey
ToolHandleArray< MlMuonDVtxHypoTool > m_hypoTools
pointer_type ptr()
Dereference the pointer.
bool setObjectLink(const std::string &name, const ElementLink< CONTAINER > &link)
Set the link to an object.
const T * get(const ReadCondHandleKey< T > &key, const EventContext &ctx)
Convenience function to retrieve an object given a ReadCondHandleKey.
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
xAOD::TrigComposite Decision
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()
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 linkToPrevious(Decision *d, const std::string &previousCollectionKey, size_t previousIndex)
Links to the previous object, location of previous 'seed' decision supplied by hand.
void decisionIDs(const Decision *d, DecisionIDContainer &destination)
Extracts DecisionIDs stored in the Decision object.
TrigCompositeContainer_v1 TrigCompositeContainer
Declare the latest version of the container.