ATLAS Offline Software
Loading...
Searching...
No Matches
TrigMufastHypoAlg.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 "TrigMufastHypoAlg.h"
6
7#include "AthLinks/ElementLink.h"
9
12
13#include <math.h>
14
15using namespace TrigCompositeUtils;
16
17// --------------------------------------------------------------------------------
18// --------------------------------------------------------------------------------
19
20TrigMufastHypoAlg::TrigMufastHypoAlg( const std::string& name,
21 ISvcLocator* pSvcLocator ) :
22 ::HypoBase( name, pSvcLocator )
23{}
24
25
26// --------------------------------------------------------------------------------
27// --------------------------------------------------------------------------------
28
30{
31 ATH_CHECK(m_hypoTools.retrieve());
32
34 ATH_CHECK(m_muFastKey.initialize());
35
36 return StatusCode::SUCCESS;
37}
38
39// --------------------------------------------------------------------------------
40// --------------------------------------------------------------------------------
41
42StatusCode TrigMufastHypoAlg::execute( const EventContext& context ) const
43{
44
45 // common for all Hypos, to move in the base class
46 ATH_MSG_DEBUG("StatusCode TrigMufastHypoAlg::execute start");
47 auto previousDecisionsHandle = SG::makeHandle( decisionInput(), context );
48 ATH_CHECK( previousDecisionsHandle.isValid() );
49 ATH_MSG_DEBUG( "Running with "<< previousDecisionsHandle->size() <<" previous decisions");
50
51 // new output decisions
53 auto decisions = outputHandle.ptr();
54 // end of common
55
56
57 std::vector<TrigMufastHypoTool::MuonClusterInfo> toolInput;
58 // loop over previous decisions
59 size_t counter=0;
60 for ( const auto previousDecision: *previousDecisionsHandle ) {
61 //get RoI
63 auto roiEL = roiInfo.link;
64 ATH_CHECK( roiEL.isValid() );
65 const TrigRoiDescriptor* roi = *roiEL;
66
67 // get View
68 auto viewEL = previousDecision->objectLink< ViewContainer >( viewString() );
69 ATH_CHECK( viewEL.isValid() );
70
72 auto muFastHandle = ViewHelper::makeHandle( *viewEL, m_muFastKey, context );
73 ATH_CHECK( muFastHandle.isValid() );
74 ATH_MSG_DEBUG ( "Muinfo handle size: " << muFastHandle->size() << "..." );
75
76 //loop over muFast (more than one muon can be found by L2 multimu-in-pad algo)
77 for(uint i=0; i < muFastHandle->size(); i++){
78 auto muonEL = ViewHelper::makeLink( *viewEL, muFastHandle, i );
79 ATH_CHECK( muonEL.isValid() );
80 const xAOD::L2StandAloneMuon* muon = *muonEL;
81
82 // create new decision
83 auto newd = newDecisionIn( decisions, hypoAlgNodeName() );
84
85 // push_back to toolInput
86 toolInput.emplace_back( newd, roi, muon, previousDecision );
87
88 newd->setObjectLink( featureString(), muonEL );
89 TrigCompositeUtils::linkToPrevious( newd, previousDecision, context );
90
91 ATH_MSG_DEBUG("REGTEST: " << m_muFastKey.key() << " pT = " << (*muonEL)->pt() << " GeV");
92 ATH_MSG_DEBUG("REGTEST: " << m_muFastKey.key() << " eta/phi = " << (*muonEL)->eta() << "/" << (*muonEL)->phi());
93 ATH_MSG_DEBUG("REGTEST: RoI = eta/phi = " << (*roiEL)->eta() << "/" << (*roiEL)->phi());
94 ATH_MSG_DEBUG("Added view, roi, feature, previous decision to new decision "<<counter <<" for view "<<(*viewEL)->name() );
95 counter++;
96 }
97 }
98
99 ATH_MSG_DEBUG("Found "<<toolInput.size()<<" inputs to tools");
100
101
102 // to TrigMufastHypoTool
103 StatusCode sc = StatusCode::SUCCESS;
104 for ( auto& tool: m_hypoTools ) {
105 ATH_MSG_DEBUG("Go to " << tool );
106 sc = tool->decide(toolInput);
107 if (!sc.isSuccess()) {
108 ATH_MSG_ERROR("MuonHypoTool is failed");
109 return StatusCode::FAILURE;
110 }
111 } // End of tool algorithms */
112
113 ATH_CHECK(hypoBaseOutputProcessing(outputHandle));
114
115 ATH_MSG_DEBUG("StatusCode TrigMufastHypoAlg::execute success");
116 return StatusCode::SUCCESS;
117}
118
119// --------------------------------------------------------------------------------
120// --------------------------------------------------------------------------------
121
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_DEBUG(x)
unsigned int uint
static Double_t sc
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 initialize() override
TrigMufastHypoAlg(const std::string &name, ISvcLocator *pSvcLocator)
virtual StatusCode execute(const EventContext &context) const override
ToolHandleArray< TrigMufastHypoTool > m_hypoTools
SG::ReadHandleKey< xAOD::L2StandAloneMuonContainer > m_muFastKey
nope - should be used for standalone also, perhaps need to protect the class def bits ifndef XAOD_ANA...
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...
const std::string & initialRoIString()
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
L2StandAloneMuon_v2 L2StandAloneMuon
Define the latest version of the muon SA class.