CMS 3D CMS Logo

TrackingRecHit.h
Go to the documentation of this file.
1 #ifndef TrackingRecHit_h
2 #define TrackingRecHit_h
3 
12 
13 
15 
16 #include<vector>
17 #include<memory>
18 
19 class TkCloner;
21 class KfComponentsHolder;
22 
24 public:
25 
26 #ifndef __GCCXML__
27  using RecHitPointer = std::shared_ptr<TrackingRecHit const>; // requires to much editing
28  using ConstRecHitPointer = std::shared_ptr<TrackingRecHit const>;
29 #else
30  typedef TrackingRecHit const * RecHitPointer;
31  typedef TrackingRecHit const * ConstRecHitPointer;
32 #endif
33 
34  typedef std::vector<ConstRecHitPointer> RecHitContainer;
35  typedef std::vector<ConstRecHitPointer> ConstRecHitContainer;
36 
37 
38 
40 
41  typedef unsigned int id_type;
42 
50  enum Type { valid = 0, missing = 1, inactive = 2, bad = 3, missing_inner = 4, missing_outer = 5, inactive_inner = 6, inactive_outer = 7};
51  static const int typeMask = 0xf; // mask for the above
52  static const int rttiShift = 24; // shift amount to get the rtti
53 
56 
58  explicit TrackingRecHit(id_type id=0, Type type=valid ) : m_id(id), m_status(type), m_det(nullptr) {}
59  TrackingRecHit(DetId id, unsigned int rt, Type type=valid ) : m_id(id), m_status((rt<< rttiShift)|int(type)), m_det(nullptr){}
60 
61 
62  explicit TrackingRecHit(const GeomDet & idet, Type type=valid) : m_id(idet.geographicalId()), m_status(type), m_det(&idet){}
63  TrackingRecHit(const GeomDet & idet, unsigned int rt, Type type=valid ) : m_id(idet.geographicalId()), m_status((rt<< rttiShift)|int(type)), m_det(&idet){}
64  TrackingRecHit(const GeomDet & idet, TrackingRecHit const & rh) : m_id(rh.m_id), m_status(rh.m_status), m_det(&idet){}
65 
66 
67  virtual ~TrackingRecHit() {}
68 
69  // fake TTRH interface
70  virtual TrackingRecHit const * hit() const { return this;}
71  virtual TrackingRecHit * cloneHit() const { return clone();}
72 
73 
74  virtual TrackingRecHit * clone() const = 0;
75 #ifndef __GCCXML__
76  virtual RecHitPointer cloneSH() const { return RecHitPointer(clone());}
77  // clone and add the geom (ready for refit)
78  RecHitPointer cloneForFit(const GeomDet & idet) const {
79  auto cl = cloneSH();
80  const_cast<TrackingRecHit&>(*cl).setDet(idet); // const_cast (can be fixed editing some 100 files)
81  return cl;
82  }
83 #endif
84  virtual void setDet(const GeomDet & idet) {m_det = &idet;}
85 
86 
87  virtual AlgebraicVector parameters() const = 0;
88 
89  virtual AlgebraicSymMatrix parametersError() const = 0;
90 
91  virtual AlgebraicMatrix projectionMatrix() const = 0;
92 
93  virtual void getKfComponents( KfComponentsHolder & holder ) const ;
94 
95  virtual int dimension() const = 0;
96 
98  virtual std::vector<const TrackingRecHit*> recHits() const = 0;
99  virtual void recHitsV(std::vector<const TrackingRecHit*> & ) const;
100 
102  virtual std::vector<TrackingRecHit*> recHits() = 0;
103  virtual void recHitsV(std::vector<TrackingRecHit*> & );
104 
105 #ifndef __GCCXML__
106  virtual ConstRecHitContainer transientHits() const {
107  ConstRecHitContainer result;
108  std::vector<const TrackingRecHit*> hits;
109  recHitsV(hits);
110  for (auto h : hits) result.push_back(h->cloneSH());
111  return result;
112  }
113 #endif
114 
115  id_type rawId() const { return m_id;}
116  DetId geographicalId() const {return m_id;}
117 
118  const GeomDet * det() const { return m_det;}
119  virtual const Surface * surface() const {return &(det()->surface());}
120 
121 
125  virtual const GeomDetUnit * detUnit() const;
126 
127 
128  virtual LocalPoint localPosition() const = 0;
129 
130  virtual LocalError localPositionError() const = 0;
131 
133  virtual bool hasPositionAndError() const {return true;};
134 
135  virtual float weight() const {return 1.;}
136 
137  Type type() const { return Type(typeMask&m_status); }
138  Type getType() const { return Type(typeMask&m_status); }
139  bool isValid() const {return getType()==valid;}
140 
141  unsigned int getRTTI() const { return m_status >> rttiShift;}
142 
148  virtual bool sharesInput( const TrackingRecHit* other, SharedInputType what) const;
149 
150 
151  // global coordinates
152 
153  virtual GlobalPoint globalPosition() const;
154  virtual GlobalError globalPositionError() const;
155 
156  virtual float errorGlobalR() const;
157  virtual float errorGlobalZ() const;
158  virtual float errorGlobalRPhi() const;
159 
160 
166  virtual bool canImproveWithTrack() const {return false;}
167 private:
168  friend class TkCloner;
169  // double dispatch
170  virtual TrackingRecHit * clone(TkCloner const&, TrajectoryStateOnSurface const&) const {
171  assert("clone"==nullptr);
172  return clone(); // default
173  }
174 #ifndef __GCCXML__
175  virtual RecHitPointer cloneSH(TkCloner const&, TrajectoryStateOnSurface const&) const {
176  assert("cloneSH"==nullptr);
177  return cloneSH(); // default
178  }
179 #endif
180 
181 protected:
182  // used by muon...
183  void setId(id_type iid) { m_id=iid;}
184  void setType(Type ttype) { m_status=ttype;}
185 
186  void setRTTI (unsigned int rt) { m_status &= (rt<< rttiShift);} // can be done only once...
187 
188 private:
189 
190  id_type m_id;
191 
192  unsigned int m_status; // bit assigned (type 0-8) (rtti 24-31)
193 
194  const GeomDet * m_det;
195 
196 };
197 
198 #endif
SharedInputType
definition of equality via shared input
type
Definition: HCALResponse.h:21
virtual void getKfComponents(KfComponentsHolder &holder) const
virtual const Surface * surface() const
virtual float weight() const
unsigned int id_type
virtual RecHitPointer cloneSH() const
virtual float errorGlobalR() const
virtual ConstRecHitContainer transientHits() const
TrackingRecHit(const GeomDet &idet, Type type=valid)
void setId(id_type iid)
virtual bool sharesInput(const TrackingRecHit *other, SharedInputType what) const
Type type() const
std::vector< ConstRecHitPointer > RecHitContainer
TrackingRecHit(const GeomDet &idet, TrackingRecHit const &rh)
virtual void setDet(const GeomDet &idet)
virtual TrackingRecHit * clone(TkCloner const &, TrajectoryStateOnSurface const &) const
#define nullptr
virtual GlobalPoint globalPosition() const
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:42
virtual std::vector< const TrackingRecHit * > recHits() const =0
Access to component RecHits (if any)
CLHEP::HepMatrix AlgebraicMatrix
virtual float errorGlobalRPhi() const
std::shared_ptr< TrackingRecHit const > ConstRecHitPointer
const GeomDet * det() const
virtual int dimension() const =0
void setType(Type ttype)
virtual TrackingRecHit * clone() const =0
virtual ~TrackingRecHit()
TrackingRecHit(const GeomDet &idet, unsigned int rt, Type type=valid)
static const int rttiShift
virtual bool hasPositionAndError() const
to be redefined by daughter class
virtual LocalPoint localPosition() const =0
unsigned int getRTTI() const
std::shared_ptr< TrackingRecHit const > RecHitPointer
std::vector< ConstRecHitPointer > ConstRecHitContainer
virtual TrackingRecHit * cloneHit() const
virtual AlgebraicSymMatrix parametersError() const =0
virtual AlgebraicVector parameters() const =0
TrackingRecHit(DetId id, Type type=valid)
Definition: DetId.h:18
virtual TrackingRecHit const * hit() const
CLHEP::HepVector AlgebraicVector
Type getType() const
virtual float errorGlobalZ() const
unsigned int m_status
void setRTTI(unsigned int rt)
TrackingRecHit(DetId id, unsigned int rt, Type type=valid)
virtual bool canImproveWithTrack() const
bool isValid() const
TrackingRecHit(id_type id=0, Type type=valid)
virtual RecHitPointer cloneSH(TkCloner const &, TrajectoryStateOnSurface const &) const
static const int typeMask
RecHitPointer cloneForFit(const GeomDet &idet) const
virtual const GeomDetUnit * detUnit() const
CLHEP::HepSymMatrix AlgebraicSymMatrix
DetId geographicalId() const
virtual LocalError localPositionError() const =0
virtual void recHitsV(std::vector< const TrackingRecHit * > &) const
virtual GlobalError globalPositionError() const
const GeomDet * m_det
id_type rawId() const
virtual AlgebraicMatrix projectionMatrix() const =0