CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Functions
PFB Namespace Reference

Functions

template<typename C , typename M >
void match (const C &candCollection, const M &matchedCandCollection, std::vector< int > &matchIndices, bool matchCharge=false, float dRMax=-1)
 

Function Documentation

template<typename C , typename M >
void PFB::match ( const C &  candCollection,
const M &  matchedCandCollection,
std::vector< int > &  matchIndices,
bool  matchCharge = false,
float  dRMax = -1 
)

Definition at line 13 of file Matchers.h.

References DeDxDiscriminatorTools::charge(), reco::deltaR2(), and i.

Referenced by PFCandidateMonitor::fill(), PFJetMonitor::fill(), and PFCandidateManager::fill().

17  {
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  }
int i
Definition: DBlmapReader.cc:9
double charge(const std::vector< uint8_t > &Ampls)
T1 deltaR2(T1 eta1, T2 phi1, T3 eta2, T4 phi2)
Definition: deltaR.h:58