00001
00002 #ifndef TRIGGER_DECISION_TOOL_Combination_H
00003 #define TRIGGER_DECISION_TOOL_Combination_H
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #include "TrigDecisionTool/Feature.h"
00018 #include "TrigDecisionTool/TypelessFeature.h"
00019 #include "TrigDecisionTool/Conditions.h"
00020 #include "TrigDecisionTool/CacheGlobalMemory.h"
00021 #include "TrigNavStructure/TrigNavStructure.h"
00022 #include "boost/foreach.hpp"
00023 #include <vector>
00024
00025 #include "xAODBase/IParticle.h"
00026 #include "xAODBase/IParticleContainer.h"
00027
00028 #if defined(ASGTOOL_ATHENA) && !defined(XAOD_ANALYSIS)
00029 #include "TrigDecisionTool/FeatureCollectAthena.h"
00030 #endif
00031
00032 #include "TrigDecisionTool/FeatureCollectStandalone.h"
00033
00034 class HltNaviChecker;
00035
00036 namespace Trig {
00037
00038 class CacheGlobalMemory;
00039
00047 class Combination
00048 {
00049 public:
00050
00051 Combination();
00052
00056 Combination(const std::vector<HLT::TriggerElement*>& tes, const Trig::CacheGlobalMemory* cgm);
00057
00058
00064 const std::vector<Trig::TypelessFeature> typelessGet(HLT::class_id_type clid, const std::string& label = "", unsigned int condition = TrigDefs::Physics, const std::string & teName = "" ) const;
00065
00073 template<class T>
00074 const std::vector<Trig::Feature<T> > get(const std::string& label = "", unsigned int condition=TrigDefs::Physics, const std::string& teName = "") const;
00075
00076
00077 template<typename CONTAINER> using ELEMENT_OF = typename CONTAINER::base_value_type;
00078
00084 std::vector<Trig::Feature<xAOD::IParticle> > getIParticle(HLT::class_id_type clid, const std::string& container_name, const std::string& label = "", unsigned int condition = TrigDefs::Physics, const std::string & teName = "" ) const{
00085 auto features = typelessGet(clid,label,condition,teName);
00086 return FeatureAccessImpl::typedGet<xAOD::IParticle,xAOD::IParticleContainer,xAOD::IParticleContainer>(features,
00087 navigation(),
00088 m_cgm->store(),
00089 container_name);
00090 }
00091
00095 template<typename CONTAINER>
00096 std::vector<Feature<ELEMENT_OF<CONTAINER> > > elementFeature(const std::string& label = "", unsigned int condition = TrigDefs::Physics, const std::string& teName = "") const{
00097 auto features = typelessGet(ClassID_traits<ELEMENT_OF<CONTAINER> >::ID(),label,condition,teName);
00098 return FeatureAccessImpl::typedGet<ELEMENT_OF<CONTAINER>,ELEMENT_OF<CONTAINER>,CONTAINER>(features,navigation(),m_cgm->store());
00099 }
00100
00104 template<typename CONTAINER>
00105 std::vector<Feature<CONTAINER> > containerFeature(const std::string& label = "", unsigned int condition = TrigDefs::Physics, const std::string& teName = "") const{
00106 auto features = typelessGet(ClassID_traits<CONTAINER>::ID(),label,condition,teName);
00107 return FeatureAccessImpl::typedGet<CONTAINER,CONTAINER,CONTAINER>(features,navigation(),m_cgm->store());
00108 }
00109
00113 template<typename CONTAINER>
00114 std::vector<Feature<ELEMENT_OF<CONTAINER> > > flattenedContainerFeature(const std::string& label = "", unsigned int condition = TrigDefs::Physics, const std::string& teName = "") const{
00115 auto features = typelessGet(ClassID_traits<CONTAINER>::ID(),label,condition,teName);
00116 return FeatureAccessImpl::typedGet<ELEMENT_OF<CONTAINER>,CONTAINER,CONTAINER>(features,navigation(),m_cgm->store());
00117 }
00118
00122 unsigned int size() const { return m_tes.size(); }
00123
00128 bool active() const;
00129
00130
00131
00136 const std::vector<const HLT::TriggerElement*>& tes() const {return m_tes; }
00137
00142 template<class T>
00143 void collect(const HLT::TriggerElement* te, std::vector<Trig::Feature<T> >& data,
00144 const std::string& label, unsigned int condition, const std::string& teName) const;
00145
00146 bool operator==(const Combination& other) const;
00147 bool operator<(const Combination& other) const;
00148
00149
00150 private:
00151 friend class ::HltNaviChecker;
00152
00153
00154
00155
00156 HLT::TrigNavStructure* navigation() const;
00157
00158 std::vector<const HLT::TriggerElement*> m_tes;
00159 const Trig::CacheGlobalMemory* m_cgm;
00160 };
00161 }
00162
00163
00164
00165
00166 template <class T>
00167 const std::vector<Trig::Feature<T> > Trig::Combination::get(const std::string& label, unsigned int condition, const std::string& teName) const
00168 {
00169 std::vector<Feature<T> > data;
00170
00171 #if defined(ASGTOOL_ATHENA) && !defined(XAOD_ANALYSIS)
00172 BOOST_FOREACH( const HLT::TriggerElement* te, m_tes )
00173 FeatureAccessImpl::collect<T>(te, data, label, condition, teName, navigation());
00174 BOOST_FOREACH( Feature<T>& f, data ) {
00175 if ( f.owned() ) {
00176 m_cgm->deleteAtTheEndOfEvent( const_cast<T*>( f.cptr() ) );
00177 }
00178 }
00179 #else
00180 std::cerr << "WARNING: Trig::Combination::get is only available in Athena proper" << std::endl;
00181 (void)label;
00182 (void)condition;
00183 (void)teName;
00184 #endif
00185 return data;
00186 }
00187
00188
00189
00190 MsgStream& operator<< ( MsgStream& m, const Trig::Combination& c );
00191
00192
00193 #endif