Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:31:42

0001 #ifndef GenericTransientTrackingRecHit_H
0002 #define GenericTransientTrackingRecHit_H
0003 
0004 #include "TrackingTools/TransientTrackingRecHit/interface/TValidTrackingRecHit.h"
0005 #include "DataFormats/CLHEP/interface/AlgebraicObjects.h"
0006 
0007 class GenericTransientTrackingRecHit : public TValidTrackingRecHit {
0008 public:
0009   typedef TrackingRecHit::Type Type;
0010 
0011   ~GenericTransientTrackingRecHit() override { delete trackingRecHit_; }
0012 
0013   AlgebraicVector parameters() const override { return trackingRecHit_->parameters(); }
0014   AlgebraicSymMatrix parametersError() const override { return trackingRecHit_->parametersError(); }
0015   AlgebraicMatrix projectionMatrix() const override { return trackingRecHit_->projectionMatrix(); }
0016   int dimension() const override { return trackingRecHit_->dimension(); }
0017 
0018   // virtual void getKfComponents( KfComponentsHolder & holder ) const  override { trackingRecHit_->getKfComponents(holder); }
0019   // NO, because someone might specialize parametersError, projectionMatrix or parameters in the transient rechit
0020   // and in fact this happens for alignment
0021 
0022   LocalPoint localPosition() const override { return trackingRecHit_->localPosition(); }
0023   LocalError localPositionError() const override { return trackingRecHit_->localPositionError(); }
0024 
0025   bool canImproveWithTrack() const override { return false; }
0026 
0027   const TrackingRecHit* hit() const override { return trackingRecHit_; }
0028   TrackingRecHit* cloneHit() const override { return hit()->clone(); }
0029 
0030   std::vector<const TrackingRecHit*> recHits() const override {
0031     return ((const TrackingRecHit*)(trackingRecHit_))->recHits();
0032   }
0033   std::vector<TrackingRecHit*> recHits() override { return trackingRecHit_->recHits(); }
0034 
0035   static RecHitPointer build(const GeomDet* geom, const TrackingRecHit* rh) {
0036     return RecHitPointer(new GenericTransientTrackingRecHit(*geom, *rh));
0037   }
0038 
0039 protected:
0040   // private constructors enforce usage of builders
0041   GenericTransientTrackingRecHit(const GeomDet& geom, const TrackingRecHit& rh) : TValidTrackingRecHit(geom, rh) {
0042     trackingRecHit_ = rh.clone();
0043   }
0044 
0045   /// for derived classes convenience, does not clone!
0046   GenericTransientTrackingRecHit(const GeomDet& geom, TrackingRecHit* rh)
0047       : TValidTrackingRecHit(geom, *rh), trackingRecHit_(rh) {}
0048 
0049   GenericTransientTrackingRecHit(const GenericTransientTrackingRecHit& other)
0050       : TValidTrackingRecHit(*other.det(), other) {
0051     trackingRecHit_ = other.cloneHit();
0052   }
0053 
0054   TrackingRecHit* trackingRecHit_;
0055 
0056 private:
0057   // should not have assignment operator (?)
0058   GenericTransientTrackingRecHit& operator=(const GenericTransientTrackingRecHit& t) {
0059     trackingRecHit_ = t.cloneHit();
0060     return *(this);
0061   }
0062 
0063   // hide the clone method for ReferenceCounted. Warning: this method is still
0064   // accessible via the bas class TrackingRecHit interface!
0065   GenericTransientTrackingRecHit* clone() const override { return new GenericTransientTrackingRecHit(*this); }
0066 };
0067 
0068 #endif