CMS 3D CMS Logo

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