CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_0/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 // static initialization
00007 AlgebraicSymMatrix55  MaterialEffectsUpdator::theNullMatrix;
00008 
00009 
00010 
00013 MaterialEffectsUpdator::MaterialEffectsUpdator ( double mass ) :
00014   theMass(mass),
00015   theLastOverP(0),
00016   theLastDxdz(0), 
00017   theLastRL(0),
00018   theLastPropDir(anyDirection),
00019   theDeltaP(0.),
00020   theDeltaCov() {}
00021 
00022 MaterialEffectsUpdator::~MaterialEffectsUpdator () {}
00023 
00027 TrajectoryStateOnSurface MaterialEffectsUpdator::updateState (const TrajectoryStateOnSurface& TSoS, 
00028                                                               const PropagationDirection propDir) const {
00029   TrajectoryStateOnSurface shallowCopy = TSoS;
00030   // A TSOS is a proxy. Its contents will be really copied only if/when the updateStateInPlace attempts to change them
00031   return updateStateInPlace(shallowCopy, propDir) ? shallowCopy : TrajectoryStateOnSurface();
00032 }
00033 
00034 
00037 double MaterialEffectsUpdator::deltaP (const TrajectoryStateOnSurface& TSoS, const PropagationDirection propDir) const {
00038   // check for material
00039   if ( !TSoS.surface().mediumProperties() )  return 0.;
00040   // check for change (avoid using compute method if possible)
00041   if ( newArguments(TSoS,propDir) )  compute(TSoS,propDir);
00042   return theDeltaP;
00043 }
00044 
00045 
00048 const AlgebraicSymMatrix55 & MaterialEffectsUpdator::deltaLocalError (const TrajectoryStateOnSurface& TSoS, 
00049                                                                       const PropagationDirection propDir) const {
00050   // check for material
00051   if ( !TSoS.surface().mediumProperties() )  return theNullMatrix;
00052   // check for change (avoid using compute method if possible)
00053   if ( newArguments(TSoS,propDir) )  compute(TSoS,propDir);
00054   return theDeltaCov;
00055 }  
00056 
00057 
00058 //
00059 // Update of the trajectory state (implemented in base class since general for
00060 //   all classes returning deltaP and deltaCov.
00061 //
00062 bool MaterialEffectsUpdator::updateStateInPlace (TrajectoryStateOnSurface& TSoS, 
00063                                                  const PropagationDirection propDir) const {
00064   //
00065   // Check if 
00066   // - material is associated to surface
00067   // - propagation direction is not anyDirection
00068   // - side of surface is not atCenterOfSurface (could be handled with 50% material?)
00069   //
00070   const Surface& surface = TSoS.surface();
00071   if ( !surface.mediumProperties() || propDir==anyDirection || 
00072        TSoS.surfaceSide()==atCenterOfSurface )  return true;
00073   //
00074   // Check, if already on right side of surface
00075   //
00076   if ( (propDir==alongMomentum && TSoS.surfaceSide()==afterSurface ) ||
00077        (propDir==oppositeToMomentum && TSoS.surfaceSide()==beforeSurface ) )  return true;
00078   //
00079   // Update momentum. In case of failure: return invalid state
00080   //
00081   LocalTrajectoryParameters lp = TSoS.localParameters();
00082   if ( !lp.updateP(deltaP(TSoS,propDir)) )  
00083     return false;
00084   //
00085   // Update covariance matrix?
00086   //
00087   SurfaceSide side = propDir==alongMomentum ? afterSurface : beforeSurface;
00088   if ( TSoS.hasError() ) {
00089     AlgebraicSymMatrix55 eloc = TSoS.localError().matrix() + deltaLocalError(TSoS,propDir);
00090     //TSoS = TrajectoryStateOnSurface(lp,LocalTrajectoryError(eloc),surface, &(TSoS.globalParameters().magneticField()),side);
00091     TSoS.update(lp,LocalTrajectoryError(eloc),surface,
00092                 &(TSoS.globalParameters().magneticField()),side);
00093   }
00094   else {
00095     TSoS.update(lp,surface,&(TSoS.globalParameters().magneticField()),side);
00096     //TSoS = TrajectoryStateOnSurface(lp,surface,&(TSoS.globalParameters().magneticField()),side);
00097   }
00098   return true;
00099 }
00100 
00101 bool MaterialEffectsUpdator::newArguments (const TrajectoryStateOnSurface & TSoS, PropagationDirection  propDir) const {
00102   // check that track as same momentum and direction, surface has same radLen
00103   // it optimize also against multiple evaluations on different "surfaces" 
00104   // belonging to contigous detectors with same radLem 
00105   bool ok = 
00106     theLastOverP != TSoS.localParameters().qbp() ||
00107     theLastDxdz != TSoS.localParameters().dxdz() || 
00108     theLastRL    != TSoS.surface().mediumProperties()->radLen() ||
00109     theLastPropDir != propDir;
00110   if (ok) {
00111     theLastOverP = TSoS.localParameters().qbp();
00112     theLastDxdz  = TSoS.localParameters().dxdz(); 
00113     theLastRL  = TSoS.surface().mediumProperties()->radLen();
00114     theLastPropDir = propDir;
00115   }
00116   return ok;
00117 }
00118