ATLAS Offline Software
Loading...
Searching...
No Matches
SPCountHypoAlg.cxx
Go to the documentation of this file.
1/*
2Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
5#include "SPCountHypoAlg.h"
7
20
21SPCountHypoAlg::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
33StatusCode 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();
58 auto d = newDecisionIn(decisions, hypoAlgNodeName());
59 d->setObjectLink(featureString(), ViewHelper::makeLink<xAOD::TrigCompositeContainer>(*viewSP, spacepointsHandle, 0));
60 linkToPrevious(d, decisionInput().key(), 0);
61
63 TrigCompositeUtils::decisionIDs(previousDecisionsHandle->at(0), prev);
64
65 SPCountHypoTool::SPCountsInfo spinfo({d, spacepointsHandle->at(0), std::move(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}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_DEBUG(x)
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.
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()
const std::string & featureString()
void linkToPrevious(Decision *d, const std::string &previousCollectionKey, size_t previousIndex)
Links to the previous object, location of previous 'seed' decision supplied by hand.
const std::string & viewString()
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
pointer_type ptr()
Dereference the pointer.
ToolHandleArray< SPCountHypoTool > m_hypoTools
virtual StatusCode initialize() override
virtual StatusCode execute(const EventContext &context) const override
SG::ReadHandleKey< xAOD::TrigCompositeContainer > m_spacePointsKey
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()
xAOD::TrigCompositeAuxContainer DecisionAuxContainer
std::set< DecisionID > DecisionIDContainer
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...
void decisionIDs(const Decision *d, DecisionIDContainer &destination)
Extracts DecisionIDs stored in the Decision object.
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
Helper to keep a Decision object, ElementLink and ActiveState (with respect to some requested ChainGr...
Definition LinkInfo.h:22