ATLAS Offline Software
RoIsUnpackingToolPhase1.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 #ifndef HLTSEEDING_ROISUNPACKINGTOOLPHASE1_H
5 #define HLTSEEDING_ROISUNPACKINGTOOLPHASE1_H
6 
7 // Local includes
10 
11 // Athena includes
15 
20 template<typename T_RoI, typename T_RoIContainer, auto F_RoIWordGetter, const char* N_RoIContainer, const char* N_ThresholdType>
22 private:
23  Gaudi::Property<std::string> m_l1RoILinkName {
24  this, "L1RoILinkName", N_RoIContainer,
25  "Name of the link to read from L1TriggerResult for L1 xAOD RoI container"};
26 
28  this, "L1RoIThresholdPatternsKey", std::string(N_RoIContainer)+".thresholdPatterns",
29  "Name of the L1 xAOD RoI container decoration for the threshold patterns"};
30 
31  Gaudi::Property<float> m_roiHalfWidthEta{
32  this, "RoIHalfWidthEta", 0.1, "Size of RoI in eta"};
33 
34  Gaudi::Property<float> m_roiHalfWidthPhi{
35  this, "RoIHalfWidthPhi", 0.1, "Size of RoI in phi"};
36 
37 public:
38  // ===========================================================================
39  RoIsUnpackingToolPhase1(const std::string& type, const std::string& name, const IInterface* parent)
41 
42  // ===========================================================================
43  virtual StatusCode initialize() override {
45  ATH_CHECK(m_l1MenuKey.initialize());
46  ATH_CHECK(m_trigRoIsKey.initialize());
48  return StatusCode::SUCCESS;
49  }
50 
51  // ===========================================================================
52  virtual StatusCode start() override {
53  ATH_CHECK(decodeMapping([](const std::string& name){
54  return name.find(N_ThresholdType)==0 or name.find(getProbeThresholdName(N_ThresholdType))==0;
55  }));
56  return StatusCode::SUCCESS;
57  }
58 
59  // ===========================================================================
61  virtual StatusCode unpack(const EventContext& ctx,
62  const xAOD::TrigComposite& l1TriggerResult,
63  const HLT::IDSet& activeChains) const override {
64  using namespace TrigCompositeUtils;
65  const bool doProbe = !m_decisionsKeyProbe.empty();
66 
67  // Create and record RoI descriptor and decision containers
68  SG::WriteHandle<TrigRoiDescriptorCollection> roiDescriptors = createAndStoreNoAux(m_trigRoIsKey, ctx);
69  SG::WriteHandle<DecisionContainer> decisionsMain = createAndStore(m_decisionsKey, ctx);
71  if (doProbe) decisionsProbe = createAndStore(m_decisionsKeyProbe, ctx);
72 
73  // Retrieve the xAOD RoI container from L1TriggerResult
75  ATH_MSG_DEBUG("No " << N_ThresholdType << " RoIs in this event");
76  auto monRoIsCount = Monitored::Scalar("count", 0);
77  Monitored::Group(m_monTool, monRoIsCount);
78  return StatusCode::SUCCESS;
79  }
81  ATH_CHECK(roisLink.isValid());
82  const T_RoIContainer& rois = roisLink.getStorableObjectRef();
83 
84  // Create threshold patterns decoration accessor
85  auto thrPatternAcc = SG::makeHandle<uint64_t>(m_thresholdPatternsKey, ctx);
86  ATH_CHECK(thrPatternAcc.isPresent());
87 
88  // Retrieve the L1 menu configuration
89  SG::ReadHandle<TrigConf::L1Menu> l1Menu = SG::makeHandle(m_l1MenuKey, ctx);
90  ATH_CHECK(l1Menu.isValid());
91  std::optional<ThrVecRef> thresholds;
92  ATH_CHECK(getL1Thresholds(*l1Menu, N_ThresholdType, thresholds));
93 
94  size_t linkIndex{0};
95  for (const T_RoI* roi : rois) {
96  // Create new RoI descriptor
97  roiDescriptors->push_back(std::make_unique<TrigRoiDescriptor>(
98  static_cast<unsigned int>((roi->*F_RoIWordGetter)()), 0u, 0u,
99  roi->eta(), roi->eta()-m_roiHalfWidthEta, roi->eta()+m_roiHalfWidthEta,
100  roi->phi(), roi->phi()-m_roiHalfWidthPhi, roi->phi()+m_roiHalfWidthPhi
101  ));
102 
103  // Create new decision and link the RoI objects
104  Decision* decisionMain = TrigCompositeUtils::newDecisionIn(decisionsMain.ptr(), hltSeedingNodeName());
105  decisionMain->setObjectLink(initialRoIString(),
106  ElementLink<TrigRoiDescriptorCollection>(m_trigRoIsKey.key(), linkIndex, ctx));
107  decisionMain->setObjectLink(initialRecRoIString(),
109 
110  Decision* decisionProbe{nullptr};
111  if (doProbe) {
112  decisionProbe = TrigCompositeUtils::newDecisionIn(decisionsProbe.ptr(), hltSeedingNodeName());
113  decisionProbe->setObjectLink(initialRoIString(),
114  ElementLink<TrigRoiDescriptorCollection>(m_trigRoIsKey.key(), linkIndex, ctx));
115  decisionProbe->setObjectLink(initialRecRoIString(),
117  }
118 
119  std::vector<TrigCompositeUtils::DecisionID> passedThresholdIDs;
120 
121  // Add positive decisions for chains to be activated by this RoI object
122  uint64_t thresholdPattern = thrPatternAcc(*roi);
123  ATH_MSG_DEBUG("RoI #" << linkIndex << " threshold pattern: " << thresholdPattern);
124  for (const std::shared_ptr<TrigConf::L1Threshold>& thr : thresholds.value().get()) {
125  if ((thresholdPattern & (1 << thr->mapping())) == 0u) {continue;}
126  passedThresholdIDs.push_back(HLT::Identifier(thr->name()));
127  ATH_MSG_DEBUG("RoI #" << linkIndex << " passed threshold number " << thr->mapping()
128  << " name" << (doProbe ? "s " : " ") << thr->name()
129  << (doProbe ? " and "+getProbeThresholdName(thr->name()) : ""));
130  addChainsToDecision(HLT::Identifier(thr->name()), decisionMain, activeChains);
131  if (doProbe) addChainsToDecision(HLT::Identifier(getProbeThresholdName(thr->name())), decisionProbe, activeChains);
132  }
133 
134  decisionMain->setDetail("thresholds", passedThresholdIDs);
135  if (doProbe) decisionProbe->setDetail("thresholds", passedThresholdIDs);
136 
137  ++linkIndex;
138  }
139 
140  // Monitor the TrigRoiDescriptorCollection
141  {
142  auto monRoIsCount = Monitored::Scalar("count", roiDescriptors->size());
143  auto monRoIsEta = Monitored::Collection("eta", *roiDescriptors, &TrigRoiDescriptor::eta);
144  auto monRoIsPhi = Monitored::Collection("phi", *roiDescriptors, &TrigRoiDescriptor::phi);
145  Monitored::Group(m_monTool, monRoIsCount, monRoIsEta, monRoIsPhi);
146  }
147 
148  return StatusCode::SUCCESS;
149  }
150 
151 }; // class RoIsUnpackingToolPhase1
152 
153 
159 public:
160  eFexEMRoIsUnpackingTool(const std::string& type, const std::string& name, const IInterface* parent)
162 };
163 
165 public:
166  eFexTauRoIsUnpackingTool(const std::string& type, const std::string& name, const IInterface* parent)
168 };
169 
171  public:
172  jFexFwdElRoIsUnpackingTool(const std::string& type, const std::string& name, const IInterface* parent)
174 };
175 
177 public:
178  jFexTauRoIsUnpackingTool(const std::string& type, const std::string& name, const IInterface* parent)
180 };
181 
183 public:
184  cTauRoIsUnpackingTool(const std::string& type, const std::string& name, const IInterface* parent)
186 };
187 
189 public:
190  jFexSRJetRoIsUnpackingTool(const std::string& type, const std::string& name, const IInterface* parent)
192 };
193 
195 public:
196  jFexLRJetRoIsUnpackingTool(const std::string& type, const std::string& name, const IInterface* parent)
198 };
199 
201 public:
202  gFexSRJetRoIsUnpackingTool(const std::string& type, const std::string& name, const IInterface* parent)
204 };
205 
207 public:
208  gFexLRJetRoIsUnpackingTool(const std::string& type, const std::string& name, const IInterface* parent)
210 };
211 
213 public:
214  MuonRoIsUnpackingTool(const std::string& type, const std::string& name, const IInterface* parent)
216 };
218 
219 #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
TrigCompositeUtils::hltSeedingNodeName
const std::string & hltSeedingNodeName()
Definition: TrigCompositeUtilsRoot.cxx:894
gFexSRJetRoIsUnpackingTool
Definition: RoIsUnpackingToolPhase1.h:200
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:46
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
gFexLRJetRoIsUnpackingTool::gFexLRJetRoIsUnpackingTool
gFexLRJetRoIsUnpackingTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition: RoIsUnpackingToolPhase1.h:208
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:226
gFexSRJetRoIsUnpackingTool::gFexSRJetRoIsUnpackingTool
gFexSRJetRoIsUnpackingTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition: RoIsUnpackingToolPhase1.h:202
HLTSeedingRoIToolDefs::eFexEM::F_RoIWordGetter
constexpr auto F_RoIWordGetter
Definition: HLTSeedingRoIToolDefs.h:42
RoIsUnpackingToolPhase1::m_l1RoILinkName
Gaudi::Property< std::string > m_l1RoILinkName
Definition: RoIsUnpackingToolPhase1.h:23
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:30
RoIsUnpackingToolPhase1::m_thresholdPatternsKey
SG::ReadDecorHandleKey< T_RoIContainer > m_thresholdPatternsKey
Definition: RoIsUnpackingToolPhase1.h:27
TrigCompositeUtils::initialRecRoIString
const std::string & initialRecRoIString()
Definition: TrigCompositeUtilsRoot.cxx:874
Muon
This class provides conversion from CSC RDO data to CSC Digits.
Definition: TrackSystemController.h:49
jFexFwdElRoIsUnpackingTool::jFexFwdElRoIsUnpackingTool
jFexFwdElRoIsUnpackingTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition: RoIsUnpackingToolPhase1.h:172
Trk::u
@ u
Enums for curvilinear frames.
Definition: ParamDefs.h:83
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:270
MuonRoIsUnpackingTool::MuonRoIsUnpackingTool
MuonRoIsUnpackingTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition: RoIsUnpackingToolPhase1.h:214
jFexLRJetRoIsUnpackingTool
Definition: RoIsUnpackingToolPhase1.h:194
RoIsUnpackingToolBase::unpack
virtual StatusCode unpack(const EventContext &, const ROIB::RoIBResult &, const HLT::IDSet &) const override
Definition: RoIsUnpackingToolBase.h:40
eFexTauRoIsUnpackingTool::eFexTauRoIsUnpackingTool
eFexTauRoIsUnpackingTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition: RoIsUnpackingToolPhase1.h:166
RoIsUnpackingToolPhase1::initialize
virtual StatusCode initialize() override
Definition: RoIsUnpackingToolPhase1.h:43
eFexEMRoIsUnpackingTool
Definition: RoIsUnpackingToolPhase1.h:158
xAOD::TrigComposite_v1::setObjectLink
bool setObjectLink(const std::string &name, const ElementLink< CONTAINER > &link)
Set the link to an object.
TrigCompositeUtils::initialRoIString
const std::string & initialRoIString()
Definition: TrigCompositeUtilsRoot.cxx:870
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:40
HLTSeedingRoIToolDefs::eFexEM::UnpackingBaseClass
RoIsUnpackingToolPhase1< T_RoI, T_RoIContainer, F_RoIWordGetter, ContainerName, ThresholdType > UnpackingBaseClass
Definition: HLTSeedingRoIToolDefs.h:44
jFexFwdElRoIsUnpackingTool
Definition: RoIsUnpackingToolPhase1.h:170
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:39
xAOD::uint64_t
uint64_t
Definition: EventInfo_v1.cxx:123
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
TrigCompositeUtils::createAndStoreNoAux
SG::WriteHandle< CONT > createAndStoreNoAux(const SG::WriteHandleKey< CONT > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Creates and right away records the Container CONT with the key.
xAOD::TrigComposite_v1
Class used to describe composite objects in the HLT.
Definition: TrigComposite_v1.h:52
RoIsUnpackingToolPhase1::start
virtual StatusCode start() override
Definition: RoIsUnpackingToolPhase1.h:52
HLT::Identifier
Definition: TrigCompositeUtils/TrigCompositeUtils/HLTIdentifier.h:20
jFexSRJetRoIsUnpackingTool::jFexSRJetRoIsUnpackingTool
jFexSRJetRoIsUnpackingTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition: RoIsUnpackingToolPhase1.h:190
Monitored.h
Header file to be included by clients of the Monitored infrastructure.
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
RoIsUnpackingToolPhase1::m_roiHalfWidthPhi
Gaudi::Property< float > m_roiHalfWidthPhi
Definition: RoIsUnpackingToolPhase1.h:34
gFexLRJetRoIsUnpackingTool
Definition: RoIsUnpackingToolPhase1.h:206
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
eFexEMRoIsUnpackingTool::eFexEMRoIsUnpackingTool
eFexEMRoIsUnpackingTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition: RoIsUnpackingToolPhase1.h:160
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:182
cTauRoIsUnpackingTool::cTauRoIsUnpackingTool
cTauRoIsUnpackingTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition: RoIsUnpackingToolPhase1.h:184
SG::WriteHandle< TrigRoiDescriptorCollection >
MuonRoIsUnpackingTool
Definition: RoIsUnpackingToolPhase1.h:212
RoiDescriptor::phi
virtual double phi() const override final
Methods to retrieve data members.
Definition: RoiDescriptor.h:100
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
jFexLRJetRoIsUnpackingTool::jFexLRJetRoIsUnpackingTool
jFexLRJetRoIsUnpackingTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition: RoIsUnpackingToolPhase1.h:196
RoIsUnpackingToolPhase1::unpack
virtual StatusCode unpack(const EventContext &ctx, const xAOD::TrigComposite &l1TriggerResult, const HLT::IDSet &activeChains) const override
Definition: RoIsUnpackingToolPhase1.h:61
TriggerTest.rois
rois
Definition: TriggerTest.py:23
jFexTauRoIsUnpackingTool
Definition: RoIsUnpackingToolPhase1.h:176
HLT::IDSet
std::set< HLT::Identifier > IDSet
Definition: TrigCompositeUtils/TrigCompositeUtils/HLTIdentifier.h:63
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:188
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:178
RoIsUnpackingToolPhase1::m_roiHalfWidthEta
Gaudi::Property< float > m_roiHalfWidthEta
Definition: RoIsUnpackingToolPhase1.h:31
RoIsUnpackingToolPhase1
Definition: HLTSeedingRoIToolDefs.h:24
Monitored::Scalar
Declare a monitored scalar variable.
Definition: MonitoredScalar.h:34
SG::ReadDecorHandleKey< T_RoIContainer >
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
HLTSeedingRoIToolDefs
Definition: HLTSeedingRoIToolDefs.cxx:7
eFexTauRoIsUnpackingTool
Definition: RoIsUnpackingToolPhase1.h:164