ATLAS Offline Software
Loading...
Searching...
No Matches
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
10
11using namespace TrigCompositeUtils;
12
13// --------------------------------------------------------------------------------
14// --------------------------------------------------------------------------------
15
17 ISvcLocator* pSvcLocator ) :
18 ::HypoBase( name, pSvcLocator )
19{
20
21}
22
25
26// --------------------------------------------------------------------------------
27// --------------------------------------------------------------------------------
28
30{
31
32 ATH_CHECK(m_hypoTools.retrieve());
34 ATH_CHECK(m_roiKey.initialize());
35
36 return StatusCode::SUCCESS;
37}
38
39
40// --------------------------------------------------------------------------------
41// --------------------------------------------------------------------------------
42
43StatusCode 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
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
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_DEBUG(x)
static Double_t sc
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
virtual double phi() const override final
Methods to retrieve data members.
virtual double eta() const override final
pointer_type ptr()
Dereference the pointer.
virtual StatusCode initialize() override
TrigMuonLateMuRoIHypoAlg(const std::string &name, ISvcLocator *pSvcLocator)
virtual StatusCode execute(const EventContext &context) const override
ToolHandleArray< TrigMuonLateMuRoIHypoTool > m_hypoTools
SG::ReadHandleKey< TrigRoiDescriptorCollection > m_roiKey
nope - should be used for standalone also, perhaps need to protect the class def bits ifndef XAOD_ANA...
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.
LinkInfo< T > findLink(const Decision *start, const std::string &linkName, const bool suppressMultipleLinksWarning=false)
Perform a recursive search for ElementLinks of type T and name 'linkName', starting from Decision obj...
const std::string & initialRoIString()
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