#include <PhysicsTools/PatUtils/interface/GenericDuplicateRemover.h>
Public Member Functions | |
template<typename Collection> | |
std::auto_ptr< std::vector < size_t > > | duplicates (const Collection &items) const |
Indices of duplicated items to remove Comparator is used to check for duplication, Arbiter to pick the best one e.g. | |
GenericDuplicateRemover (const Comparator &comp, const Arbitrator &arbiter) | |
GenericDuplicateRemover (const Comparator &comp) | |
GenericDuplicateRemover () | |
~GenericDuplicateRemover () | |
Private Attributes | |
Arbitrator | arbiter_ |
Comparator | comparator_ |
Definition at line 10 of file GenericDuplicateRemover.h.
pat::GenericDuplicateRemover< Comparator, Arbitrator >::GenericDuplicateRemover | ( | ) | [inline] |
pat::GenericDuplicateRemover< Comparator, Arbitrator >::GenericDuplicateRemover | ( | const Comparator & | comp | ) | [inline] |
pat::GenericDuplicateRemover< Comparator, Arbitrator >::GenericDuplicateRemover | ( | const Comparator & | comp, | |
const Arbitrator & | arbiter | |||
) | [inline] |
Definition at line 16 of file GenericDuplicateRemover.h.
00016 : comparator_(comp), arbiter_(arbiter) {}
pat::GenericDuplicateRemover< Comparator, Arbitrator >::~GenericDuplicateRemover | ( | ) | [inline] |
std::auto_ptr< std::vector< size_t > > pat::GenericDuplicateRemover< Comparator, Arbitrator >::duplicates | ( | const Collection & | items | ) | const [inline] |
Indices of duplicated items to remove Comparator is used to check for duplication, Arbiter to pick the best one e.g.
comparator(x1, x2) should return true if they are duplicates arbitrator(x1, x2) should return true if x1 is better, that is we want to keep x1 and delete x2 Collection can be vector, View, or anything with the same interface
Definition at line 39 of file GenericDuplicateRemover.h.
References pat::GenericDuplicateRemover< Comparator, Arbitrator >::arbiter_, pat::GenericDuplicateRemover< Comparator, Arbitrator >::comparator_, i, size, and std.
Referenced by pat::DuplicatedPhotonRemover::duplicatesBySeed(), pat::DuplicatedPhotonRemover::duplicatesBySuperCluster(), and pat::DuplicatedElectronRemover::duplicatesToRemove().
00040 { 00041 using namespace std; 00042 00043 size_t size = items.size(); 00044 00045 vector<bool> bad(size, false); 00046 00047 for (size_t ie = 0; ie < size; ++ie) { 00048 if (bad[ie]) continue; // if already marked bad 00049 00050 for (size_t je = ie+1; je < size; ++je) { 00051 00052 if (bad[je]) continue; // if already marked bad 00053 00054 if ( comparator_(items[ie], items[je]) ) { 00055 int toRemove = arbiter_(items[ie], items[je]) ? je : ie; 00056 bad[toRemove] = true; 00057 } 00058 } 00059 } 00060 00061 auto_ptr< vector<size_t> > ret(new vector<size_t>()); 00062 00063 for (size_t i = 0; i < size; ++i) { 00064 if (bad[i]) ret->push_back(i); 00065 } 00066 00067 return ret; 00068 }
Arbitrator pat::GenericDuplicateRemover< Comparator, Arbitrator >::arbiter_ [private] |
Definition at line 31 of file GenericDuplicateRemover.h.
Referenced by pat::GenericDuplicateRemover< Comparator, Arbitrator >::duplicates().
Comparator pat::GenericDuplicateRemover< Comparator, Arbitrator >::comparator_ [private] |
Definition at line 30 of file GenericDuplicateRemover.h.
Referenced by pat::GenericDuplicateRemover< Comparator, Arbitrator >::duplicates().