CMS 3D CMS Logo

Functions
UniqueElectrons.h File Reference
#include "DataFormats/EgammaCandidates/interface/GsfElectronFwd.h"
#include <vector>

Go to the source code of this file.

Functions

std::vector< reco::GsfElectronRefuniqueElectronFinder (edm::Handle< reco::GsfElectronCollection > &pElectrons)
 

Function Documentation

std::vector<reco::GsfElectronRef> uniqueElectronFinder ( edm::Handle< reco::GsfElectronCollection > &  pElectrons)

Definition at line 5 of file UniqueElectrons.h.

References genericTrackCleaner_cfi::electrons, diffTreeTool::index, and edm::Handle< T >::product().

Referenced by ErsatzMEt::analyze().

6 {
7  const reco::GsfElectronCollection *electrons = pElectrons.product();
8  //Remove duplicate electrons which share a supercluster
9  std::vector<reco::GsfElectronRef> UniqueElectrons;
10  int index =0;
11  for(reco::GsfElectronCollection::const_iterator elec = electrons->begin(); elec != electrons->end();++elec)
12  {
13  const reco::GsfElectronRef electronRef(pElectrons, index);
14  reco::GsfElectronCollection::const_iterator BestDuplicate = elec;
15  for(reco::GsfElectronCollection::const_iterator elec2 = electrons->begin(); elec2 != electrons->end(); ++elec2)
16  {
17  if(elec != elec2)
18  {
19  if(elec->superCluster() == elec2->superCluster())
20  {
21  edm::LogDebug_("", "MySelection.cc", 122)<<"e/p Best duplicate = "<< BestDuplicate->eSuperClusterOverP()
22  <<"\telec2 = "<<elec2->eSuperClusterOverP();
23  if(fabs(BestDuplicate->eSuperClusterOverP()-1.) >= fabs(elec2->eSuperClusterOverP()-1.))
24  {
25  BestDuplicate = elec2;
26  edm::LogDebug_("", "MySelection.cc", 122)<<"elec2 is now best duplicate";
27  }else edm::LogDebug_("", "MySelection.cc", 122)<<"BestDuplicate remains best duplicate";
28  }
29  }
30  }
31  if(BestDuplicate == elec) UniqueElectrons.push_back(electronRef);
32  ++index;
33  }
34  return UniqueElectrons;
35 }
std::vector< GsfElectron > GsfElectronCollection
collection of GsfElectron objects
T const * product() const
Definition: Handle.h:81