CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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) return Measurement1D ( 0. , 0. );
11  double sumZIP = 0;
12  double err = 0;
13  for (unsigned int i=0; i<trks.size(); i++) {
14  sumZIP += trks[i]->dz(); // Z at IP
15  err += trks[i]->dzError(); // error on Z at IP (I hope). Fix d.k.
16  }
17  return Measurement1D ( sumZIP/ntracks, err/ntracks/std::sqrt(ntracks) );
18 
19 }
20 
22  double ntracks = double(trks.size());
23  if (ntracks==0) return Measurement1D ( 0.0 , 0.0 );
24  double sumUp = 0;
25  double sumDown = 0;
26  double err = 0;
27  for (unsigned int i=0; i<trks.size(); i++) {
28  // double err2 = trks[i]->covariance(3,3); // error on Z at IP (I hope)
29  double err2 = trks[i]->dzError(); // Fix d.k.
30  err2 *= err2;
31  if (err2 != 0){
32  sumUp += trks[i]->dz() * 1/err2; // error-weighted average of Z at IP
33  sumDown += 1/err2;
34  }
35  err += std::sqrt( err2 );
36  }
37  if (sumDown > 0) return Measurement1D ( sumUp/sumDown , err/ntracks/sqrt(ntracks) );
38  else return Measurement1D ( 0.0 , 0.0 );
39 }
int i
Definition: DBlmapReader.cc:9
PVPositionBuilder()
Constructor does nothing, no data members.
T sqrt(T t)
Definition: SSEVec.h:46
Measurement1D average(const reco::TrackRefVector &trks) const
Calculate unweighted average of Z of tracks from const collection of track pointers.
size_type size() const
Size of the RefVector.
Definition: RefVector.h:89
Measurement1D wtAverage(const reco::TrackRefVector &trks) const
Calculate Error-Weighted average of Z of tracks from const collection of track pointers.