CMS 3D CMS Logo

CMSSW_4_4_3_patch1/src/TrackPropagation/RungeKutta/src/RKPropagatorInZ.cc

Go to the documentation of this file.
00001 #include "TrackPropagation/RungeKutta/interface/RKPropagatorInZ.h"
00002 #include "TrackingTools/TrajectoryState/interface/TrajectoryStateOnSurface.h"
00003 // #include "CommonReco/RKPropagators/interface/RK4PreciseSolver.h"
00004 #include "RKCurvilinearDistance.h"
00005 #include "CurvilinearLorentzForce.h"
00006 #include "RKLocalFieldProvider.h"
00007 #include "DataFormats/GeometrySurface/interface/Plane.h"
00008 #include "RKAdaptiveSolver.h"
00009 #include "RKOne4OrderStep.h"
00010 #include "RKOneCashKarpStep.h"
00011 
00012 TrajectoryStateOnSurface 
00013 RKPropagatorInZ::propagate (const FreeTrajectoryState& ts, const Plane& plane) const
00014 {
00015   //typedef RK4PreciseSolver<double,5>           Solver;
00016   //typedef RKAdaptiveSolver<double,RKOne4OrderStep, 5>   Solver;
00017     typedef RKAdaptiveSolver<double,RKOneCashKarpStep, 5>   Solver;
00018     typedef Solver::Vector                       RKVector;
00019 
00020     GlobalPoint pos( ts.position());
00021     GlobalVector mom( ts.momentum());
00022 
00023     // cout << "RKPropagatorInZ: starting from FTS " << ts << endl;
00024 
00025     LocalPoint startpos = plane.toLocal(pos);
00026     LocalVector startmom = plane.toLocal(mom);
00027     double pzSign = startmom.z() > 0 ? 1.0 : -1.0;
00028 
00029     // cout << "In local plane coordinates: " << startpos << ", momentum " << startmom << endl;
00030 
00031     RKVector start;
00032     start(0) = startpos.x();
00033     start(1) = startpos.y();
00034     start(2) = startmom.x()/startmom.z();
00035     start(3) = startmom.y()/startmom.z();
00036     start(4) = pzSign * ts.charge() / startmom.mag();
00037 
00038     // cout << "RKPropagatorInZ: Solving with par " <<  startpos.z() << " and state " << start << endl;
00039 
00040     RKLocalFieldProvider localField( *theVolume, plane);
00041 
00042     CurvilinearLorentzForce<double,5> deriv(localField);
00043     RKCurvilinearDistance<double,5> dist;
00044     double eps = 1.e-5;
00045     Solver solver;
00046     try {
00047         RKVector rkresult = solver( startpos.z(), start, -startpos.z(), deriv, dist, eps);
00048 
00049         return TrajectoryStateOnSurface( LocalTrajectoryParameters( rkresult(4), rkresult(2), rkresult(3),
00050                                                                     rkresult(0), rkresult(1), pzSign),
00051                                          plane, theVolume);
00052     }
00053     catch (CurvilinearLorentzForceException& e) {
00054         // the propagation failed due to momentum almost parallel to the plane.
00055         // This does not mean the propagation is impossible, but it should be done
00056         // in a different parametrization (e.g. s)  
00057         return TrajectoryStateOnSurface();
00058     }
00059 }
00060 
00061 TrajectoryStateOnSurface 
00062 RKPropagatorInZ::propagate (const FreeTrajectoryState&, const Cylinder&) const
00063 {
00064     return TrajectoryStateOnSurface();
00065 }
00066 
00067 std::pair< TrajectoryStateOnSurface, double> 
00068 RKPropagatorInZ::propagateWithPath (const FreeTrajectoryState&, const Plane&) const
00069 {
00070     return std::pair< TrajectoryStateOnSurface, double>();
00071 }
00072 
00073 std::pair< TrajectoryStateOnSurface, double> 
00074 RKPropagatorInZ::propagateWithPath (const FreeTrajectoryState&, const Cylinder&) const
00075 {
00076     return std::pair< TrajectoryStateOnSurface, double>();
00077 }
00078 
00079 Propagator * RKPropagatorInZ::clone() const
00080 {
00081     return new RKPropagatorInZ(*this);
00082 }