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 
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 || rtti(hit)==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:
35  BaseTrackerRecHit() : qualWord_(0){}
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 isProjStereo() const { return trackerHitRTTI::isProjStereo(*this);}
62  bool isMulti() const { return trackerHitRTTI::isMulti(*this);}
63 
64  virtual bool isPixel() const { return false;}
65  virtual bool isPhase2() const { return false;}
66 
67  // used by trackMerger (to be improved)
68  virtual OmniClusterRef const & firstClusterRef() const=0;
69 
70 
71  // verify that hits can share clusters...
72  inline bool sameDetModule(TrackingRecHit const & hit) const;
73 
74  bool hasPositionAndError() const final;
75 
76  virtual LocalPoint localPosition() const final { check(); return pos_;}
77 
78  virtual LocalError localPositionError() const final { check(); return err_;}
79 
80 
81  const LocalPoint & localPositionFast() const { check(); return pos_; }
82  const LocalError & localPositionErrorFast() const { check(); return err_; }
83 
84 
85 
86  // to be specialized for 1D and 2D
87  virtual void getKfComponents( KfComponentsHolder & holder ) const=0;
88  virtual int dimension() const=0;
89 
90  void getKfComponents1D( KfComponentsHolder & holder ) const;
91  void getKfComponents2D( KfComponentsHolder & holder ) const;
92 
93 
94  // global coordinates
95  // Extension of the TrackingRecHit interface
96  virtual const Surface * surface() const final {return &(det()->surface());}
97 
98 
99  virtual GlobalPoint globalPosition() const final {
100  return surface()->toGlobal(localPosition());
101  }
102 
103  GlobalError globalPositionError() const final { return ErrorFrameTransformer().transform( localPositionError(), *surface() );}
104  float errorGlobalR() const final { return std::sqrt(globalPositionError().rerr(globalPosition()));}
105  float errorGlobalZ() const final { return std::sqrt(globalPositionError().czz()); }
106  float errorGlobalRPhi() const final { return globalPosition().perp()*sqrt(globalPositionError().phierr(globalPosition())); }
107 
108  // once cache removed will obsolete the above
110  GlobalError
111  globalError = ErrorFrameTransformer::transform( localPositionError(), *surface() );
112  GlobalPoint gp = globalPosition();
113  float r = gp.perp();
114  float errorRPhi = r*std::sqrt(float(globalError.phierr(gp)));
115  float errorR = std::sqrt(float(globalError.rerr(gp)));
116  float errorZ = std::sqrt(float(globalError.czz()));
117  return (TrackingRecHitGlobalState){
118  gp.basicVector(), r, gp.barePhi(),
119  errorR,errorZ,errorRPhi
120  };
121  }
122 
124  virtual float clusterProbability() const { return 1.f; }
125 
126 public:
127 
128  // obsolete (for what tracker is concerned...) interface
129  virtual AlgebraicVector parameters() const;
130  virtual AlgebraicSymMatrix parametersError() const;
131  virtual AlgebraicMatrix projectionMatrix() const;
132 
133 private:
134 
135 #ifdef VI_DEBUG
136  void check() const { assert(det());}
137 #elif EDM_LM_DEBUG
138  void check() const;
139 #else
140  static void check(){}
141 #endif
142 
143 protected:
144 
147 protected:
148  //this comes for free (padding)
149  unsigned int qualWord_;
150 };
151 
152 
154  unsigned int myid = geographicalId().rawId();
155  unsigned int mysubd = myid >> (DetId::kSubdetOffset);
156 
157  unsigned int id = hit.geographicalId().rawId();
158  unsigned int subd = id >> (DetId::kSubdetOffset);
159 
160  if (mysubd!=subd) return false;
161 
162  //Protection against invalid hits
163  if(!hit.isValid()) return false;
164 
165  const unsigned int limdet = 10; // TIB=11
166 
167  if (mysubd>limdet) { // strip
168  // mask glue and stereo
169  myid|=3;
170  id|=3;
171  }
172  return id==myid;
173 
174 }
175 
176 
177 // Comparison operators
178 inline bool operator<( const BaseTrackerRecHit& one, const BaseTrackerRecHit& other) {
179  return ( one.geographicalId() < other.geographicalId() );
180 }
181 #endif // BaseTrackerRecHit_H
float errorGlobalR() const final
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)
T perp() const
Definition: PV3DBase.h:72
GlobalError globalPositionError() const final
TrackingRecHitGlobalState globalState() const
bool isProjMono(TrackingRecHit const &hit)
static const int kSubdetOffset
Definition: DetId.h:21
bool sameDetModule(TrackingRecHit const &hit) const
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
CLHEP::HepMatrix AlgebraicMatrix
bool isProjStereo(TrackingRecHit const &hit)
float yy() const
Definition: LocalError.h:26
T sqrt(T t)
Definition: SSEVec.h:18
BaseTrackerRecHit const * hit() const final
bool isMatched(TrackingRecHit const &hit)
virtual LocalPoint localPosition() const final
virtual GlobalPoint globalPosition() const final
virtual ~BaseTrackerRecHit()
bool isFast(TrackingRecHit const &hit)
unsigned int getRTTI() const
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
bool isSingle(TrackingRecHit const &hit)
T rerr(const GlobalPoint &aPoint) const
bool isProjected() const
bool isValid() const
bool isMatched() const
bool isMulti(TrackingRecHit const &hit)
float errorGlobalRPhi() const final
virtual bool isPhase2() const
CLHEP::HepSymMatrix AlgebraicSymMatrix
bool operator<(const BaseTrackerRecHit &one, const BaseTrackerRecHit &other)
trackerHitRTTI::RTTI rtti() const
bool isUndef(TrackingRecHit const &hit)
const LocalPoint & localPositionFast() const
DetId geographicalId() const
virtual float clusterProbability() const
cluster probability, overloaded by pixel rechits.
virtual LocalError localPositionError() const final
def check(config)
Definition: trackerTree.py:14
BaseTrackerRecHit(DetId id, trackerHitRTTI::RTTI rt)
uint32_t dimension(pat::CandKinResolution::Parametrization parametrization)
Returns the number of free parameters in a parametrization (3 or 4)
const BasicVectorType & basicVector() const
Definition: PV3DBase.h:56
bool isProjected(TrackingRecHit const &hit)
unsigned int qualWord_
virtual const Surface * surface() const final
id_type rawId() const
bool isSingle() const