CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Types | Public Member Functions | Private Member Functions | Private Attributes
JetPartonMatching Class Reference

#include <JetPartonMatching.h>

Public Types

enum  algorithms { totalMinDist, minSumDist, ptOrderedMinDist, unambiguousOnly }
 
typedef std::vector< std::pair
< unsigned int, int > > 
MatchingCollection
 

Public Member Functions

double getDistanceForParton (const unsigned int part, const unsigned int comb=0)
 
std::vector< int > getMatchesForPartons (const unsigned int comb=0)
 
int getMatchForParton (const unsigned int part, const unsigned int comb=0)
 
unsigned int getNumberOfAvailableCombinations ()
 
int getNumberOfUnmatchedPartons (const unsigned int comb=0)
 
double getSumDeltaE (const unsigned int comb=0)
 
double getSumDeltaPt (const unsigned int comb=0)
 
double getSumDeltaR (const unsigned int comb=0)
 
double getSumDistances (const unsigned int comb=0)
 
 JetPartonMatching ()
 
 JetPartonMatching (const std::vector< const reco::Candidate * > &, const std::vector< reco::GenJet > &, const int, const bool, const bool, const double)
 
 JetPartonMatching (const std::vector< const reco::Candidate * > &, const std::vector< reco::CaloJet > &, const int, const bool, const bool, const double)
 
 JetPartonMatching (const std::vector< const reco::Candidate * > &, const std::vector< pat::Jet > &, const int, const bool, const bool, const double)
 
 JetPartonMatching (const std::vector< const reco::Candidate * > &, const std::vector< const reco::Candidate * > &, const int, const bool, const bool, const double)
 
void print ()
 
 ~JetPartonMatching ()
 

Private Member Functions

void calculate ()
 
double distance (const math::XYZTLorentzVector &, const math::XYZTLorentzVector &)
 
void matchingMinSumDist ()
 
void matchingPtOrderedMinDist ()
 
void matchingTotalMinDist ()
 
void matchingUnambiguousOnly ()
 
void minSumDist_recursion (const unsigned int, std::vector< unsigned int > &, std::vector< bool > &, std::vector< std::pair< double, MatchingCollection > > &)
 

Private Attributes

int algorithm_
 
std::vector< const
reco::Candidate * > 
jets
 
std::vector< MatchingCollectionmatching
 
double maxDist_
 
std::vector< unsigned int > numberOfUnmatchedPartons
 
std::vector< const
reco::Candidate * > 
partons
 
std::vector< double > sumDeltaE
 
std::vector< double > sumDeltaPt
 
std::vector< double > sumDeltaR
 
bool useDeltaR_
 
bool useMaxDist_
 

Detailed Description

Definition at line 11 of file JetPartonMatching.h.

Member Typedef Documentation

typedef std::vector<std::pair<unsigned int, int> > JetPartonMatching::MatchingCollection

Definition at line 15 of file JetPartonMatching.h.

Member Enumeration Documentation

Constructor & Destructor Documentation

JetPartonMatching::JetPartonMatching ( )
inline

Definition at line 18 of file JetPartonMatching.h.

18 {};
JetPartonMatching::JetPartonMatching ( const std::vector< const reco::Candidate * > &  p,
const std::vector< reco::GenJet > &  j,
const int  algorithm = totalMinDist,
const bool  useMaxDist = true,
const bool  useDeltaR = true,
const double  maxDist = 0.3 
)

Definition at line 5 of file JetPartonMatching.cc.

References calculate(), mps_fire::i, and jets.

11  : partons(p), algorithm_(algorithm), useMaxDist_(useMaxDist), useDeltaR_(useDeltaR), maxDist_(maxDist) {
12  std::vector<const reco::Candidate*> js;
13  for (unsigned int i = 0; i < j.size(); ++i)
14  js.push_back(&(j[i]));
15  jets = js;
16  calculate();
17 }
std::vector< const reco::Candidate * > partons
std::vector< const reco::Candidate * > jets
JetPartonMatching::JetPartonMatching ( const std::vector< const reco::Candidate * > &  p,
const std::vector< reco::CaloJet > &  j,
const int  algorithm = totalMinDist,
const bool  useMaxDist = true,
const bool  useDeltaR = true,
const double  maxDist = 0.3 
)

Definition at line 19 of file JetPartonMatching.cc.

References calculate(), mps_fire::i, and jets.

25  : partons(p), algorithm_(algorithm), useMaxDist_(useMaxDist), useDeltaR_(useDeltaR), maxDist_(maxDist) {
26  std::vector<const reco::Candidate*> js;
27  for (unsigned int i = 0; i < j.size(); ++i)
28  js.push_back(&(j[i]));
29  jets = js;
30  calculate();
31 }
std::vector< const reco::Candidate * > partons
std::vector< const reco::Candidate * > jets
JetPartonMatching::JetPartonMatching ( const std::vector< const reco::Candidate * > &  p,
const std::vector< pat::Jet > &  j,
const int  algorithm = totalMinDist,
const bool  useMaxDist = true,
const bool  useDeltaR = true,
const double  maxDist = 0.3 
)

Definition at line 33 of file JetPartonMatching.cc.

References calculate(), mps_fire::i, and jets.

39  : partons(p), algorithm_(algorithm), useMaxDist_(useMaxDist), useDeltaR_(useDeltaR), maxDist_(maxDist) {
40  std::vector<const reco::Candidate*> js;
41  for (unsigned int i = 0; i < j.size(); ++i)
42  js.push_back(&(j[i]));
43  jets = js;
44  calculate();
45 }
std::vector< const reco::Candidate * > partons
std::vector< const reco::Candidate * > jets
JetPartonMatching::JetPartonMatching ( const std::vector< const reco::Candidate * > &  p,
const std::vector< const reco::Candidate * > &  j,
const int  algorithm = totalMinDist,
const bool  useMaxDist = true,
const bool  useDeltaR = true,
const double  maxDist = 0.3 
)

Definition at line 47 of file JetPartonMatching.cc.

References calculate().

53  : partons(p), jets(j), algorithm_(algorithm), useMaxDist_(useMaxDist), useDeltaR_(useDeltaR), maxDist_(maxDist) {
54  calculate();
55 }
std::vector< const reco::Candidate * > partons
std::vector< const reco::Candidate * > jets
JetPartonMatching::~JetPartonMatching ( )
inline

Definition at line 43 of file JetPartonMatching.h.

43 {};

Member Function Documentation

void JetPartonMatching::calculate ( )
private

Definition at line 57 of file JetPartonMatching.cc.

References algorithm_, bookConverter::comb, distance(), relval_parameters_module::energy, first, getMatchForParton(), mps_fire::i, jets, match(), matching, matchingMinSumDist(), matchingPtOrderedMinDist(), matchingTotalMinDist(), matchingUnambiguousOnly(), minSumDist, numberOfUnmatchedPartons, partons, DiDispStaMuonMonitor_cfi::pt, ptOrderedMinDist, edm::second(), sumDeltaE, sumDeltaPt, sumDeltaR, totalMinDist, unambiguousOnly, and useMaxDist_.

Referenced by JetPartonMatching().

57  {
58  // use maximal distance between objects
59  // in case of unambiguousOnly algorithmm
61  useMaxDist_ = true;
62 
63  // check if there are empty partons in
64  // the vector, which happpens if the
65  // event is not ttbar or the decay is
66  // not as expected
67  bool emptyParton = false;
68  for (unsigned int ip = 0; ip < partons.size(); ++ip) {
69  if (partons[ip]->pdgId() == 0) {
70  emptyParton = true;
71  break;
72  }
73  }
74 
75  // switch algorithm, default is to match
76  // on the minimal sum of the distance
77  // (if jets or a parton is empty fill match with blanks)
78  if (jets.empty() || emptyParton) {
79  MatchingCollection dummyMatch;
80  for (unsigned int ip = 0; ip < partons.size(); ++ip)
81  dummyMatch.push_back(std::make_pair(ip, -1));
82  matching.push_back(dummyMatch);
83  } else {
84  switch (algorithm_) {
85  case totalMinDist:
87  break;
88 
89  case minSumDist:
91  break;
92 
93  case ptOrderedMinDist:
95  break;
96 
97  case unambiguousOnly:
99  break;
100 
101  default:
103  }
104  }
105 
106  numberOfUnmatchedPartons.clear();
107  sumDeltaE.clear();
108  sumDeltaPt.clear();
109  sumDeltaR.clear();
110  for (unsigned int comb = 0; comb < matching.size(); ++comb) {
112  std::sort(match.begin(), match.end());
113  matching[comb] = match;
114 
115  int nUnmatchedPartons = partons.size();
116  for (unsigned int part = 0; part < partons.size(); ++part)
117  if (getMatchForParton(part, comb) >= 0)
118  --nUnmatchedPartons;
119 
120  double sumDE = -999.;
121  double sumDPt = -999.;
122  double sumDR = -999.;
123  if (nUnmatchedPartons == 0) {
124  sumDE = 0;
125  sumDPt = 0;
126  sumDR = 0;
127  for (unsigned int i = 0; i < match.size(); ++i) {
128  sumDE += fabs(partons[match[i].first]->energy() - jets[match[i].second]->energy());
129  sumDPt += fabs(partons[match[i].first]->pt() - jets[match[i].second]->pt());
130  sumDR += distance(partons[match[i].first]->p4(), jets[match[i].second]->p4());
131  }
132  }
133 
134  numberOfUnmatchedPartons.push_back(nUnmatchedPartons);
135  sumDeltaE.push_back(sumDE);
136  sumDeltaPt.push_back(sumDPt);
137  sumDeltaR.push_back(sumDR);
138  }
139 }
std::vector< const reco::Candidate * > partons
std::vector< double > sumDeltaE
U second(std::pair< T, U > const &p)
dictionary comb
std::vector< unsigned int > numberOfUnmatchedPartons
std::vector< std::pair< unsigned int, int > > MatchingCollection
part
Definition: HCALResponse.h:20
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
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:10
std::vector< double > sumDeltaPt
double JetPartonMatching::distance ( const math::XYZTLorentzVector v1,
const math::XYZTLorentzVector v2 
)
private

Definition at line 141 of file JetPartonMatching.cc.

References HLT_FULL_cff::DeltaR, and useDeltaR_.

Referenced by calculate(), getDistanceForParton(), matchingPtOrderedMinDist(), matchingTotalMinDist(), matchingUnambiguousOnly(), and minSumDist_recursion().

141  {
142  // calculate the distance between two lorentz vectors
143  // using DeltaR(eta, phi) or normal space angle(theta, phi)
144  if (useDeltaR_)
145  return ROOT::Math::VectorUtil::DeltaR(v1, v2);
146  return ROOT::Math::VectorUtil::Angle(v1, v2);
147 }
double JetPartonMatching::getDistanceForParton ( const unsigned int  part,
const unsigned int  comb = 0 
)

Definition at line 358 of file JetPartonMatching.cc.

References distance(), getMatchForParton(), jets, and partons.

Referenced by getSumDistances(), TtSemiEvtSolutionMaker::produce(), and TtHadEvtSolutionMaker::produce().

358  {
359  // get the distance between parton and its best matched jet
360  if (getMatchForParton(part, comb) < 0)
361  return -999.;
362  return distance(jets[getMatchForParton(part, comb)]->p4(), partons[part]->p4());
363 }
std::vector< const reco::Candidate * > partons
dictionary comb
part
Definition: HCALResponse.h:20
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< int > JetPartonMatching::getMatchesForPartons ( const unsigned int  comb = 0)

Definition at line 349 of file JetPartonMatching.cc.

References getMatchForParton(), and partons.

Referenced by TtJetPartonMatch< C >::produce().

349  {
350  // return a vector with the indices of the matched jets
351  // (ordered according to the vector of partons)
352  std::vector<int> jetIndices;
353  for (unsigned int part = 0; part < partons.size(); ++part)
354  jetIndices.push_back(getMatchForParton(part, comb));
355  return jetIndices;
356 }
std::vector< const reco::Candidate * > partons
dictionary comb
part
Definition: HCALResponse.h:20
int getMatchForParton(const unsigned int part, const unsigned int comb=0)
int JetPartonMatching::getMatchForParton ( const unsigned int  part,
const unsigned int  comb = 0 
)

Definition at line 338 of file JetPartonMatching.cc.

References matching, and findQualityFiles::size.

Referenced by calculate(), getDistanceForParton(), getMatchesForPartons(), print(), TtSemiEvtSolutionMaker::produce(), and TtHadEvtSolutionMaker::produce().

338  {
339  // return index of the matched jet for a given parton
340  // (if arguments for parton index and combinatoric index
341  // are in the valid range)
342  if (comb >= matching.size())
343  return -9;
344  if (part >= matching[comb].size())
345  return -9;
346  return (matching[comb])[part].second;
347 }
dictionary comb
part
Definition: HCALResponse.h:20
std::vector< MatchingCollection > matching
tuple size
Write out results.
unsigned int JetPartonMatching::getNumberOfAvailableCombinations ( )
inline

Definition at line 46 of file JetPartonMatching.h.

References matching.

Referenced by print(), and TtJetPartonMatch< C >::produce().

46 { return matching.size(); }
std::vector< MatchingCollection > matching
int JetPartonMatching::getNumberOfUnmatchedPartons ( const unsigned int  comb = 0)
inline

Definition at line 47 of file JetPartonMatching.h.

References bookConverter::comb, and numberOfUnmatchedPartons.

47  {
48  return (comb < numberOfUnmatchedPartons.size() ? (int)numberOfUnmatchedPartons[comb] : -1);
49  }
dictionary comb
std::vector< unsigned int > numberOfUnmatchedPartons
double JetPartonMatching::getSumDeltaE ( const unsigned int  comb = 0)
inline

Definition at line 56 of file JetPartonMatching.h.

References bookConverter::comb, and sumDeltaE.

Referenced by print().

56 { return (comb < sumDeltaE.size() ? sumDeltaE[comb] : -999.); }
std::vector< double > sumDeltaE
dictionary comb
double JetPartonMatching::getSumDeltaPt ( const unsigned int  comb = 0)
inline

Definition at line 57 of file JetPartonMatching.h.

References bookConverter::comb, and sumDeltaPt.

Referenced by print(), and TtJetPartonMatch< C >::produce().

57 { return (comb < sumDeltaPt.size() ? sumDeltaPt[comb] : -999.); }
dictionary comb
std::vector< double > sumDeltaPt
double JetPartonMatching::getSumDeltaR ( const unsigned int  comb = 0)
inline

Definition at line 58 of file JetPartonMatching.h.

References bookConverter::comb, and sumDeltaR.

Referenced by print(), and TtJetPartonMatch< C >::produce().

58 { return (comb < sumDeltaR.size() ? sumDeltaR[comb] : -999.); }
dictionary comb
std::vector< double > sumDeltaR
double JetPartonMatching::getSumDistances ( const unsigned int  comb = 0)

Definition at line 365 of file JetPartonMatching.cc.

References getDistanceForParton(), and partons.

Referenced by TtSemiEvtSolutionMaker::produce(), and TtHadEvtSolutionMaker::produce().

365  {
366  // get sum of distances between partons and matched jets
367  double sumDists = 0.;
368  for (unsigned int part = 0; part < partons.size(); ++part) {
369  double dist = getDistanceForParton(part, comb);
370  if (dist < 0.)
371  return -999.;
372  sumDists += dist;
373  }
374  return sumDists;
375 }
std::vector< const reco::Candidate * > partons
dictionary comb
part
Definition: HCALResponse.h:20
double getDistanceForParton(const unsigned int part, const unsigned int comb=0)
void JetPartonMatching::matchingMinSumDist ( )
private

Definition at line 230 of file JetPartonMatching.cc.

References mps_fire::i, jets, matching, minSumDist_recursion(), and partons.

Referenced by calculate().

230  {
231  // match partons to jets with minimal sum of
232  // the distances between all partons and jets
233 
234  std::vector<std::pair<double, MatchingCollection> > distMatchVec;
235 
236  std::vector<bool> usedJets;
237  for (unsigned int i = 0; i < jets.size(); ++i) {
238  usedJets.push_back(false);
239  }
240 
241  std::vector<unsigned int> jetIndices;
242  jetIndices.reserve(partons.size());
243 
244  minSumDist_recursion(0, jetIndices, usedJets, distMatchVec);
245 
246  std::sort(distMatchVec.begin(), distMatchVec.end());
247 
248  matching.clear();
249 
250  if (distMatchVec.empty()) {
251  MatchingCollection dummyMatch;
252  for (unsigned int ip = 0; ip < partons.size(); ++ip)
253  dummyMatch.push_back(std::make_pair(ip, -1));
254  matching.push_back(dummyMatch);
255  } else
256  for (unsigned int i = 0; i < distMatchVec.size(); ++i)
257  matching.push_back(distMatchVec[i].second);
258 
259  return;
260 }
std::vector< const reco::Candidate * > partons
std::vector< std::pair< unsigned int, int > > MatchingCollection
void minSumDist_recursion(const unsigned int, std::vector< unsigned int > &, std::vector< bool > &, std::vector< std::pair< double, MatchingCollection > > &)
std::vector< const reco::Candidate * > jets
std::vector< MatchingCollection > matching
void JetPartonMatching::matchingPtOrderedMinDist ( )
private

Definition at line 262 of file JetPartonMatching.cc.

References distance(), jets, match(), matching, maxDist_, partons, edm::second(), and useMaxDist_.

Referenced by calculate().

262  {
263  // match partons to jets with minimal sum of
264  // the distances between all partons and jets
265  // order partons in pt first
266  std::vector<std::pair<double, unsigned int> > ptOrderedPartons;
267 
268  for (unsigned int ip = 0; ip < partons.size(); ++ip)
269  ptOrderedPartons.push_back(std::make_pair(partons[ip]->pt(), ip));
270 
271  std::sort(ptOrderedPartons.begin(), ptOrderedPartons.end());
272  std::reverse(ptOrderedPartons.begin(), ptOrderedPartons.end());
273 
274  std::vector<unsigned int> jetIndices;
275  for (unsigned int ij = 0; ij < jets.size(); ++ij)
276  jetIndices.push_back(ij);
277 
279 
280  for (unsigned int ip = 0; ip < ptOrderedPartons.size(); ++ip) {
281  double minDist = 999.;
282  int ijMin = -1;
283 
284  for (unsigned int ij = 0; ij < jetIndices.size(); ++ij) {
285  double dist = distance(partons[ptOrderedPartons[ip].second]->p4(), jets[jetIndices[ij]]->p4());
286  if (dist < minDist) {
287  if (!useMaxDist_ || dist <= maxDist_) {
288  minDist = dist;
289  ijMin = ij;
290  }
291  }
292  }
293 
294  if (ijMin >= 0) {
295  match.push_back(std::make_pair(ptOrderedPartons[ip].second, jetIndices[ijMin]));
296  jetIndices.erase(jetIndices.begin() + ijMin, jetIndices.begin() + ijMin + 1);
297  } else
298  match.push_back(std::make_pair(ptOrderedPartons[ip].second, -1));
299  }
300 
301  matching.clear();
302  matching.push_back(match);
303  return;
304 }
std::vector< const reco::Candidate * > partons
U second(std::pair< T, U > const &p)
std::vector< std::pair< unsigned int, int > > MatchingCollection
double distance(const math::XYZTLorentzVector &, const math::XYZTLorentzVector &)
std::vector< const reco::Candidate * > jets
std::vector< MatchingCollection > matching
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:10
void JetPartonMatching::matchingTotalMinDist ( )
private

Definition at line 149 of file JetPartonMatching.cc.

References a, distance(), first, jets, match(), matching, maxDist_, partons, and useMaxDist_.

Referenced by calculate().

149  {
150  // match parton to jet with shortest distance
151  // starting with the shortest distance available
152  // apply some outlier rejection if desired
153 
154  // prepare vector of pairs with distances between
155  // all partons to all jets in the input vectors
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) {
159  double dist = distance(jets[ij]->p4(), partons[ip]->p4());
160  distances.push_back(std::pair<double, unsigned int>(dist, ip * jets.size() + ij));
161  }
162  }
163  std::sort(distances.begin(), distances.end());
164 
166 
167  while (match.size() < partons.size()) {
168  unsigned int partonIndex = distances[0].second / jets.size();
169  int jetIndex = distances[0].second - jets.size() * partonIndex;
170 
171  // use primitive outlier rejection if desired
172  if (useMaxDist_ && distances[0].first > maxDist_)
173  jetIndex = -1;
174 
175  // prevent underflow in case of too few jets
176  if (distances.empty())
177  match.push_back(std::make_pair(partonIndex, -1));
178  else
179  match.push_back(std::make_pair(partonIndex, jetIndex));
180 
181  // remove all values for the matched parton
182  // and the matched jet
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);
188  --a;
189  }
190  }
191  }
192 
193  matching.clear();
194  matching.push_back(match);
195  return;
196 }
std::vector< const reco::Candidate * > partons
std::vector< std::pair< unsigned int, int > > MatchingCollection
double distance(const math::XYZTLorentzVector &, const math::XYZTLorentzVector &)
std::vector< const reco::Candidate * > jets
std::vector< MatchingCollection > matching
double a
Definition: hdecay.h:119
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:10
void JetPartonMatching::matchingUnambiguousOnly ( )
private

Definition at line 306 of file JetPartonMatching.cc.

References distance(), jets, match(), matching, maxDist_, and partons.

Referenced by calculate().

306  {
307  // match partons to jets, only accept event
308  // if there are no ambiguities
309  std::vector<bool> jetMatched;
310  for (unsigned int ij = 0; ij < jets.size(); ++ij)
311  jetMatched.push_back(false);
312 
314 
315  for (unsigned int ip = 0; ip < partons.size(); ++ip) {
316  int iMatch = -1;
317  for (unsigned int ij = 0; ij < jets.size(); ++ij) {
318  double dist = distance(partons[ip]->p4(), jets[ij]->p4());
319  if (dist <= maxDist_) {
320  if (!jetMatched[ij]) { // new match for jet
321  jetMatched[ij] = true;
322  if (iMatch == -1) // new match for parton and jet
323  iMatch = ij;
324  else // parton already matched: ambiguity!
325  iMatch = -2;
326  } else // jet already matched: ambiguity!
327  iMatch = -2;
328  }
329  }
330  match.push_back(std::make_pair(ip, iMatch));
331  }
332 
333  matching.clear();
334  matching.push_back(match);
335  return;
336 }
std::vector< const reco::Candidate * > partons
std::vector< std::pair< unsigned int, int > > MatchingCollection
double distance(const math::XYZTLorentzVector &, const math::XYZTLorentzVector &)
std::vector< const reco::Candidate * > jets
std::vector< MatchingCollection > matching
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:10
void JetPartonMatching::minSumDist_recursion ( const unsigned int  ip,
std::vector< unsigned int > &  jetIndices,
std::vector< bool > &  usedJets,
std::vector< std::pair< double, MatchingCollection > > &  distMatchVec 
)
private

Definition at line 198 of file JetPartonMatching.cc.

References distance(), jets, match(), maxDist_, partons, and useMaxDist_.

Referenced by matchingMinSumDist().

201  {
202  // build up jet combinations recursively
203  if (ip < partons.size()) {
204  for (unsigned int ij = 0; ij < jets.size(); ++ij) {
205  if (usedJets[ij])
206  continue;
207  usedJets[ij] = true;
208  jetIndices[ip] = ij;
209  minSumDist_recursion(ip + 1, jetIndices, usedJets, distMatchVec);
210  usedJets[ij] = false;
211  }
212  return;
213  }
214 
215  // calculate sumDist for each completed combination
216  double sumDist = 0;
218  for (unsigned int ip = 0; ip < partons.size(); ++ip) {
219  double dist = distance(partons[ip]->p4(), jets[jetIndices[ip]]->p4());
220  if (useMaxDist_ && dist > maxDist_)
221  return; // outlier rejection
222  sumDist += distance(partons[ip]->p4(), jets[jetIndices[ip]]->p4());
223  match.push_back(std::make_pair(ip, jetIndices[ip]));
224  }
225 
226  distMatchVec.push_back(std::make_pair(sumDist, match));
227  return;
228 }
std::vector< const reco::Candidate * > partons
std::vector< std::pair< unsigned int, int > > MatchingCollection
void minSumDist_recursion(const unsigned int, std::vector< unsigned int > &, std::vector< bool > &, std::vector< std::pair< double, MatchingCollection > > &)
double distance(const math::XYZTLorentzVector &, const math::XYZTLorentzVector &)
std::vector< const reco::Candidate * > jets
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:10
void JetPartonMatching::print ( void  )

Definition at line 377 of file JetPartonMatching.cc.

References algorithm_, bookConverter::comb, getMatchForParton(), getNumberOfAvailableCombinations(), getSumDeltaE(), getSumDeltaPt(), getSumDeltaR(), jets, log, matching, maxDist_, minSumDist, partons, ptOrderedMinDist, totalMinDist, unambiguousOnly, useDeltaR_, and useMaxDist_.

Referenced by TtJetPartonMatch< C >::produce().

377  {
378  //report using MessageLogger
379  edm::LogInfo log("JetPartonMatching");
380  log << "++++++++++++++++++++++++++++++++++++++++++++++ \n";
381  log << " algorithm : ";
382  switch (algorithm_) {
383  case totalMinDist:
384  log << "totalMinDist ";
385  break;
386  case minSumDist:
387  log << "minSumDist ";
388  break;
389  case ptOrderedMinDist:
390  log << "ptOrderedMinDist";
391  break;
392  case unambiguousOnly:
393  log << "unambiguousOnly ";
394  break;
395  default:
396  log << "UNKNOWN ";
397  }
398  log << "\n";
399  log << " useDeltaR : " << std::boolalpha << useDeltaR_;
400  log << "\n";
401  log << " useMaxDist: " << std::boolalpha << useMaxDist_;
402  log << " maxDist: " << maxDist_ << "\n";
403  log << " number of partons / jets: " << partons.size() << " / " << jets.size() << "\n";
404  log << " number of available combinations: " << getNumberOfAvailableCombinations() << "\n";
405  for (unsigned int comb = 0; comb < matching.size(); ++comb) {
406  log << " -------------------------------------------- \n";
407  log << " ind. of matched jets:";
408  for (unsigned int part = 0; part < partons.size(); ++part)
409  log << std::setw(4) << getMatchForParton(part, comb);
410  log << "\n";
411  log << " sumDeltaR : " << getSumDeltaR(comb) << "\n";
412  log << " sumDeltaPt / sumDeltaE: " << getSumDeltaPt(comb) << " / " << getSumDeltaE(comb);
413  log << "\n";
414  }
415  log << "++++++++++++++++++++++++++++++++++++++++++++++";
416 }
std::vector< const reco::Candidate * > partons
static std::vector< std::string > checklist log
unsigned int getNumberOfAvailableCombinations()
dictionary comb
double getSumDeltaE(const unsigned int comb=0)
part
Definition: HCALResponse.h:20
int getMatchForParton(const unsigned int part, const unsigned int comb=0)
std::vector< const reco::Candidate * > jets
std::vector< MatchingCollection > matching
double getSumDeltaR(const unsigned int comb=0)
double getSumDeltaPt(const unsigned int comb=0)

Member Data Documentation

int JetPartonMatching::algorithm_
private

Definition at line 84 of file JetPartonMatching.h.

Referenced by calculate(), and print().

std::vector<const reco::Candidate*> JetPartonMatching::jets
private
std::vector<MatchingCollection> JetPartonMatching::matching
private
double JetPartonMatching::maxDist_
private
std::vector<unsigned int> JetPartonMatching::numberOfUnmatchedPartons
private

Definition at line 79 of file JetPartonMatching.h.

Referenced by calculate(), and getNumberOfUnmatchedPartons().

std::vector<const reco::Candidate*> JetPartonMatching::partons
private
std::vector<double> JetPartonMatching::sumDeltaE
private

Definition at line 80 of file JetPartonMatching.h.

Referenced by calculate(), and getSumDeltaE().

std::vector<double> JetPartonMatching::sumDeltaPt
private

Definition at line 81 of file JetPartonMatching.h.

Referenced by calculate(), and getSumDeltaPt().

std::vector<double> JetPartonMatching::sumDeltaR
private

Definition at line 82 of file JetPartonMatching.h.

Referenced by calculate(), and getSumDeltaR().

bool JetPartonMatching::useDeltaR_
private

Definition at line 86 of file JetPartonMatching.h.

Referenced by distance(), and print().

bool JetPartonMatching::useMaxDist_
private