From f2cbc173d0f674473f4b658650426f8435717b78 Mon Sep 17 00:00:00 2001 From: Lauren Hay Date: Tue, 30 Mar 2021 20:06:50 +0200 Subject: [PATCH 1/3] Change PFMultiLinks from using eta phi for linking to refs --- .../ParticleFlowReco/interface/PFMultilinksTC.h | 11 ++++++++++- .../PFProducer/plugins/kdtrees/KDTreeLinkerPSEcal.cc | 7 +++---- .../plugins/kdtrees/KDTreeLinkerTrackEcal.cc | 6 ++---- .../plugins/kdtrees/KDTreeLinkerTrackHcal.cc | 11 ++++------- .../plugins/linkers/PreshowerAndECALLinker.cc | 5 +---- .../PFProducer/plugins/linkers/TrackAndECALLinker.cc | 3 +-- .../PFProducer/plugins/linkers/TrackAndHCALLinker.cc | 10 ++++------ 7 files changed, 25 insertions(+), 28 deletions(-) diff --git a/DataFormats/ParticleFlowReco/interface/PFMultilinksTC.h b/DataFormats/ParticleFlowReco/interface/PFMultilinksTC.h index 4ff7357938c4d..1a14b80a60392 100644 --- a/DataFormats/ParticleFlowReco/interface/PFMultilinksTC.h +++ b/DataFormats/ParticleFlowReco/interface/PFMultilinksTC.h @@ -10,7 +10,16 @@ namespace reco { /// \brief Abstract This class is used by the KDTree Track / Ecal Cluster /// linker to store all found links. /// - typedef std::vector > PFMultilinksType; + struct PFMultilink { + PFMultilink ( const reco::PFClusterRef & clusterref ) : + trackRef(), clusterRef(clusterref) {} + PFMultilink ( const reco::PFRecTrackRef & trackref ) : + trackRef(trackref), clusterRef() {} + reco::PFRecTrackRef trackRef; + reco::PFClusterRef clusterRef; + }; + /// collection of PFSuperCluster objects + typedef std::vector PFMultilinksType; class PFMultiLinksTC { public: bool isValid; diff --git a/RecoParticleFlow/PFProducer/plugins/kdtrees/KDTreeLinkerPSEcal.cc b/RecoParticleFlow/PFProducer/plugins/kdtrees/KDTreeLinkerPSEcal.cc index 254c06ee2edcf..caf54853a5163 100644 --- a/RecoParticleFlow/PFProducer/plugins/kdtrees/KDTreeLinkerPSEcal.cc +++ b/RecoParticleFlow/PFProducer/plugins/kdtrees/KDTreeLinkerPSEcal.cc @@ -238,11 +238,10 @@ void KDTreeLinkerPSEcal::updatePFBlockEltWithLinks() { reco::PFMultiLinksTC multitracks(true); for (const auto &ecalElt : ecalEltSet) { - double clusterphi = ecalElt->clusterRef()->positionREP().phi(); - double clustereta = ecalElt->clusterRef()->positionREP().eta(); - - multitracks.linkedClusters.push_back(std::make_pair(clusterphi, clustereta)); + reco::PFMultilink multiLink( ecalElt->clusterRef() ); + multitracks.linkedClusters.push_back(multiLink); + // We set the multilinks flag of the ECAL element (for links to PS) to true. It will allow us to // use it in an optimized way in prefilter ecalElt->setIsValidMultilinks(true, _targetType); diff --git a/RecoParticleFlow/PFProducer/plugins/kdtrees/KDTreeLinkerTrackEcal.cc b/RecoParticleFlow/PFProducer/plugins/kdtrees/KDTreeLinkerTrackEcal.cc index b936f255a640d..1e7c95eb5d329 100644 --- a/RecoParticleFlow/PFProducer/plugins/kdtrees/KDTreeLinkerTrackEcal.cc +++ b/RecoParticleFlow/PFProducer/plugins/kdtrees/KDTreeLinkerTrackEcal.cc @@ -246,11 +246,9 @@ void KDTreeLinkerTrackEcal::updatePFBlockEltWithLinks() { for (const auto &trackElt : trackEltSet) { const reco::PFRecTrackRef &trackref = trackElt->trackRefPF(); - const reco::PFTrajectoryPoint &atECAL = trackref->extrapolatedPoint(reco::PFTrajectoryPoint::ECALShowerMax); - double tracketa = atECAL.positionREP().eta(); - double trackphi = atECAL.positionREP().phi(); - multitracks.linkedClusters.push_back(std::make_pair(trackphi, tracketa)); + reco::PFMultilink multiLink( trackref ); + multitracks.linkedClusters.push_back(multiLink); // We set the multilinks flag of the track (for links to ECAL) to true. It will allow us to // use it in an optimized way in prefilter diff --git a/RecoParticleFlow/PFProducer/plugins/kdtrees/KDTreeLinkerTrackHcal.cc b/RecoParticleFlow/PFProducer/plugins/kdtrees/KDTreeLinkerTrackHcal.cc index 82cfa05c8d121..3ea33b84676bd 100644 --- a/RecoParticleFlow/PFProducer/plugins/kdtrees/KDTreeLinkerTrackHcal.cc +++ b/RecoParticleFlow/PFProducer/plugins/kdtrees/KDTreeLinkerTrackHcal.cc @@ -256,9 +256,8 @@ void KDTreeLinkerTrackHcal::updatePFBlockEltWithLinks() { // No restriction on the number of HCAL links per track or isLinkedToDisplacedVertex if (nMaxHcalLinksPerTrack_ < 0. || trackElt->isLinkedToDisplacedVertex()) { for (const auto& hcalElt : hcalEltSet) { - double clusterphi = hcalElt->clusterRef()->positionREP().phi(); - double clustereta = hcalElt->clusterRef()->positionREP().eta(); - multitracks.linkedClusters.push_back(std::make_pair(clusterphi, clustereta)); + reco::PFMultilink multiLink( hcalElt->clusterRef() ); + multitracks.linkedClusters.push_back(multiLink); // We set the multilinks flag of the track (for links to ECAL) to true. It will allow us to // use it in an optimized way in prefilter @@ -316,10 +315,8 @@ void KDTreeLinkerTrackHcal::updatePFBlockEltWithLinks() { // Fill multitracks for (auto i : sort_indexes(vDist)) { const BlockEltSet::iterator hcalEltIt = std::next(hcalEltSet.begin(), i); - double clusterphi = (*hcalEltIt)->clusterRef()->positionREP().phi(); - double clustereta = (*hcalEltIt)->clusterRef()->positionREP().eta(); - multitracks.linkedClusters.push_back(std::make_pair(clusterphi, clustereta)); - + reco::PFMultilink multiLink( (*hcalEltIt)->clusterRef() ); + multitracks.linkedClusters.push_back(multiLink); // We set the multilinks flag of the track (for links to ECAL) to true. It will allow us to // use it in an optimized way in prefilter (*hcalEltIt)->setIsValidMultilinks(true, _targetType); diff --git a/RecoParticleFlow/PFProducer/plugins/linkers/PreshowerAndECALLinker.cc b/RecoParticleFlow/PFProducer/plugins/linkers/PreshowerAndECALLinker.cc index 9bffbbf3e88b4..e04910be18c22 100644 --- a/RecoParticleFlow/PFProducer/plugins/linkers/PreshowerAndECALLinker.cc +++ b/RecoParticleFlow/PFProducer/plugins/linkers/PreshowerAndECALLinker.cc @@ -58,16 +58,13 @@ double PreshowerAndECALLinker::testLink(const reco::PFBlockElement* elem1, const // Glowinski & Gouzevitch if (useKDTree_ && pselem->isMultilinksValide(ecalelem->type())) { // KDTree algo const reco::PFMultilinksType& multilinks = pselem->getMultilinks(ecalelem->type()); - const reco::PFCluster::REPPoint& ecalreppos = ecalref->positionREP(); const math::XYZPoint& ecalxyzpos = ecalref->position(); const math::XYZPoint& psxyzpos = psref->position(); - const double ecalPhi = ecalreppos.Phi(); - const double ecalEta = ecalreppos.Eta(); // Check if the link PS/Ecal exist reco::PFMultilinksType::const_iterator mlit = multilinks.begin(); for (; mlit != multilinks.end(); ++mlit) - if ((mlit->first == ecalPhi) && (mlit->second == ecalEta)) + if (mlit->clusterRef == ecalref ) break; // If the link exist, we fill dist and linktest. diff --git a/RecoParticleFlow/PFProducer/plugins/linkers/TrackAndECALLinker.cc b/RecoParticleFlow/PFProducer/plugins/linkers/TrackAndECALLinker.cc index 2cbc753897a7f..1ef9010c2fb28 100644 --- a/RecoParticleFlow/PFProducer/plugins/linkers/TrackAndECALLinker.cc +++ b/RecoParticleFlow/PFProducer/plugins/linkers/TrackAndECALLinker.cc @@ -61,11 +61,10 @@ double TrackAndECALLinker::testLink(const reco::PFBlockElement* elem1, const rec const reco::PFMultilinksType& multilinks = ecalelem->getMultilinks(tkelem->type()); const double tracketa = tkAtECAL.positionREP().Eta(); const double trackphi = tkAtECAL.positionREP().Phi(); - // Check if the link Track/Ecal exist reco::PFMultilinksType::const_iterator mlit = multilinks.begin(); for (; mlit != multilinks.end(); ++mlit) - if ((mlit->first == trackphi) && (mlit->second == tracketa)) + if (mlit->trackRef == trackref) break; // If the link exist, we fill dist and linktest. diff --git a/RecoParticleFlow/PFProducer/plugins/linkers/TrackAndHCALLinker.cc b/RecoParticleFlow/PFProducer/plugins/linkers/TrackAndHCALLinker.cc index 671e6380bd60f..15592cdd07bd6 100644 --- a/RecoParticleFlow/PFProducer/plugins/linkers/TrackAndHCALLinker.cc +++ b/RecoParticleFlow/PFProducer/plugins/linkers/TrackAndHCALLinker.cc @@ -93,13 +93,11 @@ double TrackAndHCALLinker::testLink(const reco::PFBlockElement* elem1, const rec // Glowinski & Gouzevitch if (useKDTree_ && tkelem->isMultilinksValide(hcalelem->type())) { //KDTree Algo const reco::PFMultilinksType& multilinks = tkelem->getMultilinks(hcalelem->type()); - const double hcalphi = hcalreppos.Phi(); - const double hcaleta = hcalreppos.Eta(); // Check if the link Track/Hcal exist reco::PFMultilinksType::const_iterator mlit = multilinks.begin(); for (; mlit != multilinks.end(); ++mlit) - if ((mlit->first == hcalphi) && (mlit->second == hcaleta)) + if (mlit->clusterRef == clusterref) break; // If the link exist, we fill dist and linktest. @@ -107,7 +105,7 @@ double TrackAndHCALLinker::testLink(const reco::PFBlockElement* elem1, const rec if (mlit != multilinks.end()) { // when checkExit_ is false if (!checkExit_) { - dist = LinkByRecHit::computeDist(hcaleta, hcalphi, tkreppos.Eta(), tkreppos.Phi()); + dist = LinkByRecHit::computeDist(hcalreppos.Eta(), hcalreppos.Phi(), tkreppos.Eta(), tkreppos.Phi()); } // when checkExit_ is true else { @@ -115,12 +113,12 @@ double TrackAndHCALLinker::testLink(const reco::PFBlockElement* elem1, const rec //In this case calculate the distance based on the first crossing since //the looper will probably never make it to the endcap if (dRHCALEx < tkAtHCALEnt.position().R()) { - dist = LinkByRecHit::computeDist(hcaleta, hcalphi, tkreppos.Eta(), tkreppos.Phi()); + dist = LinkByRecHit::computeDist(hcalreppos.Eta(), hcalreppos.Phi(), tkreppos.Eta(), tkreppos.Phi()); edm::LogWarning("TrackHCALLinker ") << "Special case of linking with track hitting HCAL and looping back in the tracker "; } else { dist = - LinkByRecHit::computeDist(hcaleta, hcalphi, tkreppos.Eta() + 0.1 * dHEta, tkreppos.Phi() + 0.1 * dHPhi); + LinkByRecHit::computeDist(hcalreppos.Eta(), hcalreppos.Phi(), tkreppos.Eta() + 0.1 * dHEta, tkreppos.Phi() + 0.1 * dHPhi); } } // checkExit_ } // multilinks From f5608a8bec30a79704a79f495da59bccd058cef2 Mon Sep 17 00:00:00 2001 From: Lauren Hay Date: Thu, 15 Jul 2021 22:03:20 +0200 Subject: [PATCH 2/3] Change name of linked objects and code checks --- .../ParticleFlowReco/interface/PFBlockElement.h | 2 +- .../ParticleFlowReco/interface/PFMultilinksTC.h | 8 +++----- DataFormats/ParticleFlowReco/src/classes_def_2.xml | 2 +- .../PFProducer/plugins/kdtrees/KDTreeLinkerPSEcal.cc | 5 ++--- .../plugins/kdtrees/KDTreeLinkerTrackEcal.cc | 4 ++-- .../plugins/kdtrees/KDTreeLinkerTrackHcal.cc | 10 +++++----- .../plugins/linkers/PreshowerAndECALLinker.cc | 2 +- .../PFProducer/plugins/linkers/TrackAndHCALLinker.cc | 4 ++-- 8 files changed, 17 insertions(+), 20 deletions(-) diff --git a/DataFormats/ParticleFlowReco/interface/PFBlockElement.h b/DataFormats/ParticleFlowReco/interface/PFBlockElement.h index 0c7b6b600154b..b5c44e4e9e478 100644 --- a/DataFormats/ParticleFlowReco/interface/PFBlockElement.h +++ b/DataFormats/ParticleFlowReco/interface/PFBlockElement.h @@ -121,7 +121,7 @@ namespace reco { else return false; // no multilinks_ for the specified type } - const PFMultilinksType& getMultilinks(Type type) const { return multilinks_.at(type).linkedClusters; } + const PFMultilinksType& getMultilinks(Type type) const { return multilinks_.at(type).linkedPFObjects; } // ! Glowinski & Gouzevitch /// do we have a valid time information diff --git a/DataFormats/ParticleFlowReco/interface/PFMultilinksTC.h b/DataFormats/ParticleFlowReco/interface/PFMultilinksTC.h index 1a14b80a60392..7026f0f1e0334 100644 --- a/DataFormats/ParticleFlowReco/interface/PFMultilinksTC.h +++ b/DataFormats/ParticleFlowReco/interface/PFMultilinksTC.h @@ -11,10 +11,8 @@ namespace reco { /// linker to store all found links. /// struct PFMultilink { - PFMultilink ( const reco::PFClusterRef & clusterref ) : - trackRef(), clusterRef(clusterref) {} - PFMultilink ( const reco::PFRecTrackRef & trackref ) : - trackRef(trackref), clusterRef() {} + PFMultilink(const reco::PFClusterRef& clusterref) : trackRef(), clusterRef(clusterref) {} + PFMultilink(const reco::PFRecTrackRef& trackref) : trackRef(trackref), clusterRef() {} reco::PFRecTrackRef trackRef; reco::PFClusterRef clusterRef; }; @@ -23,7 +21,7 @@ namespace reco { class PFMultiLinksTC { public: bool isValid; - PFMultilinksType linkedClusters; + PFMultilinksType linkedPFObjects; public: PFMultiLinksTC(bool isvalid = false) : isValid(isvalid) {} diff --git a/DataFormats/ParticleFlowReco/src/classes_def_2.xml b/DataFormats/ParticleFlowReco/src/classes_def_2.xml index b34feab0ce879..6c40541360768 100644 --- a/DataFormats/ParticleFlowReco/src/classes_def_2.xml +++ b/DataFormats/ParticleFlowReco/src/classes_def_2.xml @@ -287,7 +287,7 @@ - + diff --git a/RecoParticleFlow/PFProducer/plugins/kdtrees/KDTreeLinkerPSEcal.cc b/RecoParticleFlow/PFProducer/plugins/kdtrees/KDTreeLinkerPSEcal.cc index caf54853a5163..ce1e762a40721 100644 --- a/RecoParticleFlow/PFProducer/plugins/kdtrees/KDTreeLinkerPSEcal.cc +++ b/RecoParticleFlow/PFProducer/plugins/kdtrees/KDTreeLinkerPSEcal.cc @@ -238,10 +238,9 @@ void KDTreeLinkerPSEcal::updatePFBlockEltWithLinks() { reco::PFMultiLinksTC multitracks(true); for (const auto &ecalElt : ecalEltSet) { + reco::PFMultilink multiLink(ecalElt->clusterRef()); + multitracks.linkedPFObjects.push_back(multiLink); - reco::PFMultilink multiLink( ecalElt->clusterRef() ); - multitracks.linkedClusters.push_back(multiLink); - // We set the multilinks flag of the ECAL element (for links to PS) to true. It will allow us to // use it in an optimized way in prefilter ecalElt->setIsValidMultilinks(true, _targetType); diff --git a/RecoParticleFlow/PFProducer/plugins/kdtrees/KDTreeLinkerTrackEcal.cc b/RecoParticleFlow/PFProducer/plugins/kdtrees/KDTreeLinkerTrackEcal.cc index 1e7c95eb5d329..2af337f01eb45 100644 --- a/RecoParticleFlow/PFProducer/plugins/kdtrees/KDTreeLinkerTrackEcal.cc +++ b/RecoParticleFlow/PFProducer/plugins/kdtrees/KDTreeLinkerTrackEcal.cc @@ -247,8 +247,8 @@ void KDTreeLinkerTrackEcal::updatePFBlockEltWithLinks() { for (const auto &trackElt : trackEltSet) { const reco::PFRecTrackRef &trackref = trackElt->trackRefPF(); - reco::PFMultilink multiLink( trackref ); - multitracks.linkedClusters.push_back(multiLink); + reco::PFMultilink multiLink(trackref); + multitracks.linkedPFObjects.push_back(multiLink); // We set the multilinks flag of the track (for links to ECAL) to true. It will allow us to // use it in an optimized way in prefilter diff --git a/RecoParticleFlow/PFProducer/plugins/kdtrees/KDTreeLinkerTrackHcal.cc b/RecoParticleFlow/PFProducer/plugins/kdtrees/KDTreeLinkerTrackHcal.cc index 3ea33b84676bd..94c6442e85ac1 100644 --- a/RecoParticleFlow/PFProducer/plugins/kdtrees/KDTreeLinkerTrackHcal.cc +++ b/RecoParticleFlow/PFProducer/plugins/kdtrees/KDTreeLinkerTrackHcal.cc @@ -256,8 +256,8 @@ void KDTreeLinkerTrackHcal::updatePFBlockEltWithLinks() { // No restriction on the number of HCAL links per track or isLinkedToDisplacedVertex if (nMaxHcalLinksPerTrack_ < 0. || trackElt->isLinkedToDisplacedVertex()) { for (const auto& hcalElt : hcalEltSet) { - reco::PFMultilink multiLink( hcalElt->clusterRef() ); - multitracks.linkedClusters.push_back(multiLink); + reco::PFMultilink multiLink(hcalElt->clusterRef()); + multitracks.linkedPFObjects.push_back(multiLink); // We set the multilinks flag of the track (for links to ECAL) to true. It will allow us to // use it in an optimized way in prefilter @@ -315,13 +315,13 @@ void KDTreeLinkerTrackHcal::updatePFBlockEltWithLinks() { // Fill multitracks for (auto i : sort_indexes(vDist)) { const BlockEltSet::iterator hcalEltIt = std::next(hcalEltSet.begin(), i); - reco::PFMultilink multiLink( (*hcalEltIt)->clusterRef() ); - multitracks.linkedClusters.push_back(multiLink); + reco::PFMultilink multiLink((*hcalEltIt)->clusterRef()); + multitracks.linkedPFObjects.push_back(multiLink); // We set the multilinks flag of the track (for links to ECAL) to true. It will allow us to // use it in an optimized way in prefilter (*hcalEltIt)->setIsValidMultilinks(true, _targetType); - if (multitracks.linkedClusters.size() >= (unsigned)nMaxHcalLinksPerTrack_) + if (multitracks.linkedPFObjects.size() >= (unsigned)nMaxHcalLinksPerTrack_) break; } } diff --git a/RecoParticleFlow/PFProducer/plugins/linkers/PreshowerAndECALLinker.cc b/RecoParticleFlow/PFProducer/plugins/linkers/PreshowerAndECALLinker.cc index e04910be18c22..ca106378d7bfe 100644 --- a/RecoParticleFlow/PFProducer/plugins/linkers/PreshowerAndECALLinker.cc +++ b/RecoParticleFlow/PFProducer/plugins/linkers/PreshowerAndECALLinker.cc @@ -64,7 +64,7 @@ double PreshowerAndECALLinker::testLink(const reco::PFBlockElement* elem1, const // Check if the link PS/Ecal exist reco::PFMultilinksType::const_iterator mlit = multilinks.begin(); for (; mlit != multilinks.end(); ++mlit) - if (mlit->clusterRef == ecalref ) + if (mlit->clusterRef == ecalref) break; // If the link exist, we fill dist and linktest. diff --git a/RecoParticleFlow/PFProducer/plugins/linkers/TrackAndHCALLinker.cc b/RecoParticleFlow/PFProducer/plugins/linkers/TrackAndHCALLinker.cc index 15592cdd07bd6..a5b1d4d73bdad 100644 --- a/RecoParticleFlow/PFProducer/plugins/linkers/TrackAndHCALLinker.cc +++ b/RecoParticleFlow/PFProducer/plugins/linkers/TrackAndHCALLinker.cc @@ -117,8 +117,8 @@ double TrackAndHCALLinker::testLink(const reco::PFBlockElement* elem1, const rec edm::LogWarning("TrackHCALLinker ") << "Special case of linking with track hitting HCAL and looping back in the tracker "; } else { - dist = - LinkByRecHit::computeDist(hcalreppos.Eta(), hcalreppos.Phi(), tkreppos.Eta() + 0.1 * dHEta, tkreppos.Phi() + 0.1 * dHPhi); + dist = LinkByRecHit::computeDist( + hcalreppos.Eta(), hcalreppos.Phi(), tkreppos.Eta() + 0.1 * dHEta, tkreppos.Phi() + 0.1 * dHPhi); } } // checkExit_ } // multilinks From 646b703d19cab6956b22bb01efaaf56203283325 Mon Sep 17 00:00:00 2001 From: Lauren Hay Date: Mon, 19 Jul 2021 17:08:00 +0200 Subject: [PATCH 3/3] Fix imports for PFMultiLinksTC.h --- DataFormats/ParticleFlowReco/interface/PFMultilinksTC.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/DataFormats/ParticleFlowReco/interface/PFMultilinksTC.h b/DataFormats/ParticleFlowReco/interface/PFMultilinksTC.h index 7026f0f1e0334..e800a89acdad2 100644 --- a/DataFormats/ParticleFlowReco/interface/PFMultilinksTC.h +++ b/DataFormats/ParticleFlowReco/interface/PFMultilinksTC.h @@ -4,6 +4,8 @@ // Done by Glowinski & Gouzevitch #include +#include "DataFormats/ParticleFlowReco/interface/PFRecTrackFwd.h" +#include "DataFormats/ParticleFlowReco/interface/PFClusterFwd.h" namespace reco {