test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DuplicatedElectronRemover.cc
Go to the documentation of this file.
2 
3 #include <algorithm>
4 
5 
6 std::unique_ptr< std::vector<size_t> >
7 pat::DuplicatedElectronRemover::duplicatesToRemove(const std::vector<reco::GsfElectron> &electrons) const {
8  return duplicatesToRemove< std::vector<reco::GsfElectron> >(electrons);
9 }
10 
11 std::unique_ptr< std::vector<size_t> >
13  return duplicatesToRemove< edm::View<reco::GsfElectron> >(electrons);
14 }
15 
16 
17 
18 
19 /*
20 std::unique_ptr< std::vector<size_t> >
21 pat::DuplicatedElectronRemover::duplicatesToRemove(const std::vector<reco::GsfElectron> &electrons)
22 {
23  using namespace std;
24 
25  size_t size = electrons.size();
26 
27  vector<bool> bad(size, false);
28 
29  for (size_t ie = 0; ie < size; ++ie) {
30  if (bad[ie]) continue; // if already marked bad
31 
32  reco::GsfTrackRef thistrack = electrons[ie].gsfTrack();
33  reco::SuperClusterRef thissc = electrons[ie].superCluster();
34 
35  for (size_t je = ie+1; je < size; ++je) {
36  if (bad[je]) continue; // if already marked bad
37 
38  if ( ( thistrack == electrons[je].gsfTrack()) ||
39  (thissc == electrons[je].superCluster()) ) {
40  // we have a match, arbitrate and mark one for removal
41  // keep the one with E/P closer to unity
42  float diff1 = fabs(electrons[ie].eSuperClusterOverP()-1);
43  float diff2 = fabs(electrons[je].eSuperClusterOverP()-1);
44 
45  if (diff1<diff2) {
46  bad[je] = true;
47  } else {
48  bad[ie] = true;
49  }
50  }
51  }
52  }
53 
54  auto ret = std::make_unique<std::vector<size_t>>();
55 
56  for (size_t i = 0; i < size; ++i) {
57  if (bad[i]) ret->push_back(i);
58  }
59 
60  return ret;
61 }
62 */
std::unique_ptr< std::vector< size_t > > duplicatesToRemove(const std::vector< reco::GsfElectron > &electrons) const