3 #include <Math/VectorUtil.h>
6 const std::vector<reco::GenJet>&
j,
12 std::vector<const reco::Candidate*> js;
13 for (
unsigned int i = 0;
i <
j.size(); ++
i)
14 js.push_back(&(
j[
i]));
20 const std::vector<reco::CaloJet>&
j,
26 std::vector<const reco::Candidate*> js;
27 for (
unsigned int i = 0;
i <
j.size(); ++
i)
28 js.push_back(&(
j[
i]));
34 const std::vector<pat::Jet>&
j,
40 std::vector<const reco::Candidate*> js;
41 for (
unsigned int i = 0;
i <
j.size(); ++
i)
42 js.push_back(&(
j[
i]));
48 const std::vector<const reco::Candidate*>&
j,
67 bool emptyParton =
false;
68 for (
unsigned int ip = 0; ip <
partons.size(); ++ip) {
78 if (
jets.empty() || emptyParton) {
80 for (
unsigned int ip = 0; ip <
partons.size(); ++ip)
81 dummyMatch.push_back(std::make_pair(ip, -1));
115 int nUnmatchedPartons =
partons.size();
120 double sumDE = -999.;
121 double sumDPt = -999.;
122 double sumDR = -999.;
123 if (nUnmatchedPartons == 0) {
127 for (
unsigned int i = 0;
i <
match.size(); ++
i) {
146 return ROOT::Math::VectorUtil::Angle(v1, v2);
156 std::vector<std::pair<double, unsigned int> > distances;
157 for (
unsigned int ip = 0; ip <
partons.size(); ++ip) {
158 for (
unsigned int ij = 0; ij <
jets.size(); ++ij) {
160 distances.push_back(std::pair<double, unsigned int>(dist, ip *
jets.size() + ij));
163 std::sort(distances.begin(), distances.end());
168 unsigned int partonIndex = distances[0].second /
jets.size();
169 int jetIndex = distances[0].second -
jets.size() * partonIndex;
176 if (distances.empty())
177 match.push_back(std::make_pair(partonIndex, -1));
179 match.push_back(std::make_pair(partonIndex, jetIndex));
183 for (
unsigned int a = 0;
a < distances.size(); ++
a) {
184 unsigned int pIndex = distances[
a].second /
jets.size();
185 int jIndex = distances[
a].second -
jets.size() * pIndex;
186 if ((pIndex == partonIndex) || (jIndex == jetIndex)) {
187 distances.erase(distances.begin() +
a, distances.begin() +
a + 1);
199 std::vector<unsigned int>& jetIndices,
200 std::vector<bool>& usedJets,
201 std::vector<std::pair<double, MatchingCollection> >& distMatchVec) {
204 for (
unsigned int ij = 0; ij <
jets.size(); ++ij) {
210 usedJets[ij] =
false;
218 for (
unsigned int ip = 0; ip <
partons.size(); ++ip) {
223 match.push_back(std::make_pair(ip, jetIndices[ip]));
226 distMatchVec.push_back(std::make_pair(sumDist,
match));
234 std::vector<std::pair<double, MatchingCollection> > distMatchVec;
236 std::vector<bool> usedJets;
237 for (
unsigned int i = 0;
i <
jets.size(); ++
i) {
238 usedJets.push_back(
false);
241 std::vector<unsigned int> jetIndices;
242 jetIndices.reserve(
partons.size());
246 std::sort(distMatchVec.begin(), distMatchVec.end());
250 if (distMatchVec.empty()) {
252 for (
unsigned int ip = 0; ip <
partons.size(); ++ip)
253 dummyMatch.push_back(std::make_pair(ip, -1));
256 for (
unsigned int i = 0;
i < distMatchVec.size(); ++
i)
257 matching.push_back(distMatchVec[
i].second);
266 std::vector<std::pair<double, unsigned int> > ptOrderedPartons;
268 for (
unsigned int ip = 0; ip <
partons.size(); ++ip)
269 ptOrderedPartons.push_back(std::make_pair(
partons[ip]->pt(), ip));
271 std::sort(ptOrderedPartons.begin(), ptOrderedPartons.end());
272 std::reverse(ptOrderedPartons.begin(), ptOrderedPartons.end());
274 std::vector<unsigned int> jetIndices;
275 for (
unsigned int ij = 0; ij <
jets.size(); ++ij)
276 jetIndices.push_back(ij);
280 for (
unsigned int ip = 0; ip < ptOrderedPartons.size(); ++ip) {
281 double minDist = 999.;
284 for (
unsigned int ij = 0; ij < jetIndices.size(); ++ij) {
286 if (dist < minDist) {
295 match.push_back(std::make_pair(ptOrderedPartons[ip].
second, jetIndices[ijMin]));
296 jetIndices.erase(jetIndices.begin() + ijMin, jetIndices.begin() + ijMin + 1);
298 match.push_back(std::make_pair(ptOrderedPartons[ip].
second, -1));
309 std::vector<bool> jetMatched;
310 for (
unsigned int ij = 0; ij <
jets.size(); ++ij)
311 jetMatched.push_back(
false);
315 for (
unsigned int ip = 0; ip <
partons.size(); ++ip) {
317 for (
unsigned int ij = 0; ij <
jets.size(); ++ij) {
320 if (!jetMatched[ij]) {
321 jetMatched[ij] =
true;
330 match.push_back(std::make_pair(ip, iMatch));
352 std::vector<int> jetIndices;
367 double sumDists = 0.;
380 log <<
"++++++++++++++++++++++++++++++++++++++++++++++ \n";
381 log <<
" algorithm : ";
384 log <<
"totalMinDist ";
387 log <<
"minSumDist ";
390 log <<
"ptOrderedMinDist";
393 log <<
"unambiguousOnly ";
403 log <<
" number of partons / jets: " <<
partons.size() <<
" / " <<
jets.size() <<
"\n";
406 log <<
" -------------------------------------------- \n";
407 log <<
" ind. of matched jets:";
415 log <<
"++++++++++++++++++++++++++++++++++++++++++++++";