test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Functions
UniqueElectrons.h File Reference

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 1 of file UniqueElectrons.h.

References HI_PhotonSkim_cff::electrons, cmsHarvester::index, and edm::Handle< T >::product().

Referenced by ErsatzMEt::analyze().

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