CMS 3D CMS Logo

List of all members | Public Member Functions
PVPositionBuilder Class Reference

#include <RecoPixelVertexing/PixelVertexFinding/PVPositionBuilder.h>

Public Member Functions

Measurement1D average (const reco::TrackRefVector &trks) const
 Calculate unweighted average of Z of tracks from const collection of track pointers. More...
 
 PVPositionBuilder ()
 Constructor does nothing, no data members. More...
 
Measurement1D wtAverage (const reco::TrackRefVector &trks) const
 Calculate Error-Weighted average of Z of tracks from const collection of track pointers. More...
 

Detailed Description

This helper class calculates the average Z position of a collection of tracks. You have the option of calculating the straight average, or making a weighted average using the error of the Z of the tracks. This class is used by the pixel vertexing to make a PVCluster and is used by other PVCluster-related classes

Author
Aaron Dominguez (UNL)

Definition at line 17 of file PVPositionBuilder.h.

Constructor & Destructor Documentation

◆ PVPositionBuilder()

PVPositionBuilder::PVPositionBuilder ( )

Constructor does nothing, no data members.

Constructor does nothing since this class has no data.

Definition at line 5 of file PVPositionBuilder.cc.

5 {}

Member Function Documentation

◆ average()

Measurement1D PVPositionBuilder::average ( const reco::TrackRefVector trks) const

Calculate unweighted average of Z of tracks from const collection of track pointers.

Definition at line 7 of file PVPositionBuilder.cc.

References submitPVResolutionJobs::err, mps_fire::i, ntracks, mathSSE::sqrt(), and hltEgammaHLTExtra_cfi::trks.

7  {
8  // Cut and paste (more or less) from same class in ORCA framework
9  double ntracks = double(trks.size());
10  if (ntracks == 0)
11  return Measurement1D(0., 0.);
12  double sumZIP = 0;
13  double err = 0;
14  for (unsigned int i = 0; i < trks.size(); i++) {
15  sumZIP += trks[i]->dz(); // Z at IP
16  err += trks[i]->dzError(); // error on Z at IP (I hope). Fix d.k.
17  }
18  return Measurement1D(sumZIP / ntracks, err / ntracks / std::sqrt(ntracks));
19 }
T sqrt(T t)
Definition: SSEVec.h:19

◆ wtAverage()

Measurement1D PVPositionBuilder::wtAverage ( const reco::TrackRefVector trks) const

Calculate Error-Weighted average of Z of tracks from const collection of track pointers.

Definition at line 21 of file PVPositionBuilder.cc.

References submitPVResolutionJobs::err, mps_fire::i, ntracks, mathSSE::sqrt(), and hltEgammaHLTExtra_cfi::trks.

21  {
22  double ntracks = double(trks.size());
23  if (ntracks == 0)
24  return Measurement1D(0.0, 0.0);
25  double sumUp = 0;
26  double sumDown = 0;
27  double err = 0;
28  for (unsigned int i = 0; i < trks.size(); i++) {
29  // double err2 = trks[i]->covariance(3,3); // error on Z at IP (I hope)
30  double err2 = trks[i]->dzError(); // Fix d.k.
31  err2 *= err2;
32  if (err2 != 0) {
33  sumUp += trks[i]->dz() * 1 / err2; // error-weighted average of Z at IP
34  sumDown += 1 / err2;
35  }
36  err += std::sqrt(err2);
37  }
38  if (sumDown > 0)
39  return Measurement1D(sumUp / sumDown, err / ntracks / sqrt(ntracks));
40  else
41  return Measurement1D(0.0, 0.0);
42 }
T sqrt(T t)
Definition: SSEVec.h:19