Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:05:20

0001 #ifndef SiStripMatchedRecHit2D_H
0002 #define SiStripMatchedRecHit2D_H
0003 
0004 #include "DataFormats/TrackerRecHit2D/interface/SiStripRecHit2D.h"
0005 
0006 #include "TkCloner.h"
0007 
0008 class SiStripMatchedRecHit2D final : public BaseTrackerRecHit {
0009 public:
0010   typedef BaseTrackerRecHit Base;
0011 
0012   SiStripMatchedRecHit2D() {}
0013   ~SiStripMatchedRecHit2D() override {}
0014 
0015   SiStripMatchedRecHit2D(const LocalPoint& pos,
0016                          const LocalError& err,
0017                          GeomDet const& idet,
0018                          const SiStripRecHit2D* rMono,
0019                          const SiStripRecHit2D* rStereo)
0020       : BaseTrackerRecHit(pos, err, idet, trackerHitRTTI::match),
0021         clusterMono_(rMono->omniClusterRef()),
0022         clusterStereo_(rStereo->omniClusterRef()) {}
0023 
0024   // by value, as they will not exists anymore...
0025   SiStripRecHit2D stereoHit() const { return SiStripRecHit2D(stereoId(), stereoClusterRef()); }
0026   SiStripRecHit2D monoHit() const { return SiStripRecHit2D(monoId(), monoClusterRef()); }
0027 
0028   unsigned int stereoId() const { return rawId() + 1; }
0029   unsigned int monoId() const { return rawId() + 2; }
0030 
0031   // (to be improved)
0032   OmniClusterRef const& firstClusterRef() const override { return monoClusterRef(); }
0033 
0034   OmniClusterRef const& stereoClusterRef() const { return clusterStereo_; }
0035   OmniClusterRef const& monoClusterRef() const { return clusterMono_; }
0036   // Non const variants needed for cluster re-keying
0037   OmniClusterRef& stereoClusterRef() { return clusterStereo_; }
0038   OmniClusterRef& monoClusterRef() { return clusterMono_; }
0039 
0040   SiStripCluster const& stereoCluster() const { return stereoClusterRef().stripCluster(); }
0041   SiStripCluster const& monoCluster() const { return monoClusterRef().stripCluster(); }
0042 
0043   SiStripMatchedRecHit2D* clone() const override { return new SiStripMatchedRecHit2D(*this); }
0044 #ifndef __GCCXML__
0045   RecHitPointer cloneSH() const override { return std::make_shared<SiStripMatchedRecHit2D>(*this); }
0046 #endif
0047 
0048   int dimension() const override { return 2; }
0049   void getKfComponents(KfComponentsHolder& holder) const override { getKfComponents2D(holder); }
0050 
0051   bool sharesInput(const TrackingRecHit* other, SharedInputType what) const override;
0052 
0053   bool sharesInput(TrackerSingleRecHit const& other) const;
0054 
0055   std::vector<const TrackingRecHit*> recHits() const override;
0056 
0057   std::vector<TrackingRecHit*> recHits() override;
0058 
0059   bool canImproveWithTrack() const override { return true; }
0060 
0061 private:
0062   // double dispatch
0063   SiStripMatchedRecHit2D* clone_(TkCloner const& cloner, TrajectoryStateOnSurface const& tsos) const override {
0064     return cloner(*this, tsos).release();
0065   }
0066 #ifndef __GCCXML__
0067   RecHitPointer cloneSH_(TkCloner const& cloner, TrajectoryStateOnSurface const& tsos) const override {
0068     return cloner.makeShared(*this, tsos);
0069   }
0070 #endif
0071 
0072 private:
0073   OmniClusterRef clusterMono_, clusterStereo_;
0074 };
0075 
0076 inline bool sharesClusters(SiStripMatchedRecHit2D const& h1,
0077                            SiStripMatchedRecHit2D const& h2,
0078                            TrackingRecHit::SharedInputType what) {
0079   bool mono = h1.monoClusterRef() == h2.monoClusterRef();
0080   bool stereo = h1.stereoClusterRef() == h2.stereoClusterRef();
0081 
0082   return (what == TrackingRecHit::all) ? (mono && stereo) : (mono || stereo);
0083 }
0084 
0085 #endif