CMS 3D CMS Logo

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