ATLAS Offline Software
Loading...
Searching...
No Matches
RoIsUnpackingToolBase.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3*/
4
7#include <iostream>
8
9
11 const std::string& name,
12 const IInterface* parent)
13 : base_class(type, name, parent) {}
14
15
17
18 if ( !m_monTool.empty() ) ATH_CHECK( m_monTool.retrieve() );
21 if ( !m_roiupdater.empty() ) ATH_CHECK( m_roiupdater.retrieve() );
22
23 ATH_CHECK( m_decisionsKey.initialize() );
26 ATH_CHECK( m_l1MenuKey.initialize() );
27 ATH_CHECK( m_HLTMenuKey.initialize() );
28
29 return StatusCode::SUCCESS;
30}
31
32
34 const std::string& thrType,
35 std::optional<ThrVecRef>& thrVec) const {
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}
45
46
47std::string RoIsUnpackingToolBase::getProbeThresholdName(const std::string& thresholdName) {
48 return "PROBE" + thresholdName;
49}
50
51
52StatusCode RoIsUnpackingToolBase::decodeMapping( std::function<bool(const std::string&)>&& filter ) {
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}
86
87
90 const HLT::IDSet& activeChains ) const {
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_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_DEBUG(x)
std::map< HLT::Identifier, HLT::Identifier > m_legToChainMapping
SG::WriteHandleKey< TrigCompositeUtils::DecisionContainer > m_decisionsKey
ToolHandle< IRoiUpdaterTool > m_roiupdater
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
std::reference_wrapper< const ThrVec > ThrVecRef
SG::WriteHandleKey< TrigCompositeUtils::DecisionContainer > m_decisionsKeyProbe
virtual StatusCode initialize() override
SG::WriteHandleKey< TrigRoiDescriptorCollection > m_trigRoIsKey
SG::ReadHandleKey< TrigConf::HLTMenu > m_HLTMenuKey
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?
L1 menu configuration.
Definition L1Menu.h:28
std::vector< std::shared_ptr< TrigConf::L1Threshold > > thresholds() const
Access to list of all L1Thresholds.
Definition L1Menu.cxx:267
std::set< HLT::Identifier > IDSet
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.
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.