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  };
25  if(hitType >=0 && hitType <= 2) return trackerHitRTTI::fastSingle;
26  else if(hitType == siStripMatched2D) return trackerHitRTTI::fastMatch;
27  else if(hitType == siStripProjectedMono2D) return trackerHitRTTI::fastProjMono;
29  else return trackerHitRTTI::undef;
30  }
31  inline bool is2D(HitType hitType) {return hitType != siStrip1D;}
32  inline bool isPixel(HitType hitType) {return hitType == siPixel;}
33 }
34 
35 
37 {
38  public:
39 
44  , isPixel_(false)
45  , is2D_(true)
46  , recHitCombinationIndex_(-1)
47  {}
48 
51  ~FastTrackerRecHit() override {}
52 
57  : BaseTrackerRecHit(p,e,idet,fastTrackerRecHitType::rtti(hitType))
58  , isPixel_(fastTrackerRecHitType::isPixel(hitType))
59  , is2D_(fastTrackerRecHitType::is2D(hitType))
60  , recHitCombinationIndex_(-1)
61  {store();}
62 
63  FastTrackerRecHit * clone() const override {FastTrackerRecHit * p = new FastTrackerRecHit( * this); p->load(); return p;}
64 
67  void getKfComponents( KfComponentsHolder & holder ) const override { if(is2D_) getKfComponents2D(holder); else getKfComponents1D(holder);}
68 
71  int dimension() const override {return is2D_ ? 2 : 1;}
72 
75  bool canImproveWithTrack() const override {return false;}
76 
77  /* getters */
78 
79  virtual size_t nIds() const { return 0;}
80  virtual int32_t id(size_t i = 0) const { return -1;}
81  virtual int32_t eventId(size_t i = 0) const { return -1;}
82 
83  virtual size_t nSimTrackIds() const { return 0;}
84  virtual int32_t simTrackId(size_t i) const { return -1;}
85  virtual int32_t simTrackEventId(size_t i) const { return -1;}
86 
87  virtual int32_t recHitCombinationIndex() const { return recHitCombinationIndex_;}
88 
89  bool isPixel() const override {return isPixel_;}
90 
91  /* setters */
92 
93  virtual void setEventId(int32_t eventId) {};
94 
95  void set2D(bool is2D=true){is2D_ = is2D;}
96 
97  virtual void setRecHitCombinationIndex(int32_t recHitCombinationIndex) {recHitCombinationIndex_ = recHitCombinationIndex;}
98 
101  std::vector<const TrackingRecHit*> recHits() const override { return std::vector<TrackingRecHit const*>();}
102 
105  std::vector<TrackingRecHit*> recHits() override { return std::vector<TrackingRecHit*>();}
106 
109  OmniClusterRef const & firstClusterRef() const override;
110 
115  // used by functions
116  // - FastTrackerSingleRecHit::sharesInput
117  // - FastSiStripMatchedRecHit::sharesInput
118  // - FastProjectedSiStripRecHit2D::sharesInput
119  inline bool sameId(const FastTrackerRecHit * other,size_t i=0,size_t j = 0) const {return id(i) == other->id(j) && eventId(i) == other->eventId(j);}
120  inline bool sharesInput(const TrackingRecHit * other,SharedInputType what) const override {
121 
122  // cast other hit
123  if(!trackerHitRTTI::isFast(*other) )
124  return false;
125  const FastTrackerRecHit * otherCast = static_cast<const FastTrackerRecHit *>(other);
126 
127  // checks
128  if(this->nIds() == 1){ // this hit is single/projected
129  if(otherCast->nIds() == 1){ // other hit is single/projected
130  return this->sameId(otherCast,0,0);
131  }
132  else { // other hit is matched
133  if(what == all){
134  return false;
135  }
136  else {
137  return(this->sameId(otherCast,0,0) || this->sameId(otherCast,0,1));
138  }
139  }
140  }
141  else{ // this hit is matched
142  if(otherCast->nIds() == 1){ // other hit is single/projected
143  if (what == all){
144  return false;
145  }
146  else{
147  return(this->sameId(otherCast,0,0) || this->sameId(otherCast,1,0));
148  }
149  }
150  else{ // other hit is matched
151  if(what == all){
152  return(this->sameId(otherCast,0,0) && this->sameId(otherCast,1,1));
153  }
154  else {
155  return(this->sameId(otherCast,0,0) || this->sameId(otherCast,1,1));
156  }
157  }
158  }
159  }
160 
161  protected:
162 
163  const bool isPixel_;
164  bool is2D_;
165 
168 
169  void store() { myPos_=pos_; myErr_=err_;}
170  void load() { pos_=myPos_; err_=myErr_;}
171 
173 
174  protected:
175 
176  FastTrackerRecHit * clone(TkCloner const& cloner, TrajectoryStateOnSurface const& tsos) const override {
177  return this->clone();
178  }
179 
180 };
181 
184 inline bool operator<( const FastTrackerRecHit& one, const FastTrackerRecHit& other) {
185  return ( one.geographicalId() < other.geographicalId() );
186 }
187 
188 #endif
trackerHitRTTI::RTTI rtti(HitType hitType)
SharedInputType
definition of equality via shared input
virtual size_t nIds() const
void set2D(bool is2D=true)
std::vector< const TrackingRecHit * > recHits() const override
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 simTrackEventId(size_t i) 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
FastTrackerRecHit * clone() const override
void store()
helps making the hit postion and error persistent
bool is2D(HitType hitType)
virtual int32_t simTrackId(size_t i) const
virtual int32_t recHitCombinationIndex() const
bool isFast(TrackingRecHit const &hit)
FastTrackerRecHit * clone(TkCloner const &cloner, TrajectoryStateOnSurface const &tsos) const override
int dimension() const override
get the dimensions right
virtual size_t nSimTrackIds() const
TEveGeoShape * clone(const TEveElement *element, TEveElement *parent)
Definition: eve_macros.cc:135
bool isPixel() const override
pixel or strip?
bool canImproveWithTrack() const override
FastTrackerRecHit(const LocalPoint &p, const LocalError &e, GeomDet const &idet, fastTrackerRecHitType::HitType hitType)
virtual int32_t eventId(size_t i=0) const
bool isPixel(HitType hitType)
virtual int32_t id(size_t i=0) const
void getKfComponents(KfComponentsHolder &holder) const override
bool sharesInput(const TrackingRecHit *other, SharedInputType what) const override
~FastTrackerRecHit() override
virtual void setRecHitCombinationIndex(int32_t recHitCombinationIndex)
DetId geographicalId() 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)