ATLAS Offline Software
Loading...
Searching...
No Matches
TrigmuCombHypoAlg.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
5#include "TrigmuCombHypoAlg.h"
6
10
11using namespace TrigCompositeUtils;
12
13// --------------------------------------------------------------------------------
14// --------------------------------------------------------------------------------
15
16TrigmuCombHypoAlg::TrigmuCombHypoAlg( const std::string& name,
17 ISvcLocator* pSvcLocator ) :
18 ::HypoBase( name, pSvcLocator )
19{}
20
21
23{
24 ATH_CHECK(m_hypoTools.retrieve());
25
27 ATH_CHECK(m_muCombKey.initialize());
28
29 return StatusCode::SUCCESS;
30}
31
32// --------------------------------------------------------------------------------
33// --------------------------------------------------------------------------------
34
35StatusCode TrigmuCombHypoAlg::execute(const EventContext& context) const
36{
37 // common for all Hypos, to move in the base class
38 ATH_MSG_DEBUG("StatusCode TrigmuCombHypoAlg::execute start");
39 auto previousDecisionsHandle = SG::makeHandle( decisionInput(), context);
40 ATH_CHECK( previousDecisionsHandle.isValid() );
41 ATH_MSG_DEBUG( "Running with "<< previousDecisionsHandle->size() <<" previous decisions");
42
43 // new output decisions
45 auto decisions = outputHandle.ptr();
46 // end of common
47
48 std::vector<TrigmuCombHypoTool::CombinedMuonInfo> toolInput;
49 // loop over previous decisions
50 size_t counter = 0;
51
52 for ( const auto previousDecision: *previousDecisionsHandle ) {
53 // get View
54 ATH_CHECK( previousDecision->hasObjectLink(viewString()) );
55 auto viewEL = previousDecision->objectLink<ViewContainer>(viewString());
56 ATH_CHECK( viewEL.isValid() );
57
58 // get info
59 auto muCombHandle = ViewHelper::makeHandle( *viewEL, m_muCombKey, context );
60 ATH_CHECK( muCombHandle.isValid() );
61 ATH_MSG_DEBUG( "Muinfo handle size: " << muCombHandle->size() << "...");
62
63 // loop over muCombs (more than one muon can be found by L2 inside-out algos)
64 for(uint i=0; i<muCombHandle->size(); i++){
65 auto muCombEL = ViewHelper::makeLink( *viewEL, muCombHandle, i );
66 ATH_CHECK( muCombEL.isValid() );
67 const xAOD::L2CombinedMuon* muComb = *muCombEL;
68 const xAOD::L2StandAloneMuon* muFast = muComb->muSATrack();
69
70 // create new decisions
71 auto newd = newDecisionIn( decisions, hypoAlgNodeName() );
72
73 toolInput.emplace_back( TrigmuCombHypoTool::CombinedMuonInfo{ newd, muComb, muFast, previousDecision} );
74
75 // set objectLink
76 newd->setObjectLink( featureString(), muCombEL );
77 TrigCompositeUtils::linkToPrevious( newd, previousDecision, context);
78
79 //set roi link (to use same roi in EF CB step)
81 newd->setObjectLink(m_roiLinkName.value(), roiLink.link);
82
83 // DEBUG
84 ATH_MSG_DEBUG("REGTEST: muCBTrack pt in " << m_muCombKey.key() << " = " << (*muCombEL)->pt()/Gaudi::Units::GeV << " GeV");
85 ATH_MSG_DEBUG("REGTEST: muCBTrack eta/phi in " << m_muCombKey.key() << " = " << (*muCombEL)->eta() << "/" << (*muCombEL)->phi());
86 ATH_MSG_DEBUG("Added view, features, previous decision to new decision "<<counter <<" for view "<<(*viewEL)->name() );
87
88 counter++;
89 }
90 }
91 for ( auto & tool: m_hypoTools ) {
92 ATH_MSG_DEBUG("Go to " << tool);
93 ATH_CHECK( tool->decide( toolInput ) );
94 }
95
97
98 ATH_MSG_DEBUG("StatusCode TrigmuCombHypoAlg::execute success");
99 return StatusCode::SUCCESS;
100}
101
102// --------------------------------------------------------------------------------
103// --------------------------------------------------------------------------------
104
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x)
unsigned int uint
DataVector< SG::View > ViewContainer
View container for recording in StoreGate.
Definition View.h:290
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce(T &h)
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
virtual StatusCode initialize() override
Gaudi::Property< std::string > m_roiLinkName
SG::ReadHandleKey< xAOD::L2CombinedMuonContainer > m_muCombKey
ToolHandleArray< TrigmuCombHypoTool > m_hypoTools
TrigmuCombHypoAlg(const std::string &name, ISvcLocator *pSvcLocator)
Main LVL2 Algorithm.
Definition muComb.h:54
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
const std::string & viewString()
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()
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.
LinkInfo< T > findLink(const Decision *start, const std::string &linkName, const bool suppressMultipleLinksWarning=false)
Perform a recursive search for ElementLinks of type T and name 'linkName', starting from Decision obj...
ElementLink< T > makeLink(const SG::View *view, const SG::ReadHandle< T > &handle, size_t index)
Create EL to a collection in view.
Definition ViewHelper.h:309
auto makeHandle(const SG::View *view, const KEY &key, const EventContext &ctx)
Create a view handle from a handle key.
Definition ViewHelper.h:273
L2CombinedMuon_v1 L2CombinedMuon
Define the latest version of the muon CB class.
L2StandAloneMuon_v2 L2StandAloneMuon
Define the latest version of the muon SA class.