CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
FindPeakFastPV.h
Go to the documentation of this file.
1 #ifndef RecoPixelVertexing_FindPeakFastPV_h
2 #define RecoPixelVertexing_FindPeakFastPV_h
3 
12 float FindPeakFastPV(const std::vector<float> &zProjections, const std::vector<float> &zWeights, const float oldVertex, const float m_zClusterWidth, const float m_zClusterSearchArea, const float m_weightCut) {
13 float centerWMax = oldVertex;
14 if( m_zClusterWidth > 0 && m_zClusterSearchArea >0 )
15 {
16  std::vector<float>::const_iterator itCenter = zProjections.begin();
17  std::vector<float>::const_iterator itLeftSide = zProjections.begin();
18  std::vector<float>::const_iterator itRightSide = zProjections.begin();
19  const float zClusterWidth = m_zClusterWidth*0.5; //take half zCluster width
20  const float zLowerBound = oldVertex - zClusterWidth - m_zClusterSearchArea;
21  const float zUpperBound = oldVertex + zClusterWidth + m_zClusterSearchArea;
22  float maxW=0;
23  for(;itCenter!=zProjections.end(); itCenter++) {
24  //loop only on the zProjections within oldVertex +/- (zClusterWidth + m_zClusterSearchArea)
25  if( (*itCenter < zLowerBound) || (*itCenter > zUpperBound) ) continue;
26 
27  while(itLeftSide != zProjections.end() && (*itCenter - *itLeftSide) > zClusterWidth ) itLeftSide++;
28  while(itRightSide != zProjections.end() && (*itRightSide - *itCenter) < zClusterWidth ) itRightSide++;
29  float nWeighted = 0;
30  float centerW= 0;
31 
32  for(std::vector<float>::const_iterator ii = itLeftSide; ii != itRightSide; ii++) {
33  //loop inside the peak and calculate its weight
34  if(zWeights[ii-zProjections.begin()]<m_weightCut) continue;
35  nWeighted+=zWeights[ii-zProjections.begin()];
36  centerW+=(*ii)*zWeights[ii-zProjections.begin()];
37  }
38  centerW/=nWeighted; //calculate the weighted peak center
39  if(nWeighted > maxW) {
40  maxW=nWeighted;
41  centerWMax=centerW;
42  }
43  }
44 }
45 return centerWMax;
46 }
47 
48 #endif
int ii
Definition: cuy.py:588
float FindPeakFastPV(const std::vector< float > &zProjections, const std::vector< float > &zWeights, const float oldVertex, const float m_zClusterWidth, const float m_zClusterSearchArea, const float m_weightCut)