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

Obtains trigger bits from Navigation summary via getBits and (online) fills trigger bits in the HLTResultMT object. More...

#include <TriggerBitsMakerTool.h>

Inheritance diagram for TriggerBitsMakerTool:
Collaboration diagram for TriggerBitsMakerTool:

Public Member Functions

 TriggerBitsMakerTool (const std::string &type, const std::string &name, const IInterface *parent)
virtual ~TriggerBitsMakerTool () override=default
virtual StatusCode fill (HLT::HLTResultMT &resultToFill, const EventContext &ctx) const override
virtual StatusCode getBits (boost::dynamic_bitset< uint32_t > &passRaw, boost::dynamic_bitset< uint32_t > &prescaled, const EventContext &ctx) const override
virtual StatusCode initialize () override
virtual StatusCode start () override

Private Types

using ChainToBitMap = std::map< TrigCompositeUtils::DecisionID, uint32_t>

Private Member Functions

StatusCode setBit (const TrigCompositeUtils::DecisionID chain, boost::dynamic_bitset< uint32_t > &resultToFill) const
 Set to 1 the bit correspinding to 'chain' in 'resultToFill'.
StatusCode hashConsistencyCheck (const std::string &chain, const size_t hash) const
 Check that a chain's hash in the menu JSON (via python) agrees with the C++ implementation.
StatusCode preInsertCheck (const std::string &chain, const uint32_t bit) const
 Check that no existing key maps to a given value and that the string is not empty.

Private Attributes

SG::ReadHandleKey< TrigCompositeUtils::DecisionContainerm_finalChainDecisions
SG::ReadHandleKey< TrigConf::HLTMenum_HLTMenuKey {this, "HLTTriggerMenu", "DetectorStore+HLTTriggerMenu", "HLT Menu"}
Gaudi::Property< std::map< std::string, uint32_t > > m_extraChainToBit
ChainToBitMap m_mapping
 Mapping of each chain's hash ID to its chain counter.
uint32_t m_largestBit {0}
 Largest chain counter hence largest bit needed to be stored in result bitmap.

Detailed Description

Obtains trigger bits from Navigation summary via getBits and (online) fills trigger bits in the HLTResultMT object.

Definition at line 18 of file TriggerBitsMakerTool.h.

Member Typedef Documentation

◆ ChainToBitMap

Definition at line 57 of file TriggerBitsMakerTool.h.

Constructor & Destructor Documentation

◆ TriggerBitsMakerTool()

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

Definition at line 11 of file TriggerBitsMakerTool.cxx.

11 :
12 base_class(type, name, parent){}

◆ ~TriggerBitsMakerTool()

virtual TriggerBitsMakerTool::~TriggerBitsMakerTool ( )
overridevirtualdefault

Member Function Documentation

◆ fill()

StatusCode TriggerBitsMakerTool::fill ( HLT::HLTResultMT & resultToFill,
const EventContext & ctx ) const
overridevirtual

Definition at line 136 of file TriggerBitsMakerTool.cxx.

136 {
137
138 {
139 boost::dynamic_bitset<uint32_t> passRaw;
140 boost::dynamic_bitset<uint32_t> prescaled;
141
142 ATH_CHECK(getBits(passRaw, prescaled, ctx));
143 resultToFill.setHltBits(passRaw, prescaled);
144 }
145
146 if ( msgLvl( MSG::DEBUG ) ) {
147 const boost::dynamic_bitset<uint32_t>& passRawBits = resultToFill.getHltPassRawBits();
148 std::vector<uint32_t> bitsTemp(passRawBits.num_blocks());
149 boost::to_block_range(passRawBits, bitsTemp.begin());
150 ATH_MSG_VERBOSE("HLT result now has " << bitsTemp.size() << " words with HLT pass raw bits:");
151 for (const auto& w : bitsTemp) ATH_MSG_VERBOSE("0x" << MSG::hex << w << MSG::dec);
152 //
153 const boost::dynamic_bitset<uint32_t>& prescaleBits = resultToFill.getHltPrescaledBits();
154 boost::to_block_range(prescaleBits, bitsTemp.begin());
155 ATH_MSG_VERBOSE("HLT result now has " << bitsTemp.size() << " words with HLT prescale bits:");
156 for (const auto& w : bitsTemp) ATH_MSG_VERBOSE("0x" << MSG::hex << w << MSG::dec);
157 //
158 const std::vector<uint32_t>& words = resultToFill.getHltBitsAsWords();
159 ATH_MSG_DEBUG("HLT result now has " << words.size() << " words with the final trigger bits:");
160 for (const uint32_t w : words) ATH_MSG_DEBUG("0x" << MSG::hex << w << MSG::dec);
161 }
162
163 return StatusCode::SUCCESS;
164
165}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_DEBUG(x)
void setHltBits(const boost::dynamic_bitset< uint32_t > &passRawBitset, const boost::dynamic_bitset< uint32_t > &prescaledBitset)
Replace both HLT pass raw and prescaled bits with the given bitsets.
const std::vector< uint32_t > & getHltBitsAsWords() const
Const-getter for HLT bits as uint32_t array. Ordering: PassRaw, Prescaled.
const boost::dynamic_bitset< uint32_t > & getHltPassRawBits() const
Const-getter for HLT pass raw bits.
const boost::dynamic_bitset< uint32_t > & getHltPrescaledBits() const
Const-getter for HLT prescaled bits.
virtual StatusCode getBits(boost::dynamic_bitset< uint32_t > &passRaw, boost::dynamic_bitset< uint32_t > &prescaled, const EventContext &ctx) const override

◆ getBits()

StatusCode TriggerBitsMakerTool::getBits ( boost::dynamic_bitset< uint32_t > & passRaw,
boost::dynamic_bitset< uint32_t > & prescaled,
const EventContext & ctx ) const
overridevirtual

< The chains which returned a positive decision

< The chains which did not run due to being prescaled out

Definition at line 76 of file TriggerBitsMakerTool.cxx.

79{
80 using namespace TrigCompositeUtils;
81
82 passRaw.clear();
83 prescaled.clear();
84
85 auto chainsHandle = SG::makeHandle(m_finalChainDecisions, ctx);
86 if (!chainsHandle.isValid()) {
87 SmartIF<IAlgExecStateSvc> aess = svcLoc()->service<IAlgExecStateSvc>("AlgExecStateSvc", false);
88 if (aess.isValid() && aess->eventStatus(ctx) != EventStatus::Success) {
89 ATH_MSG_WARNING("Failed event, " << m_finalChainDecisions.key() << " is unavailable. Skipping trigger bits making.");
90 return StatusCode::SUCCESS;
91 }
92 ATH_MSG_ERROR("Unable to read in the " << m_finalChainDecisions.key() << " from the DecisionSummaryMakerAlg");
93 return StatusCode::FAILURE;
94 }
95
96 passRaw.resize(m_largestBit + 1);
97 prescaled.resize(m_largestBit + 1);
98
99 const Decision* HLTPassRaw = nullptr;
100 const Decision* HLTPrescaled = nullptr;
101
102 DecisionIDContainer passRawIDs;
103 DecisionIDContainer prescaledIDs;
104
105 // Read the sets of chain IDs
106 for (const Decision* decisionObject : *chainsHandle) {
107 // Collect all decisions (IDs of passed/prescaled chains) from named decisionObjects
108 if (decisionObject->name() == TrigCompositeUtils::summaryPassNodeName()) {
109 HLTPassRaw = decisionObject;
110 } else if (decisionObject->name() == TrigCompositeUtils::summaryPrescaledNodeName()) {
111 HLTPrescaled = decisionObject;
112 }
113 if (HLTPassRaw != nullptr && HLTPrescaled != nullptr) {
114 break;
115 }
116 }
117
118 ATH_CHECK(HLTPassRaw != nullptr);
119 ATH_CHECK(HLTPrescaled != nullptr);
120
121 decisionIDs(HLTPassRaw, passRawIDs);
122 decisionIDs(HLTPrescaled, prescaledIDs);
123
124 for ( DecisionID chain: passRawIDs ) {
125 ATH_CHECK(setBit(chain, passRaw));
126 }
127
128 for ( DecisionID chain: prescaledIDs ) {
129 ATH_CHECK(setBit(chain, prescaled));
130 }
131
132 return StatusCode::SUCCESS;
133
134}
#define ATH_MSG_ERROR(x)
#define ATH_MSG_WARNING(x)
unsigned int DecisionID
std::set< DecisionID > DecisionIDContainer
void decisionIDs(const Decision *d, DecisionIDContainer &id)
Extracts DecisionIDs stored in the Decision object.
SG::ReadHandleKey< TrigCompositeUtils::DecisionContainer > m_finalChainDecisions
StatusCode setBit(const TrigCompositeUtils::DecisionID chain, boost::dynamic_bitset< uint32_t > &resultToFill) const
Set to 1 the bit correspinding to 'chain' in 'resultToFill'.
uint32_t m_largestBit
Largest chain counter hence largest bit needed to be stored in result bitmap.
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
const std::string & summaryPrescaledNodeName()
const std::string & summaryPassNodeName()

◆ hashConsistencyCheck()

StatusCode TriggerBitsMakerTool::hashConsistencyCheck ( const std::string & chain,
const size_t hash ) const
private

Check that a chain's hash in the menu JSON (via python) agrees with the C++ implementation.

Definition at line 50 of file TriggerBitsMakerTool.cxx.

50 {
51 if (HLT::Identifier( chain ).numeric() != hash) {
52 ATH_MSG_ERROR("Inconsistent hashes found for chain:" << chain << ", from Python:" << hash
53 << ", from C++:" << HLT::Identifier( chain ).numeric());
54 return StatusCode::FAILURE;
55 }
56 return StatusCode::SUCCESS;
57}

◆ initialize()

StatusCode TriggerBitsMakerTool::initialize ( )
overridevirtual

Definition at line 14 of file TriggerBitsMakerTool.cxx.

14 {
15
16 ATH_CHECK( m_finalChainDecisions.initialize() );
17 ATH_CHECK( m_HLTMenuKey.initialize() );
18
19 return StatusCode::SUCCESS;
20}
SG::ReadHandleKey< TrigConf::HLTMenu > m_HLTMenuKey

◆ preInsertCheck()

StatusCode TriggerBitsMakerTool::preInsertCheck ( const std::string & chain,
const uint32_t bit ) const
private

Check that no existing key maps to a given value and that the string is not empty.

Definition at line 59 of file TriggerBitsMakerTool.cxx.

59 {
60 const auto checkIt = std::find_if(
61 m_mapping.begin(), m_mapping.end(),
62 [&](const std::pair<TrigCompositeUtils::DecisionID, uint32_t>& m) { return m.second == bit; }
63 );
64 if (checkIt != m_mapping.end()) {
65 ATH_MSG_ERROR( "Multiple chains " << HLT::Identifier(checkIt->first)
66 << " and " << chain << " are both configured with ChainCounter:" << bit);
67 return StatusCode::FAILURE;
68 }
69 if (chain.empty()) {
70 ATH_MSG_ERROR( "Trying to register an empty string as a Chain." );
71 return StatusCode::FAILURE;
72 }
73 return StatusCode::SUCCESS;
74}
ChainToBitMap m_mapping
Mapping of each chain's hash ID to its chain counter.

◆ setBit()

StatusCode TriggerBitsMakerTool::setBit ( const TrigCompositeUtils::DecisionID chain,
boost::dynamic_bitset< uint32_t > & resultToFill ) const
private

Set to 1 the bit correspinding to 'chain' in 'resultToFill'.

Definition at line 167 of file TriggerBitsMakerTool.cxx.

169{
170 // Ignore per-leg IDs, only use chain-IDs
171 if (TrigCompositeUtils::isLegId(HLT::Identifier(chain)) ) {
172 return StatusCode::SUCCESS;
173 }
174
175 auto mappingIter = m_mapping.find( chain );
176 // each chain has to have the counter
177 if( mappingIter == m_mapping.end() ) {
178 ATH_MSG_ERROR("Each chain has to have the bit/counter associated whereas the " << HLT::Identifier( chain ) << " does not" );
179 return StatusCode::FAILURE;
180 }
181 const int chainBitPosition = mappingIter->second;
182 ATH_MSG_DEBUG("Setting bit " << chainBitPosition << " corresponding to chain "<< HLT::Identifier(chain));
183 if (resultToFill.test(chainBitPosition)) {
184 ATH_MSG_WARNING(HLT::Identifier(chain) << " is setting its trigger bit " << chainBitPosition << " more than once");
185 }
186 resultToFill.set(chainBitPosition);
187 return StatusCode::SUCCESS;
188}
bool isLegId(const HLT::Identifier &legIdentifier)
Recognise whether the chain ID is a leg ID.

◆ start()

StatusCode TriggerBitsMakerTool::start ( )
overridevirtual

Definition at line 22 of file TriggerBitsMakerTool.cxx.

22 {
23 SG::ReadHandle<TrigConf::HLTMenu> hltMenuHandle = SG::makeHandle( m_HLTMenuKey );
24 ATH_CHECK( hltMenuHandle.isValid() );
25 ATH_MSG_INFO("Configuring from " << m_HLTMenuKey << " with " << hltMenuHandle->size() << " chains");
26
27 m_mapping.clear();
28 m_largestBit = 0;
29 for (const TrigConf::Chain& ch : *hltMenuHandle) {
30 ATH_MSG_DEBUG( "Chain " << ch.name() << " will flip " << ch.counter() << " bit" );
31 ATH_CHECK(preInsertCheck(ch.name(), ch.counter()));
32 ATH_CHECK(hashConsistencyCheck(ch.name(), ch.namehash()));
33 m_mapping[ HLT::Identifier( ch.name() ).numeric() ] = ch.counter();
34 m_largestBit = std::max(m_largestBit, ch.counter());
35 }
36
37 // This block allows extra mappings to be supplied by python, e.g. for testing purposes
38 for (const auto& chainAndBit: m_extraChainToBit ) {
39 struct { std::string chain; uint32_t bit; } conf { chainAndBit.first, chainAndBit.second };
40 ATH_MSG_DEBUG( "Extra Chain " << conf.chain << " will flip " << conf.bit << " bit" );
41 ATH_CHECK(preInsertCheck(conf.chain, conf.bit));
42 m_mapping[ HLT::Identifier( conf.chain ).numeric() ] = conf.bit;
43 m_largestBit = std::max(m_largestBit, conf.bit);
44 }
45
46 return StatusCode::SUCCESS;
47}
#define ATH_MSG_INFO(x)
virtual bool isValid() override final
Can the handle be successfully dereferenced?
StatusCode preInsertCheck(const std::string &chain, const uint32_t bit) const
Check that no existing key maps to a given value and that the string is not empty.
Gaudi::Property< std::map< std::string, uint32_t > > m_extraChainToBit
StatusCode hashConsistencyCheck(const std::string &chain, const size_t hash) const
Check that a chain's hash in the menu JSON (via python) agrees with the C++ implementation.
setEventNumber uint32_t

Member Data Documentation

◆ m_extraChainToBit

Gaudi::Property<std::map<std::string, uint32_t> > TriggerBitsMakerTool::m_extraChainToBit
private
Initial value:
{ this, "ExtraChainToBit", {},
"Special case and testing purposes hard-coded chain-to-bit mappings to use in addition to those from the HLT menu."}

Definition at line 54 of file TriggerBitsMakerTool.h.

54 { this, "ExtraChainToBit", {},
55 "Special case and testing purposes hard-coded chain-to-bit mappings to use in addition to those from the HLT menu."};

◆ m_finalChainDecisions

SG::ReadHandleKey<TrigCompositeUtils::DecisionContainer> TriggerBitsMakerTool::m_finalChainDecisions
private
Initial value:
{ this, "ChainDecisions", "HLTNav_Summary",
"Container with final chain decisions" }

Definition at line 49 of file TriggerBitsMakerTool.h.

49 { this, "ChainDecisions", "HLTNav_Summary",
50 "Container with final chain decisions" };

◆ m_HLTMenuKey

SG::ReadHandleKey<TrigConf::HLTMenu> TriggerBitsMakerTool::m_HLTMenuKey {this, "HLTTriggerMenu", "DetectorStore+HLTTriggerMenu", "HLT Menu"}
private

Definition at line 52 of file TriggerBitsMakerTool.h.

52{this, "HLTTriggerMenu", "DetectorStore+HLTTriggerMenu", "HLT Menu"};

◆ m_largestBit

uint32_t TriggerBitsMakerTool::m_largestBit {0}
private

Largest chain counter hence largest bit needed to be stored in result bitmap.

Definition at line 60 of file TriggerBitsMakerTool.h.

60{0};

◆ m_mapping

ChainToBitMap TriggerBitsMakerTool::m_mapping
private

Mapping of each chain's hash ID to its chain counter.

Definition at line 58 of file TriggerBitsMakerTool.h.


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