CMS 3D CMS Logo

Functions
FindPeakFastPV.h File Reference
#include <vector>

Go to the source code of this file.

Functions

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)
 

Function Documentation

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 at line 13 of file FindPeakFastPV.h.

References cuy::ii.

Referenced by FastPrimaryVertexWithWeightsProducer::produce().

13  {
14 float centerWMax = oldVertex;
15 if( m_zClusterWidth > 0 && m_zClusterSearchArea >0 )
16 {
17  std::vector<float>::const_iterator itCenter = zProjections.begin();
18  std::vector<float>::const_iterator itLeftSide = zProjections.begin();
19  std::vector<float>::const_iterator itRightSide = zProjections.begin();
20  const float zClusterWidth = m_zClusterWidth*0.5; //take half zCluster width
21  const float zLowerBound = oldVertex - zClusterWidth - m_zClusterSearchArea;
22  const float zUpperBound = oldVertex + zClusterWidth + m_zClusterSearchArea;
23  float maxW=0;
24  for(;itCenter!=zProjections.end(); itCenter++) {
25  //loop only on the zProjections within oldVertex +/- (zClusterWidth + m_zClusterSearchArea)
26  if( (*itCenter < zLowerBound) || (*itCenter > zUpperBound) ) continue;
27 
28  while(itLeftSide != zProjections.end() && (*itCenter - *itLeftSide) > zClusterWidth ) itLeftSide++;
29  while(itRightSide != zProjections.end() && (*itRightSide - *itCenter) < zClusterWidth ) itRightSide++;
30  float nWeighted = 0;
31  float centerW= 0;
32 
33  for(std::vector<float>::const_iterator ii = itLeftSide; ii != itRightSide; ii++) {
34  //loop inside the peak and calculate its weight
35  if(zWeights[ii-zProjections.begin()]<m_weightCut) continue;
36  nWeighted+=zWeights[ii-zProjections.begin()];
37  centerW+=(*ii)*zWeights[ii-zProjections.begin()];
38  }
39  centerW/=nWeighted; //calculate the weighted peak center
40  if(nWeighted > maxW) {
41  maxW=nWeighted;
42  centerWMax=centerW;
43  }
44  }
45 }
46 return centerWMax;
47 }
ii
Definition: cuy.py:588