|
| 1 | +#ifndef DataFormats_TrackerRecHit2D_VectorHit_h |
| 2 | +#define DataFormats_TrackerRecHit2D_VectorHit_h |
| 3 | + |
| 4 | +/** \class VectorHit |
| 5 | + * |
| 6 | + * 4-parameter RecHits for Phase2 Tracker (x,y, dx/dz, dy/dz) |
| 7 | + * |
| 8 | + * $Date: 2015/03/30 $ |
| 9 | + * \author Erica Brondolin |
| 10 | + * |
| 11 | + */ |
| 12 | + |
| 13 | +#include "DataFormats/TrackerRecHit2D/interface/BaseTrackerRecHit.h" |
| 14 | +#include "DataFormats/TrackerRecHit2D/interface/VectorHit2D.h" |
| 15 | +#include "DataFormats/TrackerRecHit2D/interface/OmniClusterRef.h" |
| 16 | + |
| 17 | +#include "DataFormats/Common/interface/DetSetVector.h" |
| 18 | +#include "DataFormats/Common/interface/DetSetVectorNew.h" |
| 19 | + |
| 20 | +#include "DataFormats/Phase2TrackerCluster/interface/Phase2TrackerCluster1D.h" |
| 21 | +#include "DataFormats/GeometryVector/interface/LocalVector.h" |
| 22 | +#include "Geometry/CommonDetUnit/interface/PixelGeomDetUnit.h" |
| 23 | + |
| 24 | +#include "DataFormats/TrackingRecHit/interface/KfComponentsHolder.h" |
| 25 | + |
| 26 | +#include "DataFormats/TrackerRecHit2D/interface/TkCloner.h" |
| 27 | + |
| 28 | +class VectorHit final : public BaseTrackerRecHit { |
| 29 | +public: |
| 30 | + typedef OmniClusterRef::Phase2Cluster1DRef ClusterRef; |
| 31 | + |
| 32 | + VectorHit() : thePosition(), theDirection(), theCovMatrix() { setType(bad); } |
| 33 | + |
| 34 | + VectorHit(const GeomDet& idet, |
| 35 | + const LocalPoint& posInner, |
| 36 | + const LocalVector& dir, |
| 37 | + const AlgebraicSymMatrix44& covMatrix, |
| 38 | + const float chi2, |
| 39 | + OmniClusterRef const& lower, |
| 40 | + OmniClusterRef const& upper, |
| 41 | + const float curvature, |
| 42 | + const float curvatureError, |
| 43 | + const float phi); |
| 44 | + |
| 45 | + VectorHit(const GeomDet& idet, |
| 46 | + const VectorHit2D& vh2Dzx, |
| 47 | + const VectorHit2D& vh2Dzy, |
| 48 | + OmniClusterRef const& lower, |
| 49 | + OmniClusterRef const& upper, |
| 50 | + const float curvature, |
| 51 | + const float curvatureError, |
| 52 | + const float phi); |
| 53 | + |
| 54 | + ~VectorHit() override = default; |
| 55 | + |
| 56 | + VectorHit* clone() const override { return new VectorHit(*this); } |
| 57 | + RecHitPointer cloneSH() const override { return std::make_shared<VectorHit>(*this); } |
| 58 | + |
| 59 | + bool sharesInput(const TrackingRecHit* other, SharedInputType what) const override; |
| 60 | + bool sharesClusters(VectorHit const& other, SharedInputType what) const; |
| 61 | + |
| 62 | + // Parameters of the segment, for the track fit |
| 63 | + // For a 4D segment: (dx/dz,dy/dz,x,y) |
| 64 | + bool hasPositionAndError() const override { |
| 65 | + //if det is present pos&err are available as well. |
| 66 | + //if det() is not present (null) the hit has been read from file and not updated |
| 67 | + return det(); |
| 68 | + }; |
| 69 | + |
| 70 | + void getKfComponents(KfComponentsHolder& holder) const override { getKfComponents4D(holder); } |
| 71 | + void getKfComponents4D(KfComponentsHolder& holder) const; |
| 72 | + |
| 73 | + // returning methods |
| 74 | + LocalPoint localPosition() const override { return thePosition; } |
| 75 | + virtual LocalVector localDirection() const { return theDirection; } |
| 76 | + const AlgebraicSymMatrix44& covMatrix() const; |
| 77 | + LocalError localPositionError() const override; |
| 78 | + LocalError localDirectionError() const; |
| 79 | + Global3DVector globalDirectionVH() const; |
| 80 | + |
| 81 | + float chi2() const { return theChi2; } |
| 82 | + int dimension() const override { return theDimension; } |
| 83 | + float curvature() const { return theCurvature; } |
| 84 | + float curvatureError() const { return theCurvatureError; } |
| 85 | + float phi() const { return thePhi; } |
| 86 | + |
| 87 | + float transverseMomentum(float magField) const; |
| 88 | + float momentum(float magField) const; |
| 89 | + |
| 90 | + /// "lower" is logical, not geometrically lower; in pixel-strip modules the "lower" is always a pixel |
| 91 | + ClusterRef lowerCluster() const { return theLowerCluster.cluster_phase2OT(); } |
| 92 | + ClusterRef upperCluster() const { return theUpperCluster.cluster_phase2OT(); } |
| 93 | + OmniClusterRef const lowerClusterRef() const { return theLowerCluster; } |
| 94 | + OmniClusterRef const upperClusterRef() const { return theUpperCluster; } |
| 95 | + |
| 96 | + //FIXME::to update with a proper CPE maybe... |
| 97 | + Global3DPoint lowerGlobalPos() const; |
| 98 | + Global3DPoint upperGlobalPos() const; |
| 99 | + static Global3DPoint phase2clusterGlobalPos(const PixelGeomDetUnit* geomDet, ClusterRef cluster); |
| 100 | + GlobalError lowerGlobalPosErr() const; |
| 101 | + GlobalError upperGlobalPosErr() const; |
| 102 | + static GlobalError phase2clusterGlobalPosErr(const PixelGeomDetUnit* geomDet); |
| 103 | + |
| 104 | + bool isPhase2() const override { return true; } |
| 105 | + |
| 106 | + //FIXME: I have always two clusters in a VH |
| 107 | + OmniClusterRef const& firstClusterRef() const override { return theLowerCluster; } |
| 108 | + ClusterRef cluster() const { return theLowerCluster.cluster_phase2OT(); } |
| 109 | + |
| 110 | + //This method returns the direction of the segment/stub in global coordinates |
| 111 | + Global3DVector globalDirection() const; |
| 112 | + float theta() const; |
| 113 | + |
| 114 | + // Access to component RecHits (if any) |
| 115 | + std::vector<const TrackingRecHit*> recHits() const override; |
| 116 | + std::vector<TrackingRecHit*> recHits() override; |
| 117 | + |
| 118 | +private: |
| 119 | + // double dispatch |
| 120 | + VectorHit* clone_(TkCloner const& cloner, TrajectoryStateOnSurface const& tsos) const override { |
| 121 | + return cloner(*this, tsos).release(); |
| 122 | + } |
| 123 | + RecHitPointer cloneSH_(TkCloner const& cloner, TrajectoryStateOnSurface const& tsos) const override { |
| 124 | + return cloner.makeShared(*this, tsos); |
| 125 | + } |
| 126 | + |
| 127 | + LocalPoint thePosition; |
| 128 | + LocalVector theDirection; |
| 129 | + |
| 130 | + // the covariance matrix, has the following meaning |
| 131 | + // mat[0][0]=var(dx/dz) |
| 132 | + // mat[1][1]=var(dy/dz) |
| 133 | + // mat[2][2]=var(x) |
| 134 | + // mat[3][3]=var(y) |
| 135 | + // mat[0][2]=cov(dx/dz,x) |
| 136 | + // mat[1][3]=cov(dy/dz,y) |
| 137 | + AlgebraicSymMatrix44 theCovMatrix; |
| 138 | + float theChi2; |
| 139 | + static constexpr int theDimension = 4; |
| 140 | + OmniClusterRef theLowerCluster; |
| 141 | + OmniClusterRef theUpperCluster; |
| 142 | + float theCurvature; |
| 143 | + float theCurvatureError; |
| 144 | + float thePhi; |
| 145 | +}; |
| 146 | + |
| 147 | +inline bool operator<(const VectorHit& one, const VectorHit& other) { return (one.chi2() < other.chi2()); } |
| 148 | + |
| 149 | +std::ostream& operator<<(std::ostream& os, const VectorHit& vh); |
| 150 | + |
| 151 | +typedef edmNew::DetSetVector<VectorHit> VectorHitCollection; |
| 152 | + |
| 153 | +#endif |
0 commit comments