Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #ifndef DataFormats_TrackerRecHit2D_VectorHit_h
0002 #define DataFormats_TrackerRecHit2D_VectorHit_h
0003 
0004 /** \class VectorHit
0005  *
0006  * 4-parameter RecHits for Phase2 Tracker (x,y, dx/dz, dy/dz)
0007  *
0008  * $Date: 2015/03/30 $
0009  * \author Erica Brondolin
0010  *
0011  */
0012 
0013 #include "DataFormats/TrackerRecHit2D/interface/BaseTrackerRecHit.h"
0014 #include "DataFormats/TrackerRecHit2D/interface/VectorHit2D.h"
0015 #include "DataFormats/TrackerRecHit2D/interface/OmniClusterRef.h"
0016 
0017 #include "DataFormats/Common/interface/DetSetVector.h"
0018 #include "DataFormats/Common/interface/DetSetVectorNew.h"
0019 
0020 #include "DataFormats/Phase2TrackerCluster/interface/Phase2TrackerCluster1D.h"
0021 #include "DataFormats/GeometryVector/interface/LocalVector.h"
0022 #include "Geometry/CommonDetUnit/interface/PixelGeomDetUnit.h"
0023 
0024 #include "DataFormats/TrackingRecHit/interface/KfComponentsHolder.h"
0025 
0026 #include "DataFormats/TrackerRecHit2D/interface/TkCloner.h"
0027 
0028 class VectorHit final : public BaseTrackerRecHit {
0029 public:
0030   typedef OmniClusterRef::Phase2Cluster1DRef ClusterRef;
0031 
0032   VectorHit() : thePosition(), theDirection(), theCovMatrix() { setType(bad); }
0033 
0034   VectorHit(const GeomDet& idet,
0035             const LocalPoint& posInner,
0036             const LocalVector& dir,
0037             const AlgebraicSymMatrix44& covMatrix,
0038             const float chi2,
0039             OmniClusterRef const& lower,
0040             OmniClusterRef const& upper,
0041             const float curvature,
0042             const float curvatureError,
0043             const float phi);
0044 
0045   VectorHit(const GeomDet& idet,
0046             const VectorHit2D& vh2Dzx,
0047             const VectorHit2D& vh2Dzy,
0048             OmniClusterRef const& lower,
0049             OmniClusterRef const& upper,
0050             const float curvature,
0051             const float curvatureError,
0052             const float phi);
0053 
0054   ~VectorHit() override = default;
0055 
0056   VectorHit* clone() const override { return new VectorHit(*this); }
0057   RecHitPointer cloneSH() const override { return std::make_shared<VectorHit>(*this); }
0058 
0059   bool sharesInput(const TrackingRecHit* other, SharedInputType what) const override;
0060   bool sharesClusters(VectorHit const& other, SharedInputType what) const;
0061 
0062   // Parameters of the segment, for the track fit
0063   // For a 4D segment: (dx/dz,dy/dz,x,y)
0064   bool hasPositionAndError() const override {
0065     //if det is present pos&err are available as well.
0066     //if det() is not present (null) the hit has been read from file and not updated
0067     return det();
0068   };
0069 
0070   void getKfComponents(KfComponentsHolder& holder) const override { getKfComponents4D(holder); }
0071   void getKfComponents4D(KfComponentsHolder& holder) const;
0072 
0073   // returning methods
0074   LocalPoint localPosition() const override { return thePosition; }
0075   virtual LocalVector localDirection() const { return theDirection; }
0076   const AlgebraicSymMatrix44& covMatrix() const;
0077   LocalError localPositionError() const override;
0078   LocalError localDirectionError() const;
0079   Global3DVector globalDirectionVH() const;
0080 
0081   float chi2() const { return theChi2; }
0082   int dimension() const override { return theDimension; }
0083   float curvature() const { return theCurvature; }
0084   float curvatureError() const { return theCurvatureError; }
0085   float phi() const { return thePhi; }
0086 
0087   float transverseMomentum(float magField) const;
0088   float momentum(float magField) const;
0089 
0090   /// "lower" is logical, not geometrically lower; in pixel-strip modules the "lower" is always a pixel
0091   ClusterRef lowerCluster() const { return theLowerCluster.cluster_phase2OT(); }
0092   ClusterRef upperCluster() const { return theUpperCluster.cluster_phase2OT(); }
0093   OmniClusterRef const lowerClusterRef() const { return theLowerCluster; }
0094   OmniClusterRef const upperClusterRef() const { return theUpperCluster; }
0095   // Non const variants needed for cluster re-keying
0096   OmniClusterRef& lowerClusterRef() { return theLowerCluster; }
0097   OmniClusterRef& upperClusterRef() { return theUpperCluster; }
0098 
0099   //FIXME::to update with a proper CPE maybe...
0100   Global3DPoint lowerGlobalPos() const;
0101   Global3DPoint upperGlobalPos() const;
0102   static Global3DPoint phase2clusterGlobalPos(const PixelGeomDetUnit* geomDet, ClusterRef cluster);
0103   GlobalError lowerGlobalPosErr() const;
0104   GlobalError upperGlobalPosErr() const;
0105   static GlobalError phase2clusterGlobalPosErr(const PixelGeomDetUnit* geomDet);
0106 
0107   bool isPhase2() const override { return true; }
0108 
0109   //FIXME: I have always two clusters in a VH
0110   OmniClusterRef const& firstClusterRef() const override { return theLowerCluster; }
0111   ClusterRef cluster() const { return theLowerCluster.cluster_phase2OT(); }
0112 
0113   //This method returns the direction of the segment/stub in global coordinates
0114   Global3DVector globalDirection() const;
0115   float theta() const;
0116 
0117   // Access to component RecHits (if any)
0118   std::vector<const TrackingRecHit*> recHits() const override;
0119   std::vector<TrackingRecHit*> recHits() override;
0120 
0121 private:
0122   // double dispatch
0123   VectorHit* clone_(TkCloner const& cloner, TrajectoryStateOnSurface const& tsos) const override {
0124     return cloner(*this, tsos).release();
0125   }
0126   RecHitPointer cloneSH_(TkCloner const& cloner, TrajectoryStateOnSurface const& tsos) const override {
0127     return cloner.makeShared(*this, tsos);
0128   }
0129 
0130   LocalPoint thePosition;
0131   LocalVector theDirection;
0132 
0133   // the covariance matrix, has the following meaning
0134   // mat[0][0]=var(dx/dz)
0135   // mat[1][1]=var(dy/dz)
0136   // mat[2][2]=var(x)
0137   // mat[3][3]=var(y)
0138   // mat[0][2]=cov(dx/dz,x)
0139   // mat[1][3]=cov(dy/dz,y)
0140   AlgebraicSymMatrix44 theCovMatrix;
0141   float theChi2;
0142   static constexpr int theDimension = 4;
0143   OmniClusterRef theLowerCluster;
0144   OmniClusterRef theUpperCluster;
0145   float theCurvature;
0146   float theCurvatureError;
0147   float thePhi;
0148 };
0149 
0150 inline bool operator<(const VectorHit& one, const VectorHit& other) { return (one.chi2() < other.chi2()); }
0151 
0152 std::ostream& operator<<(std::ostream& os, const VectorHit& vh);
0153 
0154 typedef edmNew::DetSetVector<VectorHit> VectorHitCollection;
0155 
0156 #endif