ATLAS Offline Software
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"
7 #include "AthViews/ViewHelper.h"
8 
9 using namespace TrigCompositeUtils;
10 
11 // --------------------------------------------------------------------------------
12 // --------------------------------------------------------------------------------
13 
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 
33 StatusCode 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 L2MuonSA Feature
53  TrigCompositeUtils::findLink<xAOD::L2StandAloneMuonContainer>(previousDecision, featureString());
55  ATH_CHECK( muFastLink.isValid() );
56  const xAOD::L2StandAloneMuon* muFast = *muFastLink;
57 
58  // get View
59  ATH_CHECK( previousDecision->hasObjectLink(viewString()) );
60  auto viewEL = previousDecision->objectLink<ViewContainer>(viewString());
61  ATH_CHECK( viewEL.isValid() );
62 
63  // get info
64  auto muCombHandle = ViewHelper::makeHandle( *viewEL, m_muCombKey, context );
65  ATH_CHECK( muCombHandle.isValid() );
66  ATH_MSG_DEBUG( "Muinfo handle size: " << muCombHandle->size() << "...");
67 
68  // loop over muCombs (more than one muon can be found by L2 inside-out algos)
69  for(uint i=0; i<muCombHandle->size(); i++){
70  auto muCombEL = ViewHelper::makeLink( *viewEL, muCombHandle, i );
71  ATH_CHECK( muCombEL.isValid() );
72  const xAOD::L2CombinedMuon* muComb = *muCombEL;
73 
74  // create new decisions
75  auto newd = newDecisionIn( decisions, hypoAlgNodeName() );
76 
77  toolInput.emplace_back( TrigmuCombHypoTool::CombinedMuonInfo{ newd, muComb, muFast, previousDecision} );
78 
79  // set objectLink
80  newd->setObjectLink( featureString(), muCombEL );
81  TrigCompositeUtils::linkToPrevious( newd, previousDecision, context);
82 
83  //set roi link (to use same roi in EF CB step)
84  auto roiLink = TrigCompositeUtils::findLink<TrigRoiDescriptorCollection>(newd, "roi");
85  newd->setObjectLink(m_roiLinkName.value(), roiLink.link);
86 
87  // DEBUG
88  ATH_MSG_DEBUG("REGTEST: muCBTrack pt in " << m_muCombKey.key() << " = " << (*muCombEL)->pt()/Gaudi::Units::GeV << " GeV");
89  ATH_MSG_DEBUG("REGTEST: muCBTrack eta/phi in " << m_muCombKey.key() << " = " << (*muCombEL)->eta() << "/" << (*muCombEL)->phi());
90  ATH_MSG_DEBUG("Added view, features, previous decision to new decision "<<counter <<" for view "<<(*viewEL)->name() );
91 
92  counter++;
93  }
94  }
95  for ( auto & tool: m_hypoTools ) {
96  ATH_MSG_DEBUG("Go to " << tool);
97  ATH_CHECK( tool->decide( toolInput ) );
98  }
99 
100  ATH_CHECK(hypoBaseOutputProcessing(outputHandle));
101 
102  ATH_MSG_DEBUG("StatusCode TrigmuCombHypoAlg::execute success");
103  return StatusCode::SUCCESS;
104 }
105 
106 // --------------------------------------------------------------------------------
107 // --------------------------------------------------------------------------------
108 
TrigmuCombHypoTool::CombinedMuonInfo
Definition: TrigmuCombHypoTool.h:39
muComb
Main LVL2 Algorithm.
Definition: muComb.h:55
TrigCompositeUtils::LinkInfo::link
ElementLink< T > link
Link to the feature.
Definition: LinkInfo.h:61
TrigCompositeUtils.h
xAOD::L2StandAloneMuon_v2
Class describing standalone muons reconstructed in the LVL2 trigger.
Definition: L2StandAloneMuon_v2.h:36
TrigCompositeUtils::newDecisionIn
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.
Definition: TrigCompositeUtilsRoot.cxx:46
ViewHelper::makeLink
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:276
TrigCompositeUtils::hypoAlgNodeName
const std::string & hypoAlgNodeName()
Definition: TrigCompositeUtilsRoot.cxx:906
ViewHelper::makeHandle
SG::ReadHandle< T > makeHandle(const SG::View *view, const SG::ReadHandleKey< T > &rhKey, const EventContext &context)
navigate from the TrigComposite to nearest view and fetch object from it
Definition: ViewHelper.h:258
AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::renounce
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)
Definition: AthCommonDataStore.h:380
HypoBase::decisionInput
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:16
TrigCompositeUtils::createAndStore
SG::WriteHandle< DecisionContainer > createAndStore(const SG::WriteHandleKey< DecisionContainer > &key, const EventContext &ctx)
Creates and right away records the DecisionContainer with the key.
Definition: TrigCompositeUtilsRoot.cxx:30
ViewHelper.h
HypoBase::decisionOutput
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:20
xAOD::L2CombinedMuon_v1
Class describing combined muon reconstructed in the LVL2 trigger.
Definition: L2CombinedMuon_v1.h:41
TrigmuCombHypoAlg::TrigmuCombHypoAlg
TrigmuCombHypoAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition: TrigmuCombHypoAlg.cxx:14
SG::makeHandle
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Definition: ReadCondHandle.h:270
TrigmuCombHypoAlg::m_hypoTools
ToolHandleArray< TrigmuCombHypoTool > m_hypoTools
Definition: TrigmuCombHypoAlg.h:26
uint
unsigned int uint
Definition: LArOFPhaseFill.cxx:20
TrigmuCombHypoAlg.h
TrigmuCombHypoAlg::m_roiLinkName
Gaudi::Property< std::string > m_roiLinkName
Definition: TrigmuCombHypoAlg.h:30
lumiFormat.i
int i
Definition: lumiFormat.py:92
HypoBase::hypoBaseOutputProcessing
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:33
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
SG::WriteHandle::ptr
pointer_type ptr()
Dereference the pointer.
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
xAOD::decisions
decisions
Definition: TrigComposite_v1.cxx:81
TrigCompositeUtils::featureString
const std::string & featureString()
Definition: TrigCompositeUtilsRoot.cxx:886
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
TrigmuCombHypoAlg::initialize
virtual StatusCode initialize() override
Definition: TrigmuCombHypoAlg.cxx:20
AtlCoolConsole.tool
tool
Definition: AtlCoolConsole.py:453
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:76
TrigCompositeUtils::linkToPrevious
void linkToPrevious(Decision *d, const std::string &previousCollectionKey, size_t previousIndex)
Links to the previous object, location of previous 'seed' decision supplied by hand.
Definition: TrigCompositeUtilsRoot.cxx:139
TrigCompositeUtils::LinkInfo
Helper to keep a Decision object, ElementLink and ActiveState (with respect to some requested ChainGr...
Definition: LinkInfo.h:28
TrigmuCombHypoAlg::m_muCombKey
SG::ReadHandleKey< xAOD::L2CombinedMuonContainer > m_muCombKey
Definition: TrigmuCombHypoAlg.h:28
TrigCompositeUtils
Definition: Event/xAOD/xAODTrigger/xAODTrigger/TrigComposite.h:19
test_pyathena.counter
counter
Definition: test_pyathena.py:15
GeV
#define GeV
Definition: CaloTransverseBalanceVecMon.cxx:30
TrigCompositeUtils::viewString
const std::string & viewString()
Definition: TrigCompositeUtilsRoot.cxx:882
TrigmuCombHypoAlg::execute
virtual StatusCode execute(const EventContext &context) const override
Definition: TrigmuCombHypoAlg.cxx:33
ViewContainer
Definition: View.h:161