CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 int dimension() const =0
virtual void getKfComponents(KfComponentsHolder &holder) const
virtual const Surface * surface() const
virtual float weight() const
unsigned int id_type
virtual RecHitPointer cloneSH() const
uint16_t *__restrict__ id
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)
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
assert(be >=bs)
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37
list rt
Definition: hcal_runs.py:76
tuple cl
Definition: haddnano.py:49
tuple result
Definition: mps_fire.py:311
virtual AlgebraicVector parameters() const =0
CLHEP::HepMatrix AlgebraicMatrix
virtual float errorGlobalRPhi() const
std::shared_ptr< TrackingRecHit const > ConstRecHitPointer
const GeomDet * det() const
void setType(Type ttype)
virtual ~TrackingRecHit()
virtual std::vector< const TrackingRecHit * > recHits() const =0
Access to component RecHits (if any)
TrackingRecHit(const GeomDet &idet, unsigned int rt, Type type=valid)
static const int rttiShift
virtual bool hasPositionAndError() const
to be redefined by daughter class
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 TrackingRecHit * clone() 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
virtual LocalError localPositionError() const =0
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 AlgebraicMatrix projectionMatrix() const =0
static const int typeMask
RecHitPointer cloneForFit(const GeomDet &idet) const
virtual const GeomDetUnit * detUnit() const
CLHEP::HepSymMatrix AlgebraicSymMatrix
DetId geographicalId() 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 void recHitsV(std::vector< const TrackingRecHit * > &) const
virtual LocalPoint localPosition() const =0
virtual GlobalError globalPositionError() const
const GeomDet * m_det
id_type rawId() const
virtual AlgebraicSymMatrix parametersError() const =0