ATLAS Offline Software
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"
9 #include "AthViews/ViewHelper.h"
10 
11 using namespace TrigCompositeUtils;
12 
13 // --------------------------------------------------------------------------------
14 // --------------------------------------------------------------------------------
15 
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 
38 StatusCode 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
58  auto roiInfo = TrigCompositeUtils::findLink<TrigRoiDescriptorCollection>( previousDecision, initialRoIString() );
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 
xAOD::muon
@ muon
Definition: TrackingPrimitives.h:195
TrigMufastHypoAlg::TrigMufastHypoAlg
TrigMufastHypoAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition: TrigMufastHypoAlg.cxx:16
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
TrigMufastHypoAlg::m_hypoTools
ToolHandleArray< TrigMufastHypoTool > m_hypoTools
Definition: TrigMufastHypoAlg.h:26
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
TrigRoiDescriptor
nope - should be used for standalone also, perhaps need to protect the class def bits #ifndef XAOD_AN...
Definition: TrigRoiDescriptor.h:56
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
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
SG::makeHandle
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Definition: ReadCondHandle.h:270
uint
unsigned int uint
Definition: LArOFPhaseFill.cxx:20
TrigMufastHypoAlg::m_muFastKey
SG::ReadHandleKey< xAOD::L2StandAloneMuonContainer > m_muFastKey
Definition: TrigMufastHypoAlg.h:28
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
lumiFormat.i
int i
Definition: lumiFormat.py:92
TrigCompositeUtils::initialRoIString
const std::string & initialRoIString()
Definition: TrigCompositeUtilsRoot.cxx:870
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
TrigMufastHypoAlg.h
xAOD::decisions
decisions
Definition: TrigComposite_v1.cxx:81
TrigMufastHypoAlg::execute
virtual StatusCode execute(const EventContext &context) const override
Definition: TrigMufastHypoAlg.cxx:38
TrigCompositeUtils::featureString
const std::string & featureString()
Definition: TrigCompositeUtilsRoot.cxx:886
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
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
Definition: Event/xAOD/xAODTrigger/xAODTrigger/TrigComposite.h:19
TrigMufastHypoAlg::initialize
virtual StatusCode initialize() override
Definition: TrigMufastHypoAlg.cxx:25
test_pyathena.counter
counter
Definition: test_pyathena.py:15
TrigCompositeUtils::viewString
const std::string & viewString()
Definition: TrigCompositeUtilsRoot.cxx:882
ViewContainer
Definition: View.h:161