ATLAS Offline Software
Loading...
Searching...
No Matches
PEBInfoWriterToolBase.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
7
8
9// TrigCompositeUtils types used here
14
15// TrigCompositeUtils methods used here
19
20// =============================================================================
21
22PEBInfoWriterToolBase::PEBInfoWriterToolBase(const std::string& type, const std::string& name, const IInterface* parent)
23: AthAlgTool(type,name,parent),
24 m_decisionId(HLT::Identifier::fromToolName(name)) {}
25
26// =============================================================================
27
29
30// =============================================================================
31
32StatusCode PEBInfoWriterToolBase::decide(const EventContext& ctx, std::vector<Input>& inputs) const {
33 std::set<ElementLink<TrigRoiDescriptorCollection>> uniqueRoIs;
34 for (Input& input : inputs) {
35 // Skip if previous step for this chain didn't pass
36 if (not TrigCompositeUtils::passed(m_decisionId.numeric(), input.previousDecisionIDs)) {
37 ATH_MSG_DEBUG("Skipping chain because previous step didn't pass");
38 continue;
39 }
40
41 if (!m_matchTriggerType.empty()) {
42 if (std::none_of(
43 m_matchTriggerType.begin(),
45 [&input](uint8_t test_tt) { return (test_tt & input.tt) == test_tt; }
46 )){
47 continue;
48 }
49 }
50
51 // Count unique RoIs
52 bool isUnique = uniqueRoIs.insert(input.roiEL).second;
53 ATH_MSG_DEBUG("RoI eta/phi = " << (*input.roiEL)->eta() << "/" << (*input.roiEL)->phi() << " has "
54 << (isUnique ? "not yet" : "already") << " been processed. So far seen "
55 << uniqueRoIs.size() << " unique RoIs including this one");
56
57 // Skip processing if max RoIs limit reached
58 bool maxRoIsReached{false};
59 if (m_maxRoIs>=0 && static_cast<int>(uniqueRoIs.size()) > m_maxRoIs) {
60 ATH_MSG_DEBUG("Will attach empty PEB Info to this decision because the number of "
61 << "processed RoIs reached MaxRoIs (" << m_maxRoIs.value() << ")");
62 maxRoIsReached = true;
63 }
64
65 // Create new PEB Info for this input (empty if max RoIs limit is reached)
66 PEBInfo pebInfo = maxRoIsReached ? PEBInfo{} : createPEBInfo(ctx, input);
67
68 // Merge with previous ROBs
69 std::vector<uint32_t> previousRobs;
70 ATH_CHECK(input.decision->getDetail(robListKey(), previousRobs));
71 pebInfo.robs.insert(previousRobs.begin(), previousRobs.end());
72
73 // Merge with previous SubDets
74 std::vector<uint32_t> previousSubDets;
75 ATH_CHECK(input.decision->getDetail(subDetListKey(), previousSubDets));
76 pebInfo.subdets.insert(previousSubDets.begin(), previousSubDets.end());
77
78 // Attach the PEB Info to the decision
79 std::vector<uint32_t> robVec(pebInfo.robs.begin(), pebInfo.robs.end());
80 if (not input.decision->setDetail(robListKey(), robVec)) {
81 ATH_MSG_ERROR("Failed to attach the detail " << robListKey() << " to the decision");
82 return StatusCode::FAILURE;
83 }
84 std::vector<uint32_t> subDetVec(pebInfo.subdets.begin(), pebInfo.subdets.end());
85 if (not input.decision->setDetail(subDetListKey(), subDetVec)) {
86 ATH_MSG_ERROR("Failed to attach the detail " << subDetListKey() << " to the decision");
87 return StatusCode::FAILURE;
88 }
89
90 ATH_MSG_DEBUG("Attached PEB Info with " << robVec.size() << " ROBs and "
91 << subDetVec.size() << " SubDets to the decision object.");
92 ATH_MSG_DEBUG("PEBInfo: " << pebInfo);
93
94 // Make an accept decision
96 }
97 return StatusCode::SUCCESS;
98}
99
100// =============================================================================
101
102std::ostream& operator<< (std::ostream& str, const PEBInfoWriterToolBase::PEBInfo& pebi) {
103 str << "ROBs = [";
104 size_t i=0;
105 for (const uint32_t robid : pebi.robs) {
106 str << "0x" << std::hex << robid << std::dec;
107 ++i;
108 if (i!=pebi.robs.size()) str << ", ";
109 }
110 str << "], SubDets = [";
111 i=0;
112 for (const uint32_t subdetid : pebi.subdets) {
113 str << "0x" << std::hex << subdetid << std::dec;
114 ++i;
115 if (i!=pebi.subdets.size()) str << ", ";
116 }
117 str << "]";
118 return str;
119}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_DEBUG(x)
std::ostream & operator<<(std::ostream &str, const PEBInfoWriterToolBase::PEBInfo &pebi)
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
virtual ~PEBInfoWriterToolBase()
Standard destructor.
virtual PEBInfo createPEBInfo(const EventContext &ctx, const Input &input) const =0
Creates the PEBInfo which is attached to the decision in decide. Has to be implemented by the derived...
Gaudi::Property< std::vector< unsigned int > > m_matchTriggerType
HLT::Identifier m_decisionId
The decision id of the tool instance.
StatusCode decide(const EventContext &ctx, std::vector< Input > &inputs) const
Adds a pass-through decision with attached PEB information created by createPEBInfo for each input.
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.
Gaudi::Property< int > m_maxRoIs
MaxRoIs property.
PEBInfoWriterToolBase(const std::string &type, const std::string &name, const IInterface *parent)
Standard constructor.
It used to be useful piece of code for replacing actual SG with other store of similar functionality ...
unsigned int DecisionID
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.
bool passed(DecisionID id, const DecisionIDContainer &idSet)
checks if required decision ID is in the set of IDs in the container
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.
void addDecisionID(DecisionID id, Decision *d)
Appends the decision (given as ID) to the decision object.
void decisionIDs(const Decision *d, DecisionIDContainer &destination)
Extracts DecisionIDs stored in the Decision object.
Input to the tool's decide method.
Structure holding the list of ROBs and SubDets.