Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:31:33

0001 #include "TrackingTools/TrajectoryState/interface/SurfaceSideDefinition.h"
0002 #include "TrackingTools/MaterialEffects/interface/MaterialEffectsUpdator.h"
0003 
0004 using namespace SurfaceSideDefinition;
0005 
0006 /** Constructor with explicit mass hypothesis
0007  */
0008 MaterialEffectsUpdator::MaterialEffectsUpdator(float mass) : theMass(mass) {}
0009 
0010 MaterialEffectsUpdator::~MaterialEffectsUpdator() {}
0011 
0012 /** Updates TrajectoryStateOnSurface with material effects
0013  *    (momentum and covariance matrix are potentially affected.
0014  */
0015 TrajectoryStateOnSurface MaterialEffectsUpdator::updateState(const TrajectoryStateOnSurface& TSoS,
0016                                                              const PropagationDirection propDir) const {
0017   TrajectoryStateOnSurface shallowCopy = TSoS;
0018   // A TSOS is a proxy. Its contents will be really copied only if/when the updateStateInPlace attempts to change them
0019   return updateStateInPlace(shallowCopy, propDir) ? shallowCopy : TrajectoryStateOnSurface();
0020 }
0021 
0022 //
0023 // Update of the trajectory state (implemented in base class since general for
0024 //   all classes returning deltaP and deltaCov.
0025 //
0026 bool MaterialEffectsUpdator::updateStateInPlace(TrajectoryStateOnSurface& TSoS,
0027                                                 const PropagationDirection propDir) const {
0028   //
0029   // Check if
0030   // - material is associated to surface
0031   // - propagation direction is not anyDirection
0032   // - side of surface is not atCenterOfSurface (could be handled with 50% material?)
0033   //
0034   const Surface& surface = TSoS.surface();
0035   if (!surface.mediumProperties().isValid() || propDir == anyDirection || TSoS.surfaceSide() == atCenterOfSurface)
0036     return true;
0037   //
0038   // Check, if already on right side of surface
0039   //
0040   if ((propDir == alongMomentum && TSoS.surfaceSide() == afterSurface) ||
0041       (propDir == oppositeToMomentum && TSoS.surfaceSide() == beforeSurface))
0042     return true;
0043   //
0044   // Update momentum. In case of failure: return invalid state
0045   //
0046   LocalTrajectoryParameters lp = TSoS.localParameters();
0047   Effect effect;
0048   compute(TSoS, propDir, effect);
0049   if (!lp.updateP(effect.deltaP))
0050     return false;
0051   //
0052   // Update covariance matrix?
0053   //
0054   SurfaceSide side = propDir == alongMomentum ? afterSurface : beforeSurface;
0055   if (TSoS.hasError()) {
0056     AlgebraicSymMatrix55 eloc = TSoS.localError().matrix();
0057     effect.deltaCov.add(eloc);
0058     //TSoS = TrajectoryStateOnSurface(lp,LocalTrajectoryError(eloc),surface, &(TSoS.globalParameters().magneticField()),side);
0059     //TSoS.update(lp,LocalTrajectoryError(eloc),side);
0060     TSoS.update(lp, eloc, side);
0061   } else {
0062     TSoS.update(lp, side);
0063     //TSoS = TrajectoryStateOnSurface(lp,surface,&(TSoS.globalParameters().magneticField()),side);
0064   }
0065   return true;
0066 }