CMS 3D CMS Logo

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