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
TrackingRecHit::typeMask
static const int typeMask
Definition: TrackingRecHit.h:55
TrackingRecHit::cloneForFit
RecHitPointer cloneForFit(const GeomDet &idet) const
Definition: TrackingRecHit.h:82
TrackingRecHit::missing_inner
Definition: TrackingRecHit.h:50
TrackingRecHit::m_id
id_type m_id
Definition: TrackingRecHit.h:190
TrackingRecHit::rawId
id_type rawId() const
Definition: TrackingRecHit.h:119
GeomDet
Definition: GeomDet.h:27
TrackingRecHit::parameters
virtual AlgebraicVector parameters() const =0
hfClusterShapes_cfi.hits
hits
Definition: hfClusterShapes_cfi.py:5
AlgebraicObjects.h
TrackingRecHit::~TrackingRecHit
virtual ~TrackingRecHit()
Definition: TrackingRecHit.h:72
TrackingRecHit::TrackingRecHit
TrackingRecHit(DetId id, Type type=valid)
Definition: TrackingRecHit.h:61
TrackingRecHit::cloneHit
virtual TrackingRecHit * cloneHit() const
Definition: TrackingRecHit.h:76
TrackingRecHit::hit
virtual TrackingRecHit const * hit() const
Definition: TrackingRecHit.h:75
hcal_runs.rt
rt
Definition: hcal_runs.py:76
TrackingRecHit::det
const GeomDet * det() const
Definition: TrackingRecHit.h:122
cms::cuda::assert
assert(be >=bs)
TrackingRecHit::m_status
unsigned int m_status
Definition: TrackingRecHit.h:192
Surface
Definition: Surface.h:36
TrackingRecHit::type
Type type() const
Definition: TrackingRecHit.h:139
MuonTransientTrackingRecHit
Definition: MuonTransientTrackingRecHit.h:19
TrackingRecHit::TrackingRecHit
TrackingRecHit(const GeomDet &idet, unsigned int rt, Type type=valid)
Definition: TrackingRecHit.h:68
TrackingRecHit::RecHitPointer
std::shared_ptr< TrackingRecHit const > RecHitPointer
Definition: TrackingRecHit.h:24
TrackingRecHit::rttiShift
static const int rttiShift
Definition: TrackingRecHit.h:56
TrackingRecHit::setId
void setId(id_type iid)
Definition: TrackingRecHit.h:184
TrackingRecHit::cloneSH_
virtual RecHitPointer cloneSH_(TkCloner const &, TrajectoryStateOnSurface const &) const
Definition: TrackingRecHit.h:176
TrackingRecHit::localPosition
virtual LocalPoint localPosition() const =0
TrackingRecHit::geographicalId
DetId geographicalId() const
Definition: TrackingRecHit.h:120
TrackingRecHit::setDet
virtual void setDet(const GeomDet &idet)
Definition: TrackingRecHit.h:88
GetRecoTauVFromDQM_MC_cff.cl
cl
Definition: GetRecoTauVFromDQM_MC_cff.py:38
DetId
Definition: DetId.h:17
GeomDet::surface
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37
TrajectoryStateOnSurface
Definition: TrajectoryStateOnSurface.h:16
TrackingRecHit::SharedInputType
SharedInputType
definition of equality via shared input
Definition: TrackingRecHit.h:59
TkCloner
Definition: TkCloner.h:16
AlgebraicVector
CLHEP::HepVector AlgebraicVector
Definition: AlgebraicObjects.h:13
Surface.h
TrackingRecHit::RecHitContainer
std::vector< ConstRecHitPointer > RecHitContainer
Definition: TrackingRecHit.h:31
LocalError.h
TrackingRecHit::clone_
virtual TrackingRecHit * clone_(TkCloner const &, TrajectoryStateOnSurface const &) const
Definition: TrackingRecHit.h:171
TrackingRecHit::Type
Type
Definition: TrackingRecHit.h:45
TrackingRecHit::errorGlobalRPhi
virtual float errorGlobalRPhi() const
Definition: TrackingRecHit.cc:48
trackingPlots.other
other
Definition: trackingPlots.py:1460
TrackingRecHit::TrackingRecHit
TrackingRecHit(const GeomDet &idet, Type type=valid)
Definition: TrackingRecHit.h:66
h
TrackingRecHit::hasPositionAndError
virtual bool hasPositionAndError() const
to be redefined by daughter class
Definition: TrackingRecHit.h:135
Point3DBase< float, LocalTag >
TrackingRecHit::some
Definition: TrackingRecHit.h:59
TrackingRecHit::inactive_inner
Definition: TrackingRecHit.h:52
TrackingRecHit::bad
Definition: TrackingRecHit.h:49
TrackingRecHit::weight
virtual float weight() const
Definition: TrackingRecHit.h:137
TrackingRecHit::transientHits
virtual ConstRecHitContainer transientHits() const
Definition: TrackingRecHit.h:109
TrackingRecHit::getType
Type getType() const
Definition: TrackingRecHit.h:140
TrackingRecHit::all
Definition: TrackingRecHit.h:59
TrackingRecHit::ConstRecHitContainer
std::vector< ConstRecHitPointer > ConstRecHitContainer
Definition: TrackingRecHit.h:32
LocalError
Definition: LocalError.h:12
type
type
Definition: SiPixelVCal_PayloadInspector.cc:37
TrackingRecHit::missing
Definition: TrackingRecHit.h:47
TrackingRecHit::id_type
unsigned int id_type
Definition: TrackingRecHit.h:36
TrackingRecHit::inactive_outer
Definition: TrackingRecHit.h:53
TrackingRecHit::ConstRecHitPointer
std::shared_ptr< TrackingRecHit const > ConstRecHitPointer
Definition: TrackingRecHit.h:25
createfilelist.int
int
Definition: createfilelist.py:10
TrackingRecHit::globalPositionError
virtual GlobalError globalPositionError() const
Definition: TrackingRecHit.cc:35
TrackingRecHit::globalPosition
virtual GlobalPoint globalPosition() const
Definition: TrackingRecHit.cc:31
TrackingRecHit::TrackingRecHit
TrackingRecHit(const GeomDet &idet, TrackingRecHit const &rh)
Definition: TrackingRecHit.h:70
GlobalError.h
TrackingRecHit::missing_outer
Definition: TrackingRecHit.h:51
GlobalErrorBase< double, ErrorMatrixTag >
AlgebraicSymMatrix
CLHEP::HepSymMatrix AlgebraicSymMatrix
Definition: AlgebraicObjects.h:15
TrackingRecHit::m_det
const GeomDet * m_det
Definition: TrackingRecHit.h:194
TrackingRecHit::errorGlobalR
virtual float errorGlobalR() const
Definition: TrackingRecHit.cc:40
KfComponentsHolder
Definition: KfComponentsHolder.h:13
TrackingRecHit::projectionMatrix
virtual AlgebraicMatrix projectionMatrix() const =0
TrackingRecHit::clone
virtual TrackingRecHit * clone() const =0
TrackingRecHit::valid
Definition: TrackingRecHit.h:46
TrackingRecHit::recHits
virtual std::vector< const TrackingRecHit * > recHits() const =0
Access to component RecHits (if any)
TrackingRecHit
Definition: TrackingRecHit.h:21
GeomDet.h
TrackingRecHit::setType
void setType(Type ttype)
Definition: TrackingRecHit.h:185
AlgebraicMatrix
CLHEP::HepMatrix AlgebraicMatrix
Definition: AlgebraicObjects.h:14
TrackingRecHit::getKfComponents
virtual void getKfComponents(KfComponentsHolder &holder) const
Definition: TrackingRecHit.cc:23
DetId.h
TrackingRecHit::dimension
virtual int dimension() const =0
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:29
LocalPoint.h
TrackingRecHit::cloneSH
virtual RecHitPointer cloneSH() const
Definition: TrackingRecHit.h:80
TrackingRecHit::sharesInput
virtual bool sharesInput(const TrackingRecHit *other, SharedInputType what) const
Definition: TrackingRecHit.cc:12
TrackingRecHit::parametersError
virtual AlgebraicSymMatrix parametersError() const =0
TrackingRecHit::TrackingRecHit
TrackingRecHit(DetId id, unsigned int rt, Type type=valid)
Definition: TrackingRecHit.h:63
TrackingRecHit::recHitsV
virtual void recHitsV(std::vector< const TrackingRecHit * > &) const
Definition: TrackingRecHit.cc:9
TrackingRecHit::canImproveWithTrack
virtual bool canImproveWithTrack() const
Definition: TrackingRecHit.h:166
TrackingRecHit::inactive
Definition: TrackingRecHit.h:48
mps_fire.result
result
Definition: mps_fire.py:311
TrackingRecHit::getRTTI
unsigned int getRTTI() const
Definition: TrackingRecHit.h:143
TrackingRecHit::isValid
bool isValid() const
Definition: TrackingRecHit.h:141
TrackingRecHit::detUnit
virtual const GeomDetUnit * detUnit() const
Definition: TrackingRecHit.cc:29
GlobalPoint.h
TrackingRecHit::surface
virtual const Surface * surface() const
Definition: TrackingRecHit.h:123
TrackingRecHit::setRTTI
void setRTTI(unsigned int rt)
Definition: TrackingRecHit.h:187
TrackingRecHit::errorGlobalZ
virtual float errorGlobalZ() const
Definition: TrackingRecHit.cc:44
TrackingRecHit::TrackingRecHit
TrackingRecHit(id_type id=0, Type type=valid)
Definition: TrackingRecHit.h:62
TrackingRecHit::localPositionError
virtual LocalError localPositionError() const =0