CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
BaseTrackerRecHit.h
Go to the documentation of this file.
1 #ifndef BaseTrackerRecHit_H
2 #define BaseTrackerRecHit_H
3 
9 
10 
11 
12 // #define VI_DEBUG
13 
14 class OmniClusterRef;
15 
16 namespace trackerHitRTTI {
17  // tracking hit can be : single (si1D, si2D, pix), projected, matched or multi
18  enum RTTI { undef=0, single=1, projStereo=2, projMono=3, match=4, multi=5,
20  inline RTTI rtti(TrackingRecHit const & hit) { return RTTI(hit.getRTTI());}
21  inline bool isUndef(TrackingRecHit const & hit) { return rtti(hit)==undef;}
22  inline bool isSingle(TrackingRecHit const & hit) { return rtti(hit)==single || rtti(hit)==fastSingle;}
23  inline bool isProjMono(TrackingRecHit const & hit) { return rtti(hit)==projMono || rtti(hit)==fastProjMono;}
24  inline bool isProjStereo(TrackingRecHit const & hit) { return rtti(hit)==projStereo || fastProjStereo;}
25  inline bool isProjected(TrackingRecHit const & hit) { return ((rtti(hit)==projMono) | (rtti(hit)==projStereo)) || (rtti(hit)==fastProjMono) | (rtti(hit)==fastProjStereo);}
26  inline bool isMatched(TrackingRecHit const & hit) { return rtti(hit)==match || rtti(hit)==fastMatch;}
27  inline bool isMulti(TrackingRecHit const & hit) { return rtti(hit)==multi;}
28  inline bool isSingleType(TrackingRecHit const & hit) { return (rtti(hit)>0) & (rtti(hit)<4) ;}
29  inline bool isFast(TrackingRecHit const & hit) { return (rtti(hit)>5) & (rtti(hit)<=9) ;}
30  inline unsigned int projId(TrackingRecHit const & hit) { return hit.rawId()+int(rtti(hit))-1;}
31 }
32 
34 public:
36 
37  // fake TTRH interface
38  BaseTrackerRecHit const * hit() const final { return this;}
39 
40  virtual ~BaseTrackerRecHit() {}
41 
42  // no position (as in persistent)
43  BaseTrackerRecHit(DetId id, trackerHitRTTI::RTTI rt) : TrackingRecHit(id,(unsigned int)(rt)),qualWord_(0) {}
44 
46  GeomDet const & idet, trackerHitRTTI::RTTI rt) :
47  TrackingRecHit(idet, (unsigned int)(rt)), pos_(p), err_(e), qualWord_(0){
48  LocalError lape = static_cast<TrackerGeomDet const *>(det())->localAlignmentError();
49  if (lape.valid())
50  err_ = LocalError(err_.xx()+lape.xx(),
51  err_.xy()+lape.xy(),
52  err_.yy()+lape.yy()
53  );
54  }
55 
57  bool isSingle() const { return trackerHitRTTI::isSingle(*this);}
58  bool isMatched() const { return trackerHitRTTI::isMatched(*this);}
59  bool isProjected() const { return trackerHitRTTI::isProjected(*this);}
60  bool isProjMono() const { return trackerHitRTTI::isProjMono(*this);}
61  bool isProjSterep() const { return trackerHitRTTI::isProjStereo(*this);}
62  bool isMulti() const { return trackerHitRTTI::isMulti(*this);}
63 
64  virtual bool isPixel() const { return false;}
65 
66  // used by trackMerger (to be improved)
67  virtual OmniClusterRef const & firstClusterRef() const=0;
68 
69 
70  // verify that hits can share clusters...
71  inline bool sameDetModule(TrackingRecHit const & hit) const;
72 
73  bool hasPositionAndError() const final;
74 
75  virtual LocalPoint localPosition() const final { check(); return pos_;}
76 
77  virtual LocalError localPositionError() const final { check(); return err_;}
78 
79 
80  const LocalPoint & localPositionFast() const { check(); return pos_; }
81  const LocalError & localPositionErrorFast() const { check(); return err_; }
82 
83 
84 
85  // to be specialized for 1D and 2D
86  virtual void getKfComponents( KfComponentsHolder & holder ) const=0;
87  virtual int dimension() const=0;
88 
89  void getKfComponents1D( KfComponentsHolder & holder ) const;
90  void getKfComponents2D( KfComponentsHolder & holder ) const;
91 
92 
93  // global coordinates
94  // Extension of the TrackingRecHit interface
95  virtual const Surface * surface() const final {return &(det()->surface());}
96 
97 
98  virtual GlobalPoint globalPosition() const final {
99  return surface()->toGlobal(localPosition());
100  }
101 
103  float errorGlobalR() const final { return std::sqrt(globalPositionError().rerr(globalPosition()));}
104  float errorGlobalZ() const final { return std::sqrt(globalPositionError().czz()); }
106 
107  // once cache removed will obsolete the above
109  GlobalError
112  float r = gp.perp();
113  float errorRPhi = r*std::sqrt(float(globalError.phierr(gp)));
114  float errorR = std::sqrt(float(globalError.rerr(gp)));
115  float errorZ = std::sqrt(float(globalError.czz()));
116  return (TrackingRecHitGlobalState){
117  gp.basicVector(), r, gp.barePhi(),
118  errorR,errorZ,errorRPhi
119  };
120  }
121 
123  virtual float clusterProbability() const { return 1.f; }
124 
125 public:
126 
127  // obsolete (for what tracker is concerned...) interface
128  virtual AlgebraicVector parameters() const;
129  virtual AlgebraicSymMatrix parametersError() const;
130  virtual AlgebraicMatrix projectionMatrix() const;
131 
132 private:
133 
134 #ifdef VI_DEBUG
135  void check() const { assert(det());}
136 #elif EDM_LM_DEBUG
137  void check() const;
138 #else
139  static void check(){}
140 #endif
141 
142 protected:
143 
146 protected:
147  //this comes for free (padding)
148  unsigned int qualWord_;
149 };
150 
151 
153  unsigned int myid = geographicalId().rawId();
154  unsigned int mysubd = myid >> (DetId::kSubdetOffset);
155 
156  unsigned int id = hit.geographicalId().rawId();
157  unsigned int subd = id >> (DetId::kSubdetOffset);
158 
159  if (mysubd!=subd) return false;
160 
161  //Protection against invalid hits
162  if(!hit.isValid()) return false;
163 
164  const unsigned int limdet = 10; // TIB=11
165 
166  if (mysubd>limdet) { // strip
167  // mask glue and stereo
168  myid|=3;
169  id|=3;
170  }
171  return id==myid;
172 
173 }
174 
175 
176 // Comparison operators
177 inline bool operator<( const BaseTrackerRecHit& one, const BaseTrackerRecHit& other) {
178  return ( one.geographicalId() < other.geographicalId() );
179 }
180 #endif // BaseTrackerRecHit_H
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
bool isSingleType(TrackingRecHit const &hit)
float errorGlobalZ() const final
T perp() const
Definition: PV3DBase.h:72
TrackingRecHitGlobalState globalState() const
GlobalError globalPositionError() const final
virtual int dimension() const =0
bool isProjMono(TrackingRecHit const &hit)
assert(m_qm.get())
BaseTrackerRecHit const * hit() const final
float errorGlobalRPhi() const final
virtual const Surface * surface() const final
static const int kSubdetOffset
Definition: DetId.h:21
virtual AlgebraicSymMatrix parametersError() const
bool sameDetModule(TrackingRecHit const &hit) const
bool isProjSterep() const
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:40
BaseTrackerRecHit(const LocalPoint &p, const LocalError &e, GeomDet const &idet, trackerHitRTTI::RTTI rt)
T phierr(const GlobalPoint &aPoint) const
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
T barePhi() const
Definition: PV3DBase.h:68
unsigned int projId(TrackingRecHit const &hit)
float xy() const
Definition: LocalError.h:25
bool operator<(const FedChannelConnection &, const FedChannelConnection &)
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
void getKfComponents2D(KfComponentsHolder &holder) const
bool isMatched(TrackingRecHit const &hit)
virtual void getKfComponents(KfComponentsHolder &holder) const =0
virtual ~BaseTrackerRecHit()
bool isFast(TrackingRecHit const &hit)
unsigned int getRTTI() const
virtual bool isPixel() const
virtual AlgebraicVector parameters() const
const LocalError & localPositionErrorFast() const
bool isProjMono() const
Definition: DetId.h:18
CLHEP::HepVector AlgebraicVector
bool isSingle(TrackingRecHit const &hit)
T rerr(const GlobalPoint &aPoint) const
virtual OmniClusterRef const & firstClusterRef() const =0
bool isProjected() const
bool isValid() const
string const
Definition: compareJSON.py:14
void getKfComponents1D(KfComponentsHolder &holder) const
bool isMatched() const
bool isMulti(TrackingRecHit const &hit)
CLHEP::HepSymMatrix AlgebraicSymMatrix
virtual GlobalPoint globalPosition() const final
trackerHitRTTI::RTTI rtti() const
bool isUndef(TrackingRecHit const &hit)
bool hasPositionAndError() const final
to be redefined by daughter class
virtual AlgebraicMatrix projectionMatrix() const
const LocalPoint & localPositionFast() const
DetId geographicalId() const
virtual float clusterProbability() const
cluster probability, overloaded by pixel rechits.
virtual LocalError localPositionError() const final
BaseTrackerRecHit(DetId id, trackerHitRTTI::RTTI rt)
float errorGlobalR() const final
const BasicVectorType & basicVector() const
Definition: PV3DBase.h:56
bool isProjected(TrackingRecHit const &hit)
unsigned int qualWord_
virtual LocalPoint localPosition() const final
id_type rawId() const
bool isSingle() const