ATLAS Offline Software
Loading...
Searching...
No Matches
TrigmuCombHypoAlg.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3*/
4
6#include "TrigmuCombHypoAlg.h"
8
9using namespace TrigCompositeUtils;
10
11// --------------------------------------------------------------------------------
12// --------------------------------------------------------------------------------
13
14TrigmuCombHypoAlg::TrigmuCombHypoAlg( const std::string& name,
15 ISvcLocator* pSvcLocator ) :
16 ::HypoBase( name, pSvcLocator )
17{}
18
19
21{
22 ATH_CHECK(m_hypoTools.retrieve());
23
25 ATH_CHECK(m_muCombKey.initialize());
26
27 return StatusCode::SUCCESS;
28}
29
30// --------------------------------------------------------------------------------
31// --------------------------------------------------------------------------------
32
33StatusCode TrigmuCombHypoAlg::execute(const EventContext& context) const
34{
35 // common for all Hypos, to move in the base class
36 ATH_MSG_DEBUG("StatusCode TrigmuCombHypoAlg::execute start");
37 auto previousDecisionsHandle = SG::makeHandle( decisionInput(), context);
38 ATH_CHECK( previousDecisionsHandle.isValid() );
39 ATH_MSG_DEBUG( "Running with "<< previousDecisionsHandle->size() <<" previous decisions");
40
41 // new output decisions
43 auto decisions = outputHandle.ptr();
44 // end of common
45
46 std::vector<TrigmuCombHypoTool::CombinedMuonInfo> toolInput;
47 // loop over previous decisions
48 size_t counter = 0;
49
50 for ( const auto previousDecision: *previousDecisionsHandle ) {
51 // get View
52 ATH_CHECK( previousDecision->hasObjectLink(viewString()) );
53 auto viewEL = previousDecision->objectLink<ViewContainer>(viewString());
54 ATH_CHECK( viewEL.isValid() );
55
56 // get info
57 auto muCombHandle = ViewHelper::makeHandle( *viewEL, m_muCombKey, context );
58 ATH_CHECK( muCombHandle.isValid() );
59 ATH_MSG_DEBUG( "Muinfo handle size: " << muCombHandle->size() << "...");
60
61 // loop over muCombs (more than one muon can be found by L2 inside-out algos)
62 for(uint i=0; i<muCombHandle->size(); i++){
63 auto muCombEL = ViewHelper::makeLink( *viewEL, muCombHandle, i );
64 ATH_CHECK( muCombEL.isValid() );
65 const xAOD::L2CombinedMuon* muComb = *muCombEL;
66 const xAOD::L2StandAloneMuon* muFast = muComb->muSATrack();
67
68 // create new decisions
69 auto newd = newDecisionIn( decisions, hypoAlgNodeName() );
70
71 toolInput.emplace_back( TrigmuCombHypoTool::CombinedMuonInfo{ newd, muComb, muFast, previousDecision} );
72
73 // set objectLink
74 newd->setObjectLink( featureString(), muCombEL );
75 TrigCompositeUtils::linkToPrevious( newd, previousDecision, context);
76
77 //set roi link (to use same roi in EF CB step)
79 newd->setObjectLink(m_roiLinkName.value(), roiLink.link);
80
81 // DEBUG
82 ATH_MSG_DEBUG("REGTEST: muCBTrack pt in " << m_muCombKey.key() << " = " << (*muCombEL)->pt()/Gaudi::Units::GeV << " GeV");
83 ATH_MSG_DEBUG("REGTEST: muCBTrack eta/phi in " << m_muCombKey.key() << " = " << (*muCombEL)->eta() << "/" << (*muCombEL)->phi());
84 ATH_MSG_DEBUG("Added view, features, previous decision to new decision "<<counter <<" for view "<<(*viewEL)->name() );
85
86 counter++;
87 }
88 }
89 for ( auto & tool: m_hypoTools ) {
90 ATH_MSG_DEBUG("Go to " << tool);
91 ATH_CHECK( tool->decide( toolInput ) );
92 }
93
95
96 ATH_MSG_DEBUG("StatusCode TrigmuCombHypoAlg::execute success");
97 return StatusCode::SUCCESS;
98}
99
100// --------------------------------------------------------------------------------
101// --------------------------------------------------------------------------------
102
#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.