ATLAS Offline Software
TrigTauCaloHypoAlg.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include "Gaudi/Property.h"
6 #include "TrigTauCaloHypoAlg.h"
9 #include "AthViews/ViewHelper.h"
10 
11 using namespace TrigCompositeUtils;
12 
14  ISvcLocator* pSvcLocator ) :
15  ::HypoBase( name, pSvcLocator ) {}
16 
17 
19  ATH_CHECK( m_hypoTools.retrieve() );
20  ATH_CHECK( m_tauJetKey.initialize() );
21  renounce( m_tauJetKey );// taus are made in views, so they are not in the EvtStore: hide them
22 
23  return StatusCode::SUCCESS;
24 }
25 
26 
27 StatusCode TrigTauCaloHypoAlg::execute( const EventContext& context ) const {
28  ATH_MSG_DEBUG ( "Executing " << name() << "..." );
29  auto previousDecisionsHandle = SG::makeHandle( decisionInput(), context );
30  if( not previousDecisionsHandle.isValid() ) {//implicit
31  ATH_MSG_DEBUG( "No implicit RH for previous decisions "<< decisionInput().key()<<": is this expected?" );
32  return StatusCode::SUCCESS;
33  }
34 
35  ATH_MSG_DEBUG( "Running with "<< previousDecisionsHandle->size() <<" previous decisions");
36 
37  // new output decisions
39  auto decisions = outputHandle.ptr();
40 
41  // input for decision
42  std::vector<ITrigTauGenericHypoTool::ClusterInfo> toolInput;
43 
44  // loop over previous decisions
45  int counter=-1;
46  for ( const xAOD::TrigComposite* previousDecision: *previousDecisionsHandle ) {
47  counter++;
48 
49  //get RoI
50  auto roiELInfo = findLink<TrigRoiDescriptorCollection>( previousDecision, roiString() );
51  ATH_CHECK( roiELInfo.isValid() );
52  const TrigRoiDescriptor* roi = *(roiELInfo.link);
53 
54  // get View
55  const auto viewEL = previousDecision->objectLink<ViewContainer>( viewString() );
56  ATH_CHECK( viewEL.isValid() );
57 
58  auto tauHandle = ViewHelper::makeHandle( *viewEL, m_tauJetKey, context);
59  ATH_CHECK( tauHandle.isValid() );
60  ATH_MSG_DEBUG ( "Tau handle size: " << tauHandle->size() << "..." );
61 
62  if( tauHandle->size() != 1 ) {
63  ATH_MSG_DEBUG("Something is wrong, unexpected number of taus " << tauHandle->size() << " is found (expected 1), continuing anyways skipping view");
64  continue;
65  }
66 
67  // create new decision
69  TrigCompositeUtils::linkToPrevious( d, previousDecision, context );
70  d->setObjectLink( roiString(), roiELInfo.link );
71 
72  auto el = ViewHelper::makeLink( *viewEL, tauHandle, 0 );
73  ATH_CHECK( el.isValid() );
74  d->setObjectLink( featureString(), el );
75 
76  toolInput.emplace_back( d, roi, tauHandle.cptr(), previousDecision );
77 
78  ATH_MSG_DEBUG( "Added view, roi, tau, previous decision to new decision " << counter << " for view " << (*viewEL)->name() );
79  }
80 
81  ATH_MSG_DEBUG( "Found "<<toolInput.size()<<" inputs to tools");
82 
83 
84  for ( auto& tool: m_hypoTools ) {
85  ATH_CHECK( tool->decide( toolInput ) );
86  }
87 
88  ATH_CHECK( hypoBaseOutputProcessing(outputHandle) );
89 
90  return StatusCode::SUCCESS;
91 }
TrigCompositeUtils.h
TrigTauCaloHypoAlg.h
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
hist_file_dump.d
d
Definition: hist_file_dump.py:137
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
TrigRoiDescriptor
nope - should be used for standalone also, perhaps need to protect the class def bits #ifndef XAOD_AN...
Definition: TrigRoiDescriptor.h:56
TrigTauCaloHypoAlg::TrigTauCaloHypoAlg
TrigTauCaloHypoAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition: TrigTauCaloHypoAlg.cxx:13
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
SG::makeHandle
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Definition: ReadCondHandle.h:270
TrigTauCaloHypoAlg::m_hypoTools
ToolHandleArray< ITrigTauGenericHypoTool > m_hypoTools
Definition: TrigTauCaloHypoAlg.h:31
TrigTauCaloHypoAlg::m_tauJetKey
SG::ReadHandleKey< xAOD::TauJetContainer > m_tauJetKey
Definition: TrigTauCaloHypoAlg.h:33
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
plotIsoValidation.el
el
Definition: plotIsoValidation.py:197
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
xAOD::TrigComposite_v1
Class used to describe composite objects in the HLT.
Definition: TrigComposite_v1.h:52
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
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
HLTIdentifier.h
TrigTauCaloHypoAlg::execute
virtual StatusCode execute(const EventContext &context) const override
Definition: TrigTauCaloHypoAlg.cxx:27
TrigCompositeUtils
Definition: Event/xAOD/xAODTrigger/xAODTrigger/TrigComposite.h:19
TrigCompositeUtils::roiString
const std::string & roiString()
Definition: TrigCompositeUtilsRoot.cxx:878
TrigTauCaloHypoAlg::initialize
virtual StatusCode initialize() override
Definition: TrigTauCaloHypoAlg.cxx:18
test_pyathena.counter
counter
Definition: test_pyathena.py:15
TrigCompositeUtils::viewString
const std::string & viewString()
Definition: TrigCompositeUtilsRoot.cxx:882
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37
ViewContainer
Definition: View.h:161