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;
92 return createChainGroup(triggerNames, {}, props);
99 std::lock_guard<std::recursive_mutex> lock(m_cgmMutex);
100 return m_chainGroupsRef.size();
105 chainGroup.
update(m_confChains, m_confItems, props);
111 std::lock_guard<std::recursive_mutex> lock(m_cgmMutex);
114 m_confChains = confChains;
117 "not attempt accessing HLT too" );
118 m_confItems =
nullptr;
121 m_confItems = &(
ctp->menu().items());
126 m_itemsCache.clear();
128 const std::vector<float>&
prescales =
ctp->prescaleSet().prescales_float();
129 for(
auto item :
ctp->menu().items() ) {
130 const auto ctpid =
item->ctpId();
131 m_itemsCache.try_emplace(ctpid,
139 m_l2chainsCache.clear();
140 m_efchainsCache.clear();
141 m_mConfChains.clear();
143 if ( ! confChains ) {
147 ATH_MSG_DEBUG(
"Updating Configuration chains. Number of conf chains: " << m_confChains->size());
150 for(
auto ch : *m_confChains) {
151 m_mConfChains[
ch->chain_name()] =
ch;
155 for(
auto ch : *m_confChains) {
157 int cntr =
ch->chain_counter();
158 if(
ch->level()==
"L2" ) {
159 m_l2chainsCache.emplace(cntr,
ch);
161 m_efchainsCache.emplace(cntr,
ch);
164 ATH_MSG_DEBUG(
"Updating configuration, done with basic HLT based on "
165 << m_confChains->size() <<
" configuration chains" );
173 for(
auto ch : *m_confChains) {
174 if ((
ch->level() ==
"EF" ||
ch->level() ==
"HLT") && !
ch->streams().empty() ) {
178 m_streams[
stream->stream()].push_back(
ch->chain_name());
182 if ( (
ch->level() ==
"EF" ||
ch->level() ==
"HLT") && !
ch->groups().empty() ) {
184 for(
auto&
group :
ch->groups()) {
186 m_groups[
group].push_back(
ch->chain_name());
194 for (
auto& [
key,
group] : m_chainGroups) {
195 updateChainGroup(
group);
202 std::lock_guard<std::recursive_mutex> lock(m_cgmMutex);
203 auto i = m_efchainsByName.find(
name);
204 if (
i != m_efchainsByName.end()) {
207 i = m_l2chainsByName.find(
name);
208 if (
i != m_l2chainsByName.end() ) {
219 ChainHashMap_t::const_iterator
f = m_mConfChains.find(
name);
220 if (
f == m_mConfChains.end() ){
229 return m_name ==
it->name();
235 TrigConf::ItemContainer::const_iterator
f = find_if(m_confItems->begin(), m_confItems->end(),
itemByName(
name));
236 if (
f == m_confItems->end() )
244 if ( m_itemsCache.count(ctpid) == 0 ) {
246 <<
" is not present in the configuration" );
249 return m_itemsCache.find(ctpid)->second.prescaleFactor();
253 return item(
i.name());
261 if ( m_itemsByName.find(
name) != m_itemsByName.end())
262 return m_itemsByName.find(
name)->second;
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;
273 #ifndef XAOD_ANALYSIS // Full Athena
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");
288 if (!m_decisionKeyPtr->empty()) {
290 contains_xAOD_decision = decisionReadHandle.
isValid();
293 #ifndef XAOD_ANALYSIS // Full Athena
295 if (!m_oldDecisionKeyPtr->empty()) {
297 contains_decision = oldDecisionReadHandle.
isValid();
298 if (contains_decision) {
303 if (!m_oldEventInfoKeyPtr->empty()) {
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");
327 m_unpacker = std::make_unique<DecisionUnpackerStandalone>(m_decisionKeyPtr, m_run2NavigationKeyPtr);
335 std::stringstream
extra;
336 #ifndef XAOD_ANALYSIS // Full Athena
337 extra <<
". Looked for old TrigDec::TrigDecision? "
338 << (m_oldDecisionKeyPtr->empty() ?
"NO" :
"YES")
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? "
344 << (m_oldEventInfoKeyPtr->empty() ?
"NO" :
"YES")
345 <<
", has old EventInto? "
346 << (contains_old_event_info ?
"YES" :
"NO");
349 <<
"(Looked for xAOD::TrigDecision? "
350 << (m_decisionKeyPtr->empty() ?
"NO" :
"YES")
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.");
358 if( !m_decisionUnpacked ) {
361 if( nc_this->unpackDecision(context).isFailure() ) {
373 m_decisionUnpacked =
false;
374 m_navigationUnpacked =
false;
381 m_decisionUnpacked =
true;
382 m_deleteAtEndOfEvent.clear();
384 bool unpackHLT = ( m_confChains != nullptr );
385 ATH_CHECK( m_unpacker->unpackDecision( ctx, m_itemsByName, m_itemsCache,
386 m_l2chainsByName, m_l2chainsCache,
387 m_efchainsByName, m_efchainsCache,
388 m_bgCode, unpackHLT ) );
389 return StatusCode::SUCCESS;
394 std::lock_guard<std::recursive_mutex> lock(m_cgmMutex);
396 m_navigationUnpacked =
true;
401 if( m_confChains ==
nullptr ) {
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;