File indexing completed on 2024-04-06 12:24:03
0001 #ifndef PhysicsTools_PatUtils_DuplicatedPhotonRemover_h
0002 #define PhysicsTools_PatUtils_DuplicatedPhotonRemover_h
0003
0004 #include "PhysicsTools/PatUtils/interface/GenericDuplicateRemover.h"
0005 #include "PhysicsTools/PatUtils/interface/GenericOverlapFinder.h"
0006
0007 #include "DataFormats/EgammaCandidates/interface/GsfElectronFwd.h"
0008 #include "DataFormats/EgammaCandidates/interface/GsfElectron.h"
0009 #include "DataFormats/EgammaCandidates/interface/PhotonFwd.h"
0010 #include "DataFormats/EgammaCandidates/interface/Photon.h"
0011
0012 #include "DataFormats/Common/interface/View.h"
0013
0014 #include "CommonTools/Utils/interface/EtComparator.h"
0015
0016 namespace pat {
0017
0018 class DuplicatedPhotonRemover {
0019 public:
0020
0021 struct EqualBySuperClusterSeed {
0022 template <typename T1, typename T2>
0023 bool operator()(const T1 &t1, const T2 &t2) const {
0024 return (t1.superCluster()->seed() == t2.superCluster()->seed());
0025 }
0026 };
0027
0028
0029 struct EqualBySuperCluster {
0030 template <typename T1, typename T2>
0031 bool operator()(const T1 &t1, const T2 &t2) const {
0032 return (t1.superCluster() == t2.superCluster());
0033 }
0034 };
0035
0036
0037
0038
0039 template <typename PhotonCollection>
0040 std::unique_ptr<std::vector<size_t> > duplicatesBySuperCluster(const PhotonCollection &photons) const;
0041
0042
0043
0044
0045 template <typename PhotonCollection>
0046 std::unique_ptr<std::vector<size_t> > duplicatesBySeed(const PhotonCollection &photons) const;
0047
0048
0049 template <typename PhotonCollection, typename ElectronCollection>
0050 std::unique_ptr<pat::OverlapList> electronsBySeed(const PhotonCollection &photons,
0051 const ElectronCollection &electrons) const;
0052
0053
0054 template <typename PhotonCollection, typename ElectronCollection>
0055 std::unique_ptr<pat::OverlapList> electronsBySuperCluster(const PhotonCollection &photons,
0056 const ElectronCollection &electrons) const;
0057
0058
0059 std::unique_ptr<std::vector<size_t> > duplicatesBySeed(const reco::PhotonCollection &photons) const;
0060 std::unique_ptr<std::vector<size_t> > duplicatesBySeed(const edm::View<reco::Photon> &photons) const;
0061 std::unique_ptr<std::vector<size_t> > duplicatesBySuperCluster(const edm::View<reco::Photon> &photons) const;
0062 std::unique_ptr<std::vector<size_t> > duplicatesBySuperCluster(const reco::PhotonCollection &photons) const;
0063 std::unique_ptr<pat::OverlapList> electronsBySeed(const reco::PhotonCollection &photons,
0064 const reco::GsfElectronCollection &electrons) const;
0065 std::unique_ptr<pat::OverlapList> electronsBySeed(const edm::View<reco::Photon> &photons,
0066 const reco::GsfElectronCollection &electrons) const;
0067 std::unique_ptr<pat::OverlapList> electronsBySuperCluster(const edm::View<reco::Photon> &photons,
0068 const reco::GsfElectronCollection &electrons) const;
0069 std::unique_ptr<pat::OverlapList> electronsBySuperCluster(const reco::PhotonCollection &photons,
0070 const reco::GsfElectronCollection &electrons) const;
0071 std::unique_ptr<pat::OverlapList> electronsBySeed(const reco::PhotonCollection &photons,
0072 const edm::View<reco::GsfElectron> &electrons) const;
0073 std::unique_ptr<pat::OverlapList> electronsBySeed(const edm::View<reco::Photon> &photons,
0074 const edm::View<reco::GsfElectron> &electrons) const;
0075 std::unique_ptr<pat::OverlapList> electronsBySuperCluster(const edm::View<reco::Photon> &photons,
0076 const edm::View<reco::GsfElectron> &electrons) const;
0077 std::unique_ptr<pat::OverlapList> electronsBySuperCluster(const reco::PhotonCollection &photons,
0078 const edm::View<reco::GsfElectron> &electrons) const;
0079 };
0080 }
0081
0082 template <typename PhotonCollection>
0083 std::unique_ptr<std::vector<size_t> > pat::DuplicatedPhotonRemover::duplicatesBySuperCluster(
0084 const PhotonCollection &photons) const {
0085 typedef typename PhotonCollection::value_type PhotonType;
0086 pat::GenericDuplicateRemover<EqualBySuperCluster, GreaterByEt<PhotonType> > dups;
0087 return dups.duplicates(photons);
0088 }
0089
0090 template <typename PhotonCollection>
0091 std::unique_ptr<std::vector<size_t> > pat::DuplicatedPhotonRemover::duplicatesBySeed(
0092 const PhotonCollection &photons) const {
0093 typedef typename PhotonCollection::value_type PhotonType;
0094 pat::GenericDuplicateRemover<EqualBySuperClusterSeed, GreaterByEt<PhotonType> > dups;
0095 return dups.duplicates(photons);
0096 }
0097
0098
0099 template <typename PhotonCollection, typename ElectronCollection>
0100 std::unique_ptr<pat::OverlapList> pat::DuplicatedPhotonRemover::electronsBySuperCluster(
0101 const PhotonCollection &photons, const ElectronCollection &electrons) const {
0102 pat::GenericOverlapFinder<pat::OverlapDistance<EqualBySuperCluster> > ovl;
0103 return ovl.find(photons, electrons);
0104 }
0105
0106
0107 template <typename PhotonCollection, typename ElectronCollection>
0108 std::unique_ptr<pat::OverlapList> pat::DuplicatedPhotonRemover::electronsBySeed(
0109 const PhotonCollection &photons, const ElectronCollection &electrons) const {
0110 pat::GenericOverlapFinder<pat::OverlapDistance<EqualBySuperClusterSeed> > ovl;
0111 return ovl.find(photons, electrons);
0112 }
0113
0114 #endif