CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_9_patch3/src/RecoCaloTools/MetaCollections/interface/CaloRecHitMetaCollections.h

Go to the documentation of this file.
00001 #ifndef RECOCALOTOOLS_METACOLLECTIONS_CALORECHITMETACOLLECTIONS_H
00002 #define RECOCALOTOOLS_METACOLLECTIONS_CALORECHITMETACOLLECTIONS_H 1
00003 
00004 #include "DataFormats/HcalRecHit/interface/HcalRecHitCollections.h"
00005 #include "DataFormats/EcalRecHit/interface/EcalRecHitCollections.h"
00006 #include "RecoCaloTools/MetaCollections/interface/CaloRecHitMetaCollectionV.h"
00007 
00008 template <class C> 
00009 class SimpleCaloRecHitMetaCollection : public CaloRecHitMetaCollectionV {
00010 public:
00011   typedef CaloRecHitMetaCollectionV::const_iterator const_iterator;
00012 
00013   SimpleCaloRecHitMetaCollection(const C& c) : coll_(c) { size_=coll_.size(); }
00014   SimpleCaloRecHitMetaCollection(const C* c) : coll_(*c) { size_=coll_.size(); }
00015   virtual const_iterator find(const DetId& id) const {
00016     const_iterator i=end();
00017     typename C::const_iterator j=coll_.find(id);
00018     if (j!=coll_.end()) {
00019       int delta=j-coll_.begin();
00020       i=const_iterator(this,delta);
00021     }
00022     return i;
00023   }
00024   virtual const CaloRecHit* at(const_iterator::offset_type i) const {
00025     return &(coll_[i]);
00026   }
00027 private:
00028   const C& coll_;
00029 };
00030 
00031 typedef SimpleCaloRecHitMetaCollection<HBHERecHitCollection> HBHERecHitMetaCollection;
00032 typedef SimpleCaloRecHitMetaCollection<HFRecHitCollection> HFRecHitMetaCollection;
00033 typedef SimpleCaloRecHitMetaCollection<HORecHitCollection> HORecHitMetaCollection;
00034 typedef SimpleCaloRecHitMetaCollection<EcalRecHitCollection> EcalRecHitMetaCollection;
00035 
00036 #endif