File indexing completed on 2024-09-07 04:35:58
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef FastTrackerRecHit_H
0011 #define FastTrackerRecHit_H
0012
0013 #include "DataFormats/TrackerRecHit2D/interface/BaseTrackerRecHit.h"
0014
0015 namespace fastTrackerRecHitType {
0016 enum HitType {
0017 siPixel = 0,
0018 siStrip1D = 1,
0019 siStrip2D = 2,
0020 siStripMatched2D = 3,
0021 siStripProjectedMono2D = 4,
0022 siStripProjectedStereo2D = 5,
0023 };
0024 inline trackerHitRTTI::RTTI rtti(HitType hitType) {
0025 if (hitType >= siPixel && hitType <= siStrip2D)
0026 return trackerHitRTTI::fastSingle;
0027 else if (hitType == siStripMatched2D)
0028 return trackerHitRTTI::fastMatch;
0029 else if (hitType == siStripProjectedMono2D)
0030 return trackerHitRTTI::fastProjMono;
0031 else if (hitType == siStripProjectedStereo2D)
0032 return trackerHitRTTI::fastProjStereo;
0033 else
0034 return trackerHitRTTI::undef;
0035 }
0036 inline bool is2D(HitType hitType) { return hitType != siStrip1D; }
0037 inline bool isPixel(HitType hitType) { return hitType == siPixel; }
0038 }
0039
0040 class FastTrackerRecHit : public BaseTrackerRecHit {
0041 public:
0042
0043
0044 FastTrackerRecHit() : BaseTrackerRecHit(), isPixel_(false), is2D_(true), recHitCombinationIndex_(-1) {}
0045
0046
0047
0048 ~FastTrackerRecHit() override {}
0049
0050
0051
0052
0053 FastTrackerRecHit(const LocalPoint& p,
0054 const LocalError& e,
0055 GeomDet const& idet,
0056 fastTrackerRecHitType::HitType hitType)
0057 : BaseTrackerRecHit(p, e, idet, fastTrackerRecHitType::rtti(hitType)),
0058 isPixel_(fastTrackerRecHitType::isPixel(hitType)),
0059 is2D_(fastTrackerRecHitType::is2D(hitType)),
0060 recHitCombinationIndex_(-1),
0061 energyLoss_(0.0)
0062 {
0063 store();
0064 }
0065
0066 FastTrackerRecHit* clone() const override {
0067 FastTrackerRecHit* p = new FastTrackerRecHit(*this);
0068 p->load();
0069 return p;
0070 }
0071
0072
0073
0074
0075 float energyLoss() const { return energyLoss_; }
0076 void setEnergyLoss(float e) { energyLoss_ = e; }
0077 void getKfComponents(KfComponentsHolder& holder) const override {
0078 if (is2D_)
0079 getKfComponents2D(holder);
0080 else
0081 getKfComponents1D(holder);
0082 }
0083
0084
0085
0086 int dimension() const override { return is2D_ ? 2 : 1; }
0087
0088
0089
0090 bool canImproveWithTrack() const override { return false; }
0091
0092
0093
0094 virtual size_t nIds() const { return 0; }
0095 virtual int32_t id(size_t i = 0) const { return -1; }
0096 virtual int32_t eventId(size_t i = 0) const { return -1; }
0097
0098 virtual size_t nSimTrackIds() const { return 0; }
0099 virtual int32_t simTrackId(size_t i) const { return -1; }
0100 virtual int32_t simTrackEventId(size_t i) const { return -1; }
0101
0102 virtual int32_t recHitCombinationIndex() const { return recHitCombinationIndex_; }
0103
0104 bool isPixel() const override { return isPixel_; }
0105
0106
0107
0108 virtual void setEventId(int32_t eventId) {}
0109
0110 void set2D(bool is2D = true) { is2D_ = is2D; }
0111
0112 virtual void setRecHitCombinationIndex(int32_t recHitCombinationIndex) {
0113 recHitCombinationIndex_ = recHitCombinationIndex;
0114 }
0115
0116
0117
0118 std::vector<const TrackingRecHit*> recHits() const override { return std::vector<TrackingRecHit const*>(); }
0119
0120
0121
0122 std::vector<TrackingRecHit*> recHits() override { return std::vector<TrackingRecHit*>(); }
0123
0124
0125
0126 OmniClusterRef const& firstClusterRef() const override;
0127
0128
0129
0130
0131
0132
0133
0134
0135
0136 inline bool sameId(const FastTrackerRecHit* other, size_t i = 0, size_t j = 0) const {
0137 return id(i) == other->id(j) && eventId(i) == other->eventId(j);
0138 }
0139 inline bool sharesInput(const TrackingRecHit* other, SharedInputType what) const override {
0140
0141 if (!trackerHitRTTI::isFast(*other))
0142 return false;
0143 const FastTrackerRecHit* otherCast = static_cast<const FastTrackerRecHit*>(other);
0144
0145
0146 if (this->nIds() == 1) {
0147 if (otherCast->nIds() == 1) {
0148 return this->sameId(otherCast, 0, 0);
0149 } else {
0150 if (what == all) {
0151 return false;
0152 } else {
0153 return (this->sameId(otherCast, 0, 0) || this->sameId(otherCast, 0, 1));
0154 }
0155 }
0156 } else {
0157 if (otherCast->nIds() == 1) {
0158 if (what == all) {
0159 return false;
0160 } else {
0161 return (this->sameId(otherCast, 0, 0) || this->sameId(otherCast, 1, 0));
0162 }
0163 } else {
0164 if (what == all) {
0165 return (this->sameId(otherCast, 0, 0) && this->sameId(otherCast, 1, 1));
0166 } else {
0167 return (this->sameId(otherCast, 0, 0) || this->sameId(otherCast, 1, 1));
0168 }
0169 }
0170 }
0171 }
0172
0173 protected:
0174 const bool isPixel_;
0175 bool is2D_;
0176
0177 LocalPoint myPos_;
0178 LocalError myErr_;
0179
0180 void store() {
0181 myPos_ = pos_;
0182 myErr_ = err_;
0183 }
0184 void load() {
0185 pos_ = myPos_;
0186 err_ = myErr_;
0187 }
0188
0189 uint32_t recHitCombinationIndex_;
0190 float energyLoss_;
0191
0192 protected:
0193 FastTrackerRecHit* clone_(TkCloner const& cloner, TrajectoryStateOnSurface const& tsos) const override {
0194 return this->clone();
0195 }
0196 };
0197
0198
0199
0200 inline bool operator<(const FastTrackerRecHit& one, const FastTrackerRecHit& other) {
0201 return (one.geographicalId() < other.geographicalId());
0202 }
0203
0204 #endif