Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #include "TrackingTools/GsfTracking/interface/GsfMaterialEffectsUpdator.h"
0002 
0003 #include "TrackingTools/GsfTools/interface/MultiTrajectoryStateAssembler.h"
0004 #include "TrackingTools/TrajectoryState/interface/SurfaceSideDefinition.h"
0005 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0006 #include "FWCore/Utilities/interface/Exception.h"
0007 //
0008 // Update of the trajectory state (implemented in base class since general for
0009 //   all classes returning deltaPs and deltaCovs.
0010 //
0011 
0012 using namespace SurfaceSideDefinition;
0013 
0014 TrajectoryStateOnSurface GsfMaterialEffectsUpdator::updateState(const TrajectoryStateOnSurface& TSoS,
0015                                                                 const PropagationDirection propDir) const {
0016   //
0017   // get components of input state and check if material is associated to surface
0018   //
0019   const Surface& surface = TSoS.surface();
0020   if (!surface.mediumProperties().isValid())
0021     return TSoS;
0022   SurfaceSide side = propDir == alongMomentum ? afterSurface : beforeSurface;
0023   // single input state?
0024   if (!TSoS.singleState())
0025     throw cms::Exception("LogicError") << "GsfMaterialEffectsUpdator::updateState used with MultiTSOS";
0026   auto weight = TSoS.weight();
0027 //
0028 // Get components (will force recalculation, if necessary)
0029 //
0030 #if __clang__
0031   std::vector<Effect> effects(size());
0032   compute(TSoS, propDir, effects.data());
0033 #else
0034   Effect effects[size()];
0035   compute(TSoS, propDir, effects);
0036 #endif
0037 
0038   //
0039   // prepare output vector
0040   //
0041   MultiTrajectoryStateAssembler result;
0042   //
0043   // loop over components
0044   //
0045   LogDebug("GsfMaterialEffectsUpdator") << "found " << size() << " components "
0046                                         << "  input state has weight " << TSoS.weight();
0047   for (auto const& effect : effects) {
0048     LogDebug("GsfMaterialEffectsUpdatorDETAIL") << "w, dp, sigp = " << effect.weight << ", " << effect.deltaP << ", "
0049                                                 << std::sqrt(effect.deltaCov[materialEffect::elos]);
0050     //
0051     // Update momentum. In case of failure: return invalid state.
0052     // Use deltaP method to ensure update of cache, if necessary!
0053     //
0054     LocalTrajectoryParameters lp = TSoS.localParameters();
0055     if (!lp.updateP(effect.deltaP))
0056       return TrajectoryStateOnSurface();
0057     //
0058     // Update covariance matrix?
0059     //
0060     if (TSoS.hasError()) {
0061       AlgebraicSymMatrix55 eloc = TSoS.localError().matrix();
0062       effect.deltaCov.add(eloc);
0063       result.addState(TrajectoryStateOnSurface(weight * effect.weight,
0064                                                lp,
0065                                                LocalTrajectoryError(eloc),
0066                                                surface,
0067                                                &(TSoS.globalParameters().magneticField()),
0068                                                side));
0069       LogDebug("GsfMaterialEffectsUpdatorDETAIL") << "adding state with weight " << weight * effect.weight;
0070     } else {
0071       result.addState(TrajectoryStateOnSurface(lp, surface, &(TSoS.globalParameters().magneticField()), side));
0072     }
0073   }
0074   LogDebug("GsfMaterialEffectsUpdator") << "  output state has weight " << result.combinedState().weight();
0075   return result.combinedState();
0076 }