00001 #ifndef TRIGGER_DECISION_TOOL_CACHE_GLOBAL_MEMORY_H
00002 #define TRIGGER_DECISION_TOOL_CACHE_GLOBAL_MEMORY_H
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include<iterator>
00016 #include<vector>
00017 #include<list>
00018 #include<set>
00019 #include<map>
00020 #include<string>
00021 #include "boost/foreach.hpp"
00022 #include <unordered_map>
00023
00024 #include "TrigConfHLTData/HLTChain.h"
00025 #include "TrigConfHLTData/HLTChainList.h"
00026 #include "TrigConfHLTData/HLTStreamTag.h"
00027
00028 #include "TrigConfL1Data/CTPConfig.h"
00029
00030 #include "TrigSteeringEvent/Chain.h"
00031 #include "xAODTrigger/TrigCompositeContainer.h"
00032
00033 #include "TrigDecisionTool/IDecisionUnpacker.h"
00034 #include "TrigDecisionTool/Logger.h"
00035 #include "AsgTools/AsgMessaging.h"
00036
00037
00038
00039 namespace HLT {
00040 class Chain;
00041 class TriggerElement;
00042 }
00043
00044 namespace LVL1CTP {
00045 class Lvl1Item;
00046 class Lvl1Result;
00047 }
00048
00049
00050 #include "TrigDecisionTool/EventPtrDef.h"
00051
00052 namespace Trig {
00053
00054 class ChainGroup;
00055
00056 class CacheGlobalMemory : public virtual Logger {
00057
00058 using Logger::msgLvl;
00059
00060 public:
00061
00062 CacheGlobalMemory();
00063 ~CacheGlobalMemory();
00064
00078 const Trig::ChainGroup* createChainGroup(const std::vector< std::string >& patterns,
00079 const std::string& alias="");
00084 void update(const TrigConf::HLTChainList* confChains,
00085 const TrigConf::CTPConfig* ctp);
00086
00087 const LVL1CTP::Lvl1Item* item(const std::string& name) const;
00088 const LVL1CTP::Lvl1Item* item(const TrigConf::TriggerItem& i) const;
00089 const TrigConf::TriggerItem* config_item(const std::string& name) const;
00090 float item_prescale(int ctpid) const;
00091
00092 const HLT::Chain* chain(const std::string& name) const;
00093 const HLT::Chain* chain(const TrigConf::HLTChain& chIt) const;
00094 const TrigConf::HLTChain* config_chain(const std::string& name) const;
00095
00096 const HLT::TrigNavStructure* navigation() const {
00097 if(!m_unpacker->unpacked_navigation()){
00098 if(const_cast<CacheGlobalMemory*>(this)->unpackNavigation().isFailure()){
00099 ATH_MSG_WARNING("unpack Navigation failed");;
00100 }
00101 }
00102 return m_navigation;
00103 }
00104 void navigation(HLT::TrigNavStructure* nav) { m_navigation = nav; }
00105
00106 std::map< std::vector< std::string >, Trig::ChainGroup* >& getChainGroups() {return m_chainGroupsRef;};
00107
00108
00109
00110
00111
00112
00113 std::map<std::string, std::vector<std::string> > getStreams() {return m_streams;};
00114 std::map<std::string, std::vector<std::string> > getStreams() const {return m_streams;};
00115
00116 const xAOD::TrigCompositeContainer* expressStreamContainer() const;
00117
00123 bool assert_decision();
00124
00125 void setUnpacker( Trig::IDecisionUnpacker* up ){ m_unpacker = up; }
00126 Trig::IDecisionUnpacker* unpacker(){ return m_unpacker; }
00127
00128
00130 void setStore( EventPtr_t store ) { m_store = store; }
00132 EventPtr_t store() const { return m_store; }
00133
00134
00135
00136 template<class T>
00137 void deleteAtTheEndOfEvent(T t) const { m_deleteAtEndOfEvent.insert(t); }
00138
00139
00140
00141
00142 private:
00143 friend class DecisionAccess;
00144
00148 StatusCode unpackDecision();
00152 StatusCode unpackNavigation();
00153
00157 void updateChainGroup(Trig::ChainGroup* chainGroup);
00158
00159
00160
00161
00162
00164 EventPtr_t m_store;
00165
00167 IDecisionUnpacker* m_unpacker;
00168
00169
00170 HLT::TrigNavStructure* m_navigation;
00171
00172
00173 typedef std::map< std::vector< std::string >, Trig::ChainGroup* >::iterator ChGrIt;
00174 std::map< std::vector< std::string >, Trig::ChainGroup* > m_chainGroups;
00175 std::map< std::vector< std::string >, Trig::ChainGroup* > m_chainGroupsRef;
00176
00177
00178
00179
00180
00181 std::map<std::string, const LVL1CTP::Lvl1Item*> m_itemsByName;
00182 std::map<std::string, const HLT::Chain*> m_l2chainsByName;
00183 std::map<std::string, const HLT::Chain*> m_efchainsByName;
00184
00185 typedef unsigned CTPID;
00186 typedef unsigned CHAIN_COUNTER;
00187 std::map<CTPID, LVL1CTP::Lvl1Item*> m_itemsCache;
00188 std::map<CHAIN_COUNTER, HLT::Chain*> m_l2chainsCache;
00189 std::map<CHAIN_COUNTER, HLT::Chain*> m_efchainsCache;
00190
00191 std::map<std::string, std::vector<std::string> > m_groups;
00192 std::map<std::string, std::vector<std::string> > m_streams;
00193
00194 const TrigConf::ItemContainer* m_confItems;
00195 const TrigConf::HLTChainList* m_confChains;
00196 mutable const xAOD::TrigCompositeContainer* m_expressStreamContainer;
00197
00198 struct eqstr
00199 {
00200 bool operator()(const char* s1, const char* s2) const
00201 {
00202 return strcmp(s1, s2) == 0;
00203 }
00204 };
00205
00206 typedef std::unordered_map<const char*, const TrigConf::HLTChain*, std::hash<const char*>, eqstr> ChainHashMap_t;
00207 ChainHashMap_t m_mConfChains;
00208
00209 char m_bgCode;
00210
00211
00212 class AnyTypeDeleter {
00213
00214
00215 struct iholder {
00216 virtual ~iholder() {}
00217 virtual void* ptr() const { return 0;}
00218 };
00219
00220 struct holder_comp {
00221 bool operator()(iholder* lhs, iholder* rhs) const {
00222 return lhs->ptr() < rhs->ptr(); }
00223 };
00224 template<class T>
00225 class holder : public iholder {
00226 public:
00227 holder(T& t): m_held(t) {}
00228 virtual ~holder() {
00229 delete m_held;
00230 m_held = 0; }
00231 virtual void* ptr() const { return (void*)m_held;}
00232 private:
00233 T m_held;
00234 };
00235
00236 public:
00237 template<class T>
00238 void insert(T t) {
00239 m_todel.insert(new holder<T>(t));
00240 }
00241 void clear() {
00242 BOOST_FOREACH(iholder* i, m_todel) {
00243 delete i;
00244 }
00245 m_todel.clear();
00246 }
00247 ~AnyTypeDeleter();
00248 private:
00249 std::set< iholder*, holder_comp > m_todel;
00250 };
00251
00252 mutable AnyTypeDeleter m_deleteAtEndOfEvent;
00253
00254
00255
00256 };
00257 }
00258
00259 #endif