ATLAS Offline Software
TrigEFTauMVHypoAlg.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 "Gaudi/Property.h"
6 #include "TrigEFTauMVHypoAlg.h"
9 #include "AthViews/ViewHelper.h"
10 
11 using namespace TrigCompositeUtils;
12 
14  ISvcLocator* pSvcLocator ) :
15  ::HypoBase( name, pSvcLocator ) {}
16 
17 
19 
20  ATH_CHECK( m_hypoTools.retrieve() );
21  ATH_CHECK( m_tauJetKey.initialize() );
22  renounce( m_tauJetKey );// tau candidates are made in views, so they are not in the EvtStore: hide them
23 
24  return StatusCode::SUCCESS;
25 }
26 
27 
28 StatusCode TrigEFTauMVHypoAlg::execute( const EventContext& context ) const {
29  ATH_MSG_DEBUG ( "Executing " << name() << "..." );
30  auto previousDecisionsHandle = SG::makeHandle( decisionInput(), context );
31  if( not previousDecisionsHandle.isValid() ) {//implicit
32  ATH_MSG_DEBUG( "No implicit RH for previous decisions "<< decisionInput().key()<<": is this expected?" );
33  return StatusCode::SUCCESS;
34  }
35 
36  ATH_MSG_DEBUG( "Running with "<< previousDecisionsHandle->size() <<" previous decisions");
37 
38  // new decisions
39 
40  // new output decisions
42  auto decisions = outputHandle.ptr();
43 
44  // input for decision
45  std::vector<ITrigEFTauMVHypoTool::TauJetInfo> toolInput;
46 
47  // loop over previous decisions
48  int counter=-1;
49  for ( auto previousDecision: *previousDecisionsHandle ) {
50  counter++;
51  //get RoI
52  auto roiELInfo = findLink<TrigRoiDescriptorCollection>( previousDecision, roiString());
53  ATH_CHECK( roiELInfo.isValid() );
54  const TrigRoiDescriptor* roi = *(roiELInfo.link);
55 
56  // get View
57  const auto viewEL = previousDecision->objectLink<ViewContainer>( viewString() );
58  ATH_CHECK( viewEL.isValid() );
59  auto tauJetHandle = ViewHelper::makeHandle( *viewEL, m_tauJetKey, context);
60 
61  if( not tauJetHandle.isValid() ) {
62  ATH_MSG_WARNING("Something is wrong, missing tau jets, continuing anyways skipping view");
63  continue;
64  }
65  ATH_MSG_DEBUG ( "TauJet handle size: " << tauJetHandle->size() << "..." );
66 
67  if( tauJetHandle->size() != 1 ) {
68  ATH_MSG_WARNING("Something is wrong, unexpectd number of tau jets " << tauJetHandle->size() << " is found (expected 1), continuing anyways skipping view");
69  continue;
70  }
71 
72  // create new decision
75  d->setObjectLink( roiString(), roiELInfo.link );
76 
77  auto el = ViewHelper::makeLink( *viewEL, tauJetHandle, 0 );
78  ATH_CHECK( el.isValid() );
79  d->setObjectLink( featureString(), el );
80 
81  toolInput.emplace_back( d, roi, tauJetHandle.cptr(), previousDecision );
82 
83  ATH_MSG_DEBUG( "Added view, roi, cluster, previous decision to new decision " << counter << " for view " << (*viewEL)->name() );
84 
85  }
86 
87  ATH_MSG_DEBUG( "Found " << toolInput.size() << " inputs to tools");
88 
89 
90  for ( auto& tool: m_hypoTools ) {
91  ATH_CHECK( tool->decide( toolInput ) );
92  }
93 
94  ATH_CHECK( hypoBaseOutputProcessing(outputHandle) );
95 
96  return StatusCode::SUCCESS;
97 }
TrigEFTauMVHypoAlg::m_hypoTools
ToolHandleArray< ITrigEFTauMVHypoTool > m_hypoTools
Definition: TrigEFTauMVHypoAlg.h:27
TrigCompositeUtils.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
TrigEFTauMVHypoAlg::m_tauJetKey
SG::ReadHandleKey< xAOD::TauJetContainer > m_tauJetKey
Definition: TrigEFTauMVHypoAlg.h:29
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
TrigEFTauMVHypoAlg::execute
virtual StatusCode execute(const EventContext &context) const override
Definition: TrigEFTauMVHypoAlg.cxx:28
SG::makeHandle
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Definition: ReadCondHandle.h:270
TrigEFTauMVHypoAlg.h
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::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
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
HLTIdentifier.h
TrigCompositeUtils
Definition: Event/xAOD/xAODTrigger/xAODTrigger/TrigComposite.h:19
TrigCompositeUtils::roiString
const std::string & roiString()
Definition: TrigCompositeUtilsRoot.cxx:878
TrigEFTauMVHypoAlg::TrigEFTauMVHypoAlg
TrigEFTauMVHypoAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition: TrigEFTauMVHypoAlg.cxx:13
test_pyathena.counter
counter
Definition: test_pyathena.py:15
TrigEFTauMVHypoAlg::initialize
virtual StatusCode initialize() override
Definition: TrigEFTauMVHypoAlg.cxx:18
TrigCompositeUtils::viewString
const std::string & viewString()
Definition: TrigCompositeUtilsRoot.cxx:882
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37
ViewContainer
Definition: View.h:161