ATLAS Offline Software
Loading...
Searching...
No Matches
CacheGlobalMemory.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef TRIGGER_DECISION_TOOL_CACHE_GLOBAL_MEMORY_H
6#define TRIGGER_DECISION_TOOL_CACHE_GLOBAL_MEMORY_H
7
8/**********************************************************************************
9 * @Project: TrigDecisionTool
10 * @Package: TrigDecisionTool
11 * @class : CacheGlobalMemory
12 *
13 * @brief registry for ChainGroups
14 *
15 * @author Michael Begel <michael.begel@cern.ch> - Brookhaven National Laboratory
16 *
17 ***********************************************************************************/
18
19#include<vector>
20#include<set>
21#include<map>
22#include<unordered_map>
23#include<string>
24#include<mutex>
25#include<memory>
26
30
32
35
39
43
47
48#ifndef XAOD_ANALYSIS // Full Athena only
49#include "EventInfo/EventInfo.h"
51#endif
52
53namespace HLT {
54 class Chain;
55 class TriggerElement;
56}
57
58namespace LVL1CTP {
59 class Lvl1Result;
60}
61
62
63namespace Trig {
64
65 class ChainGroup;
66
67 class CacheGlobalMemory : public virtual Logger {
68
69 public:
70 // constructors, destructor
71 CacheGlobalMemory() = default;
72 ~CacheGlobalMemory() = default;
73
84 const Trig::ChainGroup* createChainGroup(const std::vector< std::string >& patterns,
85 const std::string& alias="",
87
92 void update(const TrigConf::HLTChainList* confChains,
93 const TrigConf::CTPConfig* ctp);
94
95 const LVL1CTP::Lvl1Item* item(const std::string& name) const;
96 const LVL1CTP::Lvl1Item* item(const TrigConf::TriggerItem& i) const;
97 const TrigConf::TriggerItem* config_item(const std::string& name) const;
98 float item_prescale(int ctpid) const;
99
100 const HLT::Chain* chain(const std::string& name) const;
101 const HLT::Chain* chain(const TrigConf::HLTChain& chIt) const;
102 const TrigConf::HLTChain* config_chain(const std::string& name) const;
103
105 /*
106 Assumed intentional (cid 24125)
107 Accessing this->m_navigationUnpacked without holding lock
108 Trig::CacheGlobalMemory.m_cgmMutex. Elsewhere,
109 Trig::CacheGlobalMemory.m_navigationUnpacked is written to with
110 CacheGlobalMemory.m_cgmMutex held 1 out of 2 times
111 */
112 //coverity[MISSING_LOCK]
114 // CGM is slot-specific and unpackNavigation is locked
115 auto cgm ATLAS_THREAD_SAFE = const_cast<CacheGlobalMemory*>(this);
116 if(cgm->unpackNavigation().isFailure()){
117 ATH_MSG_WARNING("unpack Navigation failed");
118 }
119 }
120 return m_navigation;
121 }
123
124 const Trig::ChainGroup* getChainGroup (const std::vector<std::string>& triggerNames,
125 TrigDefs::Group props) const;
126 size_t nChainGroups() const;
127 const std::map<std::string, std::vector<std::string> >& getStreams() const {return m_streams;};
128
136 bool assert_decision() const;
137
142 void reset_decision();
143
147 const asg::EventStoreType* store() const { return m_store; }
148
154
155#ifndef XAOD_ANALYSIS // Full Athena only
158#endif
159
161
162 //
163 template<class T>
164 void deleteAtTheEndOfEvent(T t) const { m_deleteAtEndOfEvent.insert(t); }
165
166
167
168
169 private:
170 friend class DecisionAccess;
171
175 StatusCode unpackDecision(const EventContext& ctx);
179 StatusCode unpackNavigation();
180
184 void updateChainGroup(Trig::ChainGroup& chainGroup,
186
187 //
188 // Data members
189 //
190
193
195 mutable std::unique_ptr<IDecisionUnpacker> m_unpacker ATLAS_THREAD_SAFE; // for assert_decision
196
197 bool m_decisionUnpacked{false};
199
202
203 // chain groups (protected by mutex)
204 mutable std::map< std::vector< std::string >, Trig::ChainGroup > m_chainGroups ATLAS_THREAD_SAFE;
205 mutable std::map< std::vector< std::string >, Trig::ChainGroup* > m_chainGroupsRef ATLAS_THREAD_SAFE;
206
207 std::unordered_map<std::string, const LVL1CTP::Lvl1Item*> m_itemsByName;
208 std::unordered_map<std::string, const HLT::Chain*> m_l2chainsByName;
209 std::unordered_map<std::string, const HLT::Chain*> m_efchainsByName;
210
211 typedef unsigned CTPID;
212 typedef unsigned CHAIN_COUNTER;
213 std::map<CTPID, LVL1CTP::Lvl1Item> m_itemsCache;
214 std::map<CHAIN_COUNTER, HLT::Chain> m_l2chainsCache;
215 std::map<CHAIN_COUNTER, HLT::Chain> m_efchainsCache;
216
217 std::map<std::string, std::vector<std::string> > m_groups;
218 std::map<std::string, std::vector<std::string> > m_streams;
219
222
224
225#ifndef XAOD_ANALYSIS // Full Athena
228#endif
229
232
233 typedef std::unordered_map<std::string, const TrigConf::HLTChain*> ChainHashMap_t;
235
236 char m_bgCode{0};
237
238
240
241
242 struct iholder {
243 virtual ~iholder() {}
244 virtual const void* ptr() const { return nullptr;}
245 };
246
247 struct holder_comp {
248 bool operator()(iholder* lhs, iholder* rhs) const {
249 return lhs->ptr() < rhs->ptr(); }
250 };
251 template<class T>
252 class holder : public iholder {
253 public:
254 holder(T& t): m_held(t) {}
255 virtual ~holder() {
256 delete m_held;
257 m_held = 0; }
258 virtual const void* ptr() const { return m_held;}
259 private:
261 };
262
263 public:
264 template<class T>
265 void insert(T t) {
266 m_todel.insert(new holder<T>(t));
267 }
268 void clear() {
269 for(iholder* i : m_todel) {
270 delete i;
271 }
272 m_todel.clear();
273 }
275 private:
276 std::set< iholder*, holder_comp > m_todel;
277 }; // end of deleter
278
279 // Thread-safe because CacheGlobalMemory is slot-specific
280 mutable AnyTypeDeleter m_deleteAtEndOfEvent ATLAS_THREAD_SAFE;
281
282 mutable std::recursive_mutex m_cgmMutex;
283
284
285
286 };
287} // End of namespace
288
289#endif
#define ATH_MSG_WARNING(x,...)
Property holding a SG store/key/clid from which a ReadHandle is made.
Define macros for attributes used to control the static checker.
This class represents one chain of signatures, i.e.
Definition Chain.h:61
TriggerElement is the basic ingreedient of the interface between HLT algorithms and the navigation It...
Property holding a SG store/key/clid from which a ReadHandle is made.
list of all HLT chains in a trigger menu
HLT chain configuration information.
std::set< iholder *, holder_comp > m_todel
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).
SG::ReadHandleKey< TrigCompositeUtils::DecisionContainer > * m_run3NavigationKeyPtr
Parent TDT's read handle key.
void setRun2NavigationKeyPtr(SG::ReadHandleKey< xAOD::TrigNavigation > *k)
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 SG::ReadHandleKey< TrigCompositeUtils::DecisionContainer > * getRun3NavigationKeyPtr() const
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
void setDecisionKeyPtr(SG::ReadHandleKey< xAOD::TrigDecision > *k)
const SG::ReadHandleKey< TrigCompositeUtils::DecisionContainer > & getRun3NavigationKey() 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
void setStore(asg::EventStoreType *store)
Set the event store to be used by the object.
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::unordered_map< std::string, const TrigConf::HLTChain * > ChainHashMap_t
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 HLT::TrigNavStructure * navigation() const
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.
const asg::EventStoreType * m_store
Pointer to the event store in use.
SG::ReadHandleKey< xAOD::TrigNavigation > * m_run2NavigationKeyPtr
Parent TDT's read handle key.
const asg::EventStoreType * store() const
Get the event store that the object is using.
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)
void deleteAtTheEndOfEvent(T t) const
void navigation(HLT::TrigNavStructure *nav)
sets navigation object pointer
const std::map< std::string, std::vector< std::string > > & getStreams() const
SG::ReadHandleKey< EventInfo > * m_oldEventInfoKeyPtr
Parent TDT's read handle key.
void setRun3NavigationKeyPtr(SG::ReadHandleKey< TrigCompositeUtils::DecisionContainer > *k)
void setOldDecisionKeyPtr(SG::ReadHandleKey< TrigDec::TrigDecision > *k)
void setOldEventInfoKeyPtr(SG::ReadHandleKey< EventInfo > *k)
void reset_decision()
invalidate previously unpacked decision Needs to be called at the start of a new event.
const SG::ReadHandleKey< xAOD::TrigDecision > * xAODTrigDecisionKey() const
Logger()=default
std::vector< std::string > patterns
Definition listroot.cxx:187
It used to be useful piece of code for replacing actual SG with other store of similar functionality ...
boost::multi_index::multi_index_container< TriggerItem *, boost::multi_index::indexed_by< boost::multi_index::random_access<>, boost::multi_index::ordered_unique< boost::multi_index::identity< TriggerItem > >, boost::multi_index::ordered_unique< boost::multi_index::tag< tag_ctpid >, boost::multi_index::const_mem_fun< TriggerItem, int, &TriggerItem::ctpId > >, boost::multi_index::hashed_unique< boost::multi_index::tag< tag_name_hash >, boost::multi_index::const_mem_fun< TrigConfData, const std::string &, &TrigConfData::name > > > > ItemContainer
Definition Menu.h:39
Group
Properties of a chain group.
The common trigger namespace for trigger analysis tools.
StoreGateSvc EventStoreType
the type returned by AsgTool::evtStore
bool operator()(iholder *lhs, iholder *rhs) const