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 137 of file TriggerBitsMakerTool.cxx.

137 {
138
139 {
140 boost::dynamic_bitset<uint32_t> passRaw;
141 boost::dynamic_bitset<uint32_t> prescaled;
142
143 ATH_CHECK(getBits(passRaw, prescaled, ctx));
144 resultToFill.setHltBits(passRaw, prescaled);
145 }
146
147 if ( msgLvl( MSG::DEBUG ) ) {
148 const boost::dynamic_bitset<uint32_t>& passRawBits = resultToFill.getHltPassRawBits();
149 std::vector<uint32_t> bitsTemp(passRawBits.num_blocks());
150 boost::to_block_range(passRawBits, bitsTemp.begin());
151 ATH_MSG_VERBOSE("HLT result now has " << bitsTemp.size() << " words with HLT pass raw bits:");
152 for (const auto& w : bitsTemp) ATH_MSG_VERBOSE("0x" << MSG::hex << w << MSG::dec);
153 //
154 const boost::dynamic_bitset<uint32_t>& prescaleBits = resultToFill.getHltPrescaledBits();
155 boost::to_block_range(prescaleBits, bitsTemp.begin());
156 ATH_MSG_VERBOSE("HLT result now has " << bitsTemp.size() << " words with HLT prescale bits:");
157 for (const auto& w : bitsTemp) ATH_MSG_VERBOSE("0x" << MSG::hex << w << MSG::dec);
158 //
159 const std::vector<uint32_t>& words = resultToFill.getHltBitsAsWords();
160 ATH_MSG_DEBUG("HLT result now has " << words.size() << " words with the final trigger bits:");
161 for (const uint32_t w : words) ATH_MSG_DEBUG("0x" << MSG::hex << w << MSG::dec);
162 }
163
164 return StatusCode::SUCCESS;
165
166}
#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 77 of file TriggerBitsMakerTool.cxx.

80{
81 using namespace TrigCompositeUtils;
82
83 passRaw.clear();
84 prescaled.clear();
85
86 auto chainsHandle = SG::makeHandle(m_finalChainDecisions, ctx);
87 if (!chainsHandle.isValid()) {
88 SmartIF<IAlgExecStateSvc> aess = svcLoc()->service<IAlgExecStateSvc>("AlgExecStateSvc", false);
89 if (aess.isValid() && aess->eventStatus(ctx) != EventStatus::Success) {
90 ATH_MSG_WARNING("Failed event, " << m_finalChainDecisions.key() << " is unavailable. Skipping trigger bits making.");
91 return StatusCode::SUCCESS;
92 }
93 ATH_MSG_ERROR("Unable to read in the " << m_finalChainDecisions.key() << " from the DecisionSummaryMakerAlg");
94 return StatusCode::FAILURE;
95 }
96
97 passRaw.resize(m_largestBit + 1);
98 prescaled.resize(m_largestBit + 1);
99
100 const Decision* HLTPassRaw = nullptr;
101 const Decision* HLTPrescaled = nullptr;
102
103 DecisionIDContainer passRawIDs;
104 DecisionIDContainer prescaledIDs;
105
106 // Read the sets of chain IDs
107 for (const Decision* decisionObject : *chainsHandle) {
108 // Collect all decisions (IDs of passed/prescaled chains) from named decisionObjects
109 if (decisionObject->name() == TrigCompositeUtils::summaryPassNodeName()) {
110 HLTPassRaw = decisionObject;
111 } else if (decisionObject->name() == TrigCompositeUtils::summaryPrescaledNodeName()) {
112 HLTPrescaled = decisionObject;
113 }
114 if (HLTPassRaw != nullptr && HLTPrescaled != nullptr) {
115 break;
116 }
117 }
118
119 ATH_CHECK(HLTPassRaw != nullptr);
120 ATH_CHECK(HLTPrescaled != nullptr);
121
122 decisionIDs(HLTPassRaw, passRawIDs);
123 decisionIDs(HLTPrescaled, prescaledIDs);
124
125 for ( DecisionID chain: passRawIDs ) {
126 ATH_CHECK(setBit(chain, passRaw));
127 }
128
129 for ( DecisionID chain: prescaledIDs ) {
130 ATH_CHECK(setBit(chain, prescaled));
131 }
132
133 return StatusCode::SUCCESS;
134
135}
#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 51 of file TriggerBitsMakerTool.cxx.

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

◆ 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 60 of file TriggerBitsMakerTool.cxx.

60 {
61 const auto checkIt = std::find_if(
62 m_mapping.begin(), m_mapping.end(),
63 [&](const std::pair<TrigCompositeUtils::DecisionID, uint32_t>& m) { return m.second == bit; }
64 );
65 if (checkIt != m_mapping.end()) {
66 ATH_MSG_ERROR( "Multiple chains " << HLT::Identifier(checkIt->first)
67 << " and " << chain << " are both configured with ChainCounter:" << bit);
68 return StatusCode::FAILURE;
69 }
70 if (chain.empty()) {
71 ATH_MSG_ERROR( "Trying to register an empty string as a Chain." );
72 return StatusCode::FAILURE;
73 }
74 return StatusCode::SUCCESS;
75}
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 168 of file TriggerBitsMakerTool.cxx.

170{
171 // Ignore per-leg IDs, only use chain-IDs
172 if (TrigCompositeUtils::isLegId(HLT::Identifier(chain)) ) {
173 return StatusCode::SUCCESS;
174 }
175
176 auto mappingIter = m_mapping.find( chain );
177 // each chain has to have the counter
178 if( mappingIter == m_mapping.end() ) {
179 ATH_MSG_ERROR("Each chain has to have the bit/counter associated whereas the " << HLT::Identifier( chain ) << " does not" );
180 return StatusCode::FAILURE;
181 }
182 const int chainBitPosition = mappingIter->second;
183 ATH_MSG_DEBUG("Setting bit " << chainBitPosition << " corresponding to chain "<< HLT::Identifier(chain));
184 if (resultToFill.test(chainBitPosition)) {
185 ATH_MSG_WARNING(HLT::Identifier(chain) << " is setting its trigger bit " << chainBitPosition << " more than once");
186 }
187 resultToFill.set(chainBitPosition);
188 return StatusCode::SUCCESS;
189}
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 // cppcheck-suppress uninitMemberVarNoCtor
40 struct { std::string chain; uint32_t bit; } conf { chainAndBit.first, chainAndBit.second };
41 ATH_MSG_DEBUG( "Extra Chain " << conf.chain << " will flip " << conf.bit << " bit" );
42 ATH_CHECK(preInsertCheck(conf.chain, conf.bit));
43 m_mapping[ HLT::Identifier( conf.chain ).numeric() ] = conf.bit;
44 m_largestBit = std::max(m_largestBit, conf.bit);
45 }
46
47 return StatusCode::SUCCESS;
48}
#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.
constexpr unsigned int bit(int n)
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: