CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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 16 of file JetPartonMatching.h.

Member Enumeration Documentation

Constructor & Destructor Documentation

JetPartonMatching::JetPartonMatching ( )
inline

Definition at line 19 of file JetPartonMatching.h.

19 {};
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(), i, and jets.

8  : partons(p), algorithm_(algorithm), useMaxDist_(useMaxDist), useDeltaR_(useDeltaR), maxDist_(maxDist)
9 {
10  std::vector<const reco::Candidate*> js;
11  for(unsigned int i=0; i<j.size(); ++i) js.push_back( &(j[i]) );
12  jets = js;
13  calculate();
14 }
std::vector< const reco::Candidate * > partons
int i
Definition: DBlmapReader.cc:9
< trclass="colgroup">< tdclass="colgroup"colspan=5 > Ecal cluster collections</td ></tr >< tr >< td >< ahref="classreco_1_1BasicCluster.html"> reco::BasicCluster</a ></td >< td >< ahref="DataFormats_EgammaReco.html"> reco::BasicClusterCollection</a ></td >< td >< ahref="#"> hybridSuperClusters</a ></td >< tdclass="description"> Basic clusters reconstructed with hybrid algorithm(barrel only)</td >< td >S.Rahatlou</td ></tr >< tr >< td >< a href
int j
Definition: DBlmapReader.cc:9
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 16 of file JetPartonMatching.cc.

References calculate(), i, and jets.

19  : partons(p), algorithm_(algorithm), useMaxDist_(useMaxDist), useDeltaR_(useDeltaR), maxDist_(maxDist)
20 {
21  std::vector<const reco::Candidate*> js;
22  for(unsigned int i = 0; i < j.size(); ++i) js.push_back( &(j[i]) );
23  jets = js;
24  calculate();
25 }
std::vector< const reco::Candidate * > partons
int i
Definition: DBlmapReader.cc:9
< trclass="colgroup">< tdclass="colgroup"colspan=5 > Ecal cluster collections</td ></tr >< tr >< td >< ahref="classreco_1_1BasicCluster.html"> reco::BasicCluster</a ></td >< td >< ahref="DataFormats_EgammaReco.html"> reco::BasicClusterCollection</a ></td >< td >< ahref="#"> hybridSuperClusters</a ></td >< tdclass="description"> Basic clusters reconstructed with hybrid algorithm(barrel only)</td >< td >S.Rahatlou</td ></tr >< tr >< td >< a href
int j
Definition: DBlmapReader.cc:9
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 27 of file JetPartonMatching.cc.

References calculate(), i, and jets.

30  : partons(p), algorithm_(algorithm), useMaxDist_(useMaxDist), useDeltaR_(useDeltaR), maxDist_(maxDist)
31 {
32  std::vector<const reco::Candidate*> js;
33  for(unsigned int i = 0; i < j.size(); ++i) js.push_back( &(j[i]) );
34  jets = js;
35  calculate();
36 }
std::vector< const reco::Candidate * > partons
int i
Definition: DBlmapReader.cc:9
< trclass="colgroup">< tdclass="colgroup"colspan=5 > Ecal cluster collections</td ></tr >< tr >< td >< ahref="classreco_1_1BasicCluster.html"> reco::BasicCluster</a ></td >< td >< ahref="DataFormats_EgammaReco.html"> reco::BasicClusterCollection</a ></td >< td >< ahref="#"> hybridSuperClusters</a ></td >< tdclass="description"> Basic clusters reconstructed with hybrid algorithm(barrel only)</td >< td >S.Rahatlou</td ></tr >< tr >< td >< a href
int j
Definition: DBlmapReader.cc:9
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 38 of file JetPartonMatching.cc.

References calculate().

41  : partons(p), jets(j), algorithm_(algorithm), useMaxDist_(useMaxDist), useDeltaR_(useDeltaR), maxDist_(maxDist)
42 {
43  calculate();
44 }
std::vector< const reco::Candidate * > partons
< trclass="colgroup">< tdclass="colgroup"colspan=5 > Ecal cluster collections</td ></tr >< tr >< td >< ahref="classreco_1_1BasicCluster.html"> reco::BasicCluster</a ></td >< td >< ahref="DataFormats_EgammaReco.html"> reco::BasicClusterCollection</a ></td >< td >< ahref="#"> hybridSuperClusters</a ></td >< tdclass="description"> Basic clusters reconstructed with hybrid algorithm(barrel only)</td >< td >S.Rahatlou</td ></tr >< tr >< td >< a href
int j
Definition: DBlmapReader.cc:9
std::vector< const reco::Candidate * > jets
JetPartonMatching::~JetPartonMatching ( )
inline

Definition at line 28 of file JetPartonMatching.h.

28 {};

Member Function Documentation

void JetPartonMatching::calculate ( )
private

Definition at line 47 of file JetPartonMatching.cc.

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

Referenced by JetPartonMatching().

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

Definition at line 133 of file JetPartonMatching.cc.

References useDeltaR_.

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

134 {
135  // calculate the distance between two lorentz vectors
136  // using DeltaR(eta, phi) or normal space angle(theta, phi)
137  if(useDeltaR_) return ROOT::Math::VectorUtil::DeltaR(v1, v2);
138  return ROOT::Math::VectorUtil::Angle(v1, v2);
139 }
double JetPartonMatching::getDistanceForParton ( const unsigned int  part,
const unsigned int  comb = 0 
)

Definition at line 358 of file JetPartonMatching.cc.

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

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

359 {
360  // get the distance between parton and its best matched jet
361  if(getMatchForParton(part, comb) < 0) return -999.;
362  return distance( jets[getMatchForParton(part,comb)]->p4(), partons[part]->p4() );
363 }
std::vector< const reco::Candidate * > partons
double p4[4]
Definition: TauolaWrapper.h:92
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 347 of file JetPartonMatching.cc.

References getMatchForParton(), and partons.

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

348 {
349  // return a vector with the indices of the matched jets
350  // (ordered according to the vector of partons)
351  std::vector<int> jetIndices;
352  for(unsigned int part=0; part<partons.size(); ++part)
353  jetIndices.push_back( getMatchForParton(part, comb) );
354  return jetIndices;
355 }
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 336 of file JetPartonMatching.cc.

References matching, and findQualityFiles::size.

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

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

Definition at line 31 of file JetPartonMatching.h.

References matching.

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

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

Definition at line 32 of file JetPartonMatching.h.

References bookConverter::comb, and numberOfUnmatchedPartons.

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

Definition at line 39 of file JetPartonMatching.h.

References bookConverter::comb, findQualityFiles::size, and sumDeltaE.

Referenced by print().

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

Definition at line 40 of file JetPartonMatching.h.

References bookConverter::comb, and sumDeltaPt.

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

40 { 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 41 of file JetPartonMatching.h.

References bookConverter::comb, findQualityFiles::size, and sumDeltaR.

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

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

Definition at line 366 of file JetPartonMatching.cc.

References getDistanceForParton(), and partons.

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

367 {
368  // get sum of distances between partons and matched jets
369  double sumDists = 0.;
370  for(unsigned int part=0; part<partons.size(); ++part){
371  double dist = getDistanceForParton(part, comb);
372  if(dist < 0.) return -999.;
373  sumDists += dist;
374  }
375  return sumDists;
376 }
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 221 of file JetPartonMatching.cc.

References i, jets, matching, minSumDist_recursion(), partons, and python.multivaluedict::sort().

Referenced by calculate().

222 {
223  // match partons to jets with minimal sum of
224  // the distances between all partons and jets
225 
226  std::vector<std::pair<double, MatchingCollection> > distMatchVec;
227 
228  std::vector<bool> usedJets;
229  for(unsigned int i=0; i<jets.size(); ++i){
230  usedJets.push_back(false);
231  }
232 
233  std::vector<unsigned int> jetIndices;
234  jetIndices.reserve(partons.size());
235 
236  minSumDist_recursion(0, jetIndices, usedJets, distMatchVec);
237 
238  std::sort(distMatchVec.begin(), distMatchVec.end());
239 
240  matching.clear();
241 
242  if(distMatchVec.empty()) {
243  MatchingCollection dummyMatch;
244  for(unsigned int ip=0; ip<partons.size(); ++ip)
245  dummyMatch.push_back(std::make_pair(ip, -1));
246  matching.push_back( dummyMatch );
247  }
248  else
249  for(unsigned int i=0; i<distMatchVec.size(); ++i)
250  matching.push_back( distMatchVec[i].second );
251 
252  return;
253 }
std::vector< const reco::Candidate * > partons
int i
Definition: DBlmapReader.cc:9
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 256 of file JetPartonMatching.cc.

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

Referenced by calculate().

257 {
258  // match partons to jets with minimal sum of
259  // the distances between all partons and jets
260  // order partons in pt first
261  std::vector<std::pair <double, unsigned int> > ptOrderedPartons;
262 
263  for(unsigned int ip=0; ip<partons.size(); ++ip)
264  ptOrderedPartons.push_back(std::make_pair(partons[ip]->pt(), ip));
265 
266  std::sort(ptOrderedPartons.begin(), ptOrderedPartons.end());
267  std::reverse(ptOrderedPartons.begin(), ptOrderedPartons.end());
268 
269  std::vector<unsigned int> jetIndices;
270  for(unsigned int ij=0; ij<jets.size(); ++ij) jetIndices.push_back(ij);
271 
273 
274  for(unsigned int ip=0; ip<ptOrderedPartons.size(); ++ip){
275  double minDist = 999.;
276  int ijMin = -1;
277 
278  for(unsigned int ij=0; ij<jetIndices.size(); ++ij){
279  double dist = distance(partons[ptOrderedPartons[ip].second]->p4(), jets[jetIndices[ij]]->p4());
280  if(dist < minDist){
281  if(!useMaxDist_ || dist <= maxDist_){
282  minDist = dist;
283  ijMin = ij;
284  }
285  }
286  }
287 
288  if(ijMin >= 0){
289  match.push_back( std::make_pair(ptOrderedPartons[ip].second, jetIndices[ijMin]) );
290  jetIndices.erase(jetIndices.begin() + ijMin, jetIndices.begin() + ijMin + 1);
291  }
292  else
293  match.push_back( std::make_pair(ptOrderedPartons[ip].second, -1) );
294  }
295 
296  matching.clear();
297  matching.push_back( match );
298  return;
299 }
std::vector< const reco::Candidate * > partons
std::vector< std::pair< unsigned int, int > > MatchingCollection
U second(std::pair< T, U > const &p)
double p4[4]
Definition: TauolaWrapper.h:92
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:6
void JetPartonMatching::matchingTotalMinDist ( )
private

Definition at line 142 of file JetPartonMatching.cc.

References a, distance(), first, jets, match(), matching, maxDist_, p4, partons, python.multivaluedict::sort(), and useMaxDist_.

Referenced by calculate().

143 {
144  // match parton to jet with shortest distance
145  // starting with the shortest distance available
146  // apply some outlier rejection if desired
147 
148  // prepare vector of pairs with distances between
149  // all partons to all jets in the input vectors
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){
153  double dist = distance(jets[ij]->p4(), partons[ip]->p4());
154  distances.push_back(std::pair<double, unsigned int>(dist, ip*jets.size()+ij));
155  }
156  }
157  std::sort(distances.begin(), distances.end());
158 
160 
161  while(match.size() < partons.size()){
162  unsigned int partonIndex = distances[0].second/jets.size();
163  int jetIndex = distances[0].second-jets.size()*partonIndex;
164 
165  // use primitive outlier rejection if desired
166  if(useMaxDist_&& distances[0].first>maxDist_) jetIndex = -1;
167 
168  // prevent underflow in case of too few jets
169  if( distances.empty() )
170  match.push_back(std::make_pair(partonIndex, -1));
171  else
172  match.push_back(std::make_pair(partonIndex, jetIndex));
173 
174  // remove all values for the matched parton
175  // and the matched jet
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);
181  --a;
182  }
183  }
184  }
185 
186  matching.clear();
187  matching.push_back( match );
188  return;
189 }
std::vector< const reco::Candidate * > partons
std::vector< std::pair< unsigned int, int > > MatchingCollection
double p4[4]
Definition: TauolaWrapper.h:92
bool first
Definition: L1TdeRCT.cc:79
double distance(const math::XYZTLorentzVector &, const math::XYZTLorentzVector &)
std::vector< const reco::Candidate * > jets
std::vector< MatchingCollection > matching
double a
Definition: hdecay.h:121
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:6
void JetPartonMatching::matchingUnambiguousOnly ( )
private

Definition at line 302 of file JetPartonMatching.cc.

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

Referenced by calculate().

303 {
304  // match partons to jets, only accept event
305  // if there are no ambiguities
306  std::vector<bool> jetMatched;
307  for(unsigned int ij=0; ij<jets.size(); ++ij) jetMatched.push_back(false);
308 
310 
311  for(unsigned int ip=0; ip<partons.size(); ++ip){
312  int iMatch = -1;
313  for(unsigned int ij=0; ij<jets.size(); ++ij){
314  double dist = distance(partons[ip]->p4(), jets[ij]->p4());
315  if(dist <= maxDist_){
316  if(!jetMatched[ij]){ // new match for jet
317  jetMatched[ij] = true;
318  if(iMatch == -1) // new match for parton and jet
319  iMatch = ij;
320  else // parton already matched: ambiguity!
321  iMatch = -2;
322  }
323  else // jet already matched: ambiguity!
324  iMatch = -2;
325  }
326  }
327  match.push_back(std::make_pair(ip, iMatch));
328  }
329 
330  matching.clear();
331  matching.push_back( match );
332  return;
333 }
std::vector< const reco::Candidate * > partons
std::vector< std::pair< unsigned int, int > > MatchingCollection
double p4[4]
Definition: TauolaWrapper.h:92
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:6
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 192 of file JetPartonMatching.cc.

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

Referenced by matchingMinSumDist().

194 {
195  // build up jet combinations recursively
196  if(ip<partons.size()){
197  for(unsigned int ij=0; ij<jets.size(); ++ij){
198  if(usedJets[ij]) continue;
199  usedJets[ij] = true;
200  jetIndices[ip] = ij;
201  minSumDist_recursion(ip+1, jetIndices, usedJets, distMatchVec);
202  usedJets[ij] = false;
203  }
204  return;
205  }
206 
207  // calculate sumDist for each completed combination
208  double sumDist = 0;
210  for(unsigned int ip=0; ip<partons.size(); ++ip){
211  double dist = distance(partons[ip]->p4(), jets[jetIndices[ip]]->p4());
212  if(useMaxDist_ && dist > maxDist_) return; // outlier rejection
213  sumDist += distance(partons[ip]->p4(), jets[jetIndices[ip]]->p4());
214  match.push_back(std::make_pair(ip, jetIndices[ip]));
215  }
216 
217  distMatchVec.push_back( std::make_pair(sumDist, match) );
218  return;
219 }
std::vector< const reco::Candidate * > partons
std::vector< std::pair< unsigned int, int > > MatchingCollection
double p4[4]
Definition: TauolaWrapper.h:92
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:6
void JetPartonMatching::print ( void  )

Definition at line 379 of file JetPartonMatching.cc.

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

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

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

Referenced by calculate(), and getSumDeltaE().

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

Definition at line 63 of file JetPartonMatching.h.

Referenced by calculate(), and getSumDeltaPt().

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

Definition at line 64 of file JetPartonMatching.h.

Referenced by calculate(), and getSumDeltaR().

bool JetPartonMatching::useDeltaR_
private

Definition at line 68 of file JetPartonMatching.h.

Referenced by distance(), and print().

bool JetPartonMatching::useMaxDist_
private