CMS 3D CMS Logo

PVPositionBuilder.cc
Go to the documentation of this file.
2 #include <cmath>
3 
6 
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 }
20 
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 }
Measurement1D average(const reco::TrackRefVector &trks) const
Calculate unweighted average of Z of tracks from const collection of track pointers.
PVPositionBuilder()
Constructor does nothing, no data members.
Measurement1D wtAverage(const reco::TrackRefVector &trks) const
Calculate Error-Weighted average of Z of tracks from const collection of track pointers.
T sqrt(T t)
Definition: SSEVec.h:19