CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
pat::GenericOverlapFinder< Distance > Class Template Reference

#include <GenericOverlapFinder.h>

Public Member Functions

template<typename Collection , typename OtherCollection >
std::auto_ptr< OverlapListfind (const Collection &items, const OtherCollection &other) const
 
template<typename Collection , typename OtherCollection >
std::auto_ptr< pat::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.

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

Definition at line 56 of file GenericOverlapFinder.h.

56 : distance_(dist) {}

Member Function Documentation

template<typename Distance>
template<typename Collection , typename OtherCollection >
std::auto_ptr< 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

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

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

Definition at line 74 of file GenericOverlapFinder.h.

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

75 {
76  size_t size = items.size(), size2 = other.size();
77 
78  std::auto_ptr< OverlapList > ret(new OverlapList());
79 
80  for (size_t ie = 0; ie < size; ++ie) {
81  double dmin = 1.0;
82  size_t match = 0;
83 
84  for (size_t je = 0; je < size2; ++je) {
85  double dist = distance_(items[ie], other[je]);
86  if (dist < dmin) { match = je; dmin = dist; }
87  }
88 
89  if (dmin < 1.0) {
90  ret->push_back(std::make_pair(ie,match));
91  }
92  }
93 
94  return ret;
95 }
std::vector< std::pair< size_t, size_t > > OverlapList
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:10
tuple size
Write out results.

Member Data Documentation

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

Definition at line 66 of file GenericOverlapFinder.h.