ATLAS Offline Software
Classes | Public Member Functions | Private Types | Private Member Functions | Private Attributes | Friends | List of all members
Trig::CacheGlobalMemory Class Reference

#include <CacheGlobalMemory.h>

Inheritance diagram for Trig::CacheGlobalMemory:
Collaboration diagram for Trig::CacheGlobalMemory:

Classes

class  AnyTypeDeleter
 

Public Member Functions

 CacheGlobalMemory ()=default
 
 ~CacheGlobalMemory ()=default
 
const Trig::ChainGroupcreateChainGroup (const std::vector< std::string > &patterns, const std::string &alias="", TrigDefs::Group props=TrigDefs::Group::Default) const
 creates new chain group More...
 
void update (const TrigConf::HLTChainList *confChains, const TrigConf::CTPConfig *ctp)
 Updates configuration of the chain groups (i.e. More...
 
const LVL1CTP::Lvl1Itemitem (const std::string &name) const
 CTP item from given name. More...
 
const LVL1CTP::Lvl1Itemitem (const TrigConf::TriggerItem &i) const
 CTP item from given config item. More...
 
const TrigConf::TriggerItemconfig_item (const std::string &name) const
 CTP config item from given name. More...
 
float item_prescale (int ctpid) const
 Prescale for CPT item. More...
 
const HLT::Chainchain (const std::string &name) const
 HLT chain object from given name (0 pointer returned if no match) More...
 
const HLT::Chainchain (const TrigConf::HLTChain &chIt) const
 HLT chain object from given config chain. More...
 
const TrigConf::HLTChainconfig_chain (const std::string &name) const
 HLT config chain from given name. More...
 
const HLT::TrigNavStructurenavigation () const
 
void navigation (HLT::TrigNavStructure *nav)
 sets navigation object pointer More...
 
const Trig::ChainGroupgetChainGroup (const std::vector< std::string > &triggerNames, TrigDefs::Group props) const
 
size_t nChainGroups () const
 
const std::map< std::string, std::vector< std::string > > & getStreams () const
 
bool assert_decision () const
 checks if new event arrived with the decision Need to use before any call to CacheGlobalMemory. More...
 
void reset_decision ()
 invalidate previously unpacked decision Needs to be called at the start of a new event. More...
 
void setStore (asg::EventStoreType *store)
 Set the event store to be used by the object. More...
 
const asg::EventStoreTypestore () const
 Get the event store that the object is using. More...
 
void setDecisionKeyPtr (SG::ReadHandleKey< xAOD::TrigDecision > *k)
 
void setRun2NavigationKeyPtr (SG::ReadHandleKey< xAOD::TrigNavigation > *k)
 
void setRun3NavigationKeyPtr (SG::ReadHandleKey< TrigCompositeUtils::DecisionContainer > *k)
 
const SG::ReadHandleKey< TrigCompositeUtils::DecisionContainer > & getRun3NavigationKey () const
 
const SG::ReadHandleKey< TrigCompositeUtils::DecisionContainer > * getRun3NavigationKeyPtr () const
 
void setOldDecisionKeyPtr (SG::ReadHandleKey< TrigDec::TrigDecision > *k)
 
void setOldEventInfoKeyPtr (SG::ReadHandleKey< EventInfo > *k)
 
const SG::ReadHandleKey< xAOD::TrigDecision > * xAODTrigDecisionKey () const
 
template<class T >
void deleteAtTheEndOfEvent (T t) const
 
MsgStream & msg () const
 
MsgStream & msg (const MSG::Level lvl) const
 
bool msgLvl (const MSG::Level lvl) const
 

Private Types

typedef unsigned CTPID
 
typedef unsigned CHAIN_COUNTER
 
typedef std::unordered_map< std::string, const TrigConf::HLTChain * > ChainHashMap_t
 

Private Member Functions

StatusCode unpackDecision (const EventContext &ctx)
 unpacks whole trigger decision for the event More...
 
StatusCode unpackNavigation ()
 unpacks HLT navigation structure (object access) More...
 
void updateChainGroup (Trig::ChainGroup &chainGroup, TrigDefs::Group props=TrigDefs::Group::Default)
 unpacks everything that belongs to a ChainGroup More...
 

Private Attributes

const asg::EventStoreTypem_store {nullptr}
 Pointer to the event store in use. More...
 
std::unique_ptr< IDecisionUnpacker > m_unpacker ATLAS_THREAD_SAFE
 Trigger decision unpacker helper. More...
 
bool m_decisionUnpacked {false}
 Was decision unpacked for this event? More...
 
bool m_navigationUnpacked {false}
 Was navigation unpacked for this event? More...
 
HLT::TrigNavStructurem_navigation {nullptr}
 Navigation owned by CGM. More...
 
std::map< std::vector< std::string >, Trig::ChainGroup > m_chainGroups ATLAS_THREAD_SAFE
 primary storage for chain groups More...
 
std::map< std::vector< std::string >, Trig::ChainGroup * > m_chainGroupsRef ATLAS_THREAD_SAFE
 this map keeps the chain group more than once i.e. More...
 
std::unordered_map< std::string, const LVL1CTP::Lvl1Item * > m_itemsByName
 items keyed by configuration name (chainging every event) More...
 
std::unordered_map< std::string, const HLT::Chain * > m_l2chainsByName
 L2 chains keyed by chain name (chainging every event) More...
 
std::unordered_map< std::string, const HLT::Chain * > m_efchainsByName
 L2 chains keyed by chain name (chainging every event) More...
 
std::map< CTPID, LVL1CTP::Lvl1Itemm_itemsCache
 cache of all CTP items possible (given configuration) More...
 
std::map< CHAIN_COUNTER, HLT::Chainm_l2chainsCache
 cache of all L2 chains possible (given configuration) More...
 
std::map< CHAIN_COUNTER, HLT::Chainm_efchainsCache
 cache of all EF chains possible (given configuration) More...
 
std::map< std::string, std::vector< std::string > > m_groups
 mapping from group to list of chains More...
 
std::map< std::string, std::vector< std::string > > m_streams
 mapping from stream to list of chains More...
 
const TrigConf::ItemContainerm_confItems {nullptr}
 items configuration More...
 
const TrigConf::HLTChainListm_confChains {nullptr}
 all chains configuration More...
 
SG::ReadHandleKey< xAOD::TrigDecision > * m_decisionKeyPtr {nullptr}
 Parent TDT's read handle key. More...
 
SG::ReadHandleKey< TrigDec::TrigDecision > * m_oldDecisionKeyPtr {nullptr}
 Parent TDT's read handle key. More...
 
SG::ReadHandleKey< EventInfo > * m_oldEventInfoKeyPtr {nullptr}
 Parent TDT's read handle key. More...
 
SG::ReadHandleKey< xAOD::TrigNavigation > * m_run2NavigationKeyPtr {nullptr}
 Parent TDT's read handle key. More...
 
SG::ReadHandleKey< TrigCompositeUtils::DecisionContainer > * m_run3NavigationKeyPtr {nullptr}
 Parent TDT's read handle key. More...
 
ChainHashMap_t m_mConfChains
 map of conf chains More...
 
char m_bgCode {0}
 the encoded bunchgroup information More...
 
AnyTypeDeleter m_deleteAtEndOfEvent ATLAS_THREAD_SAFE
 
std::recursive_mutex m_cgmMutex
 R3 MT protection only against –threads > 1. More...
 

Friends

class DecisionAccess
 

Detailed Description

Definition at line 67 of file CacheGlobalMemory.h.

Member Typedef Documentation

◆ CHAIN_COUNTER

typedef unsigned Trig::CacheGlobalMemory::CHAIN_COUNTER
private

Definition at line 204 of file CacheGlobalMemory.h.

◆ ChainHashMap_t

typedef std::unordered_map<std::string, const TrigConf::HLTChain*> Trig::CacheGlobalMemory::ChainHashMap_t
private

Definition at line 225 of file CacheGlobalMemory.h.

◆ CTPID

typedef unsigned Trig::CacheGlobalMemory::CTPID
private

Definition at line 203 of file CacheGlobalMemory.h.

Constructor & Destructor Documentation

◆ CacheGlobalMemory()

Trig::CacheGlobalMemory::CacheGlobalMemory ( )
default

◆ ~CacheGlobalMemory()

Trig::CacheGlobalMemory::~CacheGlobalMemory ( )
default

Member Function Documentation

◆ assert_decision()

bool Trig::CacheGlobalMemory::assert_decision ( ) const

checks if new event arrived with the decision Need to use before any call to CacheGlobalMemory.

It is marked const since it is frequently called from const methods and is internally locked.

Returns
true if all went fine about decision, false otherwise

Definition at line 266 of file CacheGlobalMemory.cxx.

266  {
267  std::lock_guard<std::recursive_mutex> lock(m_cgmMutex);
268  ATH_MSG_VERBOSE("asserting decision with unpacker " << m_unpacker.get());
269 
270  // here we unpack the decision. Note: the navigation will be unpacked only on demand (see navigation())
271  bool contains_xAOD_decision = false;
272 
273 #ifndef XAOD_ANALYSIS // Full Athena
274  bool is_l1result_configured = false;
275  bool contains_decision = false;
276  bool contains_old_event_info = false;
277 #endif
278 
279  const EventContext& context = Gaudi::Hive::currentContext();
280  if(!m_unpacker){
281  ATH_MSG_INFO("decision not set on first (?) assert. deciding how to unpack");
282 
283  //Lukas 26-06-2015: we're hard coding the configuration for now
284  //but we have setters and getters for m_trigDecisionKey (as CGM datamemer)
285  //so we could in the future use the ones set by the python configuration
286  //we're hardcoding in order not to require python configuration changes
287 
288  if (!m_decisionKeyPtr->empty()) {
290  contains_xAOD_decision = decisionReadHandle.isValid();
291  }
292 
293 #ifndef XAOD_ANALYSIS // Full Athena
294 
295  if (!m_oldDecisionKeyPtr->empty()) {
297  contains_decision = oldDecisionReadHandle.isValid();
298  if (contains_decision) {
299  is_l1result_configured = oldDecisionReadHandle->getL1Result().isConfigured();
300  }
301  }
302 
303  if (!m_oldEventInfoKeyPtr->empty()) {
304  SG::ReadHandle<EventInfo> oldEventInfoHandle = SG::makeHandle(*m_oldEventInfoKeyPtr, context);
305  contains_old_event_info = oldEventInfoHandle.isValid();
306  }
307 
308  // January 2020: Note, switched the order here. DecisionUnpackerStandalone is given preference
309  // over DecisionUnpackerAthena
310  if ( contains_xAOD_decision ){
311  ATH_MSG_INFO("SG contains xAOD decision, use DecisionUnpackerStandalone");
312  m_unpacker = std::make_unique<DecisionUnpackerStandalone>
315  }
316  else if( is_l1result_configured ){
317  ATH_MSG_INFO("SG contains AOD decision, use DecisionUnpackerAthena");
318  m_unpacker = std::make_unique<DecisionUnpackerAthena>(CxxUtils::as_const_ptr(m_oldDecisionKeyPtr));
319  }
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");
322  m_unpacker = std::make_unique<DecisionUnpackerEventInfo>(CxxUtils::as_const_ptr(m_oldEventInfoKeyPtr));
323  }
324 #else
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);
328  }
329 #endif
330 
331  }//if(!m_unpacker)
332 
333  // cppcheck-suppress duplicateCondition
334  if(!m_unpacker){
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");
347 #endif
348  ATH_MSG_ERROR("No source of Trigger Decision in file. "
349  << "(Looked for xAOD::TrigDecision? "
350  << (m_decisionKeyPtr->empty() ? "NO" : "YES")
351  << ", has xAOD::TrigDecision? "
352  << (contains_xAOD_decision ? "YES" : "NO")
353  << extra.str()
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.");
356  }
357 
358  if( !m_decisionUnpacked ) {
359  // this method is locked
360  auto nc_this ATLAS_THREAD_SAFE = const_cast<Trig::CacheGlobalMemory*>(this);
361  if( nc_this->unpackDecision(context).isFailure() ) {
362  ATH_MSG_WARNING( "TrigDecion object incorrect (for chains)" );
363  }
364  else{
365  ATH_MSG_VERBOSE("unpacked decision");
366  }
367  }
368 
369  return true;
370 }

◆ chain() [1/2]

const HLT::Chain * Trig::CacheGlobalMemory::chain ( const std::string &  name) const

HLT chain object from given name (0 pointer returned if no match)

Definition at line 201 of file CacheGlobalMemory.cxx.

201  {
202  std::lock_guard<std::recursive_mutex> lock(m_cgmMutex);
203  auto i = m_efchainsByName.find(name);
204  if (i != m_efchainsByName.end()) {
205  return i->second;
206  }
207  i = m_l2chainsByName.find(name);
208  if ( i != m_l2chainsByName.end() ) {
209  return i->second;
210  }
211  return nullptr;
212 }

◆ chain() [2/2]

const HLT::Chain * Trig::CacheGlobalMemory::chain ( const TrigConf::HLTChain chIt) const

HLT chain object from given config chain.

Definition at line 214 of file CacheGlobalMemory.cxx.

214  {
215  return chain(ch.chain_name());
216 }

◆ config_chain()

const TrigConf::HLTChain * Trig::CacheGlobalMemory::config_chain ( const std::string &  name) const

HLT config chain from given name.

Definition at line 218 of file CacheGlobalMemory.cxx.

218  {
219  ChainHashMap_t::const_iterator f = m_mConfChains.find(name);
220  if ( f == m_mConfChains.end() ){
221  return nullptr;
222  }
223  return f->second;
224 }

◆ config_item()

const TrigConf::TriggerItem * Trig::CacheGlobalMemory::config_item ( const std::string &  name) const

CTP config item from given name.

Definition at line 234 of file CacheGlobalMemory.cxx.

234  {
235  TrigConf::ItemContainer::const_iterator f = find_if(m_confItems->begin(), m_confItems->end(), itemByName(name));
236  if ( f == m_confItems->end() )
237  return nullptr;
238  return *f;
239 }

◆ createChainGroup()

const Trig::ChainGroup * Trig::CacheGlobalMemory::createChainGroup ( const std::vector< std::string > &  patterns,
const std::string &  alias = "",
TrigDefs::Group  props = TrigDefs::Group::Default 
) const

creates new chain group

Parameters
patternslist of patterns i.e. regexes, if chain groups already exists it is just given back The chain group is considered to exist if the patterns are the same. Patterns are stored and made unique i.e. "EF_mu4", "EF_mu6" is the same as "EF_mu6", "EF_mu4". It is not the same though as "EF_mu.*" even if in particular case that would mean the same 2 chains.
aliasis the short human readable name for the triggers which are in the group i.e. myMuons
propsare additional properties for the chain group creation (e.g. disable regex parsing)

Definition at line 54 of file CacheGlobalMemory.cxx.

56  {
57  // mutex in case this is called directly
58  std::lock_guard<std::recursive_mutex> lock(m_cgmMutex);
59  auto nc_this ATLAS_THREAD_SAFE = const_cast<Trig::CacheGlobalMemory*>(this);
60 
61  // create a proper key
62  std::vector< std::string > key=Trig::keyWrap(triggerNames);
63 
64  auto [itr, inserted] = m_chainGroups.try_emplace (key, /*ChainGroup*/ key, *nc_this);
65  if (inserted) {
66  nc_this->updateChainGroup(itr->second, props);
67  m_chainGroupsRef[key] = &(itr->second);
68  }
69  // this overwrites the pointer in the map each time in case the alias needs defining
70  if (!alias.empty()) {
71  std::vector< std::string > key_alias=Trig::keyWrap(Trig::convertStringToVector(alias));
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.");
76  }
77  }
78 
79  return m_chainGroupsRef[key];
80 }

◆ deleteAtTheEndOfEvent()

template<class T >
void Trig::CacheGlobalMemory::deleteAtTheEndOfEvent ( t) const
inline

Definition at line 156 of file CacheGlobalMemory.h.

156 { m_deleteAtEndOfEvent.insert(t); }

◆ getChainGroup()

const Trig::ChainGroup * Trig::CacheGlobalMemory::getChainGroup ( const std::vector< std::string > &  triggerNames,
TrigDefs::Group  props 
) const

Definition at line 83 of file CacheGlobalMemory.cxx.

85 {
86  std::lock_guard<std::recursive_mutex> lock(m_cgmMutex);
87  auto searchRes = m_chainGroupsRef.find(triggerNames);
88 
89  if ( searchRes != m_chainGroupsRef.end()) {
90  return searchRes->second;
91  }
92  return createChainGroup(triggerNames, /*alias*/{}, props);
93 }

◆ getRun3NavigationKey()

const SG::ReadHandleKey<TrigCompositeUtils::DecisionContainer>& Trig::CacheGlobalMemory::getRun3NavigationKey ( ) const
inline

Definition at line 144 of file CacheGlobalMemory.h.

144 { return *m_run3NavigationKeyPtr; }

◆ getRun3NavigationKeyPtr()

const SG::ReadHandleKey<TrigCompositeUtils::DecisionContainer>* Trig::CacheGlobalMemory::getRun3NavigationKeyPtr ( ) const
inline

Definition at line 145 of file CacheGlobalMemory.h.

145 { return m_run3NavigationKeyPtr; }

◆ getStreams()

const std::map<std::string, std::vector<std::string> >& Trig::CacheGlobalMemory::getStreams ( ) const
inline

Definition at line 119 of file CacheGlobalMemory.h.

119 {return m_streams;};

◆ item() [1/2]

const LVL1CTP::Lvl1Item * Trig::CacheGlobalMemory::item ( const std::string &  name) const

CTP item from given name.

Definition at line 260 of file CacheGlobalMemory.cxx.

260  {
261  if ( m_itemsByName.find(name) != m_itemsByName.end())
262  return m_itemsByName.find(name)->second;
263  return nullptr;
264 }

◆ item() [2/2]

const LVL1CTP::Lvl1Item * Trig::CacheGlobalMemory::item ( const TrigConf::TriggerItem i) const

CTP item from given config item.

Definition at line 252 of file CacheGlobalMemory.cxx.

252  {
253  return item(i.name());
254  // unsigned cntr = i.ctpId();
255  // if ( m_items.find(cntr) != m_items.end())
256  // return m_items.find(cntr)->second;
257  // return 0;
258 }

◆ item_prescale()

float Trig::CacheGlobalMemory::item_prescale ( int  ctpid) const

Prescale for CPT item.

Definition at line 241 of file CacheGlobalMemory.cxx.

241  {
242  // Cannot be locked (CacheGlobalMemory::update > createChainGroup > ChainGroup::update > calculatePrescale > L1Prescale > CacheGlobalMemory::item_prescale)
243  // find items in cache
244  if ( m_itemsCache.count(ctpid) == 0 ) {
245  ATH_MSG_ERROR( "item of CTP: " << ctpid
246  << " is not present in the configuration" );
247  return 0;
248  }
249  return m_itemsCache.find(ctpid)->second.prescaleFactor();
250 }

◆ msg() [1/2]

MsgStream& Trig::Logger::msg ( ) const
inlineinherited

Definition at line 29 of file Trigger/TrigAnalysis/TrigDecisionTool/TrigDecisionTool/Logger.h.

29  {
30  if (s_logger) return s_logger->msg();
31  else throw std::runtime_error("TrigDecisionTool Logger not initialized.");
32  }

◆ msg() [2/2]

MsgStream& Trig::Logger::msg ( const MSG::Level  lvl) const
inlineinherited

Definition at line 33 of file Trigger/TrigAnalysis/TrigDecisionTool/TrigDecisionTool/Logger.h.

33 { return msg() << lvl; }

◆ msgLvl()

bool Trig::Logger::msgLvl ( const MSG::Level  lvl) const
inlineinherited

Definition at line 34 of file Trigger/TrigAnalysis/TrigDecisionTool/TrigDecisionTool/Logger.h.

34 { return s_logger && s_logger->msgLvl(lvl); }

◆ navigation() [1/2]

const HLT::TrigNavStructure* Trig::CacheGlobalMemory::navigation ( ) const
inline

< gives back pointer to navigation object (unpacking if necessary)

Definition at line 104 of file CacheGlobalMemory.h.

104  {
106  // CGM is slot-specific and unpackNavigation is locked
107  auto cgm ATLAS_THREAD_SAFE = const_cast<CacheGlobalMemory*>(this);
108  if(cgm->unpackNavigation().isFailure()){
109  ATH_MSG_WARNING("unpack Navigation failed");
110  }
111  }
112  return m_navigation;
113  }

◆ navigation() [2/2]

void Trig::CacheGlobalMemory::navigation ( HLT::TrigNavStructure nav)
inline

sets navigation object pointer

Definition at line 114 of file CacheGlobalMemory.h.

◆ nChainGroups()

size_t Trig::CacheGlobalMemory::nChainGroups ( ) const

Definition at line 97 of file CacheGlobalMemory.cxx.

98 {
99  std::lock_guard<std::recursive_mutex> lock(m_cgmMutex);
100  return m_chainGroupsRef.size();
101 }

◆ reset_decision()

void Trig::CacheGlobalMemory::reset_decision ( )

invalidate previously unpacked decision Needs to be called at the start of a new event.

Definition at line 372 of file CacheGlobalMemory.cxx.

372  {
373  m_decisionUnpacked = false;
374  m_navigationUnpacked = false;
375 }

◆ setDecisionKeyPtr()

void Trig::CacheGlobalMemory::setDecisionKeyPtr ( SG::ReadHandleKey< xAOD::TrigDecision > *  k)
inline

Definition at line 141 of file CacheGlobalMemory.h.

141 { m_decisionKeyPtr = k; }

◆ setOldDecisionKeyPtr()

void Trig::CacheGlobalMemory::setOldDecisionKeyPtr ( SG::ReadHandleKey< TrigDec::TrigDecision > *  k)
inline

Definition at line 148 of file CacheGlobalMemory.h.

148 { m_oldDecisionKeyPtr = k; }

◆ setOldEventInfoKeyPtr()

void Trig::CacheGlobalMemory::setOldEventInfoKeyPtr ( SG::ReadHandleKey< EventInfo > *  k)
inline

Definition at line 149 of file CacheGlobalMemory.h.

149 { m_oldEventInfoKeyPtr = k; }

◆ setRun2NavigationKeyPtr()

void Trig::CacheGlobalMemory::setRun2NavigationKeyPtr ( SG::ReadHandleKey< xAOD::TrigNavigation > *  k)
inline

Definition at line 142 of file CacheGlobalMemory.h.

◆ setRun3NavigationKeyPtr()

void Trig::CacheGlobalMemory::setRun3NavigationKeyPtr ( SG::ReadHandleKey< TrigCompositeUtils::DecisionContainer > *  k)
inline

Definition at line 143 of file CacheGlobalMemory.h.

◆ setStore()

void Trig::CacheGlobalMemory::setStore ( asg::EventStoreType store)
inline

Set the event store to be used by the object.

Definition at line 137 of file CacheGlobalMemory.h.

137 { m_store = store; }

◆ store()

const asg::EventStoreType* Trig::CacheGlobalMemory::store ( ) const
inline

Get the event store that the object is using.

Definition at line 139 of file CacheGlobalMemory.h.

139 { return m_store; }

◆ unpackDecision()

StatusCode Trig::CacheGlobalMemory::unpackDecision ( const EventContext &  ctx)
private

unpacks whole trigger decision for the event

Definition at line 377 of file CacheGlobalMemory.cxx.

377  {
378  // locked already through assert_decision
379 
380  ATH_MSG_DEBUG("Unpacking TrigDecision");
381  m_decisionUnpacked = true;
382  m_deleteAtEndOfEvent.clear();
383 
384  bool unpackHLT = ( m_confChains != nullptr );
385  ATH_CHECK( m_unpacker->unpackDecision( ctx, m_itemsByName, m_itemsCache,
388  m_bgCode, unpackHLT ) );
389  return StatusCode::SUCCESS;
390 }

◆ unpackNavigation()

StatusCode Trig::CacheGlobalMemory::unpackNavigation ( )
private

unpacks HLT navigation structure (object access)

Definition at line 393 of file CacheGlobalMemory.cxx.

393  {
394  std::lock_guard<std::recursive_mutex> lock(m_cgmMutex);
395 
396  m_navigationUnpacked = true;
397 
398  // Navigation
399  // protect from unpacking in case HLT was not run
400  // (i.e. configuration chains are 0)
401  if( m_confChains == nullptr ) {
402  return StatusCode::SUCCESS;
403  }
404 
405  // Failing to unpack the navigation is not a failure, as it may be missing
406  // from the xAOD file:
407  const EventContext& context = Gaudi::Hive::currentContext();
408  if( ! m_unpacker->unpackNavigation( context, m_navigation ).isSuccess() ) {
409  [[maybe_unused]] static std::atomic<bool> warningPrinted =
410  [&]() { ATH_MSG_WARNING( "TrigNavigation unpacking failed" );
411  return true; }();
412  }
413  // Return gracefully:
414  return StatusCode::SUCCESS;
415 }

◆ update()

void Trig::CacheGlobalMemory::update ( const TrigConf::HLTChainList confChains,
const TrigConf::CTPConfig ctp 
)

Updates configuration of the chain groups (i.e.

regexes are reapplied to new set of chains)

Definition at line 109 of file CacheGlobalMemory.cxx.

110  {
111  std::lock_guard<std::recursive_mutex> lock(m_cgmMutex);
112  ATH_MSG_DEBUG( "Updating configuration" );
113  // store a global reference to the initial answer
114  m_confChains = confChains;
115  if ( !ctp ) {
116  ATH_MSG_WARNING( "No LVL1 config, something went wrong, TDT will "
117  "not attempt accessing HLT too" );
118  m_confItems = nullptr;
119  return;
120  }
121  m_confItems = &(ctp->menu().items());
122 
123  // rebuild all the caches with decision information
124 
125  //clear cache completely because underlying config objects might have changed
126  m_itemsCache.clear();
127 
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,
132  /*LVL1CTP::Lvl1Item*/ item->name(), 0,
133  0, 0, 0, prescales[ctpid]);
134  ATH_MSG_DEBUG( "new configuration for item" << item->name() );
135  }
136  ATH_MSG_DEBUG( "Updating configuration, done with L1" );
137 
138  //clear cache completely because underlying config objects might have changed
139  m_l2chainsCache.clear();
140  m_efchainsCache.clear();
141  m_mConfChains.clear();
142 
143  if ( ! confChains ) {
144  ATH_MSG_WARNING( "No chains in configuration, probably run w/o HLT" );
145  } else {
146 
147  ATH_MSG_DEBUG("Updating Configuration chains. Number of conf chains: " << m_confChains->size());
148 
149  // updating internal map of conf chains (this map is only used for fast lookup)
150  for(auto ch : *m_confChains) {
151  m_mConfChains[ch->chain_name()] = ch;
152  }
153 
154  // updating internal cache of HLT::Chains
155  for(auto ch : *m_confChains) {
156  // std::cerr << "CacheGlobalMemory::update updating chain" << (*cChIt)->chain_name() << std::endl;
157  int cntr = ch->chain_counter();
158  if( ch->level()=="L2" ) {
159  m_l2chainsCache.emplace(cntr, /*HLT::Chain*/ch);
160  } else {//merged chains are stored in efchains
161  m_efchainsCache.emplace(cntr, /*HLT::Chain*/ch);
162  }
163  }
164  ATH_MSG_DEBUG( "Updating configuration, done with basic HLT based on "
165  << m_confChains->size() << " configuration chains" );
166 
167 
168  // code for the streams and pre-defined groups
169  // -- assume that the groups and streams have all changed!!!
170  m_groups.clear();
171  m_streams.clear();
172 
173  for(auto ch : *m_confChains) {
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()) {
177  ATH_MSG(DEBUG) << " " << stream->stream();
178  m_streams[stream->stream()].push_back(ch->chain_name());
179  }
180  ATH_MSG(DEBUG) << endmsg;
181  }
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()) {
185  ATH_MSG(DEBUG) << " " << group;
186  m_groups[group].push_back(ch->chain_name());
187  }
188  ATH_MSG(DEBUG) << endmsg;
189  }
190  }
191  }
192 
193  // update all defined chainGroups
194  for (auto& [key, group] : m_chainGroups) {
196  }
197  ATH_MSG_DEBUG( "Updating configuration done" );
198 }

◆ updateChainGroup()

void Trig::CacheGlobalMemory::updateChainGroup ( Trig::ChainGroup chainGroup,
TrigDefs::Group  props = TrigDefs::Group::Default 
)
private

unpacks everything that belongs to a ChainGroup

Definition at line 104 of file CacheGlobalMemory.cxx.

104  {
105  chainGroup.update(m_confChains, m_confItems, props);
106 }

◆ xAODTrigDecisionKey()

const SG::ReadHandleKey<xAOD::TrigDecision>* Trig::CacheGlobalMemory::xAODTrigDecisionKey ( ) const
inline

Definition at line 152 of file CacheGlobalMemory.h.

152 { return m_decisionKeyPtr; }

Friends And Related Function Documentation

◆ DecisionAccess

friend class DecisionAccess
friend

Definition at line 162 of file CacheGlobalMemory.h.

Member Data Documentation

◆ ATLAS_THREAD_SAFE [1/4]

std::unique_ptr<IDecisionUnpacker> m_unpacker Trig::CacheGlobalMemory::ATLAS_THREAD_SAFE
mutableprivate

Trigger decision unpacker helper.

Definition at line 187 of file CacheGlobalMemory.h.

◆ ATLAS_THREAD_SAFE [2/4]

std::map< std::vector< std::string >, Trig::ChainGroup > m_chainGroups Trig::CacheGlobalMemory::ATLAS_THREAD_SAFE
mutableprivate

primary storage for chain groups

Definition at line 196 of file CacheGlobalMemory.h.

◆ ATLAS_THREAD_SAFE [3/4]

std::map< std::vector< std::string >, Trig::ChainGroup* > m_chainGroupsRef Trig::CacheGlobalMemory::ATLAS_THREAD_SAFE
mutableprivate

this map keeps the chain group more than once i.e.

when alias is given

Definition at line 197 of file CacheGlobalMemory.h.

◆ ATLAS_THREAD_SAFE [4/4]

AnyTypeDeleter m_deleteAtEndOfEvent Trig::CacheGlobalMemory::ATLAS_THREAD_SAFE
mutableprivate

Definition at line 272 of file CacheGlobalMemory.h.

◆ m_bgCode

char Trig::CacheGlobalMemory::m_bgCode {0}
private

the encoded bunchgroup information

Definition at line 228 of file CacheGlobalMemory.h.

◆ m_cgmMutex

std::recursive_mutex Trig::CacheGlobalMemory::m_cgmMutex
mutableprivate

R3 MT protection only against –threads > 1.

Needs refacotring...

Definition at line 274 of file CacheGlobalMemory.h.

◆ m_confChains

const TrigConf::HLTChainList* Trig::CacheGlobalMemory::m_confChains {nullptr}
private

all chains configuration

Definition at line 213 of file CacheGlobalMemory.h.

◆ m_confItems

const TrigConf::ItemContainer* Trig::CacheGlobalMemory::m_confItems {nullptr}
private

items configuration

Definition at line 212 of file CacheGlobalMemory.h.

◆ m_decisionKeyPtr

SG::ReadHandleKey<xAOD::TrigDecision>* Trig::CacheGlobalMemory::m_decisionKeyPtr {nullptr}
private

Parent TDT's read handle key.

Definition at line 215 of file CacheGlobalMemory.h.

◆ m_decisionUnpacked

bool Trig::CacheGlobalMemory::m_decisionUnpacked {false}
private

Was decision unpacked for this event?

Definition at line 189 of file CacheGlobalMemory.h.

◆ m_efchainsByName

std::unordered_map<std::string, const HLT::Chain*> Trig::CacheGlobalMemory::m_efchainsByName
private

L2 chains keyed by chain name (chainging every event)

Definition at line 201 of file CacheGlobalMemory.h.

◆ m_efchainsCache

std::map<CHAIN_COUNTER, HLT::Chain> Trig::CacheGlobalMemory::m_efchainsCache
private

cache of all EF chains possible (given configuration)

Definition at line 207 of file CacheGlobalMemory.h.

◆ m_groups

std::map<std::string, std::vector<std::string> > Trig::CacheGlobalMemory::m_groups
private

mapping from group to list of chains

Definition at line 209 of file CacheGlobalMemory.h.

◆ m_itemsByName

std::unordered_map<std::string, const LVL1CTP::Lvl1Item*> Trig::CacheGlobalMemory::m_itemsByName
private

items keyed by configuration name (chainging every event)

Definition at line 199 of file CacheGlobalMemory.h.

◆ m_itemsCache

std::map<CTPID, LVL1CTP::Lvl1Item> Trig::CacheGlobalMemory::m_itemsCache
private

cache of all CTP items possible (given configuration)

Definition at line 205 of file CacheGlobalMemory.h.

◆ m_l2chainsByName

std::unordered_map<std::string, const HLT::Chain*> Trig::CacheGlobalMemory::m_l2chainsByName
private

L2 chains keyed by chain name (chainging every event)

Definition at line 200 of file CacheGlobalMemory.h.

◆ m_l2chainsCache

std::map<CHAIN_COUNTER, HLT::Chain> Trig::CacheGlobalMemory::m_l2chainsCache
private

cache of all L2 chains possible (given configuration)

Definition at line 206 of file CacheGlobalMemory.h.

◆ m_mConfChains

ChainHashMap_t Trig::CacheGlobalMemory::m_mConfChains
private

map of conf chains

Definition at line 226 of file CacheGlobalMemory.h.

◆ m_navigation

HLT::TrigNavStructure* Trig::CacheGlobalMemory::m_navigation {nullptr}
private

Navigation owned by CGM.

Definition at line 193 of file CacheGlobalMemory.h.

◆ m_navigationUnpacked

bool Trig::CacheGlobalMemory::m_navigationUnpacked {false}
private

Was navigation unpacked for this event?

Definition at line 190 of file CacheGlobalMemory.h.

◆ m_oldDecisionKeyPtr

SG::ReadHandleKey<TrigDec::TrigDecision>* Trig::CacheGlobalMemory::m_oldDecisionKeyPtr {nullptr}
private

Parent TDT's read handle key.

Definition at line 218 of file CacheGlobalMemory.h.

◆ m_oldEventInfoKeyPtr

SG::ReadHandleKey<EventInfo>* Trig::CacheGlobalMemory::m_oldEventInfoKeyPtr {nullptr}
private

Parent TDT's read handle key.

Definition at line 219 of file CacheGlobalMemory.h.

◆ m_run2NavigationKeyPtr

SG::ReadHandleKey<xAOD::TrigNavigation>* Trig::CacheGlobalMemory::m_run2NavigationKeyPtr {nullptr}
private

Parent TDT's read handle key.

Definition at line 222 of file CacheGlobalMemory.h.

◆ m_run3NavigationKeyPtr

SG::ReadHandleKey<TrigCompositeUtils::DecisionContainer>* Trig::CacheGlobalMemory::m_run3NavigationKeyPtr {nullptr}
private

Parent TDT's read handle key.

Definition at line 223 of file CacheGlobalMemory.h.

◆ m_store

const asg::EventStoreType* Trig::CacheGlobalMemory::m_store {nullptr}
private

Pointer to the event store in use.

Definition at line 184 of file CacheGlobalMemory.h.

◆ m_streams

std::map<std::string, std::vector<std::string> > Trig::CacheGlobalMemory::m_streams
private

mapping from stream to list of chains

Definition at line 210 of file CacheGlobalMemory.h.


The documentation for this class was generated from the following files:
Trig::ChainGroup::update
void update(const TrigConf::HLTChainList *confChains, const TrigConf::ItemContainer *confItems, TrigDefs::Group prop=TrigDefs::Group::Default)
Definition: ChainGroup.cxx:591
Trig::CacheGlobalMemory::m_decisionKeyPtr
SG::ReadHandleKey< xAOD::TrigDecision > * m_decisionKeyPtr
Parent TDT's read handle key.
Definition: CacheGlobalMemory.h:215
sendEI_SPB.ch
ch
Definition: sendEI_SPB.py:35
Trig::CacheGlobalMemory::m_store
const asg::EventStoreType * m_store
Pointer to the event store in use.
Definition: CacheGlobalMemory.h:184
Trig::CacheGlobalMemory::createChainGroup
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
Definition: CacheGlobalMemory.cxx:54
ATH_MSG
#define ATH_MSG(lvl)
Definition: AthMsgStreamMacros.h:38
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
Trig::CacheGlobalMemory::ATLAS_THREAD_SAFE
std::unique_ptr< IDecisionUnpacker > m_unpacker ATLAS_THREAD_SAFE
Trigger decision unpacker helper.
Definition: CacheGlobalMemory.h:187
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
LVL1CTP::Lvl1Result::isConfigured
bool isConfigured() const
is LVL1 configured ?
Definition: Lvl1Result.h:39
Trig::CacheGlobalMemory::item
const LVL1CTP::Lvl1Item * item(const std::string &name) const
CTP item from given name.
Definition: CacheGlobalMemory.cxx:260
Trig::CacheGlobalMemory::m_streams
std::map< std::string, std::vector< std::string > > m_streams
mapping from stream to list of chains
Definition: CacheGlobalMemory.h:210
Trig::CacheGlobalMemory
Definition: CacheGlobalMemory.h:67
Trig::CacheGlobalMemory::m_cgmMutex
std::recursive_mutex m_cgmMutex
R3 MT protection only against –threads > 1.
Definition: CacheGlobalMemory.h:274
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
SG::VarHandleKey::empty
bool empty() const
Test if the key is blank.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:150
AthenaPoolTestWrite.stream
string stream
Definition: AthenaPoolTestWrite.py:12
RatesAnalysisFullMenu.prescales
prescales
Definition: RatesAnalysisFullMenu.py:119
Trig::CacheGlobalMemory::m_confChains
const TrigConf::HLTChainList * m_confChains
all chains configuration
Definition: CacheGlobalMemory.h:213
Trig::convertStringToVector
std::vector< std::string > convertStringToVector(const std::string &triggerNames)
makes a split of list of chains into the vector of chains
Definition: TDTUtilities.cxx:41
Trig::CacheGlobalMemory::m_mConfChains
ChainHashMap_t m_mConfChains
map of conf chains
Definition: CacheGlobalMemory.h:226
SG::makeHandle
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Definition: ReadCondHandle.h:270
Trig::CacheGlobalMemory::m_groups
std::map< std::string, std::vector< std::string > > m_groups
mapping from group to list of chains
Definition: CacheGlobalMemory.h:209
Trig::CacheGlobalMemory::store
const asg::EventStoreType * store() const
Get the event store that the object is using.
Definition: CacheGlobalMemory.h:139
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
Trig::CacheGlobalMemory::m_run3NavigationKeyPtr
SG::ReadHandleKey< TrigCompositeUtils::DecisionContainer > * m_run3NavigationKeyPtr
Parent TDT's read handle key.
Definition: CacheGlobalMemory.h:223
Trig::CacheGlobalMemory::m_navigation
HLT::TrigNavStructure * m_navigation
Navigation owned by CGM.
Definition: CacheGlobalMemory.h:193
lumiFormat.i
int i
Definition: lumiFormat.py:85
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
COOLRates.alias
alias
Definition: COOLRates.py:1172
Trig::Logger::msg
MsgStream & msg() const
Definition: Trigger/TrigAnalysis/TrigDecisionTool/TrigDecisionTool/Logger.h:29
TrigDec::TrigDecision::getL1Result
const LVL1CTP::Lvl1Result & getL1Result() const
Definition: Trigger/TrigEvent/TrigDecisionEvent/TrigDecisionEvent/TrigDecision.h:88
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
Trig::CacheGlobalMemory::chain
const HLT::Chain * chain(const std::string &name) const
HLT chain object from given name (0 pointer returned if no match)
Definition: CacheGlobalMemory.cxx:201
hist_file_dump.f
f
Definition: hist_file_dump.py:135
Trig::keyWrap
std::vector< std::string > keyWrap(const std::vector< std::string > &triggerNames)
normalizes the list of triggers (patterns) by sorting and uniquing them
Definition: TDTUtilities.cxx:52
Trig::CacheGlobalMemory::m_l2chainsByName
std::unordered_map< std::string, const HLT::Chain * > m_l2chainsByName
L2 chains keyed by chain name (chainging every event)
Definition: CacheGlobalMemory.h:200
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
Trig::CacheGlobalMemory::CacheGlobalMemory
CacheGlobalMemory()=default
python.handimod.extra
int extra
Definition: handimod.py:522
Trig::CacheGlobalMemory::m_oldEventInfoKeyPtr
SG::ReadHandleKey< EventInfo > * m_oldEventInfoKeyPtr
Parent TDT's read handle key.
Definition: CacheGlobalMemory.h:219
Trig::CacheGlobalMemory::m_confItems
const TrigConf::ItemContainer * m_confItems
items configuration
Definition: CacheGlobalMemory.h:212
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
CxxUtils::as_const_ptr
const T * as_const_ptr(const T *p)
Helper for getting a const version of a pointer.
Definition: as_const_ptr.h:32
Trig::CacheGlobalMemory::m_l2chainsCache
std::map< CHAIN_COUNTER, HLT::Chain > m_l2chainsCache
cache of all L2 chains possible (given configuration)
Definition: CacheGlobalMemory.h:206
item
Definition: ItemListSvc.h:43
Trig::CacheGlobalMemory::m_efchainsByName
std::unordered_map< std::string, const HLT::Chain * > m_efchainsByName
L2 chains keyed by chain name (chainging every event)
Definition: CacheGlobalMemory.h:201
TriggerTest.ctp
ctp
Retrieve trigger EDM objects.
Definition: TriggerTest.py:14
Trig::CacheGlobalMemory::m_itemsByName
std::unordered_map< std::string, const LVL1CTP::Lvl1Item * > m_itemsByName
items keyed by configuration name (chainging every event)
Definition: CacheGlobalMemory.h:199
Trig::CacheGlobalMemory::m_navigationUnpacked
bool m_navigationUnpacked
Was navigation unpacked for this event?
Definition: CacheGlobalMemory.h:190
CaloLCW_tf.group
group
Definition: CaloLCW_tf.py:28
Trig::CacheGlobalMemory::updateChainGroup
void updateChainGroup(Trig::ChainGroup &chainGroup, TrigDefs::Group props=TrigDefs::Group::Default)
unpacks everything that belongs to a ChainGroup
Definition: CacheGlobalMemory.cxx:104
Trig::CacheGlobalMemory::m_decisionUnpacked
bool m_decisionUnpacked
Was decision unpacked for this event?
Definition: CacheGlobalMemory.h:189
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
DEBUG
#define DEBUG
Definition: page_access.h:11
Trig::CacheGlobalMemory::m_bgCode
char m_bgCode
the encoded bunchgroup information
Definition: CacheGlobalMemory.h:228
Trig::CacheGlobalMemory::m_efchainsCache
std::map< CHAIN_COUNTER, HLT::Chain > m_efchainsCache
cache of all EF chains possible (given configuration)
Definition: CacheGlobalMemory.h:207
Trig::CacheGlobalMemory::m_run2NavigationKeyPtr
SG::ReadHandleKey< xAOD::TrigNavigation > * m_run2NavigationKeyPtr
Parent TDT's read handle key.
Definition: CacheGlobalMemory.h:222
Trig::CacheGlobalMemory::m_oldDecisionKeyPtr
SG::ReadHandleKey< TrigDec::TrigDecision > * m_oldDecisionKeyPtr
Parent TDT's read handle key.
Definition: CacheGlobalMemory.h:218
itemByName
Definition: CacheGlobalMemory.cxx:226
fitman.k
k
Definition: fitman.py:528
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37
Trig::CacheGlobalMemory::m_itemsCache
std::map< CTPID, LVL1CTP::Lvl1Item > m_itemsCache
cache of all CTP items possible (given configuration)
Definition: CacheGlobalMemory.h:205