CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_7/src/TrackingTools/MaterialEffects/src/MaterialEffectsUpdator.cc

Go to the documentation of this file.
00001 #include "TrackingTools/TrajectoryState/interface/SurfaceSideDefinition.h"
00002 #include "TrackingTools/MaterialEffects/interface/MaterialEffectsUpdator.h"
00003 
00004 using namespace SurfaceSideDefinition;
00005 
00006 
00009 MaterialEffectsUpdator::MaterialEffectsUpdator ( double mass ) :
00010   theMass(mass) {}
00011 
00012 MaterialEffectsUpdator::~MaterialEffectsUpdator () {}
00013 
00017 TrajectoryStateOnSurface MaterialEffectsUpdator::updateState (const TrajectoryStateOnSurface& TSoS, 
00018                                                               const PropagationDirection propDir) const {
00019   TrajectoryStateOnSurface shallowCopy = TSoS;
00020   // A TSOS is a proxy. Its contents will be really copied only if/when the updateStateInPlace attempts to change them
00021   return updateStateInPlace(shallowCopy, propDir) ? shallowCopy : TrajectoryStateOnSurface();
00022 }
00023 
00024 
00025 
00026 //
00027 // Update of the trajectory state (implemented in base class since general for
00028 //   all classes returning deltaP and deltaCov.
00029 //
00030 bool MaterialEffectsUpdator::updateStateInPlace (TrajectoryStateOnSurface& TSoS, 
00031                                                  const PropagationDirection propDir) const {
00032   //
00033   // Check if 
00034   // - material is associated to surface
00035   // - propagation direction is not anyDirection
00036   // - side of surface is not atCenterOfSurface (could be handled with 50% material?)
00037   //
00038   const Surface& surface = TSoS.surface();
00039   if ( !surface.mediumProperties().isValid() || propDir==anyDirection || 
00040        TSoS.surfaceSide()==atCenterOfSurface )  return true;
00041   //
00042   // Check, if already on right side of surface
00043   //
00044   if ( (propDir==alongMomentum && TSoS.surfaceSide()==afterSurface ) ||
00045        (propDir==oppositeToMomentum && TSoS.surfaceSide()==beforeSurface ) )  return true;
00046   //
00047   // Update momentum. In case of failure: return invalid state
00048   //
00049   LocalTrajectoryParameters lp = TSoS.localParameters();
00050   Effect effect;
00051   compute (TSoS,propDir,effect);
00052   if ( !lp.updateP(effect.deltaP) )  
00053     return false;
00054   //
00055   // Update covariance matrix?
00056   //
00057   SurfaceSide side = propDir==alongMomentum ? afterSurface : beforeSurface;
00058   if ( TSoS.hasError() ) {
00059     AlgebraicSymMatrix55 eloc = TSoS.localError().matrix();
00060     effect.deltaCov.add(eloc);
00061     //TSoS = TrajectoryStateOnSurface(lp,LocalTrajectoryError(eloc),surface, &(TSoS.globalParameters().magneticField()),side);
00062     TSoS.update(lp,LocalTrajectoryError(eloc),surface,
00063                 &(TSoS.globalParameters().magneticField()),side);
00064   }
00065   else {
00066     TSoS.update(lp,surface,&(TSoS.globalParameters().magneticField()),side);
00067     //TSoS = TrajectoryStateOnSurface(lp,surface,&(TSoS.globalParameters().magneticField()),side);
00068   }
00069   return true;
00070 }
00071 
00072