CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_4_5_patch3/src/TrackingTools/GsfTracking/src/GsfMultiStateUpdator.cc

Go to the documentation of this file.
00001 #include "TrackingTools/GsfTracking/interface/GsfMultiStateUpdator.h"
00002 
00003 #include "TrackingTools/KalmanUpdators/interface/KFUpdator.h"
00004 #include "TrackingTools/PatternTools/interface/MeasurementExtractor.h"
00005 #include "TrackingTools/TransientTrackingRecHit/interface/TransientTrackingRecHit.h"
00006 #include "DataFormats/GeometrySurface/interface/BoundPlane.h"
00007 #include "TrackingTools/TrajectoryState/interface/TrajectoryStateOnSurface.h"
00008 #include "TrackingTools/GsfTools/interface/BasicMultiTrajectoryState.h"
00009 #include "TrackingTools/GsfTracking/interface/PosteriorWeightsCalculator.h"
00010 #include "TrackingTools/GsfTools/interface/MultiTrajectoryStateAssembler.h"
00011 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00012 
00013 TrajectoryStateOnSurface GsfMultiStateUpdator::update(const TrajectoryStateOnSurface& tsos,
00014                                                       const TransientTrackingRecHit& aRecHit) const {
00015   
00016   std::vector<TrajectoryStateOnSurface> predictedComponents = tsos.components();
00017   if (predictedComponents.empty()) {
00018     edm::LogError("GsfMultiStateUpdator") << "Trying to update trajectory state with zero components! " ;
00019     return TrajectoryStateOnSurface();
00020   }
00021 
00022   std::vector<double> weights = PosteriorWeightsCalculator(predictedComponents).weights(aRecHit);
00023   if ( weights.empty() ) {
00024     edm::LogError("GsfMultiStateUpdator") << " no weights could be retreived. invalid updated state !.";
00025     return TrajectoryStateOnSurface();
00026   }
00027 
00028   MultiTrajectoryStateAssembler result;
00029 
00030   int i = 0;
00031   for (std::vector<TrajectoryStateOnSurface>::const_iterator iter = predictedComponents.begin();
00032        iter != predictedComponents.end(); iter++) {
00033     TrajectoryStateOnSurface updatedTSOS = KFUpdator().update(*iter, aRecHit);
00034     if (updatedTSOS.isValid()){
00035       result.addState(TrajectoryStateOnSurface(updatedTSOS.localParameters(),
00036                                                updatedTSOS.localError(), updatedTSOS.surface(), 
00037                                                &(tsos.globalParameters().magneticField()),
00038                                                (*iter).surfaceSide(), weights[i]));
00039     i++;
00040     }
00041     else{
00042       edm::LogError("GsfMultiStateUpdator") << "one of the KF updated state is invalid. skipping.";
00043     }
00044 
00045   }
00046 
00047   return result.combinedState();
00048 }