Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:28:25

0001 #include "RecoVertex/VertexTools/interface/SequentialVertexSmoother.h"
0002 
0003 template <unsigned int N>
0004 SequentialVertexSmoother<N>::SequentialVertexSmoother(const VertexTrackUpdator<N>& vtu,
0005                                                       const VertexSmoothedChiSquaredEstimator<N>& vse,
0006                                                       const TrackToTrackCovCalculator<N>& covCalc)
0007     : theVertexTrackUpdator(vtu.clone()),
0008       theVertexSmoothedChiSquaredEstimator(vse.clone()),
0009       theTrackToTrackCovCalculator(covCalc.clone()) {}
0010 
0011 template <unsigned int N>
0012 SequentialVertexSmoother<N>::~SequentialVertexSmoother() {
0013   delete theVertexTrackUpdator;
0014   delete theVertexSmoothedChiSquaredEstimator;
0015   delete theTrackToTrackCovCalculator;
0016 }
0017 
0018 template <unsigned int N>
0019 SequentialVertexSmoother<N>::SequentialVertexSmoother(const SequentialVertexSmoother& smoother) {
0020   theVertexTrackUpdator = smoother.vertexTrackUpdator()->clone();
0021   theVertexSmoothedChiSquaredEstimator = smoother.vertexSmoothedChiSquaredEstimator()->clone();
0022   theTrackToTrackCovCalculator = smoother.trackToTrackCovCalculator()->clone();
0023 }
0024 
0025 template <unsigned int N>
0026 CachingVertex<N> SequentialVertexSmoother<N>::smooth(const CachingVertex<N>& vertex) const {
0027   // Track refit
0028 
0029   std::vector<RefCountedVertexTrack> newTracks;
0030   if (theVertexTrackUpdator != nullptr) {
0031     const std::vector<RefCountedVertexTrack>& vOut = vertex.tracks();
0032     for (typename std::vector<RefCountedVertexTrack>::const_iterator i = vOut.begin(); i != vOut.end(); i++) {
0033       RefCountedVertexTrack nTrack = theVertexTrackUpdator->update(vertex, *i);
0034       newTracks.push_back(nTrack);
0035     }
0036   } else {
0037     newTracks = vertex.tracks();
0038   }
0039 
0040   // intermediate vertex for chi2 calculation and TktoTkcovariance map
0041   CachingVertex<N> interVertex(vertex.position(), vertex.weight(), newTracks, 0.);
0042   if (vertex.hasPrior()) {
0043     interVertex = CachingVertex<N>(
0044         vertex.priorPosition(), vertex.priorError(), vertex.position(), vertex.weight(), newTracks, 0.);
0045   }
0046 
0047   // Smoothed chi2
0048 
0049   float smChi2 = vertex.totalChiSquared();
0050   if (theVertexSmoothedChiSquaredEstimator != nullptr) {
0051     std::pair<bool, double> result = theVertexSmoothedChiSquaredEstimator->estimate(interVertex);
0052     smChi2 = result.second;
0053   }
0054 
0055   if (theTrackToTrackCovCalculator == nullptr) {
0056     if (vertex.hasPrior()) {
0057       return CachingVertex<N>(vertex.priorVertexState(), vertex.vertexState(), newTracks, smChi2);
0058     } else {
0059       return CachingVertex<N>(vertex.vertexState(), newTracks, smChi2);
0060     }
0061   }
0062 
0063   //TktoTkcovariance map
0064   typename CachingVertex<N>::TrackToTrackMap tkMap = (*theTrackToTrackCovCalculator)(interVertex);
0065 
0066   //   CachingVertex<N> finalVertex(vertex.position(), vertex.error(),
0067   //                newTracks, smChi2, tkMap);
0068   if (vertex.hasPrior()) {
0069     CachingVertex<N> finalVertex(vertex.priorVertexState(), vertex.vertexState(), newTracks, smChi2, tkMap);
0070     return finalVertex;
0071   }
0072 
0073   CachingVertex<N> finalVertex(vertex.vertexState(), newTracks, smChi2, tkMap);
0074   return finalVertex;
0075 }
0076 
0077 template class SequentialVertexSmoother<5>;
0078 template class SequentialVertexSmoother<6>;