Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #ifndef RECOTRACKER_TRANSIENTRACKINGRECHIT_TRecHit2DPosConstraint_H
0002 #define RECOTRACKER_TRANSIENTRACKINGRECHIT_TRecHit2DPosConstraint_H
0003 
0004 #include "DataFormats/TrackerRecHit2D/interface/trackerHitRTTI.h"
0005 #include "DataFormats/GeometryCommonDetAlgo/interface/ErrorFrameTransformer.h"
0006 
0007 class TRecHit2DPosConstraint final : public TrackingRecHit {
0008 public:
0009   TRecHit2DPosConstraint(const LocalPoint& pos, const LocalError& err, const Surface* surface)
0010       : TrackingRecHit(0, int(trackerHitRTTI::notFromCluster)), pos_(pos), err_(err), surface_(surface) {}
0011 
0012   TRecHit2DPosConstraint(const GeomDet& idet, const LocalPoint& pos, const LocalError& err, const Surface* surface)
0013       : TrackingRecHit(idet, int(trackerHitRTTI::notFromCluster)), pos_(pos), err_(err) {}
0014 
0015   TRecHit2DPosConstraint(const TRecHit2DPosConstraint& other) = default;
0016   TRecHit2DPosConstraint(TRecHit2DPosConstraint&& other) = default;
0017 
0018   ~TRecHit2DPosConstraint() override {}
0019 
0020   AlgebraicVector parameters() const override {
0021     AlgebraicVector result(2);
0022     LocalPoint lp = localPosition();
0023     result[0] = lp.x();
0024     result[1] = lp.y();
0025     return result;
0026   }
0027 
0028   AlgebraicSymMatrix parametersError() const override {
0029     AlgebraicSymMatrix m(2);
0030     LocalError le(localPositionError());
0031     m[0][0] = le.xx();
0032     m[0][1] = le.xy();
0033     m[1][1] = le.yy();
0034     return m;
0035   }
0036 
0037   AlgebraicMatrix projectionMatrix() const override {
0038     AlgebraicMatrix theProjectionMatrix;
0039     theProjectionMatrix = AlgebraicMatrix(2, 5, 0);
0040     theProjectionMatrix[0][3] = 1;
0041     theProjectionMatrix[1][4] = 1;
0042     return theProjectionMatrix;
0043   }
0044   int dimension() const override { return 2; }
0045 
0046   LocalPoint localPosition() const override { return pos_; }
0047   LocalError localPositionError() const override { return err_; }
0048 
0049   std::vector<const TrackingRecHit*> recHits() const override { return std::vector<const TrackingRecHit*>(); }
0050   std::vector<TrackingRecHit*> recHits() override { return std::vector<TrackingRecHit*>(); }
0051 
0052   // use position?
0053   bool sharesInput(const TrackingRecHit*, SharedInputType) const override { return false; }
0054 
0055   bool canImproveWithTrack() const override { return false; }
0056 
0057   virtual RecHitPointer clone(const TrajectoryStateOnSurface& ts) const { return RecHitPointer(clone()); }
0058 
0059   static RecHitPointer build(const LocalPoint& pos, const LocalError& err, const Surface* surface) {
0060     return RecHitPointer(new TRecHit2DPosConstraint(pos, err, surface));
0061   }
0062 
0063   const Surface* surface() const override { return det() ? &(det()->surface()) : &(*surface_); }
0064 
0065   GlobalPoint globalPosition() const override { return surface()->toGlobal(localPosition()); }
0066   GlobalError globalPositionError() const override {
0067     return ErrorFrameTransformer().transform(localPositionError(), *surface());
0068   }
0069   float errorGlobalR() const override { return std::sqrt(globalPositionError().rerr(globalPosition())); }
0070   float errorGlobalZ() const override { return std::sqrt(globalPositionError().czz()); }
0071   float errorGlobalRPhi() const override {
0072     return globalPosition().perp() * sqrt(globalPositionError().phierr(globalPosition()));
0073   }
0074 
0075 private:
0076   const LocalPoint pos_;
0077   const LocalError err_;
0078   ConstReferenceCountingPointer<Surface> surface_;
0079 
0080   TRecHit2DPosConstraint* clone() const override { return new TRecHit2DPosConstraint(*this); }
0081 };
0082 
0083 #endif