00001
00002 #ifndef XAODMISSINGET_VERSIONS_MISSINGETCOMPONENTMAP_V1_H
00003 #define XAODMISSINGET_VERSIONS_MISSINGETCOMPONENTMAP_V1_H
00004
00005 #include "AthContainers/DataVector.h"
00006
00007 #include "xAODBase/ObjectType.h"
00008
00009 #include "xAODMissingET/versions/MissingETCompositionBase.h"
00010 #include "xAODMissingET/MissingET.h"
00011 #include "xAODMissingET/versions/MissingETComponent_v1.h"
00012
00013 #include <string>
00014 #include <vector>
00015 #include <map>
00016
00017 namespace xAOD
00018 {
00019 class MissingETComponentMap_v1 : public DataVector<MissingETComponent_v1>
00020 {
00021 public:
00022
00024 MissingETComponentMap_v1(SG::OwnershipPolicy own=SG::OWN_ELEMENTS, SG::IndexTrackingPolicy trackIndices = SG::DEFAULT_TRACK_INDICES);
00026 MissingETComponentMap_v1(MissingETComponentMap_v1::iterator first, MissingETComponentMap_v1::iterator last,
00027 SG::OwnershipPolicy own=SG::OWN_ELEMENTS, SG::IndexTrackingPolicy trackIndices = SG::DEFAULT_TRACK_INDICES);
00029 virtual ~MissingETComponentMap_v1();
00030
00040 const_iterator find(const MissingET* pMET) const;
00051 const_iterator find(const std::string& name) const;
00062 const_iterator find(MissingETBase::Types::bitmask_t src) const;
00070 iterator find(const MissingET* pMET);
00081 iterator find(const std::string& name);
00092 iterator find(MissingETBase::Types::bitmask_t src);
00093 size_t findIndex(const MissingET* pMET) const;
00094 size_t findIndex(const std::string& name) const;
00095 size_t findIndex(MissingETBase::Types::bitmask_t sw) const;
00103 const MissingET* retrieveMissingET(const std::string& name) const;
00114 const MissingET* retrieveMissingET(MissingETBase::Types::bitmask_t src,bool excl=false) const;
00124 const MissingET* retrieveMissingET(MissingETBase::Types::bitmask_t src,MissingETBase::Types::bitmask_t sw,bool excl=false) const;
00127 public:
00128
00138 bool checkUsage(const IParticle* pPart,MissingETBase::UsageHandler::Policy p=MissingETBase::UsageHandler::OnlyCluster) const;
00154 bool checkUsage(MissingETBase::Types::object_vector_t& sig,MissingETBase::UsageHandler::Policy p=MissingETBase::UsageHandler::OnlyCluster) const;
00155
00156 bool addObjects(const MissingET* pMET,const IParticle* pPart,const MissingETBase::Types::object_vector_t& signalList,
00157 MissingETBase::UsageHandler::Policy p = MissingETBase::UsageHandler::OnlyCluster);
00158 bool setClusters(const MissingET* pMET,const IParticle* pPart,const MissingETBase::Types::object_vector_t& signalList);
00159 bool setTracks(const MissingET* pMET,const IParticle* pPart,const MissingETBase::Types::object_vector_t& signalList);
00160 bool setObjects(const MissingET* pMET,const IParticle* pPart,const MissingETBase::Types::object_vector_t& objectList);
00161 size_t getComponentIndex(const IParticle* pPart) const;
00162 size_t getObjectIndex(const IParticle* pPart) const;
00165
00166
00167
00168 void resize(size_type sz);
00169 void pop_back();
00170 void clear();
00171 void sort();
00172 template <class COMPARE> void sort(COMPARE comp);
00173 void clear (SG::OwnershipPolicy ownPolicy);
00174 void clear (SG::OwnershipPolicy ownPolicy,SG::IndexTrackingPolicy trackIndices);
00175 iterator erase(iterator position);
00176 iterator erase(iterator first, iterator last);
00177
00178 protected:
00179
00182 typedef size_t signal_key_t;
00183 typedef const IParticle* particle_key_t;
00184 typedef MissingETBase::Types::indexedlink_t indexedlink_t;
00189 typedef std::vector<indexedlink_t> signal_vector_t;
00195 typedef std::map<particle_key_t,indexedlink_t> particle_map_t;
00206 mutable signal_vector_t m_clusterLinks;
00209 mutable signal_vector_t m_trackLinks;
00212 mutable particle_map_t m_particleLinks;
00219 template<int N> size_t f_getIndex(const IParticle* pPart) const
00220 {
00221
00222 if ( pPart->type() == Type::CaloCluster )
00223 { size_t idx(pPart->index()); return idx < m_clusterLinks.size() ? m_clusterLinks.at(idx).get<N>() : MissingETBase::Numerical::invalidIndex(); }
00224
00225 if ( pPart->type() == Type::TrackParticle )
00226 { size_t idx(pPart->index()); return idx < m_trackLinks.size() ? m_trackLinks.at(idx).get<N>() : MissingETBase::Numerical::invalidIndex(); }
00227
00228 particle_map_t::const_iterator fPart(m_particleLinks.find(pPart));
00229 return fPart != m_particleLinks.end() ? (fPart->second).get<N>() : MissingETBase::Numerical::invalidIndex();
00230 }
00245 bool f_checkObjectUsage(MissingETBase::Types::object_vector_t& sig,signal_vector_t& signalLinks) const ;
00256 bool f_checkObjectUsage(MissingETBase::Types::object_vector_t& objects,particle_map_t& physicsLinks) const;
00258 void f_fillLookupCache();
00260 void f_clearLookupCache();
00262 void f_setupLookupCache(signal_vector_t& signalLinks,size_t reserve);
00272 template<int OBJTYPE>
00273 bool f_extractSignal(MissingETBase::Types::object_vector_t& sig) const
00274 {
00275 MissingETBase::Types::object_vector_t::iterator fSign(sig.begin());
00276 while ( fSign != sig.end() ) { if ( (*fSign)->type() != OBJTYPE ) { fSign = sig.erase(fSign); } else { ++fSign; } }
00277 return !sig.empty();
00278 }
00300 const_iterator f_findConst(const MissingET* pMET) const;
00315 const_iterator f_findConst(const std::string& name) const;
00316 const_iterator f_findConst(MissingETBase::Types::bitmask_t src) const;
00317 void f_setConstCache(const_iterator fCont) const;
00320 iterator f_find(const MissingET* pMET);
00321 iterator f_find(const std::string& name);
00322 iterator f_find(MissingETBase::Types::bitmask_t src);
00323 void f_setCache(iterator fCont);
00324 void resetCache() const;
00325
00326 const MissingET* f_retrieveMissingETExcl(MissingETBase::Types::bitmask_t src) const;
00327 const MissingET* f_retrieveMissingETExcl(MissingETBase::Types::bitmask_t src,MissingETBase::Types::bitmask_t sw) const;
00328 const MissingET* f_retrieveMissingETIncl(MissingETBase::Types::bitmask_t src) const;
00329 const MissingET* f_retrieveMissingETIncl(MissingETBase::Types::bitmask_t src,MissingETBase::Types::bitmask_t sw) const;
00330
00331 private:
00332
00333 mutable const MissingET* m_lastMETObject;
00334 mutable size_t m_lastContribIndex;
00335
00336 static size_t m_clusterLinkReserve;
00337 static size_t m_trackLinkReserve;
00338 static size_t m_maxClusterSize;
00339 static size_t m_maxTrackSize;
00340 static size_t m_maxSignalSize;
00341
00342 };
00343 }
00344
00345 #include "xAODCore/BaseInfo.h"
00346 SG_BASE(xAOD::MissingETComponentMap_v1, DataVector<xAOD::MissingETComponent_v1>);
00347
00348 #include "xAODMissingET/versions/MissingETComponentMap_v1.icc"
00349 #endif