ATLAS Offline Software
Loading...
Searching...
No Matches
EMRoIsUnpackingTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4// HLTSeeding includes
9
10
12 const std::string& name,
13 const IInterface* parent )
14 : RoIsUnpackingToolBase(type, name, parent) {}
15
16
19 ATH_CHECK( m_recRoIsKey.initialize() );
20 return StatusCode::SUCCESS;
21}
22
23
25 ATH_CHECK(decodeMapping([](const std::string& name){
26 return name.find("EM") == 0 or name.find(getProbeThresholdName("EM")) == 0;
27 }));
28 return StatusCode::SUCCESS;
29}
30
31
32StatusCode EMRoIsUnpackingTool::unpack(const EventContext& ctx,
33 const ROIB::RoIBResult& roib,
34 const HLT::IDSet& activeChains) const {
35 using namespace TrigCompositeUtils;
36
37 // create and record the collections needed
42
43 // Retrieve the L1 menu configuration
45 ATH_CHECK(l1Menu.isValid());
46 std::optional<ThrVecRef> emThresholds;
47 ATH_CHECK(getL1Thresholds(*l1Menu, "EM", emThresholds));
48
49 // Flag if there was an overflow in the TOB transmission to CMX (there were more TOBs than can be transferred)
50 bool overflow{false};
51 constexpr static unsigned int s_maxEmTOBs{5}; // Hardcoded in L1Calo firmware, see ATR-23697 and ATR-12285
52 std::unordered_map<unsigned int, std::unordered_map<unsigned int, unsigned int>> tobCounts; // {crate, {module, count}}
53
54 // RoIBResult contains vector of EM fragments
55 for ( const auto & emTauFragment : roib.eMTauResult() ) {
56 for ( const auto & roi : emTauFragment.roIVec() ) {
57 uint32_t roIWord = roi.roIWord();
58 if ( not ( LVL1::TrigT1CaloDefs::EMRoIWordType == roi.roIType() ) ) {
59 ATH_MSG_DEBUG( "Skipping RoI as it is not EM threshold " << roIWord );
60 continue;
61 }
62
63 if (!overflow) {
64 unsigned int crate = m_cpDecoder.crate(roIWord);
65 unsigned int module = m_cpDecoder.module(roIWord);
66 overflow = (++tobCounts[crate][module] > s_maxEmTOBs);
67 }
68
69 recRoIs->push_back( std::make_unique<LVL1::RecEmTauRoI>(roIWord, l1Menu.cptr()) );
70 const LVL1::RecEmTauRoI* recRoI = recRoIs->back();
71
72 trigRoIs->push_back( std::make_unique<TrigRoiDescriptor>(
73 roIWord, 0u ,0u,
74 recRoI->eta(), recRoI->eta()-m_roIWidth, recRoI->eta()+m_roIWidth,
75 recRoI->phi(), recRoI->phi()-m_roIWidth, recRoI->phi()+m_roIWidth) );
76
77 ATH_MSG_DEBUG( "RoI word: 0x" << MSG::hex << std::setw( 8 ) << roIWord << MSG::dec );
78
79 // The hltSeedingNodeName denotes an initial node with no parents
80 Decision* decisionMain = TrigCompositeUtils::newDecisionIn( decisionOutput.ptr(), hltSeedingNodeName() );
81 Decision* decisionProbe = TrigCompositeUtils::newDecisionIn( decisionOutputProbe.ptr(), hltSeedingNodeName() );
82
83 std::vector<TrigCompositeUtils::DecisionID> passedThresholdIDs;
84
85 for (const auto& th : emThresholds.value().get()) {
86 ATH_MSG_VERBOSE( "Checking if the threshold " << th->name() << " passed" );
87 if ( recRoI->passedThreshold( th->mapping() ) ) {
88 passedThresholdIDs.push_back( HLT::Identifier( th->name() ) );
89 const std::string thresholdProbeName = getProbeThresholdName(th->name());
90 ATH_MSG_DEBUG( "Passed Threshold names " << th->name() << " and " << thresholdProbeName);
91 addChainsToDecision( HLT::Identifier( th->name() ), decisionMain, activeChains );
92 addChainsToDecision( HLT::Identifier( thresholdProbeName ), decisionProbe, activeChains );
93 }
94 }
95
96 decisionMain->setDetail( "thresholds", passedThresholdIDs );
97 decisionMain->setObjectLink( initialRoIString(),
98 ElementLink<TrigRoiDescriptorCollection>(m_trigRoIsKey.key(), trigRoIs->size()-1, ctx) );
99 decisionMain->setObjectLink( initialRecRoIString(),
100 ElementLink<DataVector<LVL1::RecEmTauRoI>>(m_recRoIsKey.key(), recRoIs->size()-1, ctx) );
101
102 decisionProbe->setDetail( "thresholds", passedThresholdIDs );
103 decisionProbe->setObjectLink( initialRoIString(),
104 ElementLink<TrigRoiDescriptorCollection>(m_trigRoIsKey.key(), trigRoIs->size()-1, ctx) );
105 decisionProbe->setObjectLink( initialRecRoIString(),
106 ElementLink<DataVector<LVL1::RecEmTauRoI>>(m_recRoIsKey.key(), recRoIs->size()-1, ctx) );
107 }
108 }
109
110 // Decorate the decisions with overflow information
111 if (overflow) {
112 ATH_MSG_WARNING("L1Calo overflow for EM TOBs to CMX detected");
113 }
114 for (Decision* decision : *decisionOutput) {
115 decision->setDetail("overflow", static_cast<char>(overflow));
116 }
117
118 for ( auto roi: *trigRoIs ) {
119 ATH_MSG_DEBUG( "RoI Eta: " << roi->eta() << " Phi: " << roi->phi() << " RoIWord: " << roi->roiWord() );
120 }
121
122 // monitoring
123 {
124 auto RoIsCount = Monitored::Scalar( "count", trigRoIs->size() );
125 auto RoIsPhi = Monitored::Collection( "phi", *trigRoIs, &TrigRoiDescriptor::phi );
126 auto RoIsEta = Monitored::Collection( "eta", *trigRoIs, &TrigRoiDescriptor::eta );
127 Monitored::Group( m_monTool, RoIsCount, RoIsEta, RoIsPhi );
128 }
129
130 ATH_MSG_DEBUG( "Unpacked " << trigRoIs->size() << " RoIs" );
131
132 return StatusCode::SUCCESS;
133}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
#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.
Derived DataVector<T>.
Definition DataVector.h:795
SG::WriteHandleKey< DataVector< LVL1::RecEmTauRoI > > m_recRoIsKey
virtual StatusCode initialize() override
virtual StatusCode start() override
EMRoIsUnpackingTool(const std::string &type, const std::string &name, const IInterface *parent)
LVL1::CPRoIDecoder m_cpDecoder
Gaudi::Property< float > m_roIWidth
StatusCode unpack(const EventContext &ctx, const ROIB::RoIBResult &roib, const HLT::IDSet &activeChains) const override
virtual double eta() const =0
virtual double phi() const =0
Methods to retrieve data members.
This class defines the reconstructed em/tau hadron ROI.
Definition RecEmTauRoI.h:44
virtual double eta() const
returns eta coord of ROI
bool passedThreshold(unsigned int threshold_number) const
returns TRUE if threshold number threshold_number has been passed by this ROI.
virtual double phi() const
returns phi coord of ROI
Group of local monitoring quantities and retain correlation when filling histograms
Declare a monitored scalar variable.
Class holding the LVL1 RoIB result build by the RoIBuilder.
Definition RoIBResult.h:47
const std::vector< EMTauResult > & eMTauResult() const
Gets the egamma part of the L1 RDO.
SG::WriteHandleKey< TrigCompositeUtils::DecisionContainer > m_decisionsKey
RoIsUnpackingToolBase(const std::string &type, const std::string &name, const IInterface *parent)
ToolHandle< GenericMonitoringTool > m_monTool
SG::ReadHandleKey< TrigConf::L1Menu > m_l1MenuKey
void addChainsToDecision(HLT::Identifier thresholdId, TrigCompositeUtils::Decision *d, const HLT::IDSet &activeChains) const
SG::WriteHandleKey< TrigCompositeUtils::DecisionContainer > m_decisionsKeyProbe
virtual StatusCode initialize() override
SG::WriteHandleKey< TrigRoiDescriptorCollection > m_trigRoIsKey
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 bool isValid() override final
Can the handle be successfully dereferenced?
const_pointer_type cptr()
Dereference the pointer.
pointer_type ptr()
Dereference the pointer.
bool setObjectLink(const std::string &name, const ElementLink< CONTAINER > &link)
Set the link to an object.
bool setDetail(const std::string &name, const TYPE &value)
Set an TYPE detail on the object.
std::set< HLT::Identifier > IDSet
ValuesCollection< T > Collection(std::string name, const T &collection)
Declare a monitored (double-convertible) collection.
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()