CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC4_patch1/src/ElectroWeakAnalysis/ZEE/interface/UniqueElectrons.h

Go to the documentation of this file.
00001 std::vector<reco::GsfElectronRef> uniqueElectronFinder(edm::Handle<reco::GsfElectronCollection>& pElectrons)
00002 {
00003         const reco::GsfElectronCollection *electrons = pElectrons.product();
00004         //Remove duplicate electrons which share a supercluster
00005         std::vector<reco::GsfElectronRef> UniqueElectrons;
00006         int index =0;
00007         for(reco::GsfElectronCollection::const_iterator elec = electrons->begin(); elec != electrons->end();++elec)
00008         {
00009                 const reco::GsfElectronRef electronRef(pElectrons, index);
00010                 reco::GsfElectronCollection::const_iterator BestDuplicate = elec;
00011                 for(reco::GsfElectronCollection::const_iterator elec2 = electrons->begin(); elec2 != electrons->end(); ++elec2)
00012                 {
00013                     if(elec != elec2)
00014                     {
00015                         if(elec->superCluster() == elec2->superCluster())
00016                         {
00017                             edm::LogDebug_("", "MySelection.cc", 122)<<"e/p Best duplicate = "<< BestDuplicate->eSuperClusterOverP()
00018                                                                                          <<"\telec2 = "<<elec2->eSuperClusterOverP();
00019                             if(fabs(BestDuplicate->eSuperClusterOverP()-1.) >= fabs(elec2->eSuperClusterOverP()-1.))
00020                             {
00021                                     BestDuplicate = elec2;
00022                                     edm::LogDebug_("", "MySelection.cc", 122)<<"elec2 is now best duplicate";
00023                             }else edm::LogDebug_("", "MySelection.cc", 122)<<"BestDuplicate remains best duplicate";
00024                          }
00025                     }
00026                  }
00027                  if(BestDuplicate == elec) UniqueElectrons.push_back(electronRef);
00028                  ++index;
00029         }       
00030         return UniqueElectrons;
00031 }
00032