Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 //  #include "TrackerReco/GsfPattern/src/MultiStatePropagation.h"
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   // weighted path length
0010   double sWeight(0.);
0011   double sWeightPath(0.);
0012 
0013   // decomposition of input state
0014   GetComponents comps(tsos);
0015   auto const& input = comps();
0016 
0017   // vector of result states
0018   MultiTrajectoryStateAssembler result;
0019   //
0020   // now propagate each input state individually
0021   //
0022   bool firstPropagation(true);
0023   SurfaceSideDefinition::SurfaceSide firstSide(SurfaceSideDefinition::atCenterOfSurface);
0024   for (auto const& iTsos : input) {
0025     //
0026     // weight of component
0027     //
0028     double weight(iTsos.weight());
0029     //
0030     // geometrical propagation (assumption: only one output state!)
0031     //
0032     TsosWP newTsosWP = thePropagator.propagateWithPath(iTsos, surface);
0033     // check validity
0034     if (!(newTsosWP.first).isValid()) {
0035       LogDebug("GsfTrackFitters") << "adding invalid state";
0036       result.addInvalidState(weight);
0037       continue;
0038     }
0039     // set weight
0040     TrajectoryStateOnSurface weightedTsos(setWeight(newTsosWP.first, weight));
0041     // trap mix of forward / backward propagations
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     // add state(s) to result vector
0054     //
0055     result.addState(weightedTsos);
0056     //
0057     // calculation of weighted path length
0058     //
0059     sWeight += weight;
0060     sWeightPath += weight * newTsosWP.second;
0061   }
0062   //
0063   // check validity
0064   //
0065   TrajectoryStateOnSurface propagatedState(result.combinedState());
0066   if (!propagatedState.isValid())
0067     return TsosWP(propagatedState, 0.);
0068   //
0069   // return with weighted path length
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 }