CMS 3D CMS Logo

CMSSW_4_4_3_patch1/src/TrackingTools/GsfTracking/src/GsfChi2MeasurementEstimator.cc

Go to the documentation of this file.
00001 #include "TrackingTools/GsfTracking/interface/GsfChi2MeasurementEstimator.h"
00002 
00003 // #include "TrackingTools/KalmanUpdators/interface/Chi2MeasurementEstimator.h"
00004 #include "TrackingTools/TrajectoryState/interface/TrajectoryStateOnSurface.h"
00005 #include "TrackingTools/GsfTracking/interface/PosteriorWeightsCalculator.h"
00006 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00007 
00008 std::pair<bool,double> 
00009 GsfChi2MeasurementEstimator::estimate (const TrajectoryStateOnSurface& tsos,
00010                                        const TransientTrackingRecHit& hit) const {
00011 
00012   std::vector<TrajectoryStateOnSurface> tsvec = tsos.components();
00013   if (tsvec.empty()) {
00014     edm::LogError("GsfChi2MeasurementEstimator") 
00015       << "Trying to calculate chi2 of hit with respect to empty mixture!";
00016     return std::make_pair(false,0.);
00017   }
00018 
00019   std::vector<double> weights = PosteriorWeightsCalculator(tsvec).weights(hit);
00020   if ( weights.empty() )  return std::make_pair(false,0);
00021 
00022   //   Chi2MeasurementEstimator est(chiSquaredCut());
00023   double chi2 = 0.;
00024   int i = 0;
00025   for (std::vector<TrajectoryStateOnSurface>::const_iterator it = tsvec.begin();
00026        it != tsvec.end(); it++) {
00027     chi2 += weights[i++] * theEstimator.estimate(*it,hit).second;
00028   }
00029   // Done - normalisation of weights is ensured 
00030   // by PosteriorWeightsCalculator
00031   return returnIt(chi2);
00032 }
00033