3 #include <Math/VectorUtil.h>
6 const int algorithm = totalMinDist,
const bool useMaxDist =
true,
7 const bool useDeltaR =
true,
const double maxDist = 0.3)
8 : partons(p), algorithm_(
algorithm), useMaxDist_(useMaxDist), useDeltaR_(useDeltaR), maxDist_(
maxDist)
10 std::vector<const reco::Candidate*> js;
11 for(
unsigned int i=0;
i<j.size(); ++
i) js.push_back( &(j[
i]) );
17 const int algorithm = totalMinDist,
const bool useMaxDist =
true,
18 const bool useDeltaR =
true,
const double maxDist = 0.3)
19 : partons(p), algorithm_(
algorithm), useMaxDist_(useMaxDist), useDeltaR_(useDeltaR), maxDist_(
maxDist)
21 std::vector<const reco::Candidate*> js;
22 for(
unsigned int i = 0;
i < j.size(); ++
i) js.push_back( &(j[
i]) );
28 const int algorithm = totalMinDist,
const bool useMaxDist =
true,
29 const bool useDeltaR =
true,
const double maxDist = 0.3)
30 : partons(p), algorithm_(
algorithm), useMaxDist_(useMaxDist), useDeltaR_(useDeltaR), maxDist_(
maxDist)
32 std::vector<const reco::Candidate*> js;
33 for(
unsigned int i = 0;
i < j.size(); ++
i) js.push_back( &(j[
i]) );
39 const int algorithm = totalMinDist,
const bool useMaxDist =
true,
40 const bool useDeltaR =
true,
const double maxDist = 0.3)
41 : partons(p),
jets(j), algorithm_(
algorithm), useMaxDist_(useMaxDist), useDeltaR_(useDeltaR), maxDist_(
maxDist)
57 bool emptyParton=
false;
58 for(
unsigned int ip=0; ip<
partons.size(); ++ip){
68 if(
jets.empty() || emptyParton ) {
70 for(
unsigned int ip=0; ip<
partons.size(); ++ip)
71 dummyMatch.push_back( std::make_pair(ip, -1) );
107 int nUnmatchedPartons =
partons.size();
111 double sumDE = -999.;
112 double sumDPt = -999.;
113 double sumDR = -999.;
114 if(nUnmatchedPartons==0){
118 for(
unsigned int i=0;
i<match.size(); ++
i){
137 if(
useDeltaR_)
return ROOT::Math::VectorUtil::DeltaR(v1, v2);
138 return ROOT::Math::VectorUtil::Angle(v1, v2);
150 std::vector< std::pair<double, unsigned int> > distances;
151 for(
unsigned int ip=0; ip<
partons.size(); ++ip){
152 for(
unsigned int ij=0; ij<
jets.size(); ++ij){
154 distances.push_back(std::pair<double, unsigned int>(dist, ip*
jets.size()+ij));
157 std::sort(distances.begin(), distances.end());
161 while(match.size() <
partons.size()){
162 unsigned int partonIndex = distances[0].second/
jets.size();
163 int jetIndex = distances[0].second-
jets.size()*partonIndex;
169 if( distances.empty() )
170 match.push_back(std::make_pair(partonIndex, -1));
172 match.push_back(std::make_pair(partonIndex, jetIndex));
176 for(
unsigned int a=0;
a<distances.size(); ++
a){
177 unsigned int pIndex = distances[
a].second/
jets.size();
178 int jIndex = distances[
a].second-
jets.size()*pIndex;
179 if((pIndex == partonIndex) || (jIndex == jetIndex)){
180 distances.erase(distances.begin()+
a, distances.begin()+
a+1);
193 std::vector<bool> & usedJets, std::vector<std::pair<double, MatchingCollection> > & distMatchVec)
197 for(
unsigned int ij=0; ij<
jets.size(); ++ij){
198 if(usedJets[ij])
continue;
202 usedJets[ij] =
false;
210 for(
unsigned int ip=0; ip<
partons.size(); ++ip){
214 match.push_back(std::make_pair(ip, jetIndices[ip]));
217 distMatchVec.push_back( std::make_pair(sumDist, match) );
226 std::vector<std::pair<double, MatchingCollection> > distMatchVec;
228 std::vector<bool> usedJets;
229 for(
unsigned int i=0;
i<
jets.size(); ++
i){
230 usedJets.push_back(
false);
233 std::vector<unsigned int> jetIndices;
234 jetIndices.reserve(
partons.size());
238 std::sort(distMatchVec.begin(), distMatchVec.end());
242 if(distMatchVec.empty()) {
244 for(
unsigned int ip=0; ip<
partons.size(); ++ip)
245 dummyMatch.push_back(std::make_pair(ip, -1));
249 for(
unsigned int i=0;
i<distMatchVec.size(); ++
i)
250 matching.push_back( distMatchVec[
i].second );
261 std::vector<std::pair <double, unsigned int> > ptOrderedPartons;
263 for(
unsigned int ip=0; ip<
partons.size(); ++ip)
264 ptOrderedPartons.push_back(std::make_pair(
partons[ip]->pt(), ip));
266 std::sort(ptOrderedPartons.begin(), ptOrderedPartons.end());
267 std::reverse(ptOrderedPartons.begin(), ptOrderedPartons.end());
269 std::vector<unsigned int> jetIndices;
270 for(
unsigned int ij=0; ij<
jets.size(); ++ij) jetIndices.push_back(ij);
274 for(
unsigned int ip=0; ip<ptOrderedPartons.size(); ++ip){
275 double minDist = 999.;
278 for(
unsigned int ij=0; ij<jetIndices.size(); ++ij){
289 match.push_back( std::make_pair(ptOrderedPartons[ip].
second, jetIndices[ijMin]) );
290 jetIndices.erase(jetIndices.begin() + ijMin, jetIndices.begin() + ijMin + 1);
293 match.push_back( std::make_pair(ptOrderedPartons[ip].
second, -1) );
306 std::vector<bool> jetMatched;
307 for(
unsigned int ij=0; ij<
jets.size(); ++ij) jetMatched.push_back(
false);
311 for(
unsigned int ip=0; ip<
partons.size(); ++ip){
313 for(
unsigned int ij=0; ij<
jets.size(); ++ij){
317 jetMatched[ij] =
true;
327 match.push_back(std::make_pair(ip, iMatch));
341 if(comb >=
matching.size())
return -9;
351 std::vector<int> jetIndices;
369 double sumDists = 0.;
372 if(dist < 0.)
return -999.;
383 log <<
"++++++++++++++++++++++++++++++++++++++++++++++ \n";
384 log <<
" algorithm : ";
387 case minSumDist : log <<
"minSumDist ";
break;
390 default : log <<
"UNKNOWN ";
393 log <<
" useDeltaR : ";
395 case false : log <<
"false";
break;
396 case true : log <<
"true ";
399 log <<
" useMaxDist: ";
401 case false : log <<
"false";
break;
402 case true : log <<
"true ";
404 log <<
" maxDist: " <<
maxDist_ <<
"\n";
405 log <<
" number of partons / jets: " <<
partons.size() <<
" / " <<
jets.size() <<
"\n";
408 log <<
" -------------------------------------------- \n";
409 log <<
" ind. of matched jets:";
417 log <<
"++++++++++++++++++++++++++++++++++++++++++++++";
void matchingTotalMinDist()
std::vector< const reco::Candidate * > partons
std::vector< std::pair< unsigned int, int > > MatchingCollection
std::vector< double > sumDeltaE
unsigned int getNumberOfAvailableCombinations()
void matchingPtOrderedMinDist()
U second(std::pair< T, U > const &p)
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
std::vector< int > getMatchesForPartons(const unsigned int comb=0)
void matchingUnambiguousOnly()
double getSumDeltaE(const unsigned int comb=0)
std::vector< unsigned int > numberOfUnmatchedPartons
Log< T >::type log(const T &t)
void matchingMinSumDist()
void minSumDist_recursion(const unsigned int, std::vector< unsigned int > &, std::vector< bool > &, std::vector< std::pair< double, MatchingCollection > > &)
int getMatchForParton(const unsigned int part, const unsigned int comb=0)
double distance(const math::XYZTLorentzVector &, const math::XYZTLorentzVector &)
std::vector< const reco::Candidate * > jets
std::vector< MatchingCollection > matching
std::vector< double > sumDeltaR
double getSumDeltaR(const unsigned int comb=0)
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
std::vector< double > sumDeltaPt
double getSumDistances(const unsigned int comb=0)
tuple size
Write out results.
double getSumDeltaPt(const unsigned int comb=0)
double getDistanceForParton(const unsigned int part, const unsigned int comb=0)