CMS 3D CMS Logo

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