ATLAS Offline Software
Loading...
Searching...
No Matches
JRoIsUnpackingTool Class Reference

#include <JRoIsUnpackingTool.h>

Inheritance diagram for JRoIsUnpackingTool:
Collaboration diagram for JRoIsUnpackingTool:

Public Member Functions

 JRoIsUnpackingTool (const std::string &type, const std::string &name, const IInterface *parent)
StatusCode unpack (const EventContext &ctx, const ROIB::RoIBResult &roib, const HLT::IDSet &activeChains) const override
virtual StatusCode initialize () override
virtual StatusCode start () override
virtual StatusCode unpack (const EventContext &, const xAOD::TrigComposite &, const HLT::IDSet &) const override

Protected Types

using ThrVec = std::vector<std::shared_ptr<TrigConf::L1Threshold>>
using ThrVecRef = std::reference_wrapper<const ThrVec>

Protected Member Functions

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.
void addChainsToDecision (HLT::Identifier thresholdId, TrigCompositeUtils::Decision *d, const HLT::IDSet &activeChains) const

Static Protected Member Functions

static std::string getProbeThresholdName (const std::string &thresholdName)
 Concatenate the probe identifier string with the threshold name string.

Protected Attributes

ToolHandle< GenericMonitoringToolm_monTool { this, "MonTool", "", "Monitoring tool" }
ToolHandle< IRoiUpdaterToolm_roiupdater { this, "RoiUpdater", "", "Roi Updater" }
std::map< HLT::Identifier, HLT::IDVecm_thresholdToChainMapping
std::map< HLT::Identifier, HLT::Identifierm_legToChainMapping
Data dependencies
SG::WriteHandleKey< TrigCompositeUtils::DecisionContainerm_decisionsKey
SG::WriteHandleKey< TrigCompositeUtils::DecisionContainerm_decisionsKeyProbe
SG::WriteHandleKey< TrigRoiDescriptorCollectionm_trigRoIsKey
SG::ReadHandleKey< TrigConf::L1Menum_l1MenuKey
SG::ReadHandleKey< TrigConf::HLTMenum_HLTMenuKey

Private Attributes

SG::WriteHandleKey< DataVector< LVL1::RecJetRoI > > m_recRoIsKey
Gaudi::Property< float > m_roIWidth
Gaudi::Property< std::string > m_fsRoIKey
LVL1::JEPRoIDecoder m_jepDecoder

Detailed Description

Definition at line 13 of file JRoIsUnpackingTool.h.

Member Typedef Documentation

◆ ThrVec

using RoIsUnpackingToolBase::ThrVec = std::vector<std::shared_ptr<TrigConf::L1Threshold>>
protectedinherited

Definition at line 73 of file RoIsUnpackingToolBase.h.

◆ ThrVecRef

using RoIsUnpackingToolBase::ThrVecRef = std::reference_wrapper<const ThrVec>
protectedinherited

Definition at line 74 of file RoIsUnpackingToolBase.h.

Constructor & Destructor Documentation

◆ JRoIsUnpackingTool()

JRoIsUnpackingTool::JRoIsUnpackingTool ( const std::string & type,
const std::string & name,
const IInterface * parent )

Definition at line 11 of file JRoIsUnpackingTool.cxx.

14 : RoIsUnpackingToolBase(type, name, parent) {}
RoIsUnpackingToolBase(const std::string &type, const std::string &name, const IInterface *parent)

Member Function Documentation

◆ addChainsToDecision()

void RoIsUnpackingToolBase::addChainsToDecision ( HLT::Identifier thresholdId,
TrigCompositeUtils::Decision * d,
const HLT::IDSet & activeChains ) const
protectedinherited

Definition at line 88 of file RoIsUnpackingToolBase.cxx.

90 {
91 auto chains = m_thresholdToChainMapping.find( thresholdId );
92 if ( chains == m_thresholdToChainMapping.end() ) {
93 ATH_MSG_DEBUG("Threshold not known " << thresholdId);
94 return;
95 }
96
98 for ( auto chainId: chains->second ) {
99 if ( activeChains.find(chainId) != activeChains.end() ) {
100 ids.insert( chainId.numeric() );
101 ATH_MSG_DEBUG( "Added " << chainId << " to the RoI/threshold decision " << thresholdId );
102 } else { // maybe it is a leg?
103 auto legIterator = m_legToChainMapping.find( chainId );
104 if ( legIterator != m_legToChainMapping.end() ) {
105 // this is a leg we care about, need to check if respective chain was active, and activate
106 if ( activeChains.find( legIterator->second ) != activeChains.end() ) {
107 ids.insert( chainId.numeric() );
108 ATH_MSG_DEBUG( "Added " << chainId << " to the RoI/threshold decision " << thresholdId );
109 }
110 }
111 }
112 }
114 ATH_MSG_DEBUG( "Number of decisions in this RoI after adding chains using threshold " << thresholdId
115 << " " << TrigCompositeUtils::decisionIDs( d ).size() );
116}
#define ATH_MSG_DEBUG(x)
std::map< HLT::Identifier, HLT::Identifier > m_legToChainMapping
std::map< HLT::Identifier, HLT::IDVec > m_thresholdToChainMapping
void insertDecisionIDs(const Decision *src, Decision *dest)
Appends the decision IDs of src to the dest decision object.
std::set< DecisionID > DecisionIDContainer
void decisionIDs(const Decision *d, DecisionIDContainer &destination)
Extracts DecisionIDs stored in the Decision object.

◆ decodeMapping()

StatusCode RoIsUnpackingToolBase::decodeMapping ( std::function< bool(const std::string &)> && filter)
protectedinherited

Fills mapping from L1 threshold -> to HLT chain.

  • filter Function that, using the threshold name, defines if this decoder instance should take care of this threshold

Definition at line 52 of file RoIsUnpackingToolBase.cxx.

52 {
53 SG::ReadHandle<TrigConf::HLTMenu> hltMenuHandle = SG::makeHandle( m_HLTMenuKey );
54 ATH_CHECK( hltMenuHandle.isValid() );
55 // Cleanup in case there was a stop/start transition
57
58 for ( const TrigConf::Chain& chain: *hltMenuHandle ) {
59 const HLT::Identifier chainIdentifier(chain.name());
60 const std::vector<std::string> thresholds{ chain.l1thresholds() };
61 const std::vector<size_t> legMultiplicities{ chain.legMultiplicities() };
62 if (thresholds.size() != legMultiplicities.size()) {
63 ATH_MSG_ERROR("Encountered a chain " << chain.name() << " with " << legMultiplicities.size()
64 << " legs but only " << thresholds.size() << " thresholds. These should be the same.");
65 return StatusCode::FAILURE;
66 }
67 size_t counter = 0;
68 for ( const std::string& th: thresholds ) {
69 if ( filter(th) ) {
70 const HLT::Identifier thresholdIdentifier(th);
71 m_thresholdToChainMapping[ thresholdIdentifier ].push_back( chainIdentifier );
72 ATH_MSG_DEBUG( "Associating " << chainIdentifier << " with threshold " << th );
73 if ( thresholds.size() > 1 ) {
74 HLT::Identifier legIdentifier = TrigCompositeUtils::createLegName(chainIdentifier, counter);
75 m_thresholdToChainMapping[ thresholdIdentifier ].push_back( legIdentifier );
76 m_legToChainMapping.insert( std::make_pair( legIdentifier, chainIdentifier ) );
77 ATH_MSG_DEBUG( "Associating additional chain leg " << legIdentifier
78 << " with threshold " << thresholdIdentifier );
79 }
80 }
81 ++counter;
82 }
83 }
84 return StatusCode::SUCCESS;
85}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
SG::ReadHandleKey< TrigConf::HLTMenu > m_HLTMenuKey
virtual bool isValid() override final
Can the handle be successfully dereferenced?
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
HLT::Identifier createLegName(const HLT::Identifier &chainIdentifier, size_t counter)
Generate the HLT::Identifier which corresponds to a specific leg of a given chain.

◆ getL1Thresholds()

StatusCode RoIsUnpackingToolBase::getL1Thresholds ( const TrigConf::L1Menu & l1Menu,
const std::string & thrType,
std::optional< ThrVecRef > & thrVec ) const
protectedinherited

Retrieve a vector of thresholds with type thrType from L1Menu.

Parameters
[in]l1MenuThe L1Menu object
[in]thrTypeThe threshold type, e.g. EM, MU, eTAU
[out]thrVecThe output will be passed into this parameter
Returns
FAILURE on exception reading the menu (e.g. thrType not in menu), SUCCESS otherwise

Definition at line 33 of file RoIsUnpackingToolBase.cxx.

35 {
36 try {
37 thrVec = ThrVecRef(l1Menu.thresholds(thrType));
38 }
39 catch (const std::exception& ex) {
40 ATH_MSG_ERROR("Failed to retrieve " << thrType << " thresholds from L1 menu. Exception:" << ex.what());
41 return StatusCode::FAILURE;
42 }
43 return StatusCode::SUCCESS;
44}
std::reference_wrapper< const ThrVec > ThrVecRef
std::vector< std::shared_ptr< TrigConf::L1Threshold > > thresholds() const
Access to list of all L1Thresholds.
Definition L1Menu.cxx:267

◆ getProbeThresholdName()

std::string RoIsUnpackingToolBase::getProbeThresholdName ( const std::string & thresholdName)
staticprotectedinherited

Concatenate the probe identifier string with the threshold name string.

Creates an alternate threshold name, used by lower pT probe legs of tag+probe chains.

Definition at line 47 of file RoIsUnpackingToolBase.cxx.

47 {
48 return "PROBE" + thresholdName;
49}

◆ initialize()

StatusCode JRoIsUnpackingTool::initialize ( )
overridevirtual

Reimplemented from RoIsUnpackingToolBase.

Definition at line 17 of file JRoIsUnpackingTool.cxx.

17 {
19 ATH_CHECK( m_recRoIsKey.initialize() );
20
21 return StatusCode::SUCCESS;
22}
SG::WriteHandleKey< DataVector< LVL1::RecJetRoI > > m_recRoIsKey
virtual StatusCode initialize() override

◆ start()

StatusCode JRoIsUnpackingTool::start ( )
overridevirtual

Definition at line 25 of file JRoIsUnpackingTool.cxx.

25 {
26 ATH_CHECK(decodeMapping([](const std::string& name){
27 return name.find('J') == 0 or name.find("JF") == 0 or name.find("JB") == 0;
28 }));
29 return StatusCode::SUCCESS;
30}
StatusCode decodeMapping(std::function< bool(const std::string &)> &&filter)
Fills mapping from L1 threshold -> to HLT chain.

◆ unpack() [1/2]

virtual StatusCode RoIsUnpackingToolBase::unpack ( const EventContext & ,
const xAOD::TrigComposite & ,
const HLT::IDSet &  ) const
inlineoverridevirtual

Reimplemented from RoIsUnpackingToolBase.

Definition at line 44 of file RoIsUnpackingToolBase.h.

46 { return StatusCode::SUCCESS; }

◆ unpack() [2/2]

StatusCode JRoIsUnpackingTool::unpack ( const EventContext & ctx,
const ROIB::RoIBResult & roib,
const HLT::IDSet & activeChains ) const
overridevirtual

Reimplemented from RoIsUnpackingToolBase.

Definition at line 33 of file JRoIsUnpackingTool.cxx.

35 {
36 using namespace TrigCompositeUtils;
37 // create and record the collections needed
38 SG::WriteHandle<TrigRoiDescriptorCollection> trigRoIs = createAndStoreNoAux(m_trigRoIsKey, ctx );
39 SG::WriteHandle< DataVector<LVL1::RecJetRoI> > recRoIs = createAndStoreNoAux( m_recRoIsKey, ctx );
40 SG::WriteHandle<DecisionContainer> decisionOutput = createAndStore(m_decisionsKey, ctx );
41
42 // Retrieve the L1 menu configuration
43 SG::ReadHandle<TrigConf::L1Menu> l1Menu = SG::makeHandle(m_l1MenuKey, ctx);
44 ATH_CHECK(l1Menu.isValid());
45 std::optional<ThrVecRef> jetThresholds;
46 ATH_CHECK(getL1Thresholds(*l1Menu, "JET", jetThresholds));
47
48 // Flag if there was an overflow in the TOB transmission to CMX (there were more TOBs than can be transferred)
49 bool overflow{false};
50 constexpr static unsigned int s_maxJetTOBs{4}; // Hardcoded in L1Calo firmware, see ATR-23697 and ATR-12285
51 std::unordered_map<unsigned int, std::unordered_map<unsigned int, unsigned int>> tobCounts; // {crate, {module, count}}
52
53 // RoIBResult contains vector of jet fragments
54 for ( const auto & jetFragment : roib.jetEnergyResult() ) {
55 for ( const auto & roi : jetFragment.roIVec() ) {
56 uint32_t roIWord = roi.roIWord();
57 if ( not ( LVL1::TrigT1CaloDefs::JetRoIWordType == roi.roIType() ) ) {
58 ATH_MSG_DEBUG( "Skipping RoI as it is not JET threshold " << roIWord <<" Type "<< roi.roIType() );
59 continue;
60 }
61
62 if (!overflow) {
63 unsigned int crate = m_jepDecoder.crate(roIWord);
64 unsigned int module = m_jepDecoder.module(roIWord);
65 overflow = (++tobCounts[crate][module] > s_maxJetTOBs);
66 }
67
68 recRoIs->push_back( std::make_unique<LVL1::RecJetRoI>(roIWord, l1Menu.cptr()) );
69 const LVL1::RecJetRoI* recRoI = recRoIs->back();
70
71 trigRoIs->push_back( std::make_unique<TrigRoiDescriptor>(
72 roIWord, 0u ,0u,
73 recRoI->eta(), recRoI->eta()-m_roIWidth, recRoI->eta()+m_roIWidth,
74 recRoI->phi(), recRoI->phi()-m_roIWidth, recRoI->phi()+m_roIWidth) );
75
76 ATH_MSG_DEBUG( "RoI word: 0x" << MSG::hex << std::setw( 8 ) << roIWord << MSG::dec );
77
78 // The hltSeedingNodeName denotes an initial node with no parents
79 Decision* decision = TrigCompositeUtils::newDecisionIn( decisionOutput.ptr(), hltSeedingNodeName() );
80
81 std::vector<unsigned> passedThresholdIDs;
82
83 for (const auto& th : jetThresholds.value().get()) {
84 ATH_MSG_VERBOSE( "Checking if the threshold " << th->name() << " passed" );
85 if ( recRoI->passedThreshold(th->mapping()) ) {
86 passedThresholdIDs.push_back( HLT::Identifier( th->name() ) );
87 ATH_MSG_DEBUG( "Passed Threshold name " << th->name() );
88 addChainsToDecision( HLT::Identifier( th->name() ), decision, activeChains );
89 ATH_MSG_DEBUG( "Labeled object with chains: " << [&](){
91 TrigCompositeUtils::decisionIDs( decision, ids );
92 return std::vector<TrigCompositeUtils::DecisionID>( ids.begin(), ids.end() ); }() );
93 }
94 }
95
96 decision->setDetail( "thresholds", passedThresholdIDs );
98 ElementLink<TrigRoiDescriptorCollection>(m_trigRoIsKey.key(), trigRoIs->size()-1, ctx) );
100 ElementLink<DataVector<LVL1::RecJetRoI>>(m_recRoIsKey.key(), recRoIs->size()-1, ctx) );
101 }
102 }
103
104 // Decorate the decisions with overflow information
105 if (overflow) {
106 ATH_MSG_WARNING("L1Calo overflow for JET TOBs to CMX detected");
107 }
108 for (Decision* decision : *decisionOutput) {
109 decision->setDetail("overflow", static_cast<char>(overflow));
110 }
111
112 if ( msgLvl(MSG::DEBUG) ) {
113 for ( auto roi: *trigRoIs ) {
114 ATH_MSG_DEBUG( "RoI Eta: " << roi->eta() << " Phi: " << roi->phi() << " RoIWord: " << roi->roiWord() );
115 }
116 }
117
118 // monitoring
119 {
120 auto RoIsCount = Monitored::Scalar( "count", trigRoIs->size() );
121 auto RoIsPhi = Monitored::Collection( "phi", *trigRoIs, &TrigRoiDescriptor::phi );
122 auto RoIsEta = Monitored::Collection( "eta", *trigRoIs, &TrigRoiDescriptor::eta );
123 Monitored::Group( m_monTool, RoIsCount, RoIsEta, RoIsPhi );
124 }
125
126 ATH_MSG_DEBUG( "Unpacked " << trigRoIs->size() << " RoIs" );
127
128 return StatusCode::SUCCESS;
129}
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
SG::WriteHandle< DecisionContainer > createAndStore(const SG::WriteHandleKey< DecisionContainer > &key, const EventContext &ctx)
Creates and right away records the DecisionContainer with the key.
virtual double eta() const =0
virtual double phi() const =0
Methods to retrieve data members.
Gaudi::Property< float > m_roIWidth
LVL1::JEPRoIDecoder m_jepDecoder
virtual double eta() const
returns eta coord of ROI
virtual double phi() const
returns phi coord of ROI
bool passedThreshold(unsigned int thresholdNumber) const
returns TRUE if threshold number threshold_number has been passed by this ROI.
const std::vector< JetEnergyResult > & jetEnergyResult() const
Gets the jet/energy part of the L1 RDO.
SG::WriteHandleKey< TrigCompositeUtils::DecisionContainer > m_decisionsKey
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< 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.
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.
ValuesCollection< T > Collection(std::string name, const T &collection)
Declare a monitored (double-convertible) collection.
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()
setEventNumber uint32_t

Member Data Documentation

◆ m_decisionsKey

SG::WriteHandleKey<TrigCompositeUtils::DecisionContainer> RoIsUnpackingToolBase::m_decisionsKey
protectedinherited
Initial value:
{
this, "Decisions", "RoIDecisions", "Decisions for each RoI"}

Definition at line 51 of file RoIsUnpackingToolBase.h.

51 {
52 this, "Decisions", "RoIDecisions", "Decisions for each RoI"};

◆ m_decisionsKeyProbe

SG::WriteHandleKey<TrigCompositeUtils::DecisionContainer> RoIsUnpackingToolBase::m_decisionsKeyProbe
protectedinherited
Initial value:
{
this, "DecisionsProbe", "", "Optional secondary set of Decisions for each RoI for probe a.k.a. delayed a.k.a. rerun chains"}

Definition at line 54 of file RoIsUnpackingToolBase.h.

54 {
55 this, "DecisionsProbe", "", "Optional secondary set of Decisions for each RoI for probe a.k.a. delayed a.k.a. rerun chains"};

◆ m_fsRoIKey

Gaudi::Property<std::string> JRoIsUnpackingTool::m_fsRoIKey
private
Initial value:
{
this, "FSRoIKey", "HLT_FSRoI", "The key of FS RoI made earlier by the HLTSeeding" }

Definition at line 35 of file JRoIsUnpackingTool.h.

35 {
36 this, "FSRoIKey", "HLT_FSRoI", "The key of FS RoI made earlier by the HLTSeeding" };

◆ m_HLTMenuKey

SG::ReadHandleKey<TrigConf::HLTMenu> RoIsUnpackingToolBase::m_HLTMenuKey
protectedinherited
Initial value:
{
this, "HLTTriggerMenu", "DetectorStore+HLTTriggerMenu", "Name of the HLTMenu object to read configuration from"}

Definition at line 63 of file RoIsUnpackingToolBase.h.

63 {
64 this, "HLTTriggerMenu", "DetectorStore+HLTTriggerMenu", "Name of the HLTMenu object to read configuration from"};

◆ m_jepDecoder

LVL1::JEPRoIDecoder JRoIsUnpackingTool::m_jepDecoder
private

Definition at line 38 of file JRoIsUnpackingTool.h.

◆ m_l1MenuKey

SG::ReadHandleKey<TrigConf::L1Menu> RoIsUnpackingToolBase::m_l1MenuKey
protectedinherited
Initial value:
{
this, "L1TriggerMenu", "DetectorStore+L1TriggerMenu", "Name of the L1Menu object to read configuration from"}

Definition at line 60 of file RoIsUnpackingToolBase.h.

60 {
61 this, "L1TriggerMenu", "DetectorStore+L1TriggerMenu", "Name of the L1Menu object to read configuration from"};

◆ m_legToChainMapping

std::map<HLT::Identifier, HLT::Identifier> RoIsUnpackingToolBase::m_legToChainMapping
protectedinherited

Definition at line 71 of file RoIsUnpackingToolBase.h.

◆ m_monTool

ToolHandle<GenericMonitoringTool> RoIsUnpackingToolBase::m_monTool { this, "MonTool", "", "Monitoring tool" }
protectedinherited

Definition at line 67 of file RoIsUnpackingToolBase.h.

67{ this, "MonTool", "", "Monitoring tool" };

◆ m_recRoIsKey

SG::WriteHandleKey< DataVector<LVL1::RecJetRoI> > JRoIsUnpackingTool::m_recRoIsKey
private
Initial value:
{
this, "OutputRecRoIs", "HLT_RecJETRoIs", "Name of the RoIs object produced by the unpacker"}

Definition at line 29 of file JRoIsUnpackingTool.h.

29 {
30 this, "OutputRecRoIs", "HLT_RecJETRoIs", "Name of the RoIs object produced by the unpacker"};

◆ m_roiupdater

ToolHandle<IRoiUpdaterTool> RoIsUnpackingToolBase::m_roiupdater { this, "RoiUpdater", "", "Roi Updater" }
protectedinherited

Definition at line 68 of file RoIsUnpackingToolBase.h.

68{ this, "RoiUpdater", "", "Roi Updater" };

◆ m_roIWidth

Gaudi::Property<float> JRoIsUnpackingTool::m_roIWidth
private
Initial value:
{
this, "RoIWidth", 0.4, "Size of RoI in eta/phi"}

Definition at line 32 of file JRoIsUnpackingTool.h.

32 {
33 this, "RoIWidth", 0.4, "Size of RoI in eta/phi"};

◆ m_thresholdToChainMapping

std::map<HLT::Identifier, HLT::IDVec> RoIsUnpackingToolBase::m_thresholdToChainMapping
protectedinherited

Definition at line 70 of file RoIsUnpackingToolBase.h.

◆ m_trigRoIsKey

SG::WriteHandleKey<TrigRoiDescriptorCollection> RoIsUnpackingToolBase::m_trigRoIsKey
protectedinherited
Initial value:
{
this, "OutputTrigRoIs", "", "Name of the RoIs collection produced by the unpacker"}

Definition at line 57 of file RoIsUnpackingToolBase.h.

57 {
58 this, "OutputTrigRoIs", "", "Name of the RoIs collection produced by the unpacker"};

The documentation for this class was generated from the following files: