CMS 3D CMS Logo

PropagationDirectionChooser Class Reference

Determination of propagation direction towards a surface. More...

#include <TrackingTools/GeomPropagators/interface/PropagationDirectionChooser.h>

List of all members.

Public Member Functions

PropagationDirection operator() (const FreeTrajectoryState &, const Cylinder &) const
PropagationDirection operator() (const FreeTrajectoryState &, const Plane &) const
PropagationDirection operator() (const FreeTrajectoryState &, const Surface &) const
 PropagationDirectionChooser ()
 ~PropagationDirectionChooser ()


Detailed Description

Determination of propagation direction towards a surface.

Uses code from the old BidirectionalPropagator.

Definition at line 15 of file PropagationDirectionChooser.h.


Constructor & Destructor Documentation

PropagationDirectionChooser::PropagationDirectionChooser (  )  [inline]

Definition at line 18 of file PropagationDirectionChooser.h.

00018 {}

PropagationDirectionChooser::~PropagationDirectionChooser (  )  [inline]

Definition at line 20 of file PropagationDirectionChooser.h.

00020 {}


Member Function Documentation

PropagationDirection PropagationDirectionChooser::operator() ( const FreeTrajectoryState fts,
const Cylinder cylinder 
) const

Definition at line 87 of file PropagationDirectionChooser.cc.

References alongMomentum, anyDirection, dir, FreeTrajectoryState::momentum(), oppositeToMomentum, p, PV3DBase< T, PVType, FrameType >::perp(), FreeTrajectoryState::position(), Cylinder::radius(), Surface::toGlobal(), PV3DBase< T, PVType, FrameType >::x(), x, and PV3DBase< T, PVType, FrameType >::y().

00089 {
00090   // propagation to cylinder with axis along z
00091   // Copied from BidirectionalPropagator.
00092   PropagationDirection dir = anyDirection;
00093 
00094   GlobalPoint sp = cylinder.toGlobal(LocalPoint(0.,0.));
00095   if (sp.x() != 0. || sp.y() != 0.) {
00096     throw PropagationException("Cannot propagate to an arbitrary cylinder");
00097   }
00098 
00099   GlobalPoint x = fts.position();
00100   GlobalVector p = fts.momentum();
00101 
00102   const double small = 1.e-4; // 1 micron distance
00103   double rdiff = x.perp() - cylinder.radius();
00104   
00105   if ( fabs(rdiff) < small ) { 
00106     // already on cylinder, choose forward as default
00107     dir = alongMomentum;
00108   } 
00109   else {
00110     int rSign = ( rdiff >= 0. ) ? 1 : -1 ;
00111     if ( rSign == -1 ) {
00112       // starting point inside cylinder 
00113       // propagate always in direction of momentum
00114       dir = alongMomentum;
00115     }
00116     else {
00117       // starting point outside cylinder
00118       // choose direction so as to approach cylinder surface
00119       double proj = (x.x()*p.x() + x.y()*p.y()) * rSign;
00120       if (proj < 0.) {
00121         dir = alongMomentum;
00122       }
00123       else {
00124         dir = oppositeToMomentum;    
00125       }
00126     }
00127   }
00128   return dir;
00129 }

PropagationDirection PropagationDirectionChooser::operator() ( const FreeTrajectoryState fts,
const Plane plane 
) const

Definition at line 41 of file PropagationDirectionChooser.cc.

References a, alongMomentum, anyDirection, b, dir, FreeTrajectoryState::momentum(), oppositeToMomentum, p, FreeTrajectoryState::position(), Surface::toGlobal(), Vector3DBase< T, FrameTag >::unit(), v, w, PV3DBase< T, PVType, FrameType >::x(), x, PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

00043 {
00044   // propagation towards arbitrary plane
00045   // need computation of intersection point between plane 
00046   // and track (straight line approximation) to set direction
00047   // Copied from BidirectionalPropagator.
00048   PropagationDirection dir = anyDirection;
00049 
00050   GlobalPoint x = fts.position();
00051   GlobalVector p = fts.momentum().unit();
00052   GlobalPoint sp = plane.toGlobal(LocalPoint(0.,0.));
00053   GlobalVector v = plane.toGlobal(LocalVector(1.,0.,0.));
00054   GlobalVector w = plane.toGlobal(LocalVector(0.,1.,0.));
00055   AlgebraicMatrix33 a;
00056   a(0,0) = v.x(); a(0,1) = w.x(); a(0,2) = -p.x();
00057   a(1,0) = v.y(); a(1,1) = w.y(); a(1,2) = -p.y();
00058   a(2,0) = v.z(); a(2,1) = w.z(); a(2,2) = -p.z();
00059   AlgebraicVector3 b;
00060   b[0] = x.x() - sp.x();
00061   b[1] = x.y() - sp.y();
00062   b[2] = x.z() - sp.z();
00063 
00064   int ifail = !a.Invert();
00065   if (ifail == 0) {
00066     // plane and momentum are not parallel
00067     b = a*b;
00068     // b[2] nb of steps along unit vector parallel to momentum to reach plane
00069 
00070     const double small = 1.e-4; // 1 micron distance
00071     if (fabs(b[2]) < small) { 
00072       // already on plane, choose forward as default
00073       dir = alongMomentum;
00074     } 
00075     else if (b[2] < 0.) {
00076       dir = oppositeToMomentum;
00077     }
00078     else {
00079       dir = alongMomentum;    
00080     }
00081   } 
00082   return dir;
00083 }

PropagationDirection PropagationDirectionChooser::operator() ( const FreeTrajectoryState fts,
const Surface surface 
) const

Definition at line 14 of file PropagationDirectionChooser.cc.

00016 {
00017   // understand the surface type (expect cylinder/plane)
00018   // unfortunately dynamic_cast on Sun is broken -- cannot deal with const
00019   // so here we get rid of const
00020   Surface* sur = (Surface*)&surface;
00021   const Cylinder* bc = dynamic_cast<Cylinder*>(sur);
00022   const Plane* bp = dynamic_cast<Plane*>(sur);
00023   if (bc != 0) {
00024     //
00025     // cylinder
00026     //
00027     return (*this)(fts, *bc);
00028   }
00029   else if (bp != 0) {
00030     //
00031     // plane
00032     //
00033     return (*this)(fts, *bp);
00034   }
00035   else {
00036     throw PropagationException("The surface is neither Cylinder nor Plane");
00037   }
00038 }


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:30:19 2009 for CMSSW by  doxygen 1.5.4