diff --git a/CommonTools/RecoAlgos/src/ClusterStorer.cc b/CommonTools/RecoAlgos/src/ClusterStorer.cc index 5452301be4f90..887137c6fbd0b 100644 --- a/CommonTools/RecoAlgos/src/ClusterStorer.cc +++ b/CommonTools/RecoAlgos/src/ClusterStorer.cc @@ -182,4 +182,30 @@ namespace helper { (*cluRef) = OmniClusterRef(newRef); } + // ------------------------------------------------------------- + // Specific rekey for class template ClusterRefType = VectorHit::ClusterRef, + // RecHitType is not used. + template <> + template // or template<> to specialise also here? + void ClusterStorer::ClusterHitRecord:: + // rekey(const VectorHit::ClusterRef &newRef) const + rekey(const VectorHit::ClusterRef &newRef) const { + TrackingRecHit &genericHit = (*hits_)[index_]; + const std::type_info &hit_type = typeid(genericHit); + + OmniClusterRef *cluRef = nullptr; + if (typeid(VectorHit) == hit_type) { + VectorHit &vHit = static_cast(genericHit); + // FIXME: this essentially uses a hack + // https://github.com/cms-sw/cmssw/blob/master/DataFormats/TrackerCommon/interface/TrackerTopology.h#L291 + cluRef = (SiStripDetId(detid_).stereo() ? &vHit.upperClusterRef() : &vHit.lowerClusterRef()); + } else { + return; + } + + assert(cluRef != nullptr); // to catch missing RecHit types + assert(cluRef->key() == ref_.key()); // otherwise something went wrong + (*cluRef) = OmniClusterRef(newRef); + } + } // namespace helper diff --git a/DataFormats/TrackerRecHit2D/interface/VectorHit.h b/DataFormats/TrackerRecHit2D/interface/VectorHit.h index df0a771f686d8..2f54b77117c96 100644 --- a/DataFormats/TrackerRecHit2D/interface/VectorHit.h +++ b/DataFormats/TrackerRecHit2D/interface/VectorHit.h @@ -92,6 +92,9 @@ class VectorHit final : public BaseTrackerRecHit { ClusterRef upperCluster() const { return theUpperCluster.cluster_phase2OT(); } OmniClusterRef const lowerClusterRef() const { return theLowerCluster; } OmniClusterRef const upperClusterRef() const { return theUpperCluster; } + // Non const variants needed for cluster re-keying + OmniClusterRef& lowerClusterRef() { return theLowerCluster; } + OmniClusterRef& upperClusterRef() { return theUpperCluster; } //FIXME::to update with a proper CPE maybe... Global3DPoint lowerGlobalPos() const;