CMS 3D CMS Logo

FindPeakFastPV.h
Go to the documentation of this file.
1 #ifndef RecoPixelVertexing_FindPeakFastPV_h
2 #define RecoPixelVertexing_FindPeakFastPV_h
3 
11 #include <vector>
12 
13 inline float FindPeakFastPV(const std::vector<float> &zProjections,
14  const std::vector<float> &zWeights,
15  const float oldVertex,
16  const float m_zClusterWidth,
17  const float m_zClusterSearchArea,
18  const float m_weightCut) {
19  float centerWMax = oldVertex;
20  if (m_zClusterWidth > 0 && m_zClusterSearchArea > 0) {
21  std::vector<float>::const_iterator itCenter = zProjections.begin();
22  std::vector<float>::const_iterator itLeftSide = zProjections.begin();
23  std::vector<float>::const_iterator itRightSide = zProjections.begin();
24  const float zClusterWidth = m_zClusterWidth * 0.5; //take half zCluster width
25  const float zLowerBound = oldVertex - zClusterWidth - m_zClusterSearchArea;
26  const float zUpperBound = oldVertex + zClusterWidth + m_zClusterSearchArea;
27  float maxW = 0;
28  for (; itCenter != zProjections.end(); itCenter++) {
29  //loop only on the zProjections within oldVertex +/- (zClusterWidth + m_zClusterSearchArea)
30  if ((*itCenter < zLowerBound) || (*itCenter > zUpperBound))
31  continue;
32 
33  while (itLeftSide != zProjections.end() && (*itCenter - *itLeftSide) > zClusterWidth)
34  itLeftSide++;
35  while (itRightSide != zProjections.end() && (*itRightSide - *itCenter) < zClusterWidth)
36  itRightSide++;
37  float nWeighted = 0;
38  float centerW = 0;
39 
40  for (std::vector<float>::const_iterator ii = itLeftSide; ii != itRightSide; ii++) {
41  //loop inside the peak and calculate its weight
42  if (zWeights[ii - zProjections.begin()] < m_weightCut)
43  continue;
44  nWeighted += zWeights[ii - zProjections.begin()];
45  centerW += (*ii) * zWeights[ii - zProjections.begin()];
46  }
47  centerW /= nWeighted; //calculate the weighted peak center
48  if (nWeighted > maxW) {
49  maxW = nWeighted;
50  centerWMax = centerW;
51  }
52  }
53  }
54  return centerWMax;
55 }
56 
57 #endif
FindPeakFastPV
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)
Definition: FindPeakFastPV.h:13
cuy.ii
ii
Definition: cuy.py:589