CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_2_7_hltpatch1/src/PhysicsTools/PatUtils/src/DuplicatedElectronRemover.cc

Go to the documentation of this file.
00001 #include "PhysicsTools/PatUtils/interface/DuplicatedElectronRemover.h"
00002 
00003 #include <algorithm>
00004 
00005 
00006 std::auto_ptr< std::vector<size_t> > 
00007 pat::DuplicatedElectronRemover::duplicatesToRemove(const std::vector<reco::GsfElectron> &electrons) const {
00008     return duplicatesToRemove< std::vector<reco::GsfElectron> >(electrons);
00009 }
00010 
00011 std::auto_ptr< std::vector<size_t> > 
00012 pat::DuplicatedElectronRemover::duplicatesToRemove(const edm::View<reco::GsfElectron>   &electrons) const {
00013     return duplicatesToRemove< edm::View<reco::GsfElectron> >(electrons);
00014 }
00015 
00016 
00017 
00018 
00019 /*
00020 std::auto_ptr< std::vector<size_t> >
00021 pat::DuplicatedElectronRemover::duplicatesToRemove(const std::vector<reco::GsfElectron> &electrons) 
00022 {
00023     using namespace std;
00024 
00025     size_t size = electrons.size();
00026 
00027     vector<bool> bad(size, false);
00028 
00029     for (size_t ie = 0; ie < size; ++ie) {
00030         if (bad[ie]) continue; // if already marked bad
00031 
00032         reco::GsfTrackRef thistrack  = electrons[ie].gsfTrack();
00033         reco::SuperClusterRef thissc = electrons[ie].superCluster();
00034 
00035         for (size_t je = ie+1; je < size; ++je) {
00036             if (bad[je]) continue; // if already marked bad
00037 
00038             if ( ( thistrack == electrons[je].gsfTrack()) ||
00039                     (thissc  == electrons[je].superCluster()) ) {
00040                 // we have a match, arbitrate and mark one for removal
00041                 // keep the one with E/P closer to unity
00042                 float diff1 = fabs(electrons[ie].eSuperClusterOverP()-1);
00043                 float diff2 = fabs(electrons[je].eSuperClusterOverP()-1);
00044 
00045                 if (diff1<diff2) {
00046                     bad[je] = true;
00047                 } else {
00048                     bad[ie] = true;
00049                 }
00050             }
00051         }
00052     }
00053 
00054     auto_ptr< vector<size_t> > ret(new vector<size_t>());
00055 
00056     for (size_t i = 0; i < size; ++i) {
00057         if (bad[i]) ret->push_back(i);
00058     }
00059 
00060     return ret;
00061 }
00062 */