ATLAS Offline Software
Loading...
Searching...
No Matches
TrigMuonEFTrackIsolationHypoAlg.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3*/
4
8
9using namespace TrigCompositeUtils;
10
11// --------------------------------------------------------------------------------
12// --------------------------------------------------------------------------------
13
15 ISvcLocator* pSvcLocator ) :
16 ::HypoBase( name, pSvcLocator )
17{}
18
19
20// --------------------------------------------------------------------------------
21// --------------------------------------------------------------------------------
22
24{
25 ATH_CHECK( m_hypoTools.retrieve() );
26
30 ATH_CHECK( m_muonKey.initialize() );
31 ATH_CHECK( m_muonIso20Key.initialize() );
32 ATH_CHECK( m_muonIso30Key.initialize() );
33
34 return StatusCode::SUCCESS;
35}
36
37// --------------------------------------------------------------------------------
38// --------------------------------------------------------------------------------
39
40StatusCode TrigMuonEFTrackIsolationHypoAlg::execute( const EventContext& context ) const
41{
42
43 ATH_MSG_DEBUG("Executing ...");
44
45 auto previousDecisionsHandle = SG::makeHandle( decisionInput(), context );
46 ATH_CHECK( previousDecisionsHandle.isValid() );
47 ATH_MSG_DEBUG( "Running with "<< previousDecisionsHandle->size() <<" previous decisions");
48
49 // prepare output decisions
51 auto decisions = outputHandle.ptr();
52
53 std::vector<TrigMuonEFTrackIsolationHypoTool::EFIsolationMuonInfo> toolInput;
54 size_t counter = 0;
55 for ( const auto previousDecision: *previousDecisionsHandle ) {
56
57 // get View
58 auto viewEL = previousDecision->objectLink<ViewContainer>(viewString());
59 ATH_CHECK( viewEL.isValid() );
60
61 // get Muon and isolation
62 auto muonHandle = ViewHelper::makeHandle( *viewEL, m_muonKey, context );
65 ATH_CHECK( muonHandle.isValid() );
66 ATH_MSG_DEBUG( "Muinfo handle size: " << muonHandle->size() << " ..." );
67
68 // It is posisble that no muons are found, in this case we go to the next decision
69 if ( muonHandle->size()==0 ) continue;
70
71 // this code only gets muon 0, since we build the views centered on a single muon
72 auto muonEL = ViewHelper::makeLink( *viewEL, muonHandle, 0 );
73 ATH_CHECK( muonEL.isValid() );
74 const xAOD::Muon* muon = *muonEL;
75
76 // create new dicions
77 auto newd = newDecisionIn( decisions, hypoAlgNodeName() );
78
79 toolInput.emplace_back( newd, muon, previousDecision, muonIso20(*muon), muonIso30(*muon) );
80
81 newd -> setObjectLink( featureString(), muonEL );
82 TrigCompositeUtils::linkToPrevious( newd, previousDecision, context );
83
84
85 ATH_MSG_DEBUG("REGTEST: " << m_muonKey.key() << " pT = " << (*muonEL)->pt()/Gaudi::Units::GeV << " GeV");
86 ATH_MSG_DEBUG("REGTEST: " << m_muonKey.key() << " eta/phi = " << (*muonEL)->eta() << "/" << (*muonEL)->phi());
87 ATH_MSG_DEBUG("Added view, feature, previous decision to new decision "<<counter <<" for view "<<(*viewEL)->name() );
88
89 counter++;
90 }
91
92 ATH_MSG_DEBUG("Found "<<toolInput.size()<<" inputs to tools");
93
94 StatusCode sc = StatusCode::SUCCESS;
95 for ( auto& tool: m_hypoTools ) {
96 ATH_MSG_DEBUG("Go to " << tool );
97 sc = tool->decide(toolInput);
98 if (!sc.isSuccess()) {
99 ATH_MSG_ERROR("MuonHypoTool is failed");
100 return StatusCode::FAILURE;
101 }
102 } // End of tool algorithm
103
104 ATH_CHECK(hypoBaseOutputProcessing(outputHandle));
105
106 return StatusCode::SUCCESS;
107}
108
109// --------------------------------------------------------------------------------
110// --------------------------------------------------------------------------------
111
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_DEBUG(x)
static Double_t sc
Handle class for reading a decoration on an object.
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
Handle class for reading a decoration on an object.
pointer_type ptr()
Dereference the pointer.
SG::ReadDecorHandleKey< xAOD::MuonContainer > m_muonIso30Key
virtual StatusCode execute(const EventContext &context) const override
SG::ReadHandleKey< xAOD::MuonContainer > m_muonKey
ToolHandleArray< TrigMuonEFTrackIsolationHypoTool > m_hypoTools
TrigMuonEFTrackIsolationHypoAlg(const std::string &name, ISvcLocator *pSvcLocator)
SG::ReadDecorHandleKey< xAOD::MuonContainer > m_muonIso20Key
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.
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
Muon_v1 Muon
Reference the current persistent version: