ATLAS Offline Software
Loading...
Searching...
No Matches
CacheGlobalMemory.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 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
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 }
115
116 const Trig::ChainGroup* getChainGroup (const std::vector<std::string>& triggerNames,
117 TrigDefs::Group props) const;
118 size_t nChainGroups() const;
119 const std::map<std::string, std::vector<std::string> >& getStreams() const {return m_streams;};
120
128 bool assert_decision() const;
129
134 void reset_decision();
135
139 const asg::EventStoreType* store() const { return m_store; }
140
146
147#ifndef XAOD_ANALYSIS // Full Athena only
150#endif
151
153
154 //
155 template<class T>
156 void deleteAtTheEndOfEvent(T t) const { m_deleteAtEndOfEvent.insert(t); }
157
158
159
160
161 private:
162 friend class DecisionAccess;
163
167 StatusCode unpackDecision(const EventContext& ctx);
171 StatusCode unpackNavigation();
172
176 void updateChainGroup(Trig::ChainGroup& chainGroup,
178
179 //
180 // Data members
181 //
182
185
187 mutable std::unique_ptr<IDecisionUnpacker> m_unpacker ATLAS_THREAD_SAFE; // for assert_decision
188
189 bool m_decisionUnpacked{false};
191
194
195 // chain groups (protected by mutex)
196 mutable std::map< std::vector< std::string >, Trig::ChainGroup > m_chainGroups ATLAS_THREAD_SAFE;
197 mutable std::map< std::vector< std::string >, Trig::ChainGroup* > m_chainGroupsRef ATLAS_THREAD_SAFE;
198
199 std::unordered_map<std::string, const LVL1CTP::Lvl1Item*> m_itemsByName;
200 std::unordered_map<std::string, const HLT::Chain*> m_l2chainsByName;
201 std::unordered_map<std::string, const HLT::Chain*> m_efchainsByName;
202
203 typedef unsigned CTPID;
204 typedef unsigned CHAIN_COUNTER;
205 std::map<CTPID, LVL1CTP::Lvl1Item> m_itemsCache;
206 std::map<CHAIN_COUNTER, HLT::Chain> m_l2chainsCache;
207 std::map<CHAIN_COUNTER, HLT::Chain> m_efchainsCache;
208
209 std::map<std::string, std::vector<std::string> > m_groups;
210 std::map<std::string, std::vector<std::string> > m_streams;
211
214
216
217#ifndef XAOD_ANALYSIS // Full Athena
220#endif
221
224
225 typedef std::unordered_map<std::string, const TrigConf::HLTChain*> ChainHashMap_t;
227
228 char m_bgCode{0};
229
230
232
233
234 struct iholder {
235 virtual ~iholder() {}
236 virtual const void* ptr() const { return nullptr;}
237 };
238
239 struct holder_comp {
240 bool operator()(iholder* lhs, iholder* rhs) const {
241 return lhs->ptr() < rhs->ptr(); }
242 };
243 template<class T>
244 class holder : public iholder {
245 public:
246 holder(T& t): m_held(t) {}
247 virtual ~holder() {
248 delete m_held;
249 m_held = 0; }
250 virtual const void* ptr() const { return m_held;}
251 private:
253 };
254
255 public:
256 template<class T>
257 void insert(T t) {
258 m_todel.insert(new holder<T>(t));
259 }
260 void clear() {
261 for(iholder* i : m_todel) {
262 delete i;
263 }
264 m_todel.clear();
265 }
267 private:
268 std::set< iholder*, holder_comp > m_todel;
269 }; // end of deleter
270
271 // Thread-safe because CacheGlobalMemory is slot-specific
272 mutable AnyTypeDeleter m_deleteAtEndOfEvent ATLAS_THREAD_SAFE;
273
274 mutable std::recursive_mutex m_cgmMutex;
275
276
277
278 };
279} // End of namespace
280
281#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:64
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