CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 14 of file Matching.h.

Member Typedef Documentation

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

Definition at line 16 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 19 of file Matching.h.

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

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

Member Function Documentation

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

Definition at line 44 of file Matching.h.

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

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

Definition at line 47 of file Matching.h.

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

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

Definition at line 111 of file Matching.h.

References getHLTprescales::index, and btag::Matching< Delta >::matched1.

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

Definition at line 112 of file Matching.h.

References getHLTprescales::index, and btag::Matching< Delta >::matched2.

112 { return matched2[index]; }
std::vector< bool > matched2
Definition: Matching.h:116
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 72 of file Matching.h.

References i, MultipleCompare::Match(), btag::Matching< Delta >::matched1, btag::Matching< Delta >::matched2, btag::Matching< Delta >::matrix, min, query::result, btag::SimpleMatrix< T >::size(), and python.multivaluedict::sort().

Referenced by MatchJet::matchCollections().

75  {
76  std::vector<index_type> matches(matrix.size());
77  for(index_type i = 0; i != matrix.size(); ++i)
78  matches[i] = i;
79 
80  std::sort(matches.begin(), matches.end(),
81  Comparator<SortComparator>(matrix, sortComparator));
82 
83  std::vector<Match> result;
84  result.reserve(std::min(matrix.rows(), matrix.cols()));
85  for(typename std::vector<index_type>::const_iterator iter =
86  matches.begin(); iter != matches.end(); ++iter) {
87 
88  index_type row = matrix.row(*iter);
89  index_type col = matrix.col(*iter);
90  if (matched1[row] || matched2[col])
91  continue;
92 
93  if (!cutCriterion(matrix[*iter]))
94  continue;
95 
96  matched1[row] = true;
97  matched2[col] = true;
98  result.push_back(Match(row, col));
99  }
100 
101  return result;
102  }
size_type rows() const
Definition: SimpleMatrix.h:19
int i
Definition: DBlmapReader.cc:9
size_type col(size_type index) const
Definition: SimpleMatrix.h:34
size_type row(size_type index) const
Definition: SimpleMatrix.h:33
#define min(a, b)
Definition: mlp_lapack.h:161
size_type cols() const
Definition: SimpleMatrix.h:20
size_type size() const
Definition: SimpleMatrix.h:21
tuple result
Definition: query.py:137
SimpleMatrix< Delta > matrix
Definition: Matching.h:115
std::vector< bool > matched1
Definition: Matching.h:116
SimpleMatrix< Delta >::size_type index_type
Definition: Matching.h:16
std::vector< bool > matched2
Definition: Matching.h:116
template<typename Delta>
template<class SortComparator >
std::vector<Match> btag::Matching< Delta >::match ( )
inline

Definition at line 105 of file Matching.h.

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

Definition at line 108 of file Matching.h.

109  { 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