test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 
14 namespace pat {
15 
16  /* --- Original comment from TQAF follows ----
17  * it is possible that there are multiple electron objects in the collection that correspond to the same
18  * real physics object - a supercluster with two tracks reconstructed to it, or a track that points to two different SC
19  * (i would guess the latter doesn't actually happen).
20  * NB triplicates also appear in the electron collection provided by egamma group, it is necessary to handle those correctly
21  */
23  public:
25  template<typename T1, typename T2>
26  bool operator()(const T1 &t1, const T2 &t2) const {
27  return ((t1.superCluster() == t2.superCluster()) ||
28  (t1.gsfTrack() == t2.gsfTrack()));
29  }
30  }; // struct
31 
32  struct BestEoverP {
33  template<typename T1, typename T2>
34  bool operator()(const T1 &t1, const T2 &t2) const {
35  float diff1 = fabs(t1.eSuperClusterOverP()-1);
36  float diff2 = fabs(t2.eSuperClusterOverP()-1);
37  return diff1 <= diff2;
38  }
39  }; //struct
40 
41  // List of duplicate electrons to remove
42  // Among those that share the same cluster or track, the one with E/P nearer to 1 is kept
43  std::auto_ptr< std::vector<size_t> > duplicatesToRemove(const std::vector<reco::GsfElectron> &electrons) const ;
44 
45  // List of duplicate electrons to remove
46  // Among those that share the same cluster or track, the one with E/P nearer to 1 is kept
47  std::auto_ptr< std::vector<size_t> > duplicatesToRemove(const edm::View<reco::GsfElectron> &electrons) const ;
48 
49  // Generic method. Collection can be vector, view or whatever you like
50  template<typename Collection>
51  std::auto_ptr< std::vector<size_t> > duplicatesToRemove(const Collection &electrons) const ;
52 
53  private:
54  }; // class
55 } // namespace
56 
57 // implemented here because is templated
58 template<typename Collection>
59 std::auto_ptr< std::vector<size_t> >
62  return dups.duplicates(electrons);
63 }
64 #endif
std::auto_ptr< std::vector< size_t > > duplicates(const Collection &items) const
bool operator()(const T1 &t1, const T2 &t2) const
auto const T2 &decltype(t1.eta()) t2
Definition: deltaR.h:16
std::auto_ptr< std::vector< size_t > > duplicatesToRemove(const std::vector< reco::GsfElectron > &electrons) const