CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Matchers.h
Go to the documentation of this file.
1 #ifndef __RecoParticleFlow_Benchmark_Matchers__
2 #define __RecoParticleFlow_Benchmark_Matchers__
3 
5 
6 #include <vector>
7 #include <iostream>
8 
9 namespace PFB {
10 
11 
12  template< typename C, typename M>
13  void match(const C& candCollection,
14  const M& matchedCandCollection,
15  std::vector<int>& matchIndices,
16  bool matchCharge = false,
17  float dRMax=-1) {
18 
19  // compute distance to each candidate in the matchedCandCollection.
20 
21  float dR2Max = 0;
22  if(dRMax>0) dR2Max = dRMax*dRMax;
23 
24  matchIndices.clear();
25  matchIndices.resize( candCollection.size(), -1);
26 
27  for( unsigned i=0; i<candCollection.size(); ++i) {
28 
29  static const double bigNumber = 1e14;
30  double dR2min = bigNumber;
31  int jMin = -1;
32  for( unsigned jm=0; jm<matchedCandCollection.size(); ++jm) {
33 
34  if( matchCharge &&
35  candCollection[i].charge()!=matchedCandCollection[jm].charge() )
36  continue;
37 
38  double dR2 = reco::deltaR2( candCollection[i],
39  matchedCandCollection[jm] );
40 
41  if( dR2<dR2min ) {
42  dR2min = dR2;
43  jMin = jm;
44  }
45  }
46 
47  if( (dR2Max>0 && dR2min < dR2Max) || dRMax<=0 ) {
48  matchIndices[i] = jMin;
49 /* std::cout<<"match "<<dR2min<<std::endl; */
50  }
51  // store the closest match, no cut on deltaR.
52  }
53  }
54 
55 
56 
57 
58 
59 
60 
61 }
62 
63 
64 #endif
int i
Definition: DBlmapReader.cc:9
void match(const C &candCollection, const M &matchedCandCollection, std::vector< int > &matchIndices, bool matchCharge=false, float dRMax=-1)
Definition: Matchers.h:13
double charge(const std::vector< uint8_t > &Ampls)
T1 deltaR2(T1 eta1, T2 phi1, T3 eta2, T4 phi2)
Definition: deltaR.h:58