ATLAS Offline Software
Loading...
Searching...
No Matches
TAURoIsUnpackingTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
8
9
11 const std::string& name,
12 const IInterface* parent)
13 : RoIsUnpackingToolBase(type, name, parent) {}
14
15
18 ATH_CHECK( m_recRoIsKey.initialize() );
19 return StatusCode::SUCCESS;
20}
21
22
24 ATH_CHECK(decodeMapping([](const std::string& name ){
25 return name.find("TAU") == 0 or name.find(getProbeThresholdName("TAU")) == 0;
26 }));
27 // For Taus, since there is threshold name change from HA to TAU we need to fill the mapping with same threshold
28 // but prefixed by HA
29 // TODO: Remove once L1 configuration switches to TAU
30 for ( const auto& [threshold, chains] : m_thresholdToChainMapping ) {
31 if ( threshold.name().find("TAU") != std::string::npos ) {
32 std::string newThresholdName = threshold.name();
33 newThresholdName.replace(threshold.name().find("TAU"), 3, "HA");
34 ATH_MSG_INFO("Temporary fix due to renaming the HA to TAU thresholds, adding decoding of " << newThresholdName );
35 m_thresholdToChainMapping[HLT::Identifier(newThresholdName)] = chains;
36 }
37 }
38
39 return StatusCode::SUCCESS;
40}
41
42
43StatusCode TAURoIsUnpackingTool::unpack(const EventContext& ctx,
44 const ROIB::RoIBResult& roib,
45 const HLT::IDSet& activeChains) const {
46 using namespace TrigCompositeUtils;
47
48 // create and record the collections needed
53
54 // Retrieve the L1 menu configuration
56 ATH_CHECK(l1Menu.isValid());
57 std::optional<ThrVecRef> tauThresholds;
58 ATH_CHECK(getL1Thresholds(*l1Menu, "TAU", tauThresholds));
59
60 // Flag if there was an overflow in the TOB transmission to CMX (there were more TOBs than can be transferred)
61 bool overflow{false};
62 constexpr static unsigned int s_maxTauTOBs{5}; // Hardcoded in L1Calo firmware, see ATR-23697 and ATR-12285
63 std::unordered_map<unsigned int, std::unordered_map<unsigned int, unsigned int>> tobCounts; // {crate, {module, count}}
64
65 // RoIBResult contains vector of TAU fragments
66 for ( const auto & emTauFragment : roib.eMTauResult() ) {
67 for ( const auto & roi : emTauFragment.roIVec() ) {
68 uint32_t roIWord = roi.roIWord();
69 if ( not ( LVL1::TrigT1CaloDefs::TauRoIWordType == roi.roIType() ) ) {
70 ATH_MSG_DEBUG( "Skipping RoI as it is not TAU threshold " << roIWord );
71 continue;
72 }
73
74 if (!overflow) {
75 unsigned int crate = m_cpDecoder.crate(roIWord);
76 unsigned int module = m_cpDecoder.module(roIWord);
77 overflow = (++tobCounts[crate][module] > s_maxTauTOBs);
78 }
79
80 recRoIs->push_back( std::make_unique<LVL1::RecEmTauRoI>(roIWord, l1Menu.cptr()) );
81 const LVL1::RecEmTauRoI* recRoI = recRoIs->back();
82
83 trigRoIs->push_back( std::make_unique<TrigRoiDescriptor>(
84 roIWord, 0u ,0u,
85 recRoI->eta(), recRoI->eta()-m_roIWidthEta, recRoI->eta()+m_roIWidthEta,
86 recRoI->phi(), recRoI->phi()-m_roIWidthPhi, recRoI->phi()+m_roIWidthPhi) );
87
88 ATH_MSG_DEBUG( "RoI word: 0x" << MSG::hex << std::setw( 8 ) << roIWord << MSG::dec );
89
90 // The hltSeedingNodeName() denotes an initial node with no parents
91 Decision* decisionMain = TrigCompositeUtils::newDecisionIn( decisionOutput.ptr(), hltSeedingNodeName() );
92 Decision* decisionProbe = TrigCompositeUtils::newDecisionIn( decisionOutputProbe.ptr(), hltSeedingNodeName() );
93
94 std::vector<TrigCompositeUtils::DecisionID> passedThresholdIDs;
95
96 for (const auto& th : tauThresholds.value().get()) {
97 ATH_MSG_VERBOSE( "Checking if the threshold " << th->name() << " passed" );
98 if ( recRoI->passedThreshold( th->mapping() ) ) {
99 passedThresholdIDs.push_back(HLT::Identifier(th->name()));
100 const std::string thresholdProbeName = getProbeThresholdName(th->name());
101 ATH_MSG_DEBUG( "Passed Threshold names " << th->name() << " and " << thresholdProbeName);
102 addChainsToDecision( HLT::Identifier( th->name() ), decisionMain, activeChains );
103 addChainsToDecision( HLT::Identifier( thresholdProbeName ), decisionProbe, activeChains );
104 }
105 }
106
107 decisionMain->setDetail("thresholds", passedThresholdIDs);
108 decisionMain->setObjectLink( initialRoIString(),
109 ElementLink<TrigRoiDescriptorCollection>(m_trigRoIsKey.key(), trigRoIs->size()-1, ctx) );
110 decisionMain->setObjectLink( initialRecRoIString(),
111 ElementLink<DataVector<LVL1::RecEmTauRoI>>(m_recRoIsKey.key(), recRoIs->size()-1, ctx) );
112
113 decisionProbe->setDetail("thresholds", passedThresholdIDs);
114 decisionProbe->setObjectLink( initialRoIString(),
115 ElementLink<TrigRoiDescriptorCollection>(m_trigRoIsKey.key(), trigRoIs->size()-1, ctx) );
116 decisionProbe->setObjectLink( initialRecRoIString(),
117 ElementLink<DataVector<LVL1::RecEmTauRoI>>(m_recRoIsKey.key(), recRoIs->size()-1, ctx) );
118 }
119 }
120
121 // Decorate the decisions with overflow information
122 if (overflow) {
123 ATH_MSG_WARNING("L1Calo overflow for TAU TOBs to CMX detected");
124 }
125 for (Decision* decision : *decisionOutput) {
126 decision->setDetail("overflow", static_cast<char>(overflow));
127 }
128
129 for ( auto roi: *trigRoIs ) {
130 ATH_MSG_DEBUG( "RoI Eta: " << roi->eta() << " Phi: " << roi->phi() << " RoIWord: " << roi->roiWord() );
131 }
132
133 // monitoring
134 {
135 auto RoIsCount = Monitored::Scalar( "count", trigRoIs->size() );
136 auto RoIsPhi = Monitored::Collection( "phi", *trigRoIs, &TrigRoiDescriptor::phi );
137 auto RoIsEta = Monitored::Collection( "eta", *trigRoIs, &TrigRoiDescriptor::eta );
138 Monitored::Group( m_monTool, RoIsCount, RoIsEta, RoIsPhi );
139 }
140
141 ATH_MSG_DEBUG( "Unpacked " << trigRoIs->size() << " RoIs" );
142
143 return StatusCode::SUCCESS;
144}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_INFO(x)
#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
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.
std::map< HLT::Identifier, HLT::IDVec > m_thresholdToChainMapping
virtual bool isValid() override final
Can the handle be successfully dereferenced?
const_pointer_type cptr()
Dereference the pointer.
pointer_type ptr()
Dereference the pointer.
StatusCode unpack(const EventContext &ctx, const ROIB::RoIBResult &roib, const HLT::IDSet &activeChains) const override
Gaudi::Property< float > m_roIWidthPhi
virtual StatusCode start() override
LVL1::CPRoIDecoder m_cpDecoder
Gaudi::Property< float > m_roIWidthEta
TAURoIsUnpackingTool(const std::string &type, const std::string &name, const IInterface *parent)
SG::WriteHandleKey< DataVector< LVL1::RecEmTauRoI > > m_recRoIsKey
virtual StatusCode initialize() override
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()