CMS 3D CMS Logo

FastTrackerRecHit.h
Go to the documentation of this file.
1 
10 #ifndef FastTrackerRecHit_H
11 #define FastTrackerRecHit_H
12 
14 
16  enum HitType {
17  siPixel = 0,
18  siStrip1D = 1,
19  siStrip2D = 2,
23  };
24  inline trackerHitRTTI::RTTI rtti(HitType hitType) {
25  if (hitType >= siPixel && hitType <= siStrip2D)
27  else if (hitType == siStripMatched2D)
29  else if (hitType == siStripProjectedMono2D)
31  else if (hitType == siStripProjectedStereo2D)
33  else
34  return trackerHitRTTI::undef;
35  }
36  inline bool is2D(HitType hitType) { return hitType != siStrip1D; }
37  inline bool isPixel(HitType hitType) { return hitType == siPixel; }
38 } // namespace fastTrackerRecHitType
39 
41 public:
45 
48  ~FastTrackerRecHit() override {}
49 
54  const LocalError& e,
55  GeomDet const& idet,
57  : BaseTrackerRecHit(p, e, idet, fastTrackerRecHitType::rtti(hitType)),
59  is2D_(fastTrackerRecHitType::is2D(hitType)),
61  energyLoss_(0.0) //holy golden seal
62  {
63  store();
64  }
65 
66  FastTrackerRecHit* clone() const override {
68  p->load();
69  return p;
70  }
71 
74 
75  float energyLoss() const { return energyLoss_; } // holy golden seal
76  void setEnergyLoss(float e) { energyLoss_ = e; } // holy golden seal was a virtual void...
77  void getKfComponents(KfComponentsHolder& holder) const override {
78  if (is2D_)
79  getKfComponents2D(holder);
80  else
81  getKfComponents1D(holder);
82  }
83 
86  int dimension() const override { return is2D_ ? 2 : 1; }
87 
90  bool canImproveWithTrack() const override { return false; }
91 
92  /* getters */
93 
94  virtual size_t nIds() const { return 0; }
95  virtual int32_t id(size_t i = 0) const { return -1; }
96  virtual int32_t eventId(size_t i = 0) const { return -1; }
97 
98  virtual size_t nSimTrackIds() const { return 0; }
99  virtual int32_t simTrackId(size_t i) const { return -1; }
100  virtual int32_t simTrackEventId(size_t i) const { return -1; }
101 
102  virtual int32_t recHitCombinationIndex() const { return recHitCombinationIndex_; }
103 
104  bool isPixel() const override { return isPixel_; }
105 
106  /* setters */
107 
108  virtual void setEventId(int32_t eventId) {}
109 
110  void set2D(bool is2D = true) { is2D_ = is2D; }
111 
114  }
115 
118  std::vector<const TrackingRecHit*> recHits() const override { return std::vector<TrackingRecHit const*>(); }
119 
122  std::vector<TrackingRecHit*> recHits() override { return std::vector<TrackingRecHit*>(); }
123 
126  OmniClusterRef const& firstClusterRef() const override;
127 
132  // used by functions
133  // - FastTrackerSingleRecHit::sharesInput
134  // - FastSiStripMatchedRecHit::sharesInput
135  // - FastProjectedSiStripRecHit2D::sharesInput
136  inline bool sameId(const FastTrackerRecHit* other, size_t i = 0, size_t j = 0) const {
137  return id(i) == other->id(j) && eventId(i) == other->eventId(j);
138  }
139  inline bool sharesInput(const TrackingRecHit* other, SharedInputType what) const override {
140  // cast other hit
142  return false;
143  const FastTrackerRecHit* otherCast = static_cast<const FastTrackerRecHit*>(other);
144 
145  // checks
146  if (this->nIds() == 1) { // this hit is single/projected
147  if (otherCast->nIds() == 1) { // other hit is single/projected
148  return this->sameId(otherCast, 0, 0);
149  } else { // other hit is matched
150  if (what == all) {
151  return false;
152  } else {
153  return (this->sameId(otherCast, 0, 0) || this->sameId(otherCast, 0, 1));
154  }
155  }
156  } else { // this hit is matched
157  if (otherCast->nIds() == 1) { // other hit is single/projected
158  if (what == all) {
159  return false;
160  } else {
161  return (this->sameId(otherCast, 0, 0) || this->sameId(otherCast, 1, 0));
162  }
163  } else { // other hit is matched
164  if (what == all) {
165  return (this->sameId(otherCast, 0, 0) && this->sameId(otherCast, 1, 1));
166  } else {
167  return (this->sameId(otherCast, 0, 0) || this->sameId(otherCast, 1, 1));
168  }
169  }
170  }
171  }
172 
173 protected:
174  const bool isPixel_;
175  bool is2D_;
176 
179 
180  void store() {
181  myPos_ = pos_;
182  myErr_ = err_;
183  }
184  void load() {
185  pos_ = myPos_;
186  err_ = myErr_;
187  }
188 
190  float energyLoss_; //holy golden seal
191 
192 protected:
193  FastTrackerRecHit* clone_(TkCloner const& cloner, TrajectoryStateOnSurface const& tsos) const override {
194  return this->clone();
195  }
196 };
197 
201  return (one.geographicalId() < other.geographicalId());
202 }
203 
204 #endif
trackerHitRTTI::RTTI rtti(HitType hitType)
SharedInputType
definition of equality via shared input
void set2D(bool is2D=true)
const bool isPixel_
hit is either on pixel modul (isPixel_ = true) or strip module (isPixel_ = false) ...
bool sameId(const FastTrackerRecHit *other, size_t i=0, size_t j=0) const
virtual int32_t id(size_t i=0) const
uint32_t recHitCombinationIndex_
virtual void setEventId(int32_t eventId)
LocalError myErr_
helps making the hit postion and error persistent
void load()
helps making the hit postion and error persistent
void store()
helps making the hit postion and error persistent
bool is2D(HitType hitType)
virtual size_t nIds() const
virtual int32_t simTrackId(size_t i) const
trackerHitRTTI::RTTI rtti() const
virtual size_t nSimTrackIds() const
bool isFast(TrackingRecHit const &hit)
int dimension() const override
get the dimensions right
virtual int32_t simTrackEventId(size_t i) const
bool canImproveWithTrack() const override
float energyLoss() const
void getKfComponents(KfComponentsHolder &holder) const override
std::vector< const TrackingRecHit * > recHits() const override
OmniClusterRef const & firstClusterRef() const override
bool isPixel() const override
pixel or strip?
void setEnergyLoss(float e)
virtual int32_t recHitCombinationIndex() const
FastTrackerRecHit * clone_(TkCloner const &cloner, TrajectoryStateOnSurface const &tsos) const override
FastTrackerRecHit(const LocalPoint &p, const LocalError &e, GeomDet const &idet, fastTrackerRecHitType::HitType hitType)
virtual int32_t eventId(size_t i=0) const
void getKfComponents1D(KfComponentsHolder &holder) const
bool isPixel(HitType hitType)
bool sharesInput(const TrackingRecHit *other, SharedInputType what) const override
~FastTrackerRecHit() override
virtual void setRecHitCombinationIndex(int32_t recHitCombinationIndex)
FastTrackerRecHit * clone() const override
void getKfComponents2D(KfComponentsHolder &holder) const
LocalPoint myPos_
helps making the hit postion and error persistent
bool operator<(const FastTrackerRecHit &one, const FastTrackerRecHit &other)
std::vector< TrackingRecHit * > recHits() override
bool is2D_
hit is either one dimensional (is2D_ = false) or two dimensions (is2D_ = true)