CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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)
27  : TrackingRecHit(idet, (unsigned int)(rt)), qualWord_(0) {}
28 
30  : TrackingRecHit(idet, (unsigned int)(rt)), pos_(p), err_(e), qualWord_(0) {
31  auto trackerDet = static_cast<TrackerGeomDet const*>(det());
32  LocalError lape = trackerDet->localAlignmentError();
33  if (lape.valid())
34  err_ = LocalError(err_.xx() + lape.xx(), err_.xy() + lape.xy(), err_.yy() + lape.yy());
35  }
36 
37  trackerHitRTTI::RTTI rtti() const { return trackerHitRTTI::rtti(*this); }
38  bool isSingle() const { return trackerHitRTTI::isSingle(*this); }
39  bool isMatched() const { return trackerHitRTTI::isMatched(*this); }
40  bool isProjected() const { return trackerHitRTTI::isProjected(*this); }
41  bool isProjMono() const { return trackerHitRTTI::isProjMono(*this); }
42  bool isProjStereo() const { return trackerHitRTTI::isProjStereo(*this); }
43  bool isMulti() const { return trackerHitRTTI::isMulti(*this); }
44 
45  virtual bool isPixel() const { return false; }
46  virtual bool isPhase2() const { return false; }
47 
48  // used by trackMerger (to be improved)
49  virtual OmniClusterRef const& firstClusterRef() const = 0;
50 
51  // verify that hits can share clusters...
52  inline bool sameDetModule(TrackingRecHit const& hit) const;
53 
54  bool hasPositionAndError() const override;
55 
56  LocalPoint localPosition() const override {
57  check();
58  return pos_;
59  }
60 
61  LocalError localPositionError() const override {
62  check();
63  return err_;
64  }
65  const LocalPoint& localPositionFast() const {
66  check();
67  return pos_;
68  }
70  check();
71  return err_;
72  }
73 
74  // to be specialized for 1D and 2D
75  void getKfComponents(KfComponentsHolder& holder) const override = 0;
76  int dimension() const override = 0;
77 
78  void getKfComponents1D(KfComponentsHolder& holder) const;
79  void getKfComponents2D(KfComponentsHolder& holder) const;
80 
81  // global coordinates
82  // Extension of the TrackingRecHit interface
83  const Surface* surface() const final { return &(det()->surface()); }
84 
86 
89  }
90  float errorGlobalR() const final { return std::sqrt(globalPositionError().rerr(globalPosition())); }
91  float errorGlobalZ() const final { return std::sqrt(globalPositionError().czz()); }
92  float errorGlobalRPhi() const final {
93  return globalPosition().perp() * sqrt(globalPositionError().phierr(globalPosition()));
94  }
95 
96  // once cache removed will obsolete the above
100  float r = gp.perp();
101  float errorRPhi = r * std::sqrt(float(globalError.phierr(gp)));
102  float errorR = std::sqrt(float(globalError.rerr(gp)));
103  float errorZ = std::sqrt(float(globalError.czz()));
104  return (TrackingRecHitGlobalState){gp.basicVector(), r, gp.barePhi(), errorR, errorZ, errorRPhi};
105  }
106 
108  virtual float clusterProbability() const { return 1.f; }
109 
110 public:
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 #ifdef VI_DEBUG
118  void check() const { assert(det()); }
119 #elif defined(DO_INTERNAL_CHECKS_BTR)
120  void check() const;
121 #else
122  static void check() {}
123 #endif
124 
125 protected:
128 
129 protected:
130  //this comes for free (padding)
131  unsigned int qualWord_;
132 };
133 
135  unsigned int myid = geographicalId().rawId();
136  unsigned int mysubd = myid >> (DetId::kSubdetOffset);
137 
138  unsigned int id = hit.geographicalId().rawId();
139  unsigned int subd = id >> (DetId::kSubdetOffset);
140 
141  if (mysubd != subd)
142  return false;
143 
144  //Protection against invalid hits
145  if (!hit.isValid())
146  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 // Comparison operators
159 inline bool operator<(const BaseTrackerRecHit& one, const BaseTrackerRecHit& other) {
160  return (one.geographicalId() < other.geographicalId());
161 }
162 #endif // BaseTrackerRecHit_H
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
Definition: Surface.h:79
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
float errorGlobalZ() const final
T perp() const
Definition: PV3DBase.h:69
TrackingRecHitGlobalState globalState() const
int dimension() const override=0
GlobalError globalPositionError() const final
AlgebraicSymMatrix parametersError() const override
bool isProjMono(TrackingRecHit const &hit)
BaseTrackerRecHit const * hit() const final
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
float errorGlobalRPhi() const final
void getKfComponents(KfComponentsHolder &holder) const override=0
static const int kSubdetOffset
Definition: DetId.h:22
bool sameDetModule(TrackingRecHit const &hit) const
assert(be >=bs)
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37
list rt
Definition: hcal_runs.py:76
AlgebraicVector parameters() const override
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
void getKfComponents2D(KfComponentsHolder &holder) const
bool hasPositionAndError() const override
to be redefined by daughter class
bool isMatched(TrackingRecHit const &hit)
virtual bool isPixel() const
bool isProjStereo() const
const LocalError & localPositionErrorFast() const
bool isProjMono() const
LocalError localPositionError() const override
Definition: DetId.h:17
GlobalPoint globalPosition() const final
CLHEP::HepVector AlgebraicVector
bool isSingle(TrackingRecHit const &hit)
T rerr(const GlobalPoint &aPoint) const
virtual OmniClusterRef const & firstClusterRef() const =0
~BaseTrackerRecHit() override
bool isProjected() const
bool isValid() const
void getKfComponents1D(KfComponentsHolder &holder) const
AlgebraicMatrix projectionMatrix() const override
bool isMatched() const
bool operator<(DTCELinkId const &lhs, DTCELinkId const &rhs)
Definition: DTCELinkId.h:70
bool isMulti(TrackingRecHit const &hit)
BaseTrackerRecHit(const GeomDet &idet, trackerHitRTTI::RTTI rt)
virtual bool isPhase2() const
LocalPoint localPosition() const override
CLHEP::HepSymMatrix AlgebraicSymMatrix
const Surface * surface() const final
trackerHitRTTI::RTTI rtti() const
const LocalPoint & localPositionFast() const
DetId geographicalId() const
virtual float clusterProbability() const
cluster probability, overloaded by pixel rechits.
BaseTrackerRecHit(DetId id, trackerHitRTTI::RTTI rt)
float errorGlobalR() const final
const BasicVectorType & basicVector() const
Definition: PV3DBase.h:53
bool isProjected(TrackingRecHit const &hit)
unsigned int qualWord_
bool isSingle() const