Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #ifndef FastMatchedTrackerRecHit_H
0002 #define FastMatchedTrackerRecHit_H
0003 
0004 #include "DataFormats/TrackerRecHit2D/interface/FastTrackerRecHit.h"
0005 #include "DataFormats/TrackerRecHit2D/interface/FastSingleTrackerRecHit.h"
0006 
0007 class FastMatchedTrackerRecHit : public FastTrackerRecHit {
0008 public:
0009   FastMatchedTrackerRecHit() : stereoHitFirst_(false) {}
0010 
0011   ~FastMatchedTrackerRecHit() override {}
0012 
0013   FastMatchedTrackerRecHit(const LocalPoint& pos,
0014                            const LocalError& err,
0015                            const GeomDet& idet,
0016                            const FastSingleTrackerRecHit& rMono,
0017                            const FastSingleTrackerRecHit& rStereo,
0018                            bool stereoHitFirst = false)
0019       : FastTrackerRecHit(pos, err, idet, fastTrackerRecHitType::siStripMatched2D),
0020         stereoHitFirst_(stereoHitFirst),
0021         componentMono_(rMono),
0022         componentStereo_(rStereo){};
0023 
0024   FastMatchedTrackerRecHit* clone() const override {
0025     FastMatchedTrackerRecHit* p = new FastMatchedTrackerRecHit(*this);
0026     p->load();
0027     return p;
0028   }
0029 
0030   size_t nIds() const override { return 2; }
0031   int32_t id(size_t i = 0) const override { return i == 0 ? monoHit().id() : stereoHit().id(); }
0032   int32_t eventId(size_t i = 0) const override { return i == 0 ? monoHit().eventId() : stereoHit().eventId(); }
0033 
0034   size_t nSimTrackIds() const override {
0035     return componentMono_.nSimTrackIds() + componentStereo_.nSimTrackIds();
0036   }  ///< see addSimTrackId(int32_t simTrackId)
0037   int32_t simTrackId(size_t i) const override {
0038     return i < componentMono_.nSimTrackIds() ? componentMono_.simTrackId(i)
0039                                              : componentStereo_.simTrackId(i - componentMono_.nSimTrackIds());
0040   }
0041   int32_t simTrackEventId(size_t i) const override {
0042     return i < componentMono_.nSimTrackIds() ? componentMono_.simTrackEventId(i)
0043                                              : componentStereo_.simTrackEventId(i - componentMono_.nSimTrackIds());
0044   }
0045 
0046   const FastSingleTrackerRecHit& monoHit() const { return componentMono_; }
0047   const FastSingleTrackerRecHit& stereoHit() const { return componentStereo_; }
0048   const FastSingleTrackerRecHit& firstHit() const { return stereoHitFirst_ ? componentStereo_ : componentMono_; }
0049   const FastSingleTrackerRecHit& secondHit() const { return stereoHitFirst_ ? componentMono_ : componentStereo_; }
0050 
0051   void setStereoLayerFirst(bool stereoHitFirst = true) { stereoHitFirst_ = stereoHitFirst; }
0052   void setEventId(int32_t eventId) override {
0053     componentMono_.setEventId(eventId);
0054     componentStereo_.setEventId(eventId);
0055   }
0056 
0057   void setRecHitCombinationIndex(int32_t recHitCombinationIndex) override {
0058     FastTrackerRecHit::setRecHitCombinationIndex(recHitCombinationIndex);
0059     componentMono_.setRecHitCombinationIndex(recHitCombinationIndex);
0060     componentStereo_.setRecHitCombinationIndex(recHitCombinationIndex);
0061   }
0062 
0063 private:
0064   bool stereoHitFirst_;
0065   FastSingleTrackerRecHit componentMono_;
0066   FastSingleTrackerRecHit componentStereo_;
0067 };
0068 
0069 #endif