1 #ifndef UtilAlgos_Matcher_h
2 #define UtilAlgos_Matcher_h
20 template <
typename C1,
typename C2,
typename M = edm::AssociationMap<edm::OneToOne<C1, C2> > >
37 virtual bool select(
const T1&,
const T2&)
const = 0;
40 template <
typename C1,
70 template <
typename C1,
typename C2,
typename M>
73 matchedToken_(consumes<C2>(cfg.
template getParameter<edm::
InputTag>(
"matched"))),
74 distMin_(cfg.
template getParameter<double>(
"distMin")) {
78 template <
typename C1,
typename C2,
typename M>
81 template <
typename C1,
typename C2,
typename M>
89 typedef typename MatchMap::ref_type ref_type;
90 typedef typename ref_type::key_type key_ref_type;
92 unique_ptr<MatchMap> matchMap(
new MatchMap(ref_type(key_ref_type(
cands), value_ref_type(matched))));
93 for (
size_t c = 0;
c !=
cands->size(); ++
c) {
94 const T1& cand = (*cands)[
c];
95 vector<helper::MatchPair>
v;
96 for (
size_t m = 0;
m != matched->size(); ++
m) {
99 double dist = matchDistance(cand, match);
101 v.push_back(make_pair(
m, dist));
106 typedef typename MatchMap::key_type key_type;
helper::MatcherGetRef< C >::ref_type getRef(const Handle< C > &c, size_t k)
virtual bool select(const T1 &, const T2 &) const =0
::ecal::reco::ComputationScalarType data_type
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
const edm::EventSetup & c
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Matcher(const edm::ParameterSet &cfg)
S make(const edm::ParameterSet &cfg)
edm::EDGetTokenT< C1 > srcToken_
Container::value_type value_type
MatcherBase< C1, C2, M >::T2 T2
virtual double matchDistance(const T1 &, const T2 &) const =0
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
bool select(const T1 &c1, const T2 &c2) const override
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
double matchDistance(const T1 &c1, const T2 &c2) const override
MatcherBase(const edm::ParameterSet &)