21#include <unordered_map>
47#ifndef XAOD_STANDALONE
55 const std::string& alias,
58 std::lock_guard<std::recursive_mutex> lock(
m_cgmMutex);
64 auto [itr, inserted] = m_chainGroups.try_emplace (key, key, *nc_this);
66 nc_this->updateChainGroup(itr->second, props);
67 m_chainGroupsRef[key] = &(itr->second);
72 auto [alias_itr, alias_inserted] = m_chainGroupsRef.try_emplace (key_alias, &m_chainGroups.at(key));
73 if (!alias_inserted && alias_itr->second!=m_chainGroupsRef[key]) {
74 throw std::runtime_error(
"TrigDecisionTool: The alias "+alias+
75 " already exists and cannot be overwritten.");
79 return m_chainGroupsRef[key];
86 std::lock_guard<std::recursive_mutex> lock(
m_cgmMutex);
87 auto searchRes = m_chainGroupsRef.find(triggerNames);
89 if ( searchRes != m_chainGroupsRef.end()) {
90 return searchRes->second;
99 std::lock_guard<std::recursive_mutex> lock(
m_cgmMutex);
100 return m_chainGroupsRef.size();
111 std::lock_guard<std::recursive_mutex> lock(
m_cgmMutex);
117 "not attempt accessing HLT too" );
128 const std::vector<float>& prescales = ctp->prescaleSet().prescales_float();
129 for(
auto item : ctp->menu().items() ) {
130 const auto ctpid =
item->ctpId();
133 0, 0, 0, prescales[ctpid]);
143 if ( ! confChains ) {
157 int cntr = ch->chain_counter();
158 if( ch->level()==
"L2" ) {
164 ATH_MSG_DEBUG(
"Updating configuration, done with basic HLT based on "
174 if (( ch->level() ==
"EF" || ch->level() ==
"HLT") && !ch->streams().empty() ) {
175 ATH_MSG_DEBUG(
"Stream: " << ch->chain_name() <<
" " << ch->streams().size() );
176 for(
auto stream : ch->streams()) {
178 m_streams[stream->stream()].push_back(ch->chain_name());
182 if ( ( ch->level() ==
"EF" || ch->level() ==
"HLT") && !ch->groups().empty() ) {
183 ATH_MSG_DEBUG(
"Groups: " << ch->chain_name() <<
" " << ch->groups().size() );
184 for(
auto& group : ch->groups()) {
186 m_groups[group].push_back(ch->chain_name());
194 for (
auto& [key, group] : m_chainGroups) {
202 std::lock_guard<std::recursive_mutex> lock(
m_cgmMutex);
215 return chain(ch.chain_name());
229 return m_name == it->name();
246 <<
" is not present in the configuration" );
249 return m_itemsCache.find(ctpid)->second.prescaleFactor();
253 return item(i.name());
267 std::lock_guard<std::recursive_mutex> lock(
m_cgmMutex);
268 ATH_MSG_VERBOSE(
"asserting decision with unpacker " << m_unpacker.get());
271 bool contains_xAOD_decision =
false;
274 bool is_l1result_configured =
false;
275 bool contains_decision =
false;
276 bool contains_old_event_info =
false;
279 const EventContext& context = Gaudi::Hive::currentContext();
281 ATH_MSG_INFO(
"decision not set on first (?) assert. deciding how to unpack");
290 contains_xAOD_decision = decisionReadHandle.
isValid();
297 contains_decision = oldDecisionReadHandle.
isValid();
298 if (contains_decision) {
299 is_l1result_configured = oldDecisionReadHandle->getL1Result().isConfigured();
305 contains_old_event_info = oldEventInfoHandle.
isValid();
310 if ( contains_xAOD_decision ){
311 ATH_MSG_INFO(
"SG contains xAOD decision, use DecisionUnpackerStandalone");
312 m_unpacker = std::make_unique<DecisionUnpackerStandalone>
316 else if( is_l1result_configured ){
317 ATH_MSG_INFO(
"SG contains AOD decision, use DecisionUnpackerAthena");
320 else if (contains_old_event_info) {
321 ATH_MSG_INFO(
"SG contains NO(!) L1Result in the AOD TrigDecision, assuming also no HLTResult. Read from EventInfo");
325 if ( contains_xAOD_decision ){
326 ATH_MSG_INFO(
"SG contains xAOD decision, use DecisionUnpackerStandalone");
335 std::stringstream extra;
337 extra <<
". Looked for old TrigDec::TrigDecision? "
339 <<
", has TrigDec::TrigDecision? "
340 << (contains_decision ?
"YES" :
"NO")
341 <<
", TrigDec::TrigDecision has L1? "
342 << (is_l1result_configured ?
"YES" :
"NO")
343 <<
". Looked for old EventInfo? "
345 <<
", has old EventInto? "
346 << (contains_old_event_info ?
"YES" :
"NO");
349 <<
"(Looked for xAOD::TrigDecision? "
351 <<
", has xAOD::TrigDecision? "
352 << (contains_xAOD_decision ?
"YES" :
"NO")
354 <<
". Check UseRun1DecisionFormat and UseOldEventInfoDecisionFormat flags if reading pre-xAOD or BS input).");
355 throw std::runtime_error(
"Trig::CacheGlobalMemory::assert_decision(): No source of Trigger Decision in file.");
361 if( nc_this->unpackDecision(context).isFailure() ) {
382 m_deleteAtEndOfEvent.clear();
389 return StatusCode::SUCCESS;
394 std::lock_guard<std::recursive_mutex> lock(
m_cgmMutex);
402 return StatusCode::SUCCESS;
407 const EventContext& context = Gaudi::Hive::currentContext();
408 if( ! m_unpacker->unpackNavigation( context,
m_navigation ).isSuccess() ) {
409 [[maybe_unused]]
static std::atomic<bool> warningPrinted =
414 return StatusCode::SUCCESS;
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
Helper for getting a const version of a pointer.
Define macros for attributes used to control the static checker.
This class represents one chain of signatures, i.e.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
list of all HLT chains in a trigger menu
HLT chain configuration information.
char m_bgCode
the encoded bunchgroup information
std::recursive_mutex m_cgmMutex
R3 MT protection only against –threads > 1.
std::unordered_map< std::string, const HLT::Chain * > m_efchainsByName
L2 chains keyed by chain name (chainging every event)
size_t nChainGroups() const
StatusCode unpackNavigation()
unpacks HLT navigation structure (object access)
std::map< CTPID, LVL1CTP::Lvl1Item > m_itemsCache
cache of all CTP items possible (given configuration)
ChainHashMap_t m_mConfChains
map of conf chains
const LVL1CTP::Lvl1Item * item(const std::string &name) const
CTP item from given name.
SG::ReadHandleKey< TrigDec::TrigDecision > * m_oldDecisionKeyPtr
Parent TDT's read handle key.
bool m_decisionUnpacked
Was decision unpacked for this event?
const TrigConf::HLTChain * config_chain(const std::string &name) const
HLT config chain from given name.
bool assert_decision() const
checks if new event arrived with the decision Need to use before any call to CacheGlobalMemory.
const Trig::ChainGroup * getChainGroup(const std::vector< std::string > &triggerNames, TrigDefs::Group props) const
std::unordered_map< std::string, const HLT::Chain * > m_l2chainsByName
L2 chains keyed by chain name (chainging every event)
const HLT::Chain * chain(const std::string &name) const
HLT chain object from given name (0 pointer returned if no match)
const TrigConf::ItemContainer * m_confItems
items configuration
const Trig::ChainGroup * createChainGroup(const std::vector< std::string > &patterns, const std::string &alias="", TrigDefs::Group props=TrigDefs::Group::Default) const
creates new chain group
bool m_navigationUnpacked
Was navigation unpacked for this event?
void updateChainGroup(Trig::ChainGroup &chainGroup, TrigDefs::Group props=TrigDefs::Group::Default)
unpacks everything that belongs to a ChainGroup
std::map< CHAIN_COUNTER, HLT::Chain > m_efchainsCache
cache of all EF chains possible (given configuration)
StatusCode unpackDecision(const EventContext &ctx)
unpacks whole trigger decision for the event
const TrigConf::HLTChainList * m_confChains
all chains configuration
std::map< std::string, std::vector< std::string > > m_groups
mapping from group to list of chains
std::map< std::string, std::vector< std::string > > m_streams
mapping from stream to list of chains
SG::ReadHandleKey< xAOD::TrigDecision > * m_decisionKeyPtr
Parent TDT's read handle key.
const TrigConf::TriggerItem * config_item(const std::string &name) const
CTP config item from given name.
HLT::TrigNavStructure * m_navigation
Navigation owned by CGM.
void update(const TrigConf::HLTChainList *confChains, const TrigConf::CTPConfig *ctp)
Updates configuration of the chain groups (i.e.
SG::ReadHandleKey< xAOD::TrigNavigation > * m_run2NavigationKeyPtr
Parent TDT's read handle key.
std::unique_ptr< IDecisionUnpacker > m_unpacker ATLAS_THREAD_SAFE
Trigger decision unpacker helper.
std::map< CHAIN_COUNTER, HLT::Chain > m_l2chainsCache
cache of all L2 chains possible (given configuration)
float item_prescale(int ctpid) const
Prescale for CPT item.
std::unordered_map< std::string, const LVL1CTP::Lvl1Item * > m_itemsByName
items keyed by configuration name (chainging every event)
SG::ReadHandleKey< EventInfo > * m_oldEventInfoKeyPtr
Parent TDT's read handle key.
void reset_decision()
invalidate previously unpacked decision Needs to be called at the start of a new event.
void update(const TrigConf::HLTChainList *confChains, const TrigConf::ItemContainer *confItems, TrigDefs::Group prop=TrigDefs::Group::Default)
const T * as_const_ptr(const T *p)
Helper for getting a const version of a pointer.
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Group
Properties of a chain group.
std::vector< std::string > convertStringToVector(const std::string &triggerNames)
makes a split of list of chains into the vector of chains
std::vector< std::string > keyWrap(const std::vector< std::string > &triggerNames)
normalizes the list of triggers (patterns) by sorting and uniquing them
itemByName(const std::string &name)
const std::string & m_name