ATLAS Offline Software
Loading...
Searching...
No Matches
PEBInfoWriterAlg.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
5// Trigger includes
6#include "PEBInfoWriterAlg.h"
8
9// TrigCompositeUtils types used here
15
16// TrigCompositeUtils methods used here
25
26// =============================================================================
27
28PEBInfoWriterAlg::PEBInfoWriterAlg(const std::string& name, ISvcLocator* pSvcLocator)
29: ::HypoBase(name, pSvcLocator) {}
30
31// =============================================================================
32
34
35// =============================================================================
36
38 ATH_MSG_DEBUG("Initialising " << name());
39 ATH_CHECK(m_hypoTools.retrieve());
40 ATH_CHECK(m_eventInfoKey.initialize());
41 return StatusCode::SUCCESS;
42}
43
44// =============================================================================
45
47 ATH_MSG_DEBUG("Finalising " << name());
48 return StatusCode::SUCCESS;
49}
50
51// =============================================================================
52
53StatusCode PEBInfoWriterAlg::execute(const EventContext& eventContext) const {
54 ATH_MSG_DEBUG("Executing " << name());
55
56 // ---------------------------------------------------------------------------
57 // Common hypo start - retrieve previous decisions and record new container
58 // ---------------------------------------------------------------------------
59 // Retrieve previous decisions
60 SG::ReadHandle<DecisionContainer> previousDecisionsHandle = SG::makeHandle(decisionInput(), eventContext);
61 if (not previousDecisionsHandle.isValid()) { // Implicit
62 ATH_MSG_DEBUG("No implicit previous decisions with key " << decisionInput().key() << " - is this expected?");
63 return StatusCode::SUCCESS;
64 }
65 ATH_MSG_DEBUG("Running with " << previousDecisionsHandle->size() << " implicit previous decisions");
66
67 // New output decisions
69 DecisionContainer* decisions = outputHandle.ptr();
70
71 // ---------------------------------------------------------------------------
72 // Prepare new decision and hypo tool inputs
73 // ---------------------------------------------------------------------------
74 std::vector<PEBInfoWriterToolBase::Input> toolInputs;
75
76 SG::ReadHandle<xAOD::EventInfo> eventInfo (m_eventInfoKey, eventContext);
77 const uint8_t tt = (uint8_t) eventInfo->level1TriggerType();
78
79 size_t counter = 0;
80 for (const Decision* previousDecision: *previousDecisionsHandle) {
81 // Get RoI
82 auto roiELInfo = findLink<TrigRoiDescriptorCollection>(previousDecision, roiString());
83 auto roiEL = roiELInfo.link;
84 ATH_CHECK(roiEL.isValid());
85
86 // Create new HypoAlg decision and link it to previousDecision
87 Decision* newd = newDecisionIn(decisions, previousDecision, hypoAlgNodeName(), eventContext);
88
89 // Attach empty PEB Info lists to the new decision
90 ATH_CHECK(newd->setDetail(PEBInfoWriterToolBase::robListKey(), std::vector<uint32_t>()));
91 ATH_CHECK(newd->setDetail(PEBInfoWriterToolBase::subDetListKey(), std::vector<uint32_t>()));
92
93 // Push_back to toolInput
94 toolInputs.emplace_back(newd, eventContext, roiEL, previousDecision, tt);
95
96 // Link to feature. Dummy link here
97 ElementLink<DecisionContainer> dummyLink(*decisions, decisions->size()-1, eventContext);
98 newd->setObjectLink(featureString(), dummyLink);
99
100 // Disable ComboHypo checks on the output of the final PEB step. All multiplicity cuts should be applied already.
101 newd->setDetail<int32_t>("noCombo", 1);
102
103 ATH_MSG_DEBUG("RoI eta/phi = " << (*roiEL)->eta() << "/" << (*roiEL)->phi());
104 ATH_MSG_DEBUG("Added RoI, previous decision and dummy feature to new decision " << counter);
105 ++counter;
106
107 }
108
109 // ---------------------------------------------------------------------------
110 // Call the hypo tools
111 // ---------------------------------------------------------------------------
112 for (const auto& tool: m_hypoTools) {
113 ATH_MSG_DEBUG("Calling " << tool);
114 ATH_CHECK(tool->decide(eventContext, toolInputs));
115 }
116
117 // ---------------------------------------------------------------------------
118 // Print the passing decisions
119 // ---------------------------------------------------------------------------
120 ATH_CHECK(outputHandle.isValid());
121 ATH_MSG_DEBUG("Exit with " << outputHandle->size() << " decisions");
122 ATH_CHECK( hypoBaseOutputProcessing(outputHandle) );
123
124 return StatusCode::SUCCESS;
125}
#define ATH_CHECK
Evaluate an expression and check for errors.
#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()
const std::string & roiString()
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 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 ~PEBInfoWriterAlg()
Standard destructor.
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfoKey
ToolHandleArray< PEBInfoWriterToolBase > m_hypoTools
virtual StatusCode execute(const EventContext &eventContext) const override
virtual StatusCode finalize() override
PEBInfoWriterAlg(const std::string &name, ISvcLocator *svcLoc)
Standard constructor.
virtual StatusCode initialize() override
static std::string robListKey()
Returns the key used to record/retrieve the ROB list.
static std::string subDetListKey()
Returns the key used to record/retrieve the SubDet list.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
virtual bool isValid() override final
Can the handle be successfully dereferenced?
pointer_type ptr()
Dereference the pointer.
bool setObjectLink(const std::string &name, const ElementLink< CONTAINER > &link)
Set the link to an object.
bool setDetail(const std::string &name, const TYPE &value)
Set an TYPE detail on the object.
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
unsigned int DecisionID
const std::string & roiString()
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()
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.
Helper to keep a Decision object, ElementLink and ActiveState (with respect to some requested ChainGr...
Definition LinkInfo.h:22