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 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)
78  auto roiLink = TrigCompositeUtils::findLink<TrigRoiDescriptorCollection>(newd, "roi");
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 
94  ATH_CHECK(hypoBaseOutputProcessing(outputHandle));
95 
96  ATH_MSG_DEBUG("StatusCode TrigmuCombHypoAlg::execute success");
97  return StatusCode::SUCCESS;
98 }
99 
100 // --------------------------------------------------------------------------------
101 // --------------------------------------------------------------------------------
102 
TrigmuCombHypoTool::CombinedMuonInfo
Definition: TrigmuCombHypoTool.h:39
GeV
#define GeV
Definition: PhysicsAnalysis/TauID/TauAnalysisTools/Root/HelperFunctions.cxx:17
muComb
Main LVL2 Algorithm.
Definition: muComb.h:55
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:291
TrigCompositeUtils::hypoAlgNodeName
const std::string & hypoAlgNodeName()
Definition: TrigCompositeUtilsRoot.cxx:904
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:259
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:85
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:101
TrigCompositeUtils::featureString
const std::string & featureString()
Definition: TrigCompositeUtilsRoot.cxx:884
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
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
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
TrigCompositeUtils::viewString
const std::string & viewString()
Definition: TrigCompositeUtilsRoot.cxx:880
TrigmuCombHypoAlg::execute
virtual StatusCode execute(const EventContext &context) const override
Definition: TrigmuCombHypoAlg.cxx:33
ViewContainer
Definition: View.h:158