CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_5/src/TrackingTools/GsfTracking/src/GsfMaterialEffectsUpdator.cc

Go to the documentation of this file.
00001 #include "TrackingTools/GsfTracking/interface/GsfMaterialEffectsUpdator.h"
00002 
00003 #include "TrackingTools/GsfTools/interface/MultiTrajectoryStateAssembler.h"
00004 #include "TrackingTools/TrajectoryState/interface/SurfaceSideDefinition.h"
00005 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00006 #include "FWCore/Utilities/interface/Exception.h"
00007 //
00008 // Update of the trajectory state (implemented in base class since general for
00009 //   all classes returning deltaPs and deltaCovs.
00010 //
00011 
00012 using namespace SurfaceSideDefinition;
00013 
00014 TrajectoryStateOnSurface 
00015 GsfMaterialEffectsUpdator::updateState (const TrajectoryStateOnSurface& TSoS, 
00016                                         const PropagationDirection propDir) const {
00017   //
00018   // get components of input state and check if material is associated to surface
00019   //
00020   const Surface& surface = TSoS.surface();
00021   if ( !surface.mediumProperties().isValid() )  return TSoS;
00022   SurfaceSide side = propDir==alongMomentum ? afterSurface : beforeSurface;
00023   // single input state?
00024   if ( TSoS.components().size()>1 )
00025     throw cms::Exception("LogicError") << "GsfMaterialEffectsUpdator::updateState used with MultiTSOS";
00026   double weight = TSoS.weight();
00027   //
00028   // Get components (will force recalculation, if necessary)
00029   //
00030   Effect effects[size()];
00031   compute(TSoS,propDir,effects);
00032 
00033   //
00034   // prepare output vector
00035   //
00036   MultiTrajectoryStateAssembler result;
00037   //
00038   // loop over components
00039   //
00040   //   edm::LogDebug("GsfMaterialEffectsUpdator") << "found " << Ws.size() << " components\n"
00041   //                                         << "  input state has weight " << TSoS.weight();
00042   for ( auto const & effect : effects ) {
00043     //      edm::LogDebug("GsfMaterialEffectsUpdator") << "w, dp, sigp = "
00044     //           << Ws[ic] << ", "
00045     //           << dPs[ic] << ", "
00046     //           << sqrt((deltaErrors[ic])[0][0]);
00047     //
00048     // Update momentum. In case of failure: return invalid state.
00049     // Use deltaP method to ensure update of cache, if necessary!
00050     //
00051     LocalTrajectoryParameters lp = TSoS.localParameters();
00052     if ( !lp.updateP(effect.deltaP) )  
00053       return TrajectoryStateOnSurface();
00054     //
00055     // Update covariance matrix?
00056     //
00057     if ( TSoS.hasError() ) {
00058       AlgebraicSymMatrix55 eloc = TSoS.localError().matrix();
00059       effect.deltaCov.add(eloc);
00060       result.addState(TrajectoryStateOnSurface(lp,
00061                                                LocalTrajectoryError(eloc),
00062                                                surface,
00063                                                &(TSoS.globalParameters().magneticField()),
00064                                                side,
00065                                                weight*effect.weight));
00066       //       edm::LogDebug("GsfMaterialEffectsUpdator") 
00067       //        << "adding state with weight " << weight*Ws[ic];
00068     }
00069     else {
00070       result.addState(TrajectoryStateOnSurface(lp,surface,
00071                                                &(TSoS.globalParameters().magneticField()),
00072                                                side));
00073     }
00074   }
00075   //   edm::LogDebug("GsfMaterialEffectsUpdator") 
00076   //     << "  output state has weight " << result.combinedState().weight();
00077   return result.combinedState();
00078 }
00079