Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:31:31

0001 #include "TrackingTools/GsfTracking/interface/GsfChi2MeasurementEstimator.h"
0002 #include "TrackingTools/GsfTools/interface/GetComponents.h"
0003 
0004 #include "TrackingTools/TrajectoryState/interface/TrajectoryStateOnSurface.h"
0005 #include "TrackingTools/GsfTracking/interface/PosteriorWeightsCalculator.h"
0006 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0007 
0008 std::pair<bool, double> GsfChi2MeasurementEstimator::estimate(const TrajectoryStateOnSurface& tsos,
0009                                                               const TrackingRecHit& hit) const {
0010   GetComponents comps(tsos);
0011   auto const& tsvec = comps();
0012   if (tsvec.empty()) {
0013     edm::LogError("GsfChi2MeasurementEstimator") << "Trying to calculate chi2 of hit with respect to empty mixture!";
0014     return std::make_pair(false, 0.);
0015   }
0016 
0017   auto const& weights = PosteriorWeightsCalculator(tsvec).weights(hit);
0018   if (weights.empty())
0019     return std::make_pair(false, 0);
0020 
0021   //   Chi2MeasurementEstimator est(chiSquaredCut());
0022   double chi2 = 0.;
0023   int i = 0;
0024   for (auto const& ts : tsvec)
0025     chi2 += weights[i++] * theEstimator.estimate(ts, hit).second;
0026   // Done - normalisation of weights is ensured
0027   // by PosteriorWeightsCalculator
0028   return returnIt(chi2);
0029 }