ATLAS Offline Software
SPCountHypoAlg.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 "SPCountHypoAlg.h"
6 #include "AthViews/ViewHelper.h"
7 
20 
21 SPCountHypoAlg::SPCountHypoAlg(const std::string &name, ISvcLocator *pSvcLocator) : ::HypoBase(name, pSvcLocator)
22 {
23 }
25 {
26 
27  ATH_CHECK(m_spacePointsKey.initialize());
28  ATH_CHECK(m_hypoTools.retrieve());
30  return StatusCode::SUCCESS;
31 }
32 
33 StatusCode SPCountHypoAlg::execute(const EventContext &context) const
34 {
35 
36  ATH_MSG_DEBUG("Executing " << name() << "...");
37 
38  auto previousDecisionsHandle = SG::makeHandle(decisionInput(), context);
39  ATH_CHECK(previousDecisionsHandle.isValid());
40 
41  if (previousDecisionsHandle->size() > 1)
42  {
43  ATH_MSG_ERROR("Found " << previousDecisionsHandle->size() << " previous decisions. SPCountHypoAlg is a full-scan HypoAlg and expects exactly one previous decision.");
44  return StatusCode::FAILURE;
45  }
46 
47  ATH_MSG_DEBUG("Running with " << previousDecisionsHandle->size() << " implicit ReadHandles for previous decisions");
48 
49  const auto viewSP = (previousDecisionsHandle->at(0))->objectLink<ViewContainer>(viewString());
50  ATH_CHECK(viewSP.isValid());
51  auto spacepointsHandle = ViewHelper::makeHandle(*viewSP, m_spacePointsKey, context);
52  ATH_CHECK(spacepointsHandle.isValid());
53  ATH_MSG_DEBUG("spacepoint handle size: " << spacepointsHandle->size() << "...");
54 
55  // new output decisions
57  auto decisions = outputHandle.ptr();
59  d->setObjectLink(featureString(), ViewHelper::makeLink<xAOD::TrigCompositeContainer>(*viewSP, spacepointsHandle, 0));
61 
63  TrigCompositeUtils::decisionIDs(previousDecisionsHandle->at(0), prev);
64 
65  SPCountHypoTool::SPCountsInfo spinfo({d, spacepointsHandle->at(0), prev});
66 
67  for (auto &tool : m_hypoTools)
68  {
69  ATH_CHECK(tool->decide(spinfo));
70  }
71  ATH_CHECK( hypoBaseOutputProcessing(outputHandle) );
72  return StatusCode::SUCCESS;
73 }
TrigCompositeUtils::DecisionContainer
xAOD::TrigCompositeContainer DecisionContainer
Definition: Event/xAOD/xAODTrigger/xAODTrigger/TrigCompositeContainer.h:21
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
TrigCompositeUtils::hypoAlgNodeName
const std::string & hypoAlgNodeName()
Definition: TrigCompositeUtilsRoot.cxx:906
SPCountHypoTool::SPCountsInfo
Definition: SPCountHypoTool.h:19
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
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
SPCountHypoAlg::initialize
virtual StatusCode initialize() override
Definition: SPCountHypoAlg.cxx:24
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
SPCountHypoAlg::m_spacePointsKey
SG::ReadHandleKey< xAOD::TrigCompositeContainer > m_spacePointsKey
Definition: SPCountHypoAlg.h:28
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
SPCountHypoAlg::m_hypoTools
ToolHandleArray< SPCountHypoTool > m_hypoTools
Definition: SPCountHypoAlg.h:27
SPCountHypoAlg::execute
virtual StatusCode execute(const EventContext &context) const override
Definition: SPCountHypoAlg.cxx:33
xAOD::decisions
decisions
Definition: TrigComposite_v1.cxx:81
TrigCompositeUtils::DecisionAuxContainer
xAOD::TrigCompositeAuxContainer DecisionAuxContainer
Definition: TrigCompositeAuxContainer.h:20
TrigCompositeUtils::featureString
const std::string & featureString()
Definition: TrigCompositeUtilsRoot.cxx:886
SPCountHypoAlg.h
SPCountHypoAlg::SPCountHypoAlg
SPCountHypoAlg()
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
HypoBase
Hypothesis algorithms take the output of reco algorithms and the decision from the preceeding InputMa...
Definition: HypoBase.h:13
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::LinkInfo
Helper to keep a Decision object, ElementLink and ActiveState (with respect to some requested ChainGr...
Definition: LinkInfo.h:28
TrigCompositeUtils::DecisionIDContainer
std::set< DecisionID > DecisionIDContainer
Definition: TrigComposite_v1.h:28
TrigCompositeUtils::findLink
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...
TrigCompositeUtils::decisionIDs
void decisionIDs(const Decision *d, DecisionIDContainer &destination)
Extracts DecisionIDs stored in the Decision object.
Definition: TrigCompositeUtilsRoot.cxx:67
TrigCompositeUtils::viewString
const std::string & viewString()
Definition: TrigCompositeUtilsRoot.cxx:882
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37