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