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
00028 n_iter++;
00029 Line T(T0,T1);
00030 GlobalPoint B = T.closerPointToLine(L);
00031 old_distance = distance;
00032
00033
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
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
00061
00062
00063
00064
00065 Line T(T0,T1);
00066 GlobalPoint origin(L.closerPointToLine(T));
00067
00068
00069
00070
00071
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 }