CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch12/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() )  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   std::vector<double> Ws = weights(TSoS,propDir);
00031   if ( Ws.empty() )  return TrajectoryStateOnSurface();
00032   std::vector<double> dPs = deltaPs(TSoS,propDir);
00033   if ( dPs.size()!=Ws.size() )
00034     throw cms::Exception("LogicError") 
00035       << "GsfMaterialEffectsUpdator: inconsistency in number of components";  
00036   std::vector<AlgebraicSymMatrix55> deltaErrors;
00037   if ( TSoS.hasError() )
00038     deltaErrors = deltaLocalErrors(TSoS,propDir);
00039   //
00040   // prepare output vector
00041   //
00042   MultiTrajectoryStateAssembler result;
00043   //
00044   // loop over components
00045   //
00046   //   edm::LogDebug("GsfMaterialEffectsUpdator") << "found " << Ws.size() << " components\n"
00047   //                                         << "  input state has weight " << TSoS.weight();
00048   for ( unsigned int ic=0; ic<Ws.size(); ic++ ) {
00049     //      edm::LogDebug("GsfMaterialEffectsUpdator") << "w, dp, sigp = "
00050     //           << Ws[ic] << ", "
00051     //           << dPs[ic] << ", "
00052     //           << sqrt((deltaErrors[ic])[0][0]);
00053     //
00054     // Update momentum. In case of failure: return invalid state.
00055     // Use deltaP method to ensure update of cache, if necessary!
00056     //
00057     LocalTrajectoryParameters lp = TSoS.localParameters();
00058     if ( !lp.updateP(dPs[ic]) )  
00059       return TrajectoryStateOnSurface();
00060     //
00061     // Update covariance matrix?
00062     //
00063     if ( TSoS.hasError() ) {
00064       AlgebraicSymMatrix55 eloc = TSoS.localError().matrix();
00065       eloc += deltaErrors[ic];
00066       result.addState(TrajectoryStateOnSurface(lp,
00067                                                LocalTrajectoryError(eloc),
00068                                                surface,
00069                                                &(TSoS.globalParameters().magneticField()),
00070                                                side,
00071                                                weight*Ws[ic]));
00072       //       edm::LogDebug("GsfMaterialEffectsUpdator") 
00073       //        << "adding state with weight " << weight*Ws[ic];
00074     }
00075     else {
00076       result.addState(TrajectoryStateOnSurface(lp,surface,
00077                                                &(TSoS.globalParameters().magneticField()),
00078                                                side));
00079     }
00080   }
00081   //   edm::LogDebug("GsfMaterialEffectsUpdator") 
00082   //     << "  output state has weight " << result.combinedState().weight();
00083   return result.combinedState();
00084 }
00085