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 
13 
15 #if !defined(__CINT__) && !defined(__MAKECINT__) && !defined(__REFLEX__)
16 #define NO_DICT
17 #endif
18 
19 #include<vector>
20 #include<memory>
21 
22 class GeomDet;
23 class GeomDetUnit;
24 class TkCloner;
26 class KfComponentsHolder;
27 
29 public:
30 
31 #ifdef NO_DICT
32  using RecHitPointer = std::shared_ptr<TrackingRecHit const>; // requires to much editing
33  using ConstRecHitPointer = std::shared_ptr<TrackingRecHit const>;
34 #else
35  typedef TrackingRecHit const * RecHitPointer;
36  typedef TrackingRecHit const * ConstRecHitPointer;
37 #endif
38 
39  typedef std::vector<ConstRecHitPointer> RecHitContainer;
40  typedef std::vector<ConstRecHitPointer> ConstRecHitContainer;
41 
42 
43 
45 
46  typedef unsigned int id_type;
47 
55  enum Type { valid = 0, missing = 1, inactive = 2, bad = 3 };
56  static const int typeMask = 0xf; // mask for the above
57  static const int rttiShift = 24; // shift amount to get the rtti
58 
61 
64  TrackingRecHit(DetId id, unsigned int rt, Type type=valid ) : m_id(id), m_status((rt<< rttiShift)|int(type)), m_det(nullptr){}
65 
66 
67  explicit TrackingRecHit(const GeomDet & idet, Type type=valid) : m_id(idet.geographicalId()), m_status(type), m_det(&idet){}
68  TrackingRecHit(const GeomDet & idet, unsigned int rt, Type type=valid ) : m_id(idet.geographicalId()), m_status((rt<< rttiShift)|int(type)), m_det(&idet){}
69  TrackingRecHit(const GeomDet & idet, TrackingRecHit const & rh) : m_id(rh.m_id), m_status(rh.m_status), m_det(&idet){}
70 
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 
79  virtual TrackingRecHit * clone() const = 0;
80 #ifdef NO_DICT
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  void setDet(const GeomDet & idet) {m_det = &idet;}
89 #endif
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 #ifdef NO_DICT
112  std::vector<const TrackingRecHit*> hits;
113  recHitsV(hits);
114  for (auto h : hits) 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 
125 
129  virtual const GeomDetUnit * detUnit() const;
130 
131 
132  virtual LocalPoint localPosition() const = 0;
133 
134  virtual LocalError localPositionError() const = 0;
135 
137  virtual bool hasPositionAndError() const {return true;};
138 
139  virtual float weight() const {return 1.;}
140 
141  Type type() const { return Type(typeMask&m_status); }
142  Type getType() const { return Type(typeMask&m_status); }
143  bool isValid() const {return getType()==valid;}
144 
145  unsigned int getRTTI() const { return m_status >> rttiShift;}
146 
152  virtual bool sharesInput( const TrackingRecHit* other, SharedInputType what) const;
153 
154 
155  // global coordinates
156 
157  virtual GlobalPoint globalPosition() const;
158  virtual GlobalError globalPositionError() const;
159 
160  virtual float errorGlobalR() const;
161  virtual float errorGlobalZ() const;
162  virtual float errorGlobalRPhi() const;
163 
164 
170  virtual bool canImproveWithTrack() const {return false;}
171 private:
172  friend class TkCloner;
173  // double dispatch
174  virtual TrackingRecHit * clone(TkCloner const&, TrajectoryStateOnSurface const&) const {
175  assert("clone"==nullptr);
176  return clone(); // default
177  }
178 #ifdef NO_DICT
179  virtual RecHitPointer cloneSH(TkCloner const&, TrajectoryStateOnSurface const&) const {
180  assert("cloneSH"==nullptr);
181  return cloneSH(); // default
182  }
183 #endif
184 
185 protected:
186  // used by muon...
187  void setId(id_type iid) { m_id=iid;}
188  void setType(Type ttype) { m_status=ttype;}
189 
190  void setRTTI (unsigned int rt) { m_status &= (rt<< rttiShift);} // can be done only once...
191 
192 private:
193 
195 
196  unsigned int m_status; // bit assigned (type 0-8) (rtti 24-31)
197 
198  const GeomDet * m_det;
199 
200 };
201 
202 #endif
SharedInputType
definition of equality via shared input
type
Definition: HCALResponse.h:21
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
virtual float errorGlobalR() 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 TrackingRecHit * clone(TkCloner const &, TrajectoryStateOnSurface const &) const
virtual GlobalPoint globalPosition() const
void setDet(const GeomDet &idet)
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:35
virtual AlgebraicVector parameters() const =0
CLHEP::HepMatrix AlgebraicMatrix
virtual float errorGlobalRPhi() const
std::shared_ptr< TrackingRecHit const > ConstRecHitPointer
const GeomDet * det() const
tuple result
Definition: query.py:137
void setType(Type ttype)
virtual ~TrackingRecHit()
virtual std::vector< const TrackingRecHit * > recHits() const =0
Access to component RecHits (if any)
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
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
std::vector< ConstRecHitPointer > ConstRecHitContainer
virtual TrackingRecHit * cloneHit() const
virtual TrackingRecHit * clone() 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
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 RecHitPointer cloneSH(TkCloner const &, TrajectoryStateOnSurface const &) const
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
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