CMS 3D CMS Logo

DuplicatedElectronRemover.h
Go to the documentation of this file.
1 #ifndef PhysicsTools_PatUtils_DuplicatedElectronRemover_h
2 #define PhysicsTools_PatUtils_DuplicatedElectronRemover_h
3 
5 
9 
10 #include <memory>
11 #include <vector>
12 
13 namespace pat {
14 
15  /* --- Original comment from TQAF follows ----
16  * it is possible that there are multiple electron objects in the collection that correspond to the same
17  * real physics object - a supercluster with two tracks reconstructed to it, or a track that points to two different SC
18  * (i would guess the latter doesn't actually happen).
19  * NB triplicates also appear in the electron collection provided by egamma group, it is necessary to handle those correctly
20  */
22  public:
24  template <typename T1, typename T2>
25  bool operator()(const T1 &t1, const T2 &t2) const {
26  return ((t1.superCluster() == t2.superCluster()) || (t1.gsfTrack() == t2.gsfTrack()));
27  }
28  }; // struct
29 
30  struct BestEoverP {
31  template <typename T1, typename T2>
32  bool operator()(const T1 &t1, const T2 &t2) const {
33  float diff1 = fabs(t1.eSuperClusterOverP() - 1);
34  float diff2 = fabs(t2.eSuperClusterOverP() - 1);
35  return diff1 <= diff2;
36  }
37  }; //struct
38 
39  // List of duplicate electrons to remove
40  // Among those that share the same cluster or track, the one with E/P nearer to 1 is kept
41  std::unique_ptr<std::vector<size_t> > duplicatesToRemove(const std::vector<reco::GsfElectron> &electrons) const;
42 
43  // List of duplicate electrons to remove
44  // Among those that share the same cluster or track, the one with E/P nearer to 1 is kept
45  std::unique_ptr<std::vector<size_t> > duplicatesToRemove(const edm::View<reco::GsfElectron> &electrons) const;
46 
47  // Generic method. Collection can be vector, view or whatever you like
48  template <typename Collection>
49  std::unique_ptr<std::vector<size_t> > duplicatesToRemove(const Collection &electrons) const;
50 
51  private:
52  }; // class
53 } // namespace pat
54 
55 // implemented here because is templated
56 template <typename Collection>
57 std::unique_ptr<std::vector<size_t> > pat::DuplicatedElectronRemover::duplicatesToRemove(
58  const Collection &electrons) const {
60  return dups.duplicates(electrons);
61 }
62 #endif
Definition: HeavyIon.h:7
std::unique_ptr< std::vector< size_t > > duplicatesToRemove(const std::vector< reco::GsfElectron > &electrons) const
bool operator()(const T1 &t1, const T2 &t2) const