Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:26:52

0001 #include "RecoPixelVertexing/PixelVertexFinding/interface/PVPositionBuilder.h"
0002 #include <cmath>
0003 
0004 /// Constructor does nothing since this class has no data
0005 PVPositionBuilder::PVPositionBuilder() {}
0006 
0007 Measurement1D PVPositionBuilder::average(const reco::TrackRefVector &trks) const {
0008   // Cut and paste (more or less) from same class in ORCA framework
0009   double ntracks = double(trks.size());
0010   if (ntracks == 0)
0011     return Measurement1D(0., 0.);
0012   double sumZIP = 0;
0013   double err = 0;
0014   for (unsigned int i = 0; i < trks.size(); i++) {
0015     sumZIP += trks[i]->dz();    // Z at IP
0016     err += trks[i]->dzError();  // error on Z at IP (I hope). Fix d.k.
0017   }
0018   return Measurement1D(sumZIP / ntracks, err / ntracks / std::sqrt(ntracks));
0019 }
0020 
0021 Measurement1D PVPositionBuilder::wtAverage(const reco::TrackRefVector &trks) const {
0022   double ntracks = double(trks.size());
0023   if (ntracks == 0)
0024     return Measurement1D(0.0, 0.0);
0025   double sumUp = 0;
0026   double sumDown = 0;
0027   double err = 0;
0028   for (unsigned int i = 0; i < trks.size(); i++) {
0029     //    double err2 = trks[i]->covariance(3,3); // error on Z at IP (I hope)
0030     double err2 = trks[i]->dzError();  // Fix d.k.
0031     err2 *= err2;
0032     if (err2 != 0) {
0033       sumUp += trks[i]->dz() * 1 / err2;  // error-weighted average of Z at IP
0034       sumDown += 1 / err2;
0035     }
0036     err += std::sqrt(err2);
0037   }
0038   if (sumDown > 0)
0039     return Measurement1D(sumUp / sumDown, err / ntracks / sqrt(ntracks));
0040   else
0041     return Measurement1D(0.0, 0.0);
0042 }