ATLAS Offline Software
Loading...
Searching...
No Matches
RoIsUnpackingToolPhase1.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4#ifndef HLTSEEDING_ROISUNPACKINGTOOLPHASE1_H
5#define HLTSEEDING_ROISUNPACKINGTOOLPHASE1_H
6
7// Local includes
10#include "utilities.h"
11
12// Athena includes
16
17
22template<typename T_RoI, typename T_RoIContainer, auto F_RoIWordGetter, const char* N_RoIContainer, const char* N_ThresholdType>
24private:
25 Gaudi::Property<std::string> m_l1RoILinkName {
26 this, "L1RoILinkName", N_RoIContainer,
27 "Name of the link to read from L1TriggerResult for L1 xAOD RoI container"};
28
30 this, "L1RoIThresholdPatternsKey", std::string(N_RoIContainer)+".thresholdPatterns",
31 "Name of the L1 xAOD RoI container decoration for the threshold patterns"};
32
33 Gaudi::Property<float> m_roiHalfWidthEta{
34 this, "RoIHalfWidthEta", 0.1, "Size of RoI in eta"};
35
36 Gaudi::Property<float> m_roiHalfWidthPhi{
37 this, "RoIHalfWidthPhi", 0.1, "Size of RoI in phi"};
38
39public:
40 // ===========================================================================
41 RoIsUnpackingToolPhase1(const std::string& type, const std::string& name, const IInterface* parent)
42 : RoIsUnpackingToolBase(type, name, parent) {}
43
44 // ===========================================================================
45 virtual StatusCode initialize() override {
47 ATH_CHECK(m_l1MenuKey.initialize());
48 ATH_CHECK(m_trigRoIsKey.initialize());
50 return StatusCode::SUCCESS;
51 }
52
53 // ===========================================================================
54 virtual StatusCode start() override {
55 ATH_CHECK(decodeMapping([](const std::string& name){
56 return name.find(N_ThresholdType)==0 or name.find(getProbeThresholdName(N_ThresholdType))==0;
57 }));
58 return StatusCode::SUCCESS;
59 }
60
61 // ===========================================================================
63 virtual StatusCode unpack(const EventContext& ctx,
64 const xAOD::TrigComposite& l1TriggerResult,
65 const HLT::IDSet& activeChains) const override {
66 using namespace HLTSeedingNs;
67 using namespace TrigCompositeUtils;
68 const bool doProbe = !m_decisionsKeyProbe.empty();
69
70 // Create and record RoI descriptor and decision containers
74 if (doProbe) decisionsProbe = createAndStore(m_decisionsKeyProbe, ctx);
75
76 // Retrieve the xAOD RoI container from L1TriggerResult
78 ATH_MSG_DEBUG("No " << N_ThresholdType << " RoIs in this event");
79 auto monRoIsCount = Monitored::Scalar("count", 0);
80 Monitored::Group(m_monTool, monRoIsCount);
81 return StatusCode::SUCCESS;
82 }
83 ElementLink<T_RoIContainer> roisLink = l1TriggerResult.objectLink<T_RoIContainer>(m_l1RoILinkName);
84 ATH_CHECK(roisLink.isValid());
85 const T_RoIContainer& rois = roisLink.getStorableObjectRef();
86
87 // Create threshold patterns decoration accessor
88 auto thrPatternAcc = SG::makeHandle<uint64_t>(m_thresholdPatternsKey, ctx);
89 ATH_CHECK(thrPatternAcc.isPresent());
90
91 // Retrieve the L1 menu configuration
93 ATH_CHECK(l1Menu.isValid());
94 std::optional<ThrVecRef> thresholds;
95 ATH_CHECK(getL1Thresholds(*l1Menu, N_ThresholdType, thresholds));
96
97 size_t linkIndex{0};
98 for (const T_RoI* roi : rois) {
99 // Create new RoI descriptor
100 roiDescriptors->push_back(std::make_unique<TrigRoiDescriptor>(
101 static_cast<unsigned int>((roi->*F_RoIWordGetter)()), 0u, 0u,
102 roi->eta(), roi->eta()-m_roiHalfWidthEta, roi->eta()+m_roiHalfWidthEta,
103 roi->phi(), roi->phi()-m_roiHalfWidthPhi, roi->phi()+m_roiHalfWidthPhi
104 ));
105
106 // Create new decision and link the RoI objects
107 Decision* decisionMain = TrigCompositeUtils::newDecisionIn(decisionsMain.ptr(), hltSeedingNodeName());
108 decisionMain->setObjectLink(initialRoIString(),
110 decisionMain->setObjectLink(initialRecRoIString(),
112
113 Decision* decisionProbe{nullptr};
114 if (doProbe) {
115 decisionProbe = TrigCompositeUtils::newDecisionIn(decisionsProbe.ptr(), hltSeedingNodeName());
116 decisionProbe->setObjectLink(initialRoIString(),
118 decisionProbe->setObjectLink(initialRecRoIString(),
120 }
121
122 std::vector<TrigCompositeUtils::DecisionID> passedThresholdIDs;
123
124 // Add positive decisions for chains to be activated by this RoI object
125 uint64_t thresholdPattern = thrPatternAcc(*roi);
126 ATH_MSG_DEBUG("RoI #" << linkIndex << " threshold pattern: " << thresholdPattern);
127 for (const std::shared_ptr<TrigConf::L1Threshold>& thr : thresholds.value().get()) {
128 if ((thresholdPattern & (1_u64 << thr->mapping())) == 0_u64) {continue;}
129 passedThresholdIDs.push_back(HLT::Identifier(thr->name()));
130 ATH_MSG_DEBUG("RoI #" << linkIndex << " passed threshold number " << thr->mapping()
131 << " name" << (doProbe ? "s " : " ") << thr->name()
132 << (doProbe ? " and "+getProbeThresholdName(thr->name()) : ""));
133 addChainsToDecision(HLT::Identifier(thr->name()), decisionMain, activeChains);
134 if (doProbe) addChainsToDecision(HLT::Identifier(getProbeThresholdName(thr->name())), decisionProbe, activeChains);
135 }
136
137 decisionMain->setDetail("thresholds", passedThresholdIDs);
138 if (doProbe) decisionProbe->setDetail("thresholds", passedThresholdIDs);
139
140 ++linkIndex;
141 }
142
143 // Monitor the TrigRoiDescriptorCollection
144 {
145 auto monRoIsCount = Monitored::Scalar("count", roiDescriptors->size());
146 auto monRoIsEta = Monitored::Collection("eta", *roiDescriptors, &TrigRoiDescriptor::eta);
147 auto monRoIsPhi = Monitored::Collection("phi", *roiDescriptors, &TrigRoiDescriptor::phi);
148 Monitored::Group(m_monTool, monRoIsCount, monRoIsEta, monRoIsPhi);
149 }
150
151 return StatusCode::SUCCESS;
152 }
153
154}; // class RoIsUnpackingToolPhase1
155
156
162public:
163 eFexEMRoIsUnpackingTool(const std::string& type, const std::string& name, const IInterface* parent)
164 : HLTSeedingRoIToolDefs::eFexEM::UnpackingBaseClass(type, name, parent) {}
165};
166
168public:
169 eFexTauRoIsUnpackingTool(const std::string& type, const std::string& name, const IInterface* parent)
170 : HLTSeedingRoIToolDefs::eFexTau::UnpackingBaseClass(type, name, parent) {}
171};
172
174 public:
175 jFexFwdElRoIsUnpackingTool(const std::string& type, const std::string& name, const IInterface* parent)
176 : HLTSeedingRoIToolDefs::jFexFwdEl::UnpackingBaseClass(type, name, parent) {}
177};
178
180public:
181 jFexTauRoIsUnpackingTool(const std::string& type, const std::string& name, const IInterface* parent)
182 : HLTSeedingRoIToolDefs::jFexTau::UnpackingBaseClass(type, name, parent) {}
183};
184
186public:
187 cTauRoIsUnpackingTool(const std::string& type, const std::string& name, const IInterface* parent)
188 : HLTSeedingRoIToolDefs::cTau::UnpackingBaseClass(type, name, parent) {}
189};
190
192public:
193 jFexSRJetRoIsUnpackingTool(const std::string& type, const std::string& name, const IInterface* parent)
194 : HLTSeedingRoIToolDefs::jFexSRJet::UnpackingBaseClass(type, name, parent) {}
195};
196
198public:
199 jFexLRJetRoIsUnpackingTool(const std::string& type, const std::string& name, const IInterface* parent)
200 : HLTSeedingRoIToolDefs::jFexLRJet::UnpackingBaseClass(type, name, parent) {}
201};
202
204public:
205 gFexSRJetRoIsUnpackingTool(const std::string& type, const std::string& name, const IInterface* parent)
206 : HLTSeedingRoIToolDefs::gFexSRJet::UnpackingBaseClass(type, name, parent) {}
207};
208
210public:
211 gFexLRJetRoIsUnpackingTool(const std::string& type, const std::string& name, const IInterface* parent)
212 : HLTSeedingRoIToolDefs::gFexLRJet::UnpackingBaseClass(type, name, parent) {}
213};
214
216public:
217 MuonRoIsUnpackingTool(const std::string& type, const std::string& name, const IInterface* parent)
218 : HLTSeedingRoIToolDefs::Muon::UnpackingBaseClass(type, name, parent) {}
219};
220
221
222#endif //> !HLTSEEDING_ROISUNPACKINGTOOLPHASE1_H
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x)
SG::WriteHandle< DecisionContainer > createAndStore(const SG::WriteHandleKey< DecisionContainer > &key, const EventContext &ctx)
Creates and right away records the DecisionContainer with the key.
Header file to be included by clients of the Monitored infrastructure.
Property holding a SG store/key/clid/attr name from which a ReadDecorHandle is made.
Handle class for reading a decoration on an object.
virtual double eta() const =0
virtual double phi() const =0
Methods to retrieve data members.
Group of local monitoring quantities and retain correlation when filling histograms
Declare a monitored scalar variable.
MuonRoIsUnpackingTool(const std::string &type, const std::string &name, const IInterface *parent)
virtual StatusCode unpack(const EventContext &, const ROIB::RoIBResult &, const HLT::IDSet &) const override
RoIsUnpackingToolBase(const std::string &type, const std::string &name, const IInterface *parent)
void addChainsToDecision(HLT::Identifier thresholdId, TrigCompositeUtils::Decision *d, const HLT::IDSet &activeChains) const
virtual StatusCode initialize() override
StatusCode getL1Thresholds(const TrigConf::L1Menu &l1Menu, const std::string &thrType, std::optional< ThrVecRef > &thrVec) const
Retrieve a vector of thresholds with type thrType from L1Menu.
StatusCode decodeMapping(std::function< bool(const std::string &)> &&filter)
Fills mapping from L1 threshold -> to HLT chain.
static std::string getProbeThresholdName(const std::string &thresholdName)
Concatenate the probe identifier string with the threshold name string.
virtual StatusCode unpack(const EventContext &ctx, const xAOD::TrigComposite &l1TriggerResult, const HLT::IDSet &activeChains) const override
RoIsUnpackingToolPhase1(const std::string &type, const std::string &name, const IInterface *parent)
virtual StatusCode initialize() override
virtual StatusCode start() override
Property holding a SG store/key/clid/attr name from which a ReadDecorHandle is made.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
pointer_type ptr()
Dereference the pointer.
cTauRoIsUnpackingTool(const std::string &type, const std::string &name, const IInterface *parent)
eFexEMRoIsUnpackingTool(const std::string &type, const std::string &name, const IInterface *parent)
eFexTauRoIsUnpackingTool(const std::string &type, const std::string &name, const IInterface *parent)
gFexLRJetRoIsUnpackingTool(const std::string &type, const std::string &name, const IInterface *parent)
gFexSRJetRoIsUnpackingTool(const std::string &type, const std::string &name, const IInterface *parent)
jFexFwdElRoIsUnpackingTool(const std::string &type, const std::string &name, const IInterface *parent)
jFexLRJetRoIsUnpackingTool(const std::string &type, const std::string &name, const IInterface *parent)
jFexSRJetRoIsUnpackingTool(const std::string &type, const std::string &name, const IInterface *parent)
jFexTauRoIsUnpackingTool(const std::string &type, const std::string &name, const IInterface *parent)
bool setObjectLink(const std::string &name, const ElementLink< CONTAINER > &link)
Set the link to an object.
bool hasObjectLink(const std::string &name, const CLID clid=CLID_NULL) const
Check if a link to an object with a given name and type exists. CLID_NULL to not check type.
bool setDetail(const std::string &name, const TYPE &value)
Set an TYPE detail on the object.
ElementLink< CONTAINER > objectLink(const std::string &name) const
Get the link with the requested name.
RoIsUnpackingToolPhase1< T_RoI, T_RoIContainer, F_RoIWordGetter, ContainerName, ThresholdType > UnpackingBaseClass
RoIsUnpackingToolPhase1< T_RoI, T_RoIContainer, F_RoIWordGetter, ContainerName, ThresholdType > UnpackingBaseClass
RoIsUnpackingToolPhase1< T_RoI, T_RoIContainer, F_RoIWordGetter, ContainerName, ThresholdType > UnpackingBaseClass
RoIsUnpackingToolPhase1< T_RoI, T_RoIContainer, F_RoIWordGetter, ContainerName, ThresholdType > UnpackingBaseClass
RoIsUnpackingToolPhase1< T_RoI, T_RoIContainer, F_RoIWordGetter, ContainerName, ThresholdType > UnpackingBaseClass
RoIsUnpackingToolPhase1< T_RoI, T_RoIContainer, F_RoIWordGetter, ContainerName, ThresholdType > UnpackingBaseClass
RoIsUnpackingToolPhase1< T_RoI, T_RoIContainer, F_RoIWordGetter, ContainerName, ThresholdType > UnpackingBaseClass
RoIsUnpackingToolPhase1< T_RoI, T_RoIContainer, F_RoIWordGetter, ContainerName, ThresholdType > UnpackingBaseClass
RoIsUnpackingToolPhase1< T_RoI, T_RoIContainer, F_RoIWordGetter, ContainerName, ThresholdType > UnpackingBaseClass
RoIsUnpackingToolPhase1< T_RoI, T_RoIContainer, F_RoIWordGetter, ContainerName, ThresholdType > UnpackingBaseClass
Collection of template parameter values for the RoIThresholdsTool and RoIsUnpackingToolPhase1 class t...
std::set< HLT::Identifier > IDSet
ValuesCollection< T > Collection(std::string name, const T &collection)
Declare a monitored (double-convertible) collection.
NRpcCablingAlg reads raw condition data and writes derived condition data to the condition store.
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
SG::WriteHandle< CONT > createAndStoreNoAux(const SG::WriteHandleKey< CONT > &key, const EventContext &ctx)
Creates and right away records the Container CONT with the key.
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 & initialRecRoIString()
const std::string & initialRoIString()
const std::string & hltSeedingNodeName()
TrigComposite_v1 TrigComposite
Declare the latest version of the class.