1 #ifndef RecoBTag_Analysis_Matching_h 2 #define RecoBTag_Analysis_Matching_h 13 template<
typename Delta>
18 template<
typename V1,
typename V2,
class Separation>
19 Matching(
const V1 &v1,
const V2 &v2, Separation separation) :
25 for(
typename V1::const_iterator iter1 = v1.begin();
26 iter1 != v1.end(); ++iter1, ++
i) {
28 for(
typename V2::const_iterator iter2 = v2.begin();
29 iter2 != v2.end(); ++iter2, ++j)
30 matrix(i, j) = separation(*iter1, *iter2);
38 inline Match(index_type i1, index_type i2) :
45 {
return matrix(index1, index2); }
51 template<
class SortComparator>
52 struct Comparator :
public std::binary_function<Delta, Delta, bool> {
56 SortComparator &sort) :
57 matrix(matrix), sort(sort) {}
59 inline bool operator () (index_type i1, index_type i2)
const 66 struct AlwaysTrue :
public std::unary_function<Delta, bool> {
67 inline bool operator () (Delta
dummy) {
return true; }
71 template<
class SortComparator,
class CutCriterion>
73 SortComparator sortComparator = SortComparator(),
74 CutCriterion cutCriterion = CutCriterion())
84 result.reserve(
std::min(matrix.rows(), matrix.cols()));
85 for(
typename std::vector<index_type>::const_iterator iter =
88 index_type row = matrix.row(*iter);
89 index_type
col = matrix.col(*iter);
93 if (!cutCriterion(matrix[*iter]))
98 result.push_back(
Match(row, col));
104 template<
class SortComparator>
106 {
return match<SortComparator, AlwaysTrue>(); }
109 {
return match<std::less<Delta>,
AlwaysTrue>(); }
121 #endif // GeneratorEvent_Analysis_Matching_h
Matching::index_type index_type
Match(index_type i1, index_type i2)
Comparator(const SimpleMatrix< Delta > &matrix, SortComparator &sort)
Matching(const V1 &v1, const V2 &v2, Separation separation)
Delta delta(index_type index1, index_type index2) const
Matching::index_type index_type
std::vector< Match > match()
SimpleMatrix< Delta > matrix
Delta delta(Match match) const
bool isMatched2nd(index_type index)
bool isMatched1st(index_type index)
std::vector< bool > matched1
const SimpleMatrix< Delta > & matrix
std::vector< Match > match(SortComparator sortComparator=SortComparator(), CutCriterion cutCriterion=CutCriterion())
SimpleMatrix< Delta >::size_type index_type
std::vector< bool > matched2
std::vector< Match > match()