File indexing completed on 2024-04-06 12:31:30
0001
0002 #include "TrackingTools/GsfTools/interface/MultiTrajectoryStateAssembler.h"
0003 #include "TrackingTools/GsfTools/interface/GetComponents.h"
0004 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0005
0006 template <class T>
0007 std::pair<TrajectoryStateOnSurface, double> MultiStatePropagation<T>::propagateWithPath(
0008 const TrajectoryStateOnSurface& tsos, const T& surface) const {
0009
0010 double sWeight(0.);
0011 double sWeightPath(0.);
0012
0013
0014 GetComponents comps(tsos);
0015 auto const& input = comps();
0016
0017
0018 MultiTrajectoryStateAssembler result;
0019
0020
0021
0022 bool firstPropagation(true);
0023 SurfaceSideDefinition::SurfaceSide firstSide(SurfaceSideDefinition::atCenterOfSurface);
0024 for (auto const& iTsos : input) {
0025
0026
0027
0028 double weight(iTsos.weight());
0029
0030
0031
0032 TsosWP newTsosWP = thePropagator.propagateWithPath(iTsos, surface);
0033
0034 if (!(newTsosWP.first).isValid()) {
0035 LogDebug("GsfTrackFitters") << "adding invalid state";
0036 result.addInvalidState(weight);
0037 continue;
0038 }
0039
0040 TrajectoryStateOnSurface weightedTsos(setWeight(newTsosWP.first, weight));
0041
0042 if (firstPropagation) {
0043 firstSide = weightedTsos.surfaceSide();
0044 firstPropagation = false;
0045 } else {
0046 if (weightedTsos.surfaceSide() != firstSide) {
0047 edm::LogInfo("GsfTrackFitters") << "MultiStatePropagation resulted in states "
0048 << "on different sides of the target surface";
0049 return TsosWP(TrajectoryStateOnSurface(), 0.);
0050 }
0051 }
0052
0053
0054
0055 result.addState(weightedTsos);
0056
0057
0058
0059 sWeight += weight;
0060 sWeightPath += weight * newTsosWP.second;
0061 }
0062
0063
0064
0065 TrajectoryStateOnSurface propagatedState(result.combinedState());
0066 if (!propagatedState.isValid())
0067 return TsosWP(propagatedState, 0.);
0068
0069
0070
0071 if (sWeight != 0.)
0072 sWeightPath /= sWeight;
0073 return TsosWP(propagatedState, sWeightPath);
0074 }
0075
0076 template <class T>
0077 TrajectoryStateOnSurface MultiStatePropagation<T>::setWeight(const TrajectoryStateOnSurface state,
0078 const double weight) const {
0079 return TrajectoryStateOnSurface(weight,
0080 state.localParameters(),
0081 state.localError(),
0082 state.surface(),
0083 &(state.globalParameters().magneticField()),
0084 state.surfaceSide());
0085 }