ATLAS Offline Software
Loading...
Searching...
No Matches
RoIsUnpackingToolPhase1< T_RoI, T_RoIContainer, F_RoIWordGetter, N_RoIContainer, N_ThresholdType > Class Template Reference

Class template for all phase-1 L1 RoI unpacking tools. More...

#include <RoIsUnpackingToolPhase1.h>

Inheritance diagram for RoIsUnpackingToolPhase1< T_RoI, T_RoIContainer, F_RoIWordGetter, N_RoIContainer, N_ThresholdType >:
Collaboration diagram for RoIsUnpackingToolPhase1< T_RoI, T_RoIContainer, F_RoIWordGetter, N_RoIContainer, N_ThresholdType >:

Public Member Functions

 RoIsUnpackingToolPhase1 (const std::string &type, const std::string &name, const IInterface *parent)
virtual StatusCode initialize () override
virtual StatusCode start () override
virtual StatusCode unpack (const EventContext &ctx, const xAOD::TrigComposite &l1TriggerResult, const HLT::IDSet &activeChains) const override
virtual StatusCode unpack (const EventContext &, const ROIB::RoIBResult &, 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

Gaudi::Property< std::string > m_l1RoILinkName
SG::ReadDecorHandleKey< T_RoIContainer > m_thresholdPatternsKey
Gaudi::Property< float > m_roiHalfWidthEta
Gaudi::Property< float > m_roiHalfWidthPhi

Detailed Description

template<typename T_RoI, typename T_RoIContainer, auto F_RoIWordGetter, const char * N_RoIContainer, const char * N_ThresholdType>
class RoIsUnpackingToolPhase1< T_RoI, T_RoIContainer, F_RoIWordGetter, N_RoIContainer, N_ThresholdType >

Class template for all phase-1 L1 RoI unpacking tools.

Definition at line 23 of file RoIsUnpackingToolPhase1.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

◆ RoIsUnpackingToolPhase1()

template<typename T_RoI, typename T_RoIContainer, auto F_RoIWordGetter, const char * N_RoIContainer, const char * N_ThresholdType>
RoIsUnpackingToolPhase1< T_RoI, T_RoIContainer, F_RoIWordGetter, N_RoIContainer, N_ThresholdType >::RoIsUnpackingToolPhase1 ( const std::string & type,
const std::string & name,
const IInterface * parent )
inline

Definition at line 41 of file RoIsUnpackingToolPhase1.h.

RoIsUnpackingToolBase(const std::string &type, const std::string &name, const IInterface *parent)
Class template for all phase-1 L1 RoI unpacking tools.

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()

template<typename T_RoI, typename T_RoIContainer, auto F_RoIWordGetter, const char * N_RoIContainer, const char * N_ThresholdType>
virtual StatusCode RoIsUnpackingToolPhase1< T_RoI, T_RoIContainer, F_RoIWordGetter, N_RoIContainer, N_ThresholdType >::initialize ( )
inlineoverridevirtual

Reimplemented from RoIsUnpackingToolBase.

Definition at line 45 of file RoIsUnpackingToolPhase1.h.

45 {
47 ATH_CHECK(m_l1MenuKey.initialize());
48 ATH_CHECK(m_trigRoIsKey.initialize());
51 }
SG::ReadHandleKey< TrigConf::L1Menu > m_l1MenuKey
SG::WriteHandleKey< TrigRoiDescriptorCollection > m_trigRoIsKey
SG::ReadDecorHandleKey< T_RoIContainer > m_thresholdPatternsKey

◆ start()

template<typename T_RoI, typename T_RoIContainer, auto F_RoIWordGetter, const char * N_RoIContainer, const char * N_ThresholdType>
virtual StatusCode RoIsUnpackingToolPhase1< T_RoI, T_RoIContainer, F_RoIWordGetter, N_RoIContainer, N_ThresholdType >::start ( )
inlineoverridevirtual

Definition at line 54 of file RoIsUnpackingToolPhase1.h.

54 {
57 }));
59 }
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.

◆ unpack() [1/2]

template<typename T_RoI, typename T_RoIContainer, auto F_RoIWordGetter, const char * N_RoIContainer, const char * N_ThresholdType>
virtual StatusCode RoIsUnpackingToolBase::unpack ( const EventContext & ,
const ROIB::RoIBResult & ,
const HLT::IDSet &  ) const
inlineoverridevirtual

Reimplemented from RoIsUnpackingToolBase.

Definition at line 40 of file RoIsUnpackingToolBase.h.

42 { return StatusCode::SUCCESS; }

◆ unpack() [2/2]

template<typename T_RoI, typename T_RoIContainer, auto F_RoIWordGetter, const char * N_RoIContainer, const char * N_ThresholdType>
virtual StatusCode RoIsUnpackingToolPhase1< T_RoI, T_RoIContainer, F_RoIWordGetter, N_RoIContainer, N_ThresholdType >::unpack ( const EventContext & ctx,
const xAOD::TrigComposite & l1TriggerResult,
const HLT::IDSet & activeChains ) const
inlineoverridevirtual

Reimplemented from RoIsUnpackingToolBase.

Definition at line 63 of file RoIsUnpackingToolPhase1.h.

65 {
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
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);
82 }
84 ATH_CHECK(roisLink.isValid());
85 const T_RoIContainer& rois = roisLink.getStorableObjectRef();
86
87 // Create threshold patterns decoration accessor
89 ATH_CHECK(thrPatternAcc.isPresent());
90
91 // Retrieve the L1 menu configuration
93 ATH_CHECK(l1Menu.isValid());
96
97 size_t linkIndex{0};
98 for (const T_RoI* roi : rois) {
99 // Create new RoI descriptor
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
108 decisionMain->setObjectLink(initialRoIString(),
110 decisionMain->setObjectLink(initialRecRoIString(),
112
113 Decision* decisionProbe{nullptr};
114 if (doProbe) {
116 decisionProbe->setObjectLink(initialRoIString(),
118 decisionProbe->setObjectLink(initialRecRoIString(),
120 }
121
123
124 // Add positive decisions for chains to be activated by this RoI object
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()) : ""));
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());
149 }
150
151 return StatusCode::SUCCESS;
152 }
SG::WriteHandle< DecisionContainer > createAndStore(const SG::WriteHandleKey< DecisionContainer > &key, const EventContext &ctx)
Creates and right away records the DecisionContainer with the key.
SG::WriteHandleKey< TrigCompositeUtils::DecisionContainer > m_decisionsKey
ToolHandle< GenericMonitoringTool > m_monTool
void addChainsToDecision(HLT::Identifier thresholdId, TrigCompositeUtils::Decision *d, const HLT::IDSet &activeChains) const
SG::WriteHandleKey< TrigCompositeUtils::DecisionContainer > m_decisionsKeyProbe
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.
Gaudi::Property< std::string > m_l1RoILinkName
Gaudi::Property< float > m_roiHalfWidthEta
Gaudi::Property< float > m_roiHalfWidthPhi
ValuesCollection< T > Collection(std::string name, const T &collection)
Declare a monitored (double-convertible) collection.
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.

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_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_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_l1RoILinkName

template<typename T_RoI, typename T_RoIContainer, auto F_RoIWordGetter, const char * N_RoIContainer, const char * N_ThresholdType>
Gaudi::Property<std::string> RoIsUnpackingToolPhase1< T_RoI, T_RoIContainer, F_RoIWordGetter, N_RoIContainer, N_ThresholdType >::m_l1RoILinkName
private
Initial value:
{
this, "L1RoILinkName", N_RoIContainer,
"Name of the link to read from L1TriggerResult for L1 xAOD RoI container"}

Definition at line 25 of file RoIsUnpackingToolPhase1.h.

25 {
26 this, "L1RoILinkName", N_RoIContainer,
27 "Name of the link to read from L1TriggerResult for L1 xAOD RoI container"};

◆ 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_roiHalfWidthEta

template<typename T_RoI, typename T_RoIContainer, auto F_RoIWordGetter, const char * N_RoIContainer, const char * N_ThresholdType>
Gaudi::Property<float> RoIsUnpackingToolPhase1< T_RoI, T_RoIContainer, F_RoIWordGetter, N_RoIContainer, N_ThresholdType >::m_roiHalfWidthEta
private
Initial value:
{
this, "RoIHalfWidthEta", 0.1, "Size of RoI in eta"}

Definition at line 33 of file RoIsUnpackingToolPhase1.h.

33 {
34 this, "RoIHalfWidthEta", 0.1, "Size of RoI in eta"};

◆ m_roiHalfWidthPhi

template<typename T_RoI, typename T_RoIContainer, auto F_RoIWordGetter, const char * N_RoIContainer, const char * N_ThresholdType>
Gaudi::Property<float> RoIsUnpackingToolPhase1< T_RoI, T_RoIContainer, F_RoIWordGetter, N_RoIContainer, N_ThresholdType >::m_roiHalfWidthPhi
private
Initial value:
{
this, "RoIHalfWidthPhi", 0.1, "Size of RoI in phi"}

Definition at line 36 of file RoIsUnpackingToolPhase1.h.

36 {
37 this, "RoIHalfWidthPhi", 0.1, "Size of RoI in phi"};

◆ 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_thresholdPatternsKey

template<typename T_RoI, typename T_RoIContainer, auto F_RoIWordGetter, const char * N_RoIContainer, const char * N_ThresholdType>
SG::ReadDecorHandleKey<T_RoIContainer> RoIsUnpackingToolPhase1< T_RoI, T_RoIContainer, F_RoIWordGetter, N_RoIContainer, N_ThresholdType >::m_thresholdPatternsKey
private
Initial value:
{
this, "L1RoIThresholdPatternsKey", std::string(N_RoIContainer)+".thresholdPatterns",
"Name of the L1 xAOD RoI container decoration for the threshold patterns"}

Definition at line 29 of file RoIsUnpackingToolPhase1.h.

29 {
30 this, "L1RoIThresholdPatternsKey", std::string(N_RoIContainer)+".thresholdPatterns",
31 "Name of the L1 xAOD RoI container decoration for the threshold patterns"};

◆ 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: