CMS 3D CMS Logo

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::unique_ptr< OverlapListfind (const Collection &items, const OtherCollection &other) const
 
template<typename Collection , typename OtherCollection >
std::unique_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 52 of file GenericOverlapFinder.h.

Constructor & Destructor Documentation

◆ GenericOverlapFinder() [1/2]

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

Definition at line 54 of file GenericOverlapFinder.h.

54 {}

◆ GenericOverlapFinder() [2/2]

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

Definition at line 55 of file GenericOverlapFinder.h.

55 : distance_(dist) {}

Member Function Documentation

◆ find() [1/2]

template<typename Distance>
template<typename Collection , typename OtherCollection >
std::unique_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().

◆ find() [2/2]

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

Definition at line 71 of file GenericOverlapFinder.h.

References distance_, mps_monitormerge::items, match(), trackingPlots::other, runTheMatrix::ret, and findQualityFiles::size.

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

Member Data Documentation

◆ distance_

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

Definition at line 64 of file GenericOverlapFinder.h.