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 14 of file Matchers.h.

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

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

18  {
19 
20  // compute distance to each candidate in the matchedCandCollection.
21 
22  float dR2Max = 0;
23  if(dRMax>0) dR2Max = dRMax*dRMax;
24 
25  matchIndices.clear();
26  matchIndices.resize( candCollection.size(), -1);
27 
28  for( unsigned i=0; i<candCollection.size(); ++i) {
29 
30  static const double bigNumber = 1e14;
31  double dR2min = bigNumber;
32  int jMin = -1;
33  for( unsigned jm=0; jm<matchedCandCollection.size(); ++jm) {
34 
35  if( matchCharge &&
36  candCollection[i].charge()!=matchedCandCollection[jm].charge() )
37  continue;
38 
39  double dR2 = reco::deltaR2( candCollection[i],
40  matchedCandCollection[jm] );
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)
double deltaR2(const T1 &t1, const T2 &t2)
Definition: deltaR.h:36