CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_3/src/TrackingTools/GeomPropagators/src/HelixBarrelPlaneCrossing2OrderLocal.cc

Go to the documentation of this file.
00001 #include "TrackingTools/GeomPropagators/interface/HelixBarrelPlaneCrossing2OrderLocal.h"
00002 #include <algorithm>
00003 #include <cmath>
00004 
00005 HelixBarrelPlaneCrossing2OrderLocal::
00006 HelixBarrelPlaneCrossing2OrderLocal( const GlobalPoint& startingPos,
00007                                      const GlobalVector& startingDir,
00008                                      double rho, const Plane& plane)
00009 {
00010   // translate problem to local frame of the plane
00011   LocalPoint lPos = plane.toLocal(startingPos);
00012   LocalVector lDir = plane.toLocal(startingDir);
00013 
00014   // check if local frame is already special (local Y axis == global Z axis)
00015   LocalVector yPrime = plane.toLocal( GlobalVector(0,0,1.f));
00016   LocalVector diff = yPrime - LocalVector(0,-1.f,0);
00017   float sinPhi=0, cosPhi=0;
00018   bool rotated;
00019   Vector2D pos;
00020   Vector2D dir;
00021 
00022   if (diff.mag2() < 1.e-10) {
00023 
00024     // cout << "Plane already oriented, yPrime = " << yPrime << endl;
00025 
00026     // we are already in the special orientation
00027     pos = Vector2D( lPos.x(), lPos.y());
00028     dir = Vector2D( lDir.x(), lDir.y());;
00029     rotated = false;
00030   }
00031   else {
00032 
00033     // cout << "Plane needs rotation, yPrime = " << yPrime << endl;
00034 
00035     // we need to rotate the problem 
00036     sinPhi = yPrime.y();
00037     cosPhi = yPrime.x();
00038     pos = Vector2D( lPos.x()*cosPhi + lPos.y()*sinPhi,
00039                     -lPos.x()*sinPhi + lPos.y()*cosPhi);
00040     dir = Vector2D( lDir.x()*cosPhi + lDir.y()*sinPhi,
00041                     -lDir.x()*sinPhi + lDir.y()*cosPhi);
00042     rotated = true;
00043   }
00044 
00045   double d = -lPos.z();
00046   double x = pos.x() + dir.x()/lDir.z()*d - 0.5*rho*d*d;
00047   double y = pos.y() + dir.y()/lDir.z()*d;
00048 
00049 //    cout << "d= " << d << ", pos.x()= " << pos.x() 
00050 //         << ", dir.x()/lDir.z()= " << dir.x()/lDir.z() 
00051 //         << ", 0.5*rho*d*d= " << 0.5*rho*d*d << endl;
00052 
00053   if (!rotated) {
00054     thePos = LocalPoint( x, y, 0);
00055     theDir = LocalVector( dir.x()+rho*d, dir.y(), lDir.z());
00056   }
00057   else {
00058     thePos = LocalPoint( x*cosPhi - y*sinPhi,
00059                          x*sinPhi + y*cosPhi, 0);
00060     float px = dir.x()+rho*d;
00061     theDir = LocalVector( px*cosPhi - dir.y()*sinPhi,
00062                           px*sinPhi + dir.y()*cosPhi, lDir.z());
00063   }
00064 }
00065