ATLAS Offline Software
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 
22 template<typename T_RoI, typename T_RoIContainer, auto F_RoIWordGetter, const char* N_RoIContainer, const char* N_ThresholdType>
24 private:
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 
39 public:
40  // ===========================================================================
41  RoIsUnpackingToolPhase1(const std::string& type, const std::string& name, const IInterface* 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
71  SG::WriteHandle<TrigRoiDescriptorCollection> roiDescriptors = createAndStoreNoAux(m_trigRoIsKey, ctx);
72  SG::WriteHandle<DecisionContainer> decisionsMain = createAndStore(m_decisionsKey, ctx);
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  }
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
92  SG::ReadHandle<TrigConf::L1Menu> l1Menu = SG::makeHandle(m_l1MenuKey, ctx);
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(),
109  ElementLink<TrigRoiDescriptorCollection>(m_trigRoIsKey.key(), linkIndex, ctx));
110  decisionMain->setObjectLink(initialRecRoIString(),
112 
113  Decision* decisionProbe{nullptr};
114  if (doProbe) {
115  decisionProbe = TrigCompositeUtils::newDecisionIn(decisionsProbe.ptr(), hltSeedingNodeName());
116  decisionProbe->setObjectLink(initialRoIString(),
117  ElementLink<TrigRoiDescriptorCollection>(m_trigRoIsKey.key(), linkIndex, ctx));
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 
162 public:
163  eFexEMRoIsUnpackingTool(const std::string& type, const std::string& name, const IInterface* parent)
165 };
166 
168 public:
169  eFexTauRoIsUnpackingTool(const std::string& type, const std::string& name, const IInterface* parent)
171 };
172 
174  public:
175  jFexFwdElRoIsUnpackingTool(const std::string& type, const std::string& name, const IInterface* parent)
177 };
178 
180 public:
181  jFexTauRoIsUnpackingTool(const std::string& type, const std::string& name, const IInterface* parent)
183 };
184 
186 public:
187  cTauRoIsUnpackingTool(const std::string& type, const std::string& name, const IInterface* parent)
189 };
190 
192 public:
193  jFexSRJetRoIsUnpackingTool(const std::string& type, const std::string& name, const IInterface* parent)
195 };
196 
198 public:
199  jFexLRJetRoIsUnpackingTool(const std::string& type, const std::string& name, const IInterface* parent)
201 };
202 
204 public:
205  gFexSRJetRoIsUnpackingTool(const std::string& type, const std::string& name, const IInterface* parent)
207 };
208 
210 public:
211  gFexLRJetRoIsUnpackingTool(const std::string& type, const std::string& name, const IInterface* parent)
213 };
214 
216 public:
217  MuonRoIsUnpackingTool(const std::string& type, const std::string& name, const IInterface* parent)
219 };
221 
222 #endif //> !HLTSEEDING_ROISUNPACKINGTOOLPHASE1_H
RoIsUnpackingToolBase.h
HLTSeedingRoIToolDefs::eFexEM::T_RoI
xAOD::eFexEMRoI T_RoI
Definition: HLTSeedingRoIToolDefs.h:40
xAOD::TrigComposite_v1::setDetail
bool setDetail(const std::string &name, const TYPE &value)
Set an TYPE detail on the object.
TrigDefs::Group
Group
Properties of a chain group.
Definition: GroupProperties.h:13
ReadDecorHandleKey.h
Property holding a SG store/key/clid/attr name from which a ReadDecorHandle is made.
RoIsUnpackingToolBase
Base class for RoI unpackers.
Definition: RoIsUnpackingToolBase.h:32
gFexSRJetRoIsUnpackingTool
Definition: RoIsUnpackingToolPhase1.h:203
xAOD::TrigComposite_v1::objectLink
ElementLink< CONTAINER > objectLink(const std::string &name) const
Get the link with the requested name.
TrigCompositeUtils::newDecisionIn
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.
Definition: TrigCompositeUtilsRoot.cxx:44
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:67
gFexLRJetRoIsUnpackingTool::gFexLRJetRoIsUnpackingTool
gFexLRJetRoIsUnpackingTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition: RoIsUnpackingToolPhase1.h:211
xAOD::TrigComposite_v1::hasObjectLink
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.
Definition: TrigComposite_v1.cxx:244
gFexSRJetRoIsUnpackingTool::gFexSRJetRoIsUnpackingTool
gFexSRJetRoIsUnpackingTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition: RoIsUnpackingToolPhase1.h:205
HLTSeedingRoIToolDefs::eFexEM::F_RoIWordGetter
constexpr auto F_RoIWordGetter
Definition: HLTSeedingRoIToolDefs.h:42
RoIsUnpackingToolPhase1::m_l1RoILinkName
Gaudi::Property< std::string > m_l1RoILinkName
Definition: RoIsUnpackingToolPhase1.h:25
RoIsUnpackingToolPhase1::m_thresholdPatternsKey
SG::ReadDecorHandleKey< T_RoIContainer > m_thresholdPatternsKey
Definition: RoIsUnpackingToolPhase1.h:29
Muon
NRpcCablingAlg reads raw condition data and writes derived condition data to the condition store.
Definition: TrackSystemController.h:45
TrigCompositeUtils::createAndStore
SG::WriteHandle< DecisionContainer > createAndStore(const SG::WriteHandleKey< DecisionContainer > &key, const EventContext &ctx)
Creates and right away records the DecisionContainer with the key.
Definition: TrigCompositeUtilsRoot.cxx:28
jFexFwdElRoIsUnpackingTool::jFexFwdElRoIsUnpackingTool
jFexFwdElRoIsUnpackingTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition: RoIsUnpackingToolPhase1.h:175
Trk::u
@ u
Enums for curvilinear frames.
Definition: ParamDefs.h:77
python.CaloAddPedShiftConfig.type
type
Definition: CaloAddPedShiftConfig.py:42
Monitored::Collection
ValuesCollection< T > Collection(std::string name, const T &collection)
Declare a monitored (double-convertible) collection.
Definition: MonitoredCollection.h:38
SG::makeHandle
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Definition: ReadCondHandle.h:274
MuonRoIsUnpackingTool::MuonRoIsUnpackingTool
MuonRoIsUnpackingTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition: RoIsUnpackingToolPhase1.h:217
jFexLRJetRoIsUnpackingTool
Definition: RoIsUnpackingToolPhase1.h:197
RoIsUnpackingToolBase::unpack
virtual StatusCode unpack(const EventContext &, const ROIB::RoIBResult &, const HLT::IDSet &) const override
Definition: RoIsUnpackingToolBase.h:40
IBLCalibrationConfig.thr
thr
Definition: IBLCalibrationConfig.py:39
TrigCompositeUtils::initialRecRoIString
const std::string & initialRecRoIString()
Definition: TrigCompositeUtils.h:417
eFexTauRoIsUnpackingTool::eFexTauRoIsUnpackingTool
eFexTauRoIsUnpackingTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition: RoIsUnpackingToolPhase1.h:169
RoIsUnpackingToolPhase1::initialize
virtual StatusCode initialize() override
Definition: RoIsUnpackingToolPhase1.h:45
eFexEMRoIsUnpackingTool
Definition: RoIsUnpackingToolPhase1.h:161
xAOD::TrigComposite_v1::setObjectLink
bool setObjectLink(const std::string &name, const ElementLink< CONTAINER > &link)
Set the link to an object.
SG::ReadDecorHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
SG::WriteHandle::ptr
pointer_type ptr()
Dereference the pointer.
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
ClassID_traits
Default, invalid implementation of ClassID_traits.
Definition: Control/AthenaKernel/AthenaKernel/ClassID_traits.h:37
HLTSeedingRoIToolDefs::eFexEM::UnpackingBaseClass
RoIsUnpackingToolPhase1< T_RoI, T_RoIContainer, F_RoIWordGetter, ContainerName, ThresholdType > UnpackingBaseClass
Definition: HLTSeedingRoIToolDefs.h:44
jFexFwdElRoIsUnpackingTool
Definition: RoIsUnpackingToolPhase1.h:173
TrigCompositeUtils::createAndStoreNoAux
SG::WriteHandle< CONT > createAndStoreNoAux(const SG::WriteHandleKey< CONT > &key, const EventContext &ctx)
Creates and right away records the Container CONT with the key.
test_pyathena.parent
parent
Definition: test_pyathena.py:15
RoIsUnpackingToolPhase1::RoIsUnpackingToolPhase1
RoIsUnpackingToolPhase1(const std::string &type, const std::string &name, const IInterface *parent)
Definition: RoIsUnpackingToolPhase1.h:41
xAOD::uint64_t
uint64_t
Definition: EventInfo_v1.cxx:123
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
xAOD::TrigComposite_v1
Class used to describe composite objects in the HLT.
Definition: TrigComposite_v1.h:49
RoIsUnpackingToolPhase1::start
virtual StatusCode start() override
Definition: RoIsUnpackingToolPhase1.h:54
TrigCompositeUtils::initialRoIString
const std::string & initialRoIString()
Definition: TrigCompositeUtils.h:416
HLT::Identifier
Definition: TrigCompositeUtils/TrigCompositeUtils/HLTIdentifier.h:19
jFexSRJetRoIsUnpackingTool::jFexSRJetRoIsUnpackingTool
jFexSRJetRoIsUnpackingTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition: RoIsUnpackingToolPhase1.h:193
Monitored.h
Header file to be included by clients of the Monitored infrastructure.
TrigCompositeUtils::hltSeedingNodeName
const std::string & hltSeedingNodeName()
Definition: TrigCompositeUtils.h:423
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
utilities.h
RoIsUnpackingToolPhase1::m_roiHalfWidthPhi
Gaudi::Property< float > m_roiHalfWidthPhi
Definition: RoIsUnpackingToolPhase1.h:36
gFexLRJetRoIsUnpackingTool
Definition: RoIsUnpackingToolPhase1.h:209
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
eFexEMRoIsUnpackingTool::eFexEMRoIsUnpackingTool
eFexEMRoIsUnpackingTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition: RoIsUnpackingToolPhase1.h:163
DataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
HLTSeedingRoIToolDefs.h
cTauRoIsUnpackingTool
Definition: RoIsUnpackingToolPhase1.h:185
cTauRoIsUnpackingTool::cTauRoIsUnpackingTool
cTauRoIsUnpackingTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition: RoIsUnpackingToolPhase1.h:187
SG::WriteHandle< TrigRoiDescriptorCollection >
MuonRoIsUnpackingTool
Definition: RoIsUnpackingToolPhase1.h:215
RoiDescriptor::phi
virtual double phi() const override final
Methods to retrieve data members.
Definition: RoiDescriptor.h:100
jFexLRJetRoIsUnpackingTool::jFexLRJetRoIsUnpackingTool
jFexLRJetRoIsUnpackingTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition: RoIsUnpackingToolPhase1.h:199
RoIsUnpackingToolPhase1::unpack
virtual StatusCode unpack(const EventContext &ctx, const xAOD::TrigComposite &l1TriggerResult, const HLT::IDSet &activeChains) const override
Definition: RoIsUnpackingToolPhase1.h:63
TriggerTest.rois
rois
Definition: TriggerTest.py:23
jFexTauRoIsUnpackingTool
Definition: RoIsUnpackingToolPhase1.h:179
HLT::IDSet
std::set< HLT::Identifier > IDSet
Definition: TrigCompositeUtils/TrigCompositeUtils/HLTIdentifier.h:56
RoIsUnpackingToolBase::initialize
virtual StatusCode initialize() override
Definition: RoIsUnpackingToolBase.cxx:16
RoiDescriptor::eta
virtual double eta() const override final
Definition: RoiDescriptor.h:101
TrigCompositeUtils
Definition: Event/xAOD/xAODTrigger/xAODTrigger/TrigComposite.h:19
ReadDecorHandle.h
Handle class for reading a decoration on an object.
jFexSRJetRoIsUnpackingTool
Definition: RoIsUnpackingToolPhase1.h:191
HLTSeedingRoIToolDefs::eFexEM::T_RoIContainer
xAOD::eFexEMRoIContainer T_RoIContainer
Definition: HLTSeedingRoIToolDefs.h:41
egammaParameters::linkIndex
@ linkIndex
link index for multiple track and vertex matches
Definition: egammaParamDefs.h:574
jFexTauRoIsUnpackingTool::jFexTauRoIsUnpackingTool
jFexTauRoIsUnpackingTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition: RoIsUnpackingToolPhase1.h:181
RoIsUnpackingToolPhase1::m_roiHalfWidthEta
Gaudi::Property< float > m_roiHalfWidthEta
Definition: RoIsUnpackingToolPhase1.h:33
RoIsUnpackingToolPhase1
Definition: HLTSeedingRoIToolDefs.h:24
Monitored::Scalar
Declare a monitored scalar variable.
Definition: MonitoredScalar.h:34
SG::ReadDecorHandleKey< T_RoIContainer >
HLTSeedingNs
Definition: utilities.h:8
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
HLTSeedingRoIToolDefs
Definition: HLTSeedingRoIToolDefs.cxx:7
eFexTauRoIsUnpackingTool
Definition: RoIsUnpackingToolPhase1.h:167