ATLAS Offline Software
Loading...
Searching...
No Matches
PEBInfoWriterToolBase.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
6
7// TrigCompositeUtils types used here
12
13// TrigCompositeUtils methods used here
17
18// =============================================================================
19
20PEBInfoWriterToolBase::PEBInfoWriterToolBase(const std::string& type, const std::string& name, const IInterface* parent)
21: AthAlgTool(type,name,parent),
22 m_decisionId(HLT::Identifier::fromToolName(name)) {}
23
24// =============================================================================
25
27
28// =============================================================================
29
30StatusCode PEBInfoWriterToolBase::decide(const EventContext& ctx, std::vector<Input>& inputs) const {
31 std::set<ElementLink<TrigRoiDescriptorCollection>> uniqueRoIs;
32 for (Input& input : inputs) {
33 // Skip if previous step for this chain didn't pass
34 if (not TrigCompositeUtils::passed(m_decisionId.numeric(), input.previousDecisionIDs)) {
35 ATH_MSG_DEBUG("Skipping chain because previous step didn't pass");
36 continue;
37 }
38
39 if (!m_matchTriggerType.empty()) {
40 if (std::none_of(
41 m_matchTriggerType.begin(),
43 [&input](uint8_t test_tt) { return (test_tt & input.tt) == test_tt; }
44 )){
45 continue;
46 }
47 }
48
49 // Count unique RoIs
50 bool isUnique = uniqueRoIs.insert(input.roiEL).second;
51 ATH_MSG_DEBUG("RoI eta/phi = " << (*input.roiEL)->eta() << "/" << (*input.roiEL)->phi() << " has "
52 << (isUnique ? "not yet" : "already") << " been processed. So far seen "
53 << uniqueRoIs.size() << " unique RoIs including this one");
54
55 // Skip processing if max RoIs limit reached
56 bool maxRoIsReached{false};
57 if (m_maxRoIs>=0 && static_cast<int>(uniqueRoIs.size()) > m_maxRoIs) {
58 ATH_MSG_DEBUG("Will attach empty PEB Info to this decision because the number of "
59 << "processed RoIs reached MaxRoIs (" << m_maxRoIs.value() << ")");
60 maxRoIsReached = true;
61 }
62
63 // Create new PEB Info for this input (empty if max RoIs limit is reached)
64 PEBInfo pebInfo = maxRoIsReached ? PEBInfo{} : createPEBInfo(ctx, input);
65
66 // Merge with previous ROBs
67 std::vector<uint32_t> previousRobs;
68 ATH_CHECK(input.decision->getDetail(robListKey(), previousRobs));
69 pebInfo.robs.insert(previousRobs.begin(), previousRobs.end());
70
71 // Merge with previous SubDets
72 std::vector<uint32_t> previousSubDets;
73 ATH_CHECK(input.decision->getDetail(subDetListKey(), previousSubDets));
74 pebInfo.subdets.insert(previousSubDets.begin(), previousSubDets.end());
75
76 // Attach the PEB Info to the decision
77 std::vector<uint32_t> robVec(pebInfo.robs.begin(), pebInfo.robs.end());
78 if (not input.decision->setDetail(robListKey(), robVec)) {
79 ATH_MSG_ERROR("Failed to attach the detail " << robListKey() << " to the decision");
80 return StatusCode::FAILURE;
81 }
82 std::vector<uint32_t> subDetVec(pebInfo.subdets.begin(), pebInfo.subdets.end());
83 if (not input.decision->setDetail(subDetListKey(), subDetVec)) {
84 ATH_MSG_ERROR("Failed to attach the detail " << subDetListKey() << " to the decision");
85 return StatusCode::FAILURE;
86 }
87
88 ATH_MSG_DEBUG("Attached PEB Info with " << robVec.size() << " ROBs and "
89 << subDetVec.size() << " SubDets to the decision object.");
90 ATH_MSG_DEBUG("PEBInfo: " << pebInfo);
91
92 // Make an accept decision
94 }
95 return StatusCode::SUCCESS;
96}
97
98// =============================================================================
99
100std::ostream& operator<< (std::ostream& str, const PEBInfoWriterToolBase::PEBInfo& pebi) {
101 str << "ROBs = [";
102 size_t i=0;
103 for (const uint32_t robid : pebi.robs) {
104 str << "0x" << std::hex << robid << std::dec;
105 ++i;
106 if (i!=pebi.robs.size()) str << ", ";
107 }
108 str << "], SubDets = [";
109 i=0;
110 for (const uint32_t subdetid : pebi.subdets) {
111 str << "0x" << std::hex << subdetid << std::dec;
112 ++i;
113 if (i!=pebi.subdets.size()) str << ", ";
114 }
115 str << "]";
116 return str;
117}
#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.