1 #ifndef UtilAlgos_Matcher_h 2 #define UtilAlgos_Matcher_h 20 template<
typename C1,
typename C2,
typename M = edm::AssociationMap<edm::OneToOne<C1, C2> > >
36 virtual double matchDistance(
const T1 &,
const T2 & )
const = 0;
37 virtual bool select(
const T1 &,
const T2 & )
const = 0;
40 template<
typename C1,
typename C2,
58 bool select(
const T1 &
c1,
const T2 & c2 )
const override {
59 return select_( c1, c2 );
70 return p1.second < p2.second;
75 template<
typename C1,
typename C2,
typename M>
83 template<
typename C1,
typename C2,
typename M>
86 template<
typename C1,
typename C2,
typename M>
94 typedef typename MatchMap::ref_type ref_type;
95 typedef typename ref_type::key_type key_ref_type;
97 unique_ptr<MatchMap> matchMap(
new MatchMap( ref_type( key_ref_type( cands ),
98 value_ref_type( matched ) ) ) );
99 for(
size_t c = 0;
c != cands->size(); ++
c ) {
100 const T1 &
cand = (*cands)[
c ];
101 vector<helper::MatchPair>
v;
102 for(
size_t m = 0;
m != matched->size(); ++
m ) {
103 const T2 &
match = ( * matched )[
m ];
104 if (
select( cand, match ) ) {
106 if ( dist <
distMin_ ) v.push_back( make_pair(
m, dist ) );
111 typedef typename MatchMap::key_type key_type;
112 typedef typename MatchMap::data_type data_type;
helper::MatcherGetRef< C >::ref_type getRef(const Handle< C > &c, size_t k)
bool select(const T1 &c1, const T2 &c2) const override
double matchDistance(const T1 &c1, const T2 &c2) const override
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Matcher(const edm::ParameterSet &cfg)
S make(const edm::ParameterSet &cfg)
edm::EDGetTokenT< C1 > srcToken_
virtual double matchDistance(const T1 &, const T2 &) const =0
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
Container::value_type value_type
MatcherBase< C1, C2, M >::T2 T2
def template(fileName, svg, replaceme="REPLACEME")
DecomposeProduct< arg, typename Div::arg > D
MatcherBase< C1, C2, M >::T1 T1
void produce(edm::Event &, const edm::EventSetup &) override
double S(const TLorentzVector &, const TLorentzVector &)
std::pair< size_t, double > MatchPair
edm::EDGetTokenT< C2 > matchedToken_
bool operator()(const MatchPair &p1, const MatchPair &p2) const
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
MatcherBase< C1, C2, M >::MatchMap MatchMap
virtual bool select(const T1 &, const T2 &) const =0
MatcherBase(const edm::ParameterSet &)