Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:31:42

0001 
0002 #include "TrackingTools/PatternTools/interface/TrajectoryExtrapolatorToLine.h"
0003 #include "TrackingTools/GeomPropagators/interface/AnalyticalPropagator.h"
0004 #include "DataFormats/GeometryCommonDetAlgo/interface/DeepCopyPointerByClone.h"
0005 #include "DataFormats/GeometrySurface/interface/BoundPlane.h"
0006 #include "DataFormats/GeometrySurface/interface/OpenBounds.h"
0007 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0008 
0009 TrajectoryStateOnSurface TrajectoryExtrapolatorToLine::extrapolate(const FreeTrajectoryState& fts,
0010                                                                    const Line& L,
0011                                                                    const Propagator& aPropagator) const {
0012   DeepCopyPointerByClone<Propagator> p(aPropagator.clone());
0013   p->setPropagationDirection(anyDirection);
0014 
0015   FreeTrajectoryState fastFts(fts.parameters(), fts.curvilinearError());
0016   GlobalVector T1 = fastFts.momentum().unit();
0017   GlobalPoint T0 = fastFts.position();
0018   double distance = 9999999.9;
0019   double old_distance;
0020   int n_iter = 0;
0021   bool refining = true;
0022 
0023   LogDebug("TrajectoryExtrapolatorToLine") << "START REFINING";
0024   while (refining) {
0025     LogDebug("TrajectoryExtrapolatorToLine") << "Refining cycle...";
0026     // describe orientation of target surface on basis of track parameters
0027     n_iter++;
0028     Line T(T0, T1);
0029     GlobalPoint B = T.closerPointToLine(L);
0030     old_distance = distance;
0031 
0032     //create surface
0033     GlobalPoint BB = B + 0.3 * (T0 - B);
0034     Surface::PositionType pos(BB);
0035     GlobalVector XX(T1.y(), -T1.x(), 0.);
0036     GlobalVector YY(T1.cross(XX));
0037     Surface::RotationType rot(XX, YY);
0038     ReferenceCountingPointer<Plane> surface = Plane::build(pos, rot);
0039     LogDebug("TrajectoryExtrapolatorToLine") << "Current plane position: " << surface->toGlobal(LocalPoint(0., 0., 0.));
0040     LogDebug("TrajectoryExtrapolatorToLine") << "Current plane normal: " << surface->toGlobal(LocalVector(0, 0, 1));
0041     LogDebug("TrajectoryExtrapolatorToLine") << "Current momentum:     " << T1;
0042 
0043     // extrapolate fastFts to target surface
0044     TrajectoryStateOnSurface tsos = p->propagate(fastFts, *surface);
0045 
0046     if (!tsos.isValid()) {
0047       LogDebug("TrajectoryExtrapolatorToLine") << "TETL - extrapolation failed";
0048       return tsos;
0049     } else {
0050       T0 = tsos.globalPosition();
0051       T1 = tsos.globalMomentum().unit();
0052       GlobalVector D = L.distance(T0);
0053       distance = D.mag();
0054       if (fabs(old_distance - distance) < 0.000001) {
0055         refining = false;
0056       }
0057       if (old_distance - distance < 0.) {
0058         refining = false;
0059         LogDebug("TrajectoryExtrapolatorToLine") << "TETL- stop to skip loops";
0060       }
0061     }
0062   }
0063   //
0064   // Now propagate with errors and (not for the moment) perform rotation
0065   //
0066   // Origin of local system: point of closest approach on the line
0067   // (w.r.t. to tangent to helix at last iteration)
0068   //
0069   Line T(T0, T1);
0070   GlobalPoint origin(L.closerPointToLine(T));
0071   //
0072   // Axes of local system:
0073   //   x from line to helix at closest approach
0074   //   z along the helix
0075   //   y to complete right-handed system
0076   //
0077   GlobalVector ZZ(T1.unit());
0078   GlobalVector YY(ZZ.cross(T0 - origin).unit());
0079   GlobalVector XX(YY.cross(ZZ));
0080   Surface::RotationType rot(XX, YY, ZZ);
0081   ReferenceCountingPointer<Plane> surface = Plane::build(origin, rot);
0082   TrajectoryStateOnSurface tsos = p->propagate(fts, *surface);
0083 
0084   return tsos;
0085 }