CMS 3D CMS Logo

BaseTrackerRecHit.h
Go to the documentation of this file.
1 #ifndef BaseTrackerRecHit_H
2 #define BaseTrackerRecHit_H
3 
9 
10 
11 //#define DO_INTERNAL_CHECKS_BTR
12 //#define VI_DEBUG
13 
14 class OmniClusterRef;
15 
17 public:
19 
20  // fake TTRH interface
21  BaseTrackerRecHit const * hit() const final { return this;}
22 
23  ~BaseTrackerRecHit() override {}
24 
25  // no position (as in persistent)
27 
29  GeomDet const & idet, trackerHitRTTI::RTTI rt) :
30  TrackingRecHit(idet, (unsigned int)(rt)), pos_(p), err_(e), qualWord_(0){
31  LocalError lape = static_cast<TrackerGeomDet const *>(det())->localAlignmentError();
32  if (lape.valid())
33  err_ = LocalError(err_.xx()+lape.xx(),
34  err_.xy()+lape.xy(),
35  err_.yy()+lape.yy()
36  );
37  }
38 
40  bool isSingle() const { return trackerHitRTTI::isSingle(*this);}
41  bool isMatched() const { return trackerHitRTTI::isMatched(*this);}
42  bool isProjected() const { return trackerHitRTTI::isProjected(*this);}
43  bool isProjMono() const { return trackerHitRTTI::isProjMono(*this);}
44  bool isProjStereo() const { return trackerHitRTTI::isProjStereo(*this);}
45  bool isMulti() const { return trackerHitRTTI::isMulti(*this);}
46 
47  virtual bool isPixel() const { return false;}
48  virtual bool isPhase2() const { return false;}
49 
50  // used by trackMerger (to be improved)
51  virtual OmniClusterRef const & firstClusterRef() const=0;
52 
53 
54  // verify that hits can share clusters...
55  inline bool sameDetModule(TrackingRecHit const & hit) const;
56 
57  bool hasPositionAndError() const final;
58 
59  LocalPoint localPosition() const final { check(); return pos_;}
60 
61  LocalError localPositionError() const final { check(); return err_;}
62 
63 
64  const LocalPoint & localPositionFast() const { check(); return pos_; }
65  const LocalError & localPositionErrorFast() const { check(); return err_; }
66 
67 
68 
69  // to be specialized for 1D and 2D
70  void getKfComponents( KfComponentsHolder & holder ) const override =0;
71  int dimension() const override =0;
72 
73  void getKfComponents1D( KfComponentsHolder & holder ) const;
74  void getKfComponents2D( KfComponentsHolder & holder ) const;
75 
76 
77  // global coordinates
78  // Extension of the TrackingRecHit interface
79  const Surface * surface() const final {return &(det()->surface());}
80 
81 
82  GlobalPoint globalPosition() const final {
83  return surface()->toGlobal(localPosition());
84  }
85 
87  float errorGlobalR() const final { return std::sqrt(globalPositionError().rerr(globalPosition()));}
88  float errorGlobalZ() const final { return std::sqrt(globalPositionError().czz()); }
89  float errorGlobalRPhi() const final { return globalPosition().perp()*sqrt(globalPositionError().phierr(globalPosition())); }
90 
91  // once cache removed will obsolete the above
96  float r = gp.perp();
97  float errorRPhi = r*std::sqrt(float(globalError.phierr(gp)));
98  float errorR = std::sqrt(float(globalError.rerr(gp)));
99  float errorZ = std::sqrt(float(globalError.czz()));
100  return (TrackingRecHitGlobalState){
101  gp.basicVector(), r, gp.barePhi(),
102  errorR,errorZ,errorRPhi
103  };
104  }
105 
107  virtual float clusterProbability() const { return 1.f; }
108 
109 public:
110 
111  // obsolete (for what tracker is concerned...) interface
112  AlgebraicVector parameters() const override;
113  AlgebraicSymMatrix parametersError() const override;
114  AlgebraicMatrix projectionMatrix() const override;
115 
116 private:
117 
118 #ifdef VI_DEBUG
119  void check() const { assert(det());}
120 #elif defined(DO_INTERNAL_CHECKS_BTR)
121  void check() const;
122 #else
123  static void check(){}
124 #endif
125 
126 protected:
127 
130 protected:
131  //this comes for free (padding)
132  unsigned int qualWord_;
133 };
134 
135 
137  unsigned int myid = geographicalId().rawId();
138  unsigned int mysubd = myid >> (DetId::kSubdetOffset);
139 
140  unsigned int id = hit.geographicalId().rawId();
141  unsigned int subd = id >> (DetId::kSubdetOffset);
142 
143  if (mysubd!=subd) return false;
144 
145  //Protection against invalid hits
146  if(!hit.isValid()) return false;
147 
148  const unsigned int limdet = 10; // TIB=11
149 
150  if (mysubd>limdet) { // strip
151  // mask glue and stereo
152  myid|=3;
153  id|=3;
154  }
155  return id==myid;
156 
157 }
158 
159 
160 // Comparison operators
161 inline bool operator<( const BaseTrackerRecHit& one, const BaseTrackerRecHit& other) {
162  return ( one.geographicalId() < other.geographicalId() );
163 }
164 #endif // BaseTrackerRecHit_H
float errorGlobalR() const final
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
Definition: Surface.h:106
bool valid() const
Definition: LocalError.h:21
bool isMulti() const
RTTI rtti(TrackingRecHit const &hit)
static GlobalError transform(const LocalError &le, const Surface &surf)
float xx() const
Definition: LocalError.h:24
T perp() const
Definition: PV3DBase.h:72
LocalError localPositionError() const final
GlobalError globalPositionError() const final
TrackingRecHitGlobalState globalState() const
bool isProjMono(TrackingRecHit const &hit)
bool hasPositionAndError() const final
to be redefined by daughter class
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:50
AlgebraicMatrix projectionMatrix() const override
static const int kSubdetOffset
Definition: DetId.h:23
bool sameDetModule(TrackingRecHit const &hit) const
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:42
BaseTrackerRecHit(const LocalPoint &p, const LocalError &e, GeomDet const &idet, trackerHitRTTI::RTTI rt)
T phierr(const GlobalPoint &aPoint) const
T barePhi() const
Definition: PV3DBase.h:68
float xy() const
Definition: LocalError.h:25
CLHEP::HepMatrix AlgebraicMatrix
bool isProjStereo(TrackingRecHit const &hit)
float yy() const
Definition: LocalError.h:26
const GeomDet * det() const
T sqrt(T t)
Definition: SSEVec.h:18
BaseTrackerRecHit const * hit() const final
void getKfComponents2D(KfComponentsHolder &holder) const
bool isMatched(TrackingRecHit const &hit)
virtual bool isPixel() const
bool isProjStereo() const
float errorGlobalZ() const final
const LocalError & localPositionErrorFast() const
bool isProjMono() const
Definition: DetId.h:18
CLHEP::HepVector AlgebraicVector
AlgebraicSymMatrix parametersError() const override
int dimension() const override=0
bool isSingle(TrackingRecHit const &hit)
T rerr(const GlobalPoint &aPoint) const
~BaseTrackerRecHit() override
bool isProjected() const
bool isValid() const
void getKfComponents(KfComponentsHolder &holder) const override=0
void getKfComponents1D(KfComponentsHolder &holder) const
AlgebraicVector parameters() const override
const Surface * surface() const final
bool isMatched() const
bool isMulti(TrackingRecHit const &hit)
float errorGlobalRPhi() const final
virtual bool isPhase2() const
virtual OmniClusterRef const & firstClusterRef() const =0
CLHEP::HepSymMatrix AlgebraicSymMatrix
bool operator<(const BaseTrackerRecHit &one, const BaseTrackerRecHit &other)
trackerHitRTTI::RTTI rtti() const
LocalPoint localPosition() const final
GlobalPoint globalPosition() const final
const LocalPoint & localPositionFast() const
DetId geographicalId() const
virtual float clusterProbability() const
cluster probability, overloaded by pixel rechits.
BaseTrackerRecHit(DetId id, trackerHitRTTI::RTTI rt)
const BasicVectorType & basicVector() const
Definition: PV3DBase.h:56
bool isProjected(TrackingRecHit const &hit)
unsigned int qualWord_
bool isSingle() const