CMS 3D CMS Logo

Public Member Functions | Private Attributes

pat::GenericDuplicateRemover< Comparator, Arbitrator > Class Template Reference

#include <GenericDuplicateRemover.h>

List of all members.

Public Member Functions

template<typename Collection >
std::auto_ptr< std::vector
< size_t > > 
duplicates (const Collection &items) const
 GenericDuplicateRemover (const Comparator &comp)
 GenericDuplicateRemover ()
 GenericDuplicateRemover (const Comparator &comp, const Arbitrator &arbiter)
 ~GenericDuplicateRemover ()

Private Attributes

Arbitrator arbiter_
Comparator comparator_

Detailed Description

template<typename Comparator, typename Arbitrator>
class pat::GenericDuplicateRemover< Comparator, Arbitrator >

Definition at line 11 of file GenericDuplicateRemover.h.


Constructor & Destructor Documentation

template<typename Comparator, typename Arbitrator>
pat::GenericDuplicateRemover< Comparator, Arbitrator >::GenericDuplicateRemover ( ) [inline]

Definition at line 15 of file GenericDuplicateRemover.h.

{}
template<typename Comparator, typename Arbitrator>
pat::GenericDuplicateRemover< Comparator, Arbitrator >::GenericDuplicateRemover ( const Comparator comp) [inline]

Definition at line 16 of file GenericDuplicateRemover.h.

: comparator_(comp) {}
template<typename Comparator, typename Arbitrator>
pat::GenericDuplicateRemover< Comparator, Arbitrator >::GenericDuplicateRemover ( const Comparator comp,
const Arbitrator &  arbiter 
) [inline]

Definition at line 17 of file GenericDuplicateRemover.h.

: comparator_(comp), arbiter_(arbiter) {}
template<typename Comparator, typename Arbitrator>
pat::GenericDuplicateRemover< Comparator, Arbitrator >::~GenericDuplicateRemover ( ) [inline]

Definition at line 19 of file GenericDuplicateRemover.h.

{}

Member Function Documentation

template<typename Comparator , typename Arbitrator >
template<typename Collection >
std::auto_ptr< std::vector< size_t > > pat::GenericDuplicateRemover< Comparator, Arbitrator >::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. 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 40 of file GenericDuplicateRemover.h.

References cond::ecalcond::bad(), i, run_regression::ret, and findQualityFiles::size.

Referenced by pat::DuplicatedPhotonRemover::duplicatesBySeed(), pat::DuplicatedPhotonRemover::duplicatesBySuperCluster(), and pat::DuplicatedElectronRemover::duplicatesToRemove().

{
    size_t size = items.size();

    std::vector<bool> bad(size, false);

    for (size_t ie = 0; ie < size; ++ie) {
        if (bad[ie]) continue; // if already marked bad

        for (size_t je = ie+1; je < size; ++je) {

            if (bad[je]) continue; // if already marked bad

            if ( comparator_(items[ie], items[je]) ) {
                int toRemove = arbiter_(items[ie], items[je]) ? je : ie;
                bad[toRemove] = true;
            }
        }
    }

    std::auto_ptr< std::vector<size_t> > ret(new std::vector<size_t>());

    for (size_t i = 0; i < size; ++i) {
        if (bad[i]) ret->push_back(i);
    }

    return ret;
}

Member Data Documentation

template<typename Comparator, typename Arbitrator>
Arbitrator pat::GenericDuplicateRemover< Comparator, Arbitrator >::arbiter_ [private]

Definition at line 32 of file GenericDuplicateRemover.h.

template<typename Comparator, typename Arbitrator>
Comparator pat::GenericDuplicateRemover< Comparator, Arbitrator >::comparator_ [private]

Definition at line 31 of file GenericDuplicateRemover.h.