CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_10/src/CommonTools/RecoAlgos/interface/ClusterStorer.h

Go to the documentation of this file.
00001 #ifndef RecoAlgos_ClusterStorer_h
00002 #define RecoAlgos_ClusterStorer_h
00003 
00017 #include "DataFormats/TrackingRecHit/interface/TrackingRecHitFwd.h"
00018 #include "DataFormats/TrackerRecHit2D/interface/SiPixelRecHit.h"
00019 #include "DataFormats/TrackerRecHit2D/interface/SiStripRecHit2D.h"
00020 #include "DataFormats/SiStripCluster/interface/SiStripCluster.h"
00021 #include "DataFormats/SiPixelCluster/interface/SiPixelCluster.h"
00022 #include "DataFormats/Common/interface/DetSetVectorNew.h"
00023 
00024 namespace helper {
00025 
00026   class ClusterStorer {
00027   public:
00028     ClusterStorer () {}
00030     void addCluster(TrackingRecHitCollection &hits, size_t index);
00032     void clear();
00033     //------------------------------------------------------------------
00037     //------------------------------------------------------------------
00038     void processAllClusters(edmNew::DetSetVector<SiPixelCluster> &pixelDsvToFill,                   
00039                             edm::RefProd<edmNew::DetSetVector<SiPixelCluster> > refPixelClusters,
00040                             edmNew::DetSetVector<SiStripCluster> &stripDsvToFill,
00041                             edm::RefProd<edmNew::DetSetVector<SiStripCluster> > refStripClusters);
00042    
00043     private:
00045     template<typename ClusterRefType>
00046     class ClusterHitRecord {
00047     public:
00050       template<typename RecHitType>
00051       ClusterHitRecord(const RecHitType &hit, TrackingRecHitCollection &hits, size_t idx)
00052         : detid_(hit.geographicalId().rawId()), hits_(&hits), index_(idx), ref_(hit.cluster()) {}
00054       uint32_t detid() const { return detid_; }
00056       const ClusterRefType & clusterRef() const { return ref_; }
00058       bool operator<(const ClusterHitRecord<ClusterRefType> &other) const
00059       {
00060         return (detid_ != other.detid_) ? detid_ < other.detid_ : ref_  < other.ref_;
00061       }
00064       template <typename RecHitType>
00065       void rekey(const ClusterRefType &newRef) const;
00066     private:
00067       ClusterHitRecord() {}
00068       uint32_t detid_;
00069       TrackingRecHitCollection *hits_;
00070       size_t   index_;
00071       ClusterRefType ref_;
00072     };
00073     
00074     typedef ClusterHitRecord<SiPixelRecHit::ClusterRef>   PixelClusterHitRecord;
00076     typedef ClusterHitRecord<SiStripRecHit2D::ClusterRef> StripClusterHitRecord;
00077 
00078     //------------------------------------------------------------------
00081     //------------------------------------------------------------------
00082     template<typename HitType, typename ClusterType>
00083       void
00084       processClusters(std::vector<ClusterHitRecord<typename HitType::ClusterRef> > &clusterRecords,
00085                       edmNew::DetSetVector<ClusterType>                            &dsvToFill,
00086                       edm::RefProd< edmNew::DetSetVector<ClusterType> >            &refprod);
00087 
00088     //--- Information about the cloned clusters
00089     std::vector<PixelClusterHitRecord>                  pixelClusterRecords_;
00090     std::vector<StripClusterHitRecord>                  stripClusterRecords_;
00091   };
00092 
00093 }
00094 
00095 #endif