CMS 3D CMS Logo

Classes | Public Types | Public Member Functions | Private Attributes

btag::Matching< Delta > Class Template Reference

#include <Matching.h>

List of all members.

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 >
std::vector< Matchmatch ()
template<class SortComparator , class CutCriterion >
std::vector< Matchmatch (SortComparator sortComparator=SortComparator(), CutCriterion cutCriterion=CutCriterion())
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 15 of file Matching.h.


Member Typedef Documentation

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

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

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

        {
                index_type i = 0;
                for(typename V1::const_iterator iter1 = v1.begin();
                    iter1 != v1.end(); ++iter1, ++i) {
                        index_type j = 0;
                        for(typename V2::const_iterator iter2 = v2.begin();
                            iter2 != v2.end(); ++iter2, ++j)
                                matrix(i, j) = separation(*iter1, *iter2);
                                        
                }
        }


Member Function Documentation

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

Definition at line 45 of file Matching.h.

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

        { return matrix(index1, index2); }

template<typename Delta>
Delta btag::Matching< Delta >::delta ( Match  match) const [inline]

Definition at line 48 of file Matching.h.

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

        { return matrix(match.index1, match.index2); }

template<typename Delta>
bool btag::Matching< Delta >::isMatched1st ( index_type  index) [inline]

Definition at line 112 of file Matching.h.

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

{ return matched2[index]; }
template<typename Delta>
bool btag::Matching< Delta >::isMatched2nd ( index_type  index) [inline]

Definition at line 113 of file Matching.h.

:
        SimpleMatrix<Delta>     matrix;
template<typename Delta>
template<class SortComparator >
std::vector<Match> btag::Matching< Delta >::match ( ) [inline]

Definition at line 106 of file Matching.h.

        { return match<SortComparator, AlwaysTrue>(); }

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 73 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().

        {
                std::vector<index_type> matches(matrix.size());
                for(index_type i = 0; i != matrix.size(); ++i)
                        matches[i] = i;

                std::sort(matches.begin(), matches.end(),
                          Comparator<SortComparator>(matrix, sortComparator));

                std::vector<Match> result;
                result.reserve(std::min(matrix.rows(), matrix.cols()));
                for(typename std::vector<index_type>::const_iterator iter =
                        matches.begin(); iter != matches.end(); ++iter) {

                        index_type row = matrix.row(*iter);
                        index_type col = matrix.col(*iter);
                        if (matched1[row] || matched2[col])
                                continue;

                        if (!cutCriterion(matrix[*iter]))
                                continue;

                        matched1[row] = true;
                        matched2[col] = true;
                        result.push_back(Match(row, col));
                }

                return result;
        }

template<typename Delta>
std::vector<Match> btag::Matching< Delta >::match ( ) [inline]

Definition at line 109 of file Matching.h.

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


Member Data Documentation

template<typename Delta>
std::vector<bool> btag::Matching< Delta >::matched1 [private]

Definition at line 117 of file Matching.h.

Referenced by btag::Matching< Delta >::match().

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