CMS 3D CMS Logo

Public Member Functions | Private Attributes

pat::GenericOverlapFinder< Distance > Class Template Reference

#include <GenericOverlapFinder.h>

List of all members.

Public Member Functions

template<typename Collection , typename OtherCollection >
std::auto_ptr< OverlapListfind (const Collection &items, const OtherCollection &other) const
 GenericOverlapFinder ()
 GenericOverlapFinder (const Distance &dist)

Private Attributes

Distance distance_

Detailed Description

template<typename Distance>
class pat::GenericOverlapFinder< Distance >

Definition at line 51 of file GenericOverlapFinder.h.


Constructor & Destructor Documentation

template<typename Distance>
pat::GenericOverlapFinder< Distance >::GenericOverlapFinder ( ) [inline]

Definition at line 55 of file GenericOverlapFinder.h.

{}
template<typename Distance>
pat::GenericOverlapFinder< Distance >::GenericOverlapFinder ( const Distance &  dist) [inline]

Definition at line 56 of file GenericOverlapFinder.h.

: distance_(dist) {}

Member Function Documentation

template<typename Distance >
template<typename Collection , typename OtherCollection >
std::auto_ptr< pat::OverlapList > pat::GenericOverlapFinder< Distance >::find ( const Collection &  items,
const OtherCollection &  other 
) const

Indices of overlapped items, and of the nearest item on they overlap with Items are considered to overlap if distance(x1,x2) < 1 both Collections can be vectors, Views, or anything with the same interface

Definition at line 74 of file GenericOverlapFinder.h.

References dmin, match(), run_regression::ret, and findQualityFiles::size.

Referenced by pat::DuplicatedPhotonRemover::electronsBySeed(), and pat::DuplicatedPhotonRemover::electronsBySuperCluster().

{
    size_t size = items.size(), size2 = other.size();

    std::auto_ptr< OverlapList > ret(new OverlapList());
    
    for (size_t ie = 0; ie < size; ++ie) {
        double dmin   = 1.0;
        size_t match = 0;

        for (size_t je = 0; je < size2; ++je) {
            double dist = distance_(items[ie], other[je]);
            if (dist < dmin) { match = je; dmin = dist;  }
        }
        
        if (dmin < 1.0) {
            ret->push_back(std::make_pair(ie,match));
        }
    }

    return ret;
}

Member Data Documentation

template<typename Distance>
Distance pat::GenericOverlapFinder< Distance >::distance_ [private]

Definition at line 66 of file GenericOverlapFinder.h.