CMS 3D CMS Logo

List of all members | Classes | Public Types | Public Member Functions | Private Attributes
btag::Matching< Delta > Class Template Reference

#include <Matching.h>

Classes

struct  AlwaysTrue
 
struct  Comparator
 
struct  Match
 

Public Types

typedef SimpleMatrix< Delta >::size_type index_type
 

Public Member Functions

Delta delta (index_type index1, index_type index2) const
 
Delta delta (Match match) const
 
bool isMatched1st (index_type index)
 
bool isMatched2nd (index_type index)
 
template<class SortComparator , class CutCriterion >
std::vector< Matchmatch (SortComparator sortComparator=SortComparator(), CutCriterion cutCriterion=CutCriterion())
 
template<class SortComparator >
std::vector< Matchmatch ()
 
std::vector< Matchmatch ()
 
template<typename V1 , typename V2 , class Separation >
 Matching (const V1 &v1, const V2 &v2, Separation separation)
 

Private Attributes

std::vector< bool > matched1
 
std::vector< bool > matched2
 
SimpleMatrix< Delta > matrix
 

Detailed Description

template<typename Delta>
class btag::Matching< Delta >

Definition at line 13 of file Matching.h.

Member Typedef Documentation

template<typename Delta>
typedef SimpleMatrix<Delta>::size_type btag::Matching< Delta >::index_type

Definition at line 15 of file Matching.h.

Constructor & Destructor Documentation

template<typename Delta>
template<typename V1 , typename V2 , class Separation >
btag::Matching< Delta >::Matching ( const V1 &  v1,
const V2 &  v2,
Separation  separation 
)
inline

Definition at line 18 of file Matching.h.

References mps_fire::i, and btag::Matching< Delta >::matrix.

18  :
19  matrix(v1.size(), v2.size()),
20  matched1(v1.size(), false),
21  matched2(v2.size(), false)
22  {
23  index_type i = 0;
24  for(typename V1::const_iterator iter1 = v1.begin();
25  iter1 != v1.end(); ++iter1, ++i) {
26  index_type j = 0;
27  for(typename V2::const_iterator iter2 = v2.begin();
28  iter2 != v2.end(); ++iter2, ++j)
29  matrix(i, j) = separation(*iter1, *iter2);
30 
31  }
32  }
SimpleMatrix< Delta > matrix
Definition: Matching.h:114
std::vector< bool > matched1
Definition: Matching.h:115
SimpleMatrix< Delta >::size_type index_type
Definition: Matching.h:15
std::vector< bool > matched2
Definition: Matching.h:115

Member Function Documentation

template<typename Delta>
Delta btag::Matching< Delta >::delta ( index_type  index1,
index_type  index2 
) const
inline

Definition at line 43 of file Matching.h.

References btag::Matching< Delta >::matrix.

44  { return matrix(index1, index2); }
SimpleMatrix< Delta > matrix
Definition: Matching.h:114
template<typename Delta>
Delta btag::Matching< Delta >::delta ( Match  match) const
inline

Definition at line 46 of file Matching.h.

References btag::Matching< Delta >::Match::index1, btag::Matching< Delta >::Match::index2, and btag::Matching< Delta >::matrix.

47  { return matrix(match.index1, match.index2); }
SimpleMatrix< Delta > matrix
Definition: Matching.h:114
std::vector< Match > match()
Definition: Matching.h:104
template<typename Delta>
bool btag::Matching< Delta >::isMatched1st ( index_type  index)
inline

Definition at line 110 of file Matching.h.

References btag::Matching< Delta >::matched1.

110 { return matched1[index]; }
std::vector< bool > matched1
Definition: Matching.h:115
template<typename Delta>
bool btag::Matching< Delta >::isMatched2nd ( index_type  index)
inline

Definition at line 111 of file Matching.h.

References btag::Matching< Delta >::matched2.

111 { return matched2[index]; }
std::vector< bool > matched2
Definition: Matching.h:115
template<typename Delta>
template<class SortComparator , class CutCriterion >
std::vector<Match> btag::Matching< Delta >::match ( SortComparator  sortComparator = SortComparator(),
CutCriterion  cutCriterion = CutCriterion() 
)
inline

Definition at line 71 of file Matching.h.

References cuy::col, mps_fire::i, btag::Matching< Delta >::Match::Match(), btag::Matching< Delta >::matched1, btag::Matching< Delta >::matched2, patRefSel_triggerMatching_cfi::matches, btag::Matching< Delta >::matrix, min(), mps_fire::result, btag::SimpleMatrix< T >::size(), and jetUpdater_cfi::sort.

74  {
75  std::vector<index_type> matches(matrix.size());
76  for(index_type i = 0; i != matrix.size(); ++i)
77  matches[i] = i;
78 
79  std::sort(matches.begin(), matches.end(),
80  Comparator<SortComparator>(matrix, sortComparator));
81 
82  std::vector<Match> result;
83  result.reserve(std::min(matrix.rows(), matrix.cols()));
84  for(typename std::vector<index_type>::const_iterator iter =
85  matches.begin(); iter != matches.end(); ++iter) {
86 
87  index_type row = matrix.row(*iter);
88  index_type col = matrix.col(*iter);
89  if (matched1[row] || matched2[col])
90  continue;
91 
92  if (!cutCriterion(matrix[*iter]))
93  continue;
94 
95  matched1[row] = true;
96  matched2[col] = true;
97  result.push_back(Match(row, col));
98  }
99 
100  return result;
101  }
size_type rows() const
Definition: SimpleMatrix.h:20
size_type col(size_type index) const
Definition: SimpleMatrix.h:35
size_type row(size_type index) const
Definition: SimpleMatrix.h:34
size_type cols() const
Definition: SimpleMatrix.h:21
size_type size() const
Definition: SimpleMatrix.h:22
T min(T a, T b)
Definition: MathUtil.h:58
SimpleMatrix< Delta > matrix
Definition: Matching.h:114
std::vector< bool > matched1
Definition: Matching.h:115
def Match(required, got)
col
Definition: cuy.py:1010
SimpleMatrix< Delta >::size_type index_type
Definition: Matching.h:15
std::vector< bool > matched2
Definition: Matching.h:115
template<typename Delta>
template<class SortComparator >
std::vector<Match> btag::Matching< Delta >::match ( )
inline

Definition at line 104 of file Matching.h.

105  { return match<SortComparator, AlwaysTrue>(); }
template<typename Delta>
std::vector<Match> btag::Matching< Delta >::match ( )
inline

Definition at line 107 of file Matching.h.

108  { return match<std::less<Delta>, AlwaysTrue>(); }

Member Data Documentation

template<typename Delta>
std::vector<bool> btag::Matching< Delta >::matched1
private
template<typename Delta>
std::vector<bool> btag::Matching< Delta >::matched2
private
template<typename Delta>
SimpleMatrix<Delta> btag::Matching< Delta >::matrix
private