11#include <boost/algorithm/string.hpp>
17 const std::string& name,
18 const IInterface* parent )
30 return StatusCode::SUCCESS;
35 ATH_MSG_INFO(
"Updating CTP bits decoding configuration");
44 if( l1menu.isValid() ) {
52 auto addIfItemExists = [&](
const std::string& itemName,
HLT::Identifier id,
bool warningOnly = false ) -> StatusCode {
55 return StatusCode::SUCCESS;
59 ATH_MSG_WARNING(itemName <<
" used to seed the chain " <<
id <<
" not in the configuration ");
60 return StatusCode::SUCCESS;
62 ATH_MSG_ERROR(itemName <<
" used to seed the chain " <<
id <<
" not in the configuration ");
63 return StatusCode::FAILURE;
70 if ( chain.l1item().empty() ) {
72 }
else if ( chain.l1item().find(
',') != std::string::npos ) {
74 std::vector<std::string> items;
75 boost::split(items, chain.l1item(), [](
char c){return c ==
',';});
76 for (
const std::string& i: items ) {
77 ATH_CHECK( addIfItemExists( i, chainID,
true ) );
80 ATH_CHECK( addIfItemExists( chain.l1item(), chainID ) );
85 for (
auto chain: ctpIDtoChain.second ) {
86 ATH_MSG_DEBUG(
"CTP seed of " << ctpIDtoChain.first <<
" enables chains " << chain );
90 return StatusCode::SUCCESS;
98 std::vector<uint32_t> ctpBits;
105 return StatusCode::FAILURE;
109 ctpBits =
m_useTBPBit ? ctpRes->getTBPWords() : ctpRes->getTAVWords();
116 ctpBits.reserve(rois.size());
119 std::transform(rois.begin(), rois.end(), std::back_inserter(ctpBits), [](
const ROIB::CTPRoI& roi){ return roi.roIWord(); });
122 const size_t bitsSize = ctpBits.size();
123 constexpr static size_t wordSize{32};
125 for (
size_t wordCounter = 0; wordCounter < bitsSize; ++wordCounter ) {
126 for (
size_t bitCounter = 0; bitCounter < wordSize; ++bitCounter ) {
127 const size_t ctpIndex = wordSize*wordCounter + bitCounter;
128 const bool decision = ( ctpBits[wordCounter] & ((uint32_t)1 << bitCounter) ) > 0;
133 ATH_MSG_DEBUG(
"L1 item " << ctpIndex <<
" active, enabling chains "
134 << (
m_forceEnable ?
" due to the forceEnable flag" :
" due to the seed"));
139 enabledChains.insert( enabledChains.end(), itr->second.begin(), itr->second.end() );
147 enabledChains.insert( enabledChains.end(), itr->second.begin(), itr->second.end());
150 nChains = enabledChains.size();
151 for (
auto chain: enabledChains ) {
155 ATH_MSG_ERROR(
"All CTP bits were disabled, this event should not have shown here" );
156 return StatusCode::FAILURE;
159 return StatusCode::SUCCESS;
164 const std::vector<std::string>& l1ItemNames,
171 for (
const std::string& l1name : l1ItemNames) {
175 const size_t bitCounter = ctpId % 32;
176 const size_t wordCounter = ctpId / 32;
178 const bool decision = (ctpBits[wordCounter].roIWord() & ((uint32_t)1 << bitCounter)) > 0;
180 pass = (pass || decision);
182 catch (
const std::exception& e) {
184 return StatusCode::FAILURE;
188 return StatusCode::SUCCESS;
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
Header file to be included by clients of the Monitored infrastructure.
Group of local monitoring quantities and retain correlation when filling histograms
Declare a monitored scalar variable.
const std::vector< CTPRoI > TBP() const
get trigger result before prescale
const std::vector< CTPRoI > TAV() const
get trigger result after veto
ROIB::CTPRoI contains a RoI delivered by the CTP.
Class holding the LVL1 RoIB result build by the RoIBuilder.
const CTPResult & cTPResult() const
Gets the CTP part of the L1 RDO.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
L1 threshold configuration.
It used to be useful piece of code for replacing actual SG with other store of similar functionality ...
std::vector< HLT::Identifier > IDVec
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())