CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/TrackingTools/PatternTools/src/TrajectoryExtrapolatorToLine.cc

Go to the documentation of this file.
00001 
00002 #include "TrackingTools/PatternTools/interface/TrajectoryExtrapolatorToLine.h"
00003 #include "TrackingTools/GeomPropagators/interface/AnalyticalPropagator.h"
00004 #include "DataFormats/GeometryCommonDetAlgo/interface/DeepCopyPointerByClone.h"
00005 #include "DataFormats/GeometrySurface/interface/BoundPlane.h"
00006 #include "DataFormats/GeometrySurface/interface/OpenBounds.h"
00007 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00008 
00009 TrajectoryStateOnSurface TrajectoryExtrapolatorToLine::extrapolate(const FreeTrajectoryState& fts,
00010                                                                    const Line & L, 
00011                                                                    const Propagator& aPropagator) const
00012 {
00013   DeepCopyPointerByClone<Propagator> p(aPropagator.clone());
00014   p->setPropagationDirection(anyDirection);
00015 
00016   FreeTrajectoryState fastFts(fts.parameters());
00017   GlobalVector T1 = fastFts.momentum().unit();
00018    GlobalPoint T0 = fastFts.position();
00019    double distance = 9999999.9;
00020    double old_distance;
00021    int n_iter = 0;
00022    bool refining = true;
00023 
00024  
00025    while (refining) {
00026  
00027      // describe orientation of target surface on basis of track parameters
00028      n_iter++;
00029      Line T(T0,T1);
00030      GlobalPoint B = T.closerPointToLine(L);
00031      old_distance = distance;
00032  
00033      //create surface
00034      GlobalPoint BB = B + 0.3 * (T0-B);
00035      Surface::PositionType pos(BB);
00036      GlobalVector XX(T1.y(),-T1.x(),0.);
00037      GlobalVector YY(T1.cross(XX));
00038      Surface::RotationType rot(XX,YY);
00039      ReferenceCountingPointer<BoundPlane> surface = BoundPlane::build(pos, rot,OpenBounds());
00040 
00041      // extrapolate fastFts to target surface
00042      TrajectoryStateOnSurface tsos = p->propagate(fastFts, *surface);
00043 
00044      if (!tsos.isValid()) {
00045        LogDebug("TrajectoryExtrapolatorToLine") << "TETL - extrapolation failed";
00046        return tsos;
00047      } else {
00048        T0 = tsos.globalPosition();
00049        T1 = tsos.globalMomentum().unit();
00050        GlobalVector D = L.distance(T0);
00051        distance = D.mag();
00052        if (fabs(old_distance - distance) < 0.000001) {refining = false;}
00053        if (old_distance-distance<0.){
00054          refining=false;
00055          LogDebug("TrajectoryExtrapolatorToLine")<< "TETL- stop to skip loops";
00056        }
00057      }
00058    }
00059    //
00060    // Now propagate with errors and (not for the moment) perform rotation
00061    //
00062    // Origin of local system: point of closest approach on the line
00063    // (w.r.t. to tangent to helix at last iteration)
00064    //
00065    Line T(T0,T1);
00066    GlobalPoint origin(L.closerPointToLine(T));
00067    //
00068    // Axes of local system: 
00069    //   x from line to helix at closest approach
00070    //   z along the helix
00071    //   y to complete right-handed system
00072    //
00073    GlobalVector ZZ(T1.unit());
00074    GlobalVector YY(ZZ.cross(T0-origin).unit());
00075    GlobalVector XX(YY.cross(ZZ));
00076    Surface::RotationType rot(XX,YY,ZZ);
00077    ReferenceCountingPointer<BoundPlane> surface = BoundPlane::build(origin, rot,OpenBounds());
00078    TrajectoryStateOnSurface tsos = p->propagate(fts, *surface);
00079  
00080    return tsos;
00081 
00082 }