ATLAS Offline Software
TrigMuonLateMuRoIHypoAlg.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 "GaudiKernel/MsgStream.h"
6 #include "GaudiKernel/StatusCode.h"
7 
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 
24 {}
25 
26 // --------------------------------------------------------------------------------
27 // --------------------------------------------------------------------------------
28 
30 {
31 
32  ATH_CHECK(m_hypoTools.retrieve());
35 
36  return StatusCode::SUCCESS;
37 }
38 
39 
40 // --------------------------------------------------------------------------------
41 // --------------------------------------------------------------------------------
42 
43 StatusCode TrigMuonLateMuRoIHypoAlg::execute( const EventContext& context ) const
44 {
45  ATH_MSG_DEBUG("StatusCode TrigMuonLateMuRoIHypoAlg::execute start");
46 
47  // common for all hypos
48  auto previousDecisionsHandle = SG::makeHandle( decisionInput(), context );
49  ATH_CHECK( previousDecisionsHandle.isValid() );
50  ATH_MSG_DEBUG( "Running with "<< previousDecisionsHandle->size() <<" previous decisions");
51 
52  // new output decisions
54  auto decisions = outputHandle.ptr();
55  // end of common
56 
57 
58  std::vector<TrigMuonLateMuRoIHypoTool::MuonEFInfo> toolInput;
59  // loop over previous decisions
60  for (const auto previousDecision: *previousDecisionsHandle ) {
61 
62  // get RoIs
63  auto roiInfo = TrigCompositeUtils::findLink<TrigRoiDescriptorCollection>( previousDecision, initialRoIString() );
64  auto roiEL = roiInfo.link;
65  ATH_CHECK( roiEL.isValid() );
66  const TrigRoiDescriptor* roi = *roiEL;
67 
68  // get View
69  ATH_CHECK( previousDecision->hasObjectLink( viewString()) );
70  auto viewEL = previousDecision->objectLink<ViewContainer>( viewString() );
71  ATH_CHECK( viewEL.isValid() );
72 
73  // get muons
74  auto roiHandle = ViewHelper::makeHandle( *viewEL, m_roiKey, context );
75  ATH_CHECK( roiHandle.isValid() );
76  ATH_MSG_DEBUG( "Muinfo handle size: " << roiHandle->size() << " ..." );
77 
78  // It is posisble that no rois are found, in this case we go to the next decision
79  if(roiHandle->size()<1) continue;
80 
81  for(size_t i=0; i<roiHandle->size();i++){
82  auto lateRoIEL = ViewHelper::makeLink( *viewEL, roiHandle, i );
83  ATH_CHECK( lateRoIEL.isValid() );
84  const TrigRoiDescriptor* lateRoI = *lateRoIEL;
85  // create new decisions
86  auto newd = newDecisionIn( decisions, hypoAlgNodeName() );
87  // push_back to toolInput
88  toolInput.emplace_back( newd, roi, lateRoI, previousDecision );
89  newd -> setObjectLink( featureString(), lateRoIEL );
90  TrigCompositeUtils::linkToPrevious( newd, previousDecision, context );
91 
92  ATH_MSG_DEBUG("REGTEST: " << m_roiKey.key() << " eta/phi roi= " << lateRoI->eta() << "/" << lateRoI->phi() );
93  }
94  }
95 
96 
97  ATH_MSG_DEBUG("Found "<<toolInput.size()<<" inputs to tools");
98 
99  // to TrigMuonLateMuRoIHypoTool
100  StatusCode sc = StatusCode::SUCCESS;
101  for ( auto& tool: m_hypoTools ) {
102  ATH_MSG_DEBUG("Go to " << tool );
103  sc = tool->decide(toolInput);
104  if (!sc.isSuccess()) {
105  ATH_MSG_ERROR("MuonHypoTool is failed");
106  return StatusCode::FAILURE;
107  }
108  } // End of tool algorithms */
109 
110  ATH_CHECK(hypoBaseOutputProcessing(outputHandle));
111 
112  return StatusCode::SUCCESS;
113 }
114 
115 // --------------------------------------------------------------------------------
116 // --------------------------------------------------------------------------------
117 
TrigMuonLateMuRoIHypoAlg::~TrigMuonLateMuRoIHypoAlg
virtual ~TrigMuonLateMuRoIHypoAlg()
Definition: TrigMuonLateMuRoIHypoAlg.cxx:23
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
TrigMuonLateMuRoIHypoAlg.h
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
TrigMuonLateMuRoIHypoAlg::TrigMuonLateMuRoIHypoAlg
TrigMuonLateMuRoIHypoAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition: TrigMuonLateMuRoIHypoAlg.cxx:16
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
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
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
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
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
AtlCoolConsole.tool
tool
Definition: AtlCoolConsole.py:453
TrigMuonLateMuRoIHypoAlg::m_hypoTools
ToolHandleArray< TrigMuonLateMuRoIHypoTool > m_hypoTools
Definition: TrigMuonLateMuRoIHypoAlg.h:35
TrigMuonLateMuRoIHypoAlg::m_roiKey
SG::ReadHandleKey< TrigRoiDescriptorCollection > m_roiKey
Definition: TrigMuonLateMuRoIHypoAlg.h:37
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
TrigMuonLateMuRoIHypoAlg::initialize
virtual StatusCode initialize() override
Definition: TrigMuonLateMuRoIHypoAlg.cxx:29
RoiDescriptor::phi
virtual double phi() const override final
Methods to retrieve data members.
Definition: RoiDescriptor.h:100
RoiDescriptor::eta
virtual double eta() const override final
Definition: RoiDescriptor.h:101
TrigCompositeUtils
Definition: Event/xAOD/xAODTrigger/xAODTrigger/TrigComposite.h:19
TrigMuonLateMuRoIHypoAlg::execute
virtual StatusCode execute(const EventContext &context) const override
Definition: TrigMuonLateMuRoIHypoAlg.cxx:43
TrigCompositeUtils::viewString
const std::string & viewString()
Definition: TrigCompositeUtilsRoot.cxx:882
ViewContainer
Definition: View.h:161