ATLAS Offline Software
Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
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'. More...
 
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. More...
 
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. More...
 

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. More...
 
uint32_t m_largestBit {0}
 Largest chain counter hence largest bit needed to be stored in result bitmap. More...
 

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 }

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

◆ 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() );
18 
19  return StatusCode::SUCCESS;
20 }

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

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

◆ start()

StatusCode TriggerBitsMakerTool::start ( )
overridevirtual

Definition at line 22 of file TriggerBitsMakerTool.cxx.

22  {
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;
44  }
45 
46  return StatusCode::SUCCESS;
47 }

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.

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

◆ m_HLTMenuKey

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

Definition at line 52 of file TriggerBitsMakerTool.h.

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

◆ 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:
TrigCompositeUtils::summaryPrescaledNodeName
const std::string & summaryPrescaledNodeName()
Definition: TrigCompositeUtilsRoot.cxx:924
HLT::HLTResultMT::setHltBits
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.
Definition: HLTResultMT.cxx:125
TriggerBitsMakerTool::preInsertCheck
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.
Definition: TriggerBitsMakerTool.cxx:59
sendEI_SPB.ch
ch
Definition: sendEI_SPB.py:35
python.SystemOfUnits.m
int m
Definition: SystemOfUnits.py:91
runLayerRecalibration.chain
chain
Definition: runLayerRecalibration.py:175
TrigCompositeUtils::DecisionID
unsigned int DecisionID
Definition: TrigComposite_v1.h:27
TriggerBitsMakerTool::m_extraChainToBit
Gaudi::Property< std::map< std::string, uint32_t > > m_extraChainToBit
Definition: TriggerBitsMakerTool.h:54
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
HLT::Identifier::numeric
TrigCompositeUtils::DecisionID numeric() const
numeric ID
Definition: TrigCompositeUtils/TrigCompositeUtils/HLTIdentifier.h:47
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
TriggerBitsMakerTool::m_finalChainDecisions
SG::ReadHandleKey< TrigCompositeUtils::DecisionContainer > m_finalChainDecisions
Definition: TriggerBitsMakerTool.h:49
max
constexpr double max()
Definition: ap_fixedTest.cxx:33
TriggerBitsMakerTool::m_HLTMenuKey
SG::ReadHandleKey< TrigConf::HLTMenu > m_HLTMenuKey
Definition: TriggerBitsMakerTool.h:52
TriggerBitsMakerTool::setBit
StatusCode setBit(const TrigCompositeUtils::DecisionID chain, boost::dynamic_bitset< uint32_t > &resultToFill) const
Set to 1 the bit correspinding to 'chain' in 'resultToFill'.
Definition: TriggerBitsMakerTool.cxx:167
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
TriggerBitsMakerTool::hashConsistencyCheck
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.
Definition: TriggerBitsMakerTool.cxx:50
SG::makeHandle
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Definition: ReadCondHandle.h:270
python.ConfigurableDb.conf
def conf
Definition: ConfigurableDb.py:282
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
test_pyathena.parent
parent
Definition: test_pyathena.py:15
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
xAOD::TrigComposite_v1
Class used to describe composite objects in the HLT.
Definition: TrigComposite_v1.h:52
HLT::Identifier
Definition: TrigCompositeUtils/TrigCompositeUtils/HLTIdentifier.h:20
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
TriggerBitsMakerTool::getBits
virtual StatusCode getBits(boost::dynamic_bitset< uint32_t > &passRaw, boost::dynamic_bitset< uint32_t > &prescaled, const EventContext &ctx) const override
Definition: TriggerBitsMakerTool.cxx:76
TrigConf::HLTMenu::size
std::size_t size() const
Accessor to the number of HLT chains.
Definition: HLTMenu.cxx:35
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
TrigCompositeUtils::summaryPassNodeName
const std::string & summaryPassNodeName()
Definition: TrigCompositeUtilsRoot.cxx:916
TriggerBitsMakerTool::m_mapping
ChainToBitMap m_mapping
Mapping of each chain's hash ID to its chain counter.
Definition: TriggerBitsMakerTool.h:58
TrigCompositeUtils::isLegId
bool isLegId(const HLT::Identifier &legIdentifier)
Recognise whether the chain ID is a leg ID.
Definition: TrigCompositeUtilsRoot.cxx:204
TrigCompositeUtils::DecisionIDContainer
std::set< DecisionID > DecisionIDContainer
Definition: TrigComposite_v1.h:28
CaloCondBlobAlgs_fillNoiseFromASCII.hash
dictionary hash
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:109
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
DEBUG
#define DEBUG
Definition: page_access.h:11
TrigCompositeUtils::decisionIDs
void decisionIDs(const Decision *d, DecisionIDContainer &destination)
Extracts DecisionIDs stored in the Decision object.
Definition: TrigCompositeUtilsRoot.cxx:67
TrigCompositeUtils
Definition: Event/xAOD/xAODTrigger/xAODTrigger/TrigComposite.h:19
HLT::HLTResultMT::getHltPrescaledBits
const boost::dynamic_bitset< uint32_t > & getHltPrescaledBits() const
Const-getter for HLT prescaled bits.
Definition: HLTResultMT.cxx:95
HLT::HLTResultMT::getHltBitsAsWords
const std::vector< uint32_t > & getHltBitsAsWords() const
Const-getter for HLT bits as uint32_t array. Ordering: PassRaw, Prescaled.
Definition: HLTResultMT.cxx:100
python.IoTestsLib.w
def w
Definition: IoTestsLib.py:200
TrigConf::Chain
HLT chain configuration.
Definition: TrigConfData/TrigConfData/HLTChain.h:18
checkFileSG.words
words
Definition: checkFileSG.py:76
TriggerBitsMakerTool::m_largestBit
uint32_t m_largestBit
Largest chain counter hence largest bit needed to be stored in result bitmap.
Definition: TriggerBitsMakerTool.h:60
HLT::HLTResultMT::getHltPassRawBits
const boost::dynamic_bitset< uint32_t > & getHltPassRawBits() const
Const-getter for HLT pass raw bits.
Definition: HLTResultMT.cxx:90