Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:01:08

0001 #ifndef RecoAlgos_ClusterStorer_h
0002 #define RecoAlgos_ClusterStorer_h
0003 /** \class ClusterStorer
0004  *
0005  * Helper to store clones of SiStrip- and SiPixelClusters
0006  * of selected RecHits
0007  * 
0008  * \author Gero Flucke, DESY
0009  *         based on code originally part of TrackSelector.h by Giovanni Petrucciani,
0010  *         but extended to deal with both SiStripRecHit1D and SiStripRecHit2D
0011  * 
0012  * \version $Revision: 1.1 $
0013  *
0014  * $Id: TrackSelector.h,v 1.1 2009/03/04 13:11:28 llista Exp $
0015  *
0016  */
0017 #include "DataFormats/TrackingRecHit/interface/TrackingRecHitFwd.h"
0018 #include "DataFormats/TrackerRecHit2D/interface/SiPixelRecHit.h"
0019 #include "DataFormats/TrackerRecHit2D/interface/SiStripRecHit2D.h"
0020 #include "DataFormats/TrackerRecHit2D/interface/Phase2TrackerRecHit1D.h"
0021 #include "DataFormats/SiStripCluster/interface/SiStripCluster.h"
0022 #include "DataFormats/SiPixelCluster/interface/SiPixelCluster.h"
0023 #include "DataFormats/Phase2TrackerCluster/interface/Phase2TrackerCluster1D.h"
0024 #include "DataFormats/Common/interface/DetSetVectorNew.h"
0025 
0026 namespace helper {
0027 
0028   class ClusterStorer {
0029   public:
0030     ClusterStorer() {}
0031     /// add cluster of newHit to list (throws if hit is of unknown type)
0032     void addCluster(TrackingRecHitCollection &hits, size_t index);
0033     /// clear records
0034     void clear();
0035     //------------------------------------------------------------------
0036     //!  Processes all the clusters of the tracks
0037     //!  (after the tracks have been dealt with),
0038     //!  need Refs to products (i.e. full collections) in the event.
0039     //------------------------------------------------------------------
0040     void processAllClusters(edmNew::DetSetVector<SiPixelCluster> &pixelDsvToFill,
0041                             edm::RefProd<edmNew::DetSetVector<SiPixelCluster> > refPixelClusters,
0042                             edmNew::DetSetVector<SiStripCluster> &stripDsvToFill,
0043                             edm::RefProd<edmNew::DetSetVector<SiStripCluster> > refStripClusters,
0044                             edmNew::DetSetVector<Phase2TrackerCluster1D> &phase2OTDsvToFill,
0045                             edm::RefProd<edmNew::DetSetVector<Phase2TrackerCluster1D> > refPhase2OTClusters);
0046 
0047   private:
0048     /// A struct for clusters associated to hits
0049     template <typename ClusterRefType>
0050     class ClusterHitRecord {
0051     public:
0052       /// Create a record for a hit with a given index in the TrackingRecHitCollection.
0053       /// 'RecHitType' must have a method 'cluster()' that returns a 'ClusterRefType'.
0054       template <typename RecHitType>
0055       ClusterHitRecord(const RecHitType &hit, TrackingRecHitCollection &hits, size_t idx)
0056           : detid_(hit.geographicalId().rawId()), hits_(&hits), index_(idx), ref_(hit.cluster()) {}
0057       /// returns the detid
0058       uint32_t detid() const { return detid_; }
0059       /// this method is to be able to compare and see if two refs are the same
0060       const ClusterRefType &clusterRef() const { return ref_; }
0061       /// this one is to sort by detid and then by index of the rechit
0062       bool operator<(const ClusterHitRecord<ClusterRefType> &other) const {
0063         return (detid_ != other.detid_) ? detid_ < other.detid_ : ref_ < other.ref_;
0064       }
0065       /// Set the reference of the hit of this record to 'newRef',
0066       /// will not modify the ref stored in this object.
0067       template <typename RecHitType>
0068       void rekey(const ClusterRefType &newRef);
0069 
0070     private:
0071       ClusterHitRecord() {}  /// private => unusable
0072       uint32_t detid_;
0073       TrackingRecHitCollection *hits_;
0074       size_t index_;
0075       ClusterRefType ref_;
0076     };
0077 
0078     typedef ClusterHitRecord<SiPixelRecHit::ClusterRef> PixelClusterHitRecord;
0079     /// Assuming that the ClusterRef is the same for all SiStripRecHit*:
0080     typedef ClusterHitRecord<SiStripRecHit2D::ClusterRef> StripClusterHitRecord;
0081     //FIXME:: this is just temporary solution for phase2,
0082     //probably is good to add a Phase2ClusterStorer?
0083     typedef ClusterHitRecord<Phase2TrackerRecHit1D::ClusterRef> Phase2OTClusterHitRecord;
0084 
0085     //------------------------------------------------------------------
0086     //!  Processes all the clusters of a specific type
0087     //!  (after the tracks have been dealt with)
0088     //------------------------------------------------------------------
0089     template <typename HitType, typename ClusterType>
0090     void processClusters(std::vector<ClusterHitRecord<typename HitType::ClusterRef> > &clusterRecords,
0091                          edmNew::DetSetVector<ClusterType> &dsvToFill,
0092                          edm::RefProd<edmNew::DetSetVector<ClusterType> > &refprod);
0093 
0094     //--- Information about the cloned clusters
0095     std::vector<PixelClusterHitRecord> pixelClusterRecords_;
0096     std::vector<StripClusterHitRecord> stripClusterRecords_;
0097     std::vector<Phase2OTClusterHitRecord> phase2OTClusterRecords_;
0098   };
0099 
0100 }  // namespace helper
0101 
0102 #endif