Skip to content

Commit f1e5d11

Browse files
authored
Merge pull request #48403 from mmasciov/trackListMergedStripOverlap
Strip overlap check for different product ID
2 parents 05b857c + 457caf3 commit f1e5d11

File tree

6 files changed

+80
-14
lines changed

6 files changed

+80
-14
lines changed

DataFormats/TrackerRecHit2D/interface/OmniClusterRef.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,22 @@ class OmniClusterRef {
6565
return rawIndex() < lh.rawIndex(); // in principle this is enough!
6666
}
6767

68+
bool const stripOverlap(OmniClusterRef const& lh, bool includeEdges = true) const {
69+
if (!isStrip())
70+
return false;
71+
const auto& tc = stripCluster();
72+
const uint16_t tf = tc.firstStrip();
73+
const uint16_t tl = tf + tc.amplitudes().size();
74+
const auto& oc = lh.stripCluster();
75+
const uint16_t of = oc.firstStrip();
76+
const uint16_t ol = of + oc.amplitudes().size();
77+
// By default, include edge overlaps
78+
const auto e = includeEdges ? 1 : 0;
79+
// Check that last strip of "other" cluster is within first and last strip of "this", or viceversa
80+
// Edge strips are considered for determining overlap (e=1) if includeEdges = true (default)
81+
return (((ol + e) > tf && ol < (tl + e)) || ((tl + e) > of && tl < (ol + e)));
82+
}
83+
6884
public:
6985
// edm Ref interface
7086
/* auto */ edm::ProductID id() const { return me.id(); }

DataFormats/TrackerRecHit2D/interface/SiStripMatchedRecHit2D.h

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,20 @@ class SiStripMatchedRecHit2D final : public BaseTrackerRecHit {
7676
inline bool sharesClusters(SiStripMatchedRecHit2D const& h1,
7777
SiStripMatchedRecHit2D const& h2,
7878
TrackingRecHit::SharedInputType what) {
79-
bool mono = h1.monoClusterRef() == h2.monoClusterRef();
80-
bool stereo = h1.stereoClusterRef() == h2.stereoClusterRef();
81-
82-
return (what == TrackingRecHit::all) ? (mono && stereo) : (mono || stereo);
79+
auto const& thisMonoClus = h1.monoClusterRef();
80+
auto const& otherMonoClus = h2.monoClusterRef();
81+
auto const& thisStereoClus = h1.stereoClusterRef();
82+
auto const& otherStereoClus = h2.stereoClusterRef();
83+
84+
if (thisMonoClus.id() == otherMonoClus.id()) {
85+
const bool monoIdentity = thisMonoClus == otherMonoClus;
86+
const bool stereoIdentity = thisStereoClus == otherStereoClus;
87+
return (what == TrackingRecHit::all) ? (monoIdentity && stereoIdentity) : (monoIdentity || stereoIdentity);
88+
} else {
89+
bool monoOverlap = (h1.monoId() == h2.monoId()) ? otherMonoClus.stripOverlap(thisMonoClus) : false;
90+
bool stereoOverlap = (h1.stereoId() == h2.stereoId()) ? otherStereoClus.stripOverlap(thisStereoClus) : false;
91+
return (what == TrackingRecHit::all) ? (monoOverlap && stereoOverlap) : (monoOverlap || stereoOverlap);
92+
}
8393
}
8494

8595
#endif

DataFormats/TrackerRecHit2D/interface/TrackerSingleRecHit.h

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,15 @@ class TrackerSingleRecHit : public BaseTrackerRecHit {
6868

6969
bool sharesInput(const TrackingRecHit* other, SharedInputType what) const final;
7070

71-
bool sharesInput(TrackerSingleRecHit const& other) const { return cluster_ == other.cluster_; }
72-
73-
bool sameCluster(OmniClusterRef const& oh) const { return oh == cluster_; }
71+
bool sharesInput(TrackerSingleRecHit const& other) const {
72+
//auto const& otherClus = reinterpret_cast<const BaseTrackerRecHit*>(other)->firstClusterRef();
73+
if (cluster_.id() == other.cluster_.id())
74+
return (cluster_ == other.cluster_);
75+
else {
76+
const bool sameDetId = (geographicalId() == other.geographicalId());
77+
return (sameDetId) ? other.cluster_.stripOverlap(cluster_) : false;
78+
}
79+
}
7480

7581
std::vector<const TrackingRecHit*> recHits() const override;
7682
std::vector<TrackingRecHit*> recHits() override;

DataFormats/TrackerRecHit2D/src/BaseTrackerRecHit.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
//#define DO_THROW_UNINITIALIZED
22
#include "DataFormats/TrackerRecHit2D/interface/BaseTrackerRecHit.h"
3+
#include "DataFormats/TrackerRecHit2D/interface/OmniClusterRef.h"
34
#include "DataFormats/TrackingRecHit/interface/KfComponentsHolder.h"
45
#include "DataFormats/Math/interface/ProjectMatrix.h"
56
#include "FWCore/Utilities/interface/Exception.h"

DataFormats/TrackerRecHit2D/src/SiStripMatchedRecHit2D.cc

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,26 @@ bool SiStripMatchedRecHit2D::sharesInput(const TrackingRecHit* other, SharedInpu
1919
return false;
2020

2121
auto const& otherClus = reinterpret_cast<const BaseTrackerRecHit*>(other)->firstClusterRef();
22-
return (otherClus == stereoClusterRef()) || (otherClus == monoClusterRef());
22+
if (monoClusterRef().id() == otherClus.id() || stereoClusterRef().id() == otherClus.id())
23+
return (otherClus == stereoClusterRef()) || (otherClus == monoClusterRef());
24+
else {
25+
const bool sameDetId = (geographicalId() == other->geographicalId());
26+
bool stereoOverlap = (sameDetId) ? otherClus.stripOverlap(stereoClusterRef()) : false;
27+
bool monoOverlap = (sameDetId) ? otherClus.stripOverlap(monoClusterRef()) : false;
28+
return (stereoOverlap || monoOverlap);
29+
}
2330
}
2431

2532
bool SiStripMatchedRecHit2D::sharesInput(TrackerSingleRecHit const& other) const {
26-
return other.sameCluster(monoClusterRef()) || other.sameCluster(stereoClusterRef());
33+
auto const& otherClus = other.firstClusterRef();
34+
if (monoClusterRef().id() == otherClus.id() || stereoClusterRef().id() == otherClus.id())
35+
return (otherClus == stereoClusterRef()) || (otherClus == monoClusterRef());
36+
else {
37+
const bool sameDetId = (geographicalId() == other.geographicalId());
38+
bool stereoOverlap = (sameDetId) ? otherClus.stripOverlap(stereoClusterRef()) : false;
39+
bool monoOverlap = (sameDetId) ? otherClus.stripOverlap(monoClusterRef()) : false;
40+
return (stereoOverlap || monoOverlap);
41+
}
2742
}
2843

2944
// it does not have components anymore...

DataFormats/TrackerRecHit2D/src/VectorHit.cc

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,32 @@ bool VectorHit::sharesInput(const TrackingRecHit* other, SharedInputType what) c
7272

7373
// what about multi???
7474
auto const& otherClus = reinterpret_cast<const BaseTrackerRecHit*>(other)->firstClusterRef();
75-
return (otherClus == lowerClusterRef()) || (otherClus == upperClusterRef());
75+
76+
if (lowerClusterRef().id() == otherClus.id() || upperClusterRef().id() == otherClus.id())
77+
return (otherClus == lowerClusterRef()) || (otherClus == upperClusterRef());
78+
else {
79+
bool lowerOverlap = false;
80+
bool upperOverlap = false;
81+
if (geographicalId() == other->geographicalId()) {
82+
lowerOverlap = otherClus.stripOverlap(lowerClusterRef());
83+
upperOverlap = otherClus.stripOverlap(upperClusterRef());
84+
}
85+
return (lowerOverlap || upperOverlap);
86+
}
7687
}
7788

7889
bool VectorHit::sharesClusters(VectorHit const& other, SharedInputType what) const {
79-
bool lower = this->lowerClusterRef() == other.lowerClusterRef();
80-
bool upper = this->upperClusterRef() == other.upperClusterRef();
81-
82-
return (what == TrackingRecHit::all) ? (lower && upper) : (upper || lower);
90+
if (this->lowerClusterRef().id() == other.lowerClusterRef().id() ||
91+
this->upperClusterRef().id() == other.upperClusterRef().id()) {
92+
const bool lowerIdentity = this->lowerClusterRef() == other.lowerClusterRef();
93+
const bool upperIdentity = this->upperClusterRef() == other.upperClusterRef();
94+
return (what == TrackingRecHit::all) ? (lowerIdentity && upperIdentity) : (lowerIdentity || upperIdentity);
95+
} else {
96+
const bool sameDetId = (geographicalId() == other.geographicalId());
97+
bool lowerOverlap = (sameDetId) ? other.lowerClusterRef().stripOverlap(this->lowerClusterRef()) : false;
98+
bool upperOverlap = (sameDetId) ? other.upperClusterRef().stripOverlap(this->upperClusterRef()) : false;
99+
return (what == TrackingRecHit::all) ? (lowerOverlap && upperOverlap) : (lowerOverlap || upperOverlap);
100+
}
83101
}
84102

85103
void VectorHit::getKfComponents4D(KfComponentsHolder& holder) const {

0 commit comments

Comments
 (0)