CMS 3D CMS Logo

CMSSW_4_4_3_patch1/src/RecoTracker/TkMSParametrization/interface/PixelRecoLineRZ.h

Go to the documentation of this file.
00001 #ifndef PixelRecoLineRZ_H
00002 #define PixelRecoLineRZ_H
00003 
00007 #include <cmath>
00008 
00009 #include "RecoTracker/TkMSParametrization/interface/PixelRecoPointRZ.h"
00010 #include "DataFormats/GeometryVector/interface/GlobalPoint.h"
00011 
00012 class PixelRecoLineRZ {
00013 public:
00014 
00015   typedef PixelRecoPointRZ LineOrigin;
00016 
00017   PixelRecoLineRZ() { }
00018 
00019   PixelRecoLineRZ(const GlobalPoint & p1, const GlobalPoint & p2) 
00020     : theTIP2 ( initTIP2( p1.x(), p1.y(), p2.x(), p2.y() ) ),
00021       theOrigin ( LineOrigin( subTIP(p1.perp()), p1.z() ) ),
00022       theCotLine ( initCot( p2.z()-theOrigin.z(), subTIP(p2.perp())-theOrigin.r() ) )
00023     { }
00024 
00025   PixelRecoLineRZ(const LineOrigin & aOrigin, float aCotLine, float transverseIP = 0.f)
00026     : theTIP2( transverseIP*transverseIP ),
00027       theOrigin( subTIP(aOrigin.r()), aOrigin.z() ),
00028       theCotLine(aCotLine) { }
00029 
00030   PixelRecoLineRZ(const LineOrigin & aOrigin, const PixelRecoPointRZ & aPoint, float transverseIP = 0.f)
00031     : theTIP2( transverseIP*transverseIP ),
00032       theOrigin( subTIP(aOrigin.r()), aOrigin.z() ),
00033       theCotLine( initCot( aPoint.z()-theOrigin.z(), subTIP(aPoint.r())-theOrigin.r() ) )
00034     { } 
00035 
00036   float cotLine() const { return theCotLine; }
00037   float transverseIP() const { return std::sqrt(theTIP2); }
00038   float transverseIP2() const { return theTIP2; }
00039   LineOrigin origin() const { return LineOrigin( addTIP(theOrigin.r()), theOrigin.z() ); }
00040 
00041   float zAtR (float r) const 
00042     { return theOrigin.z()+(subTIP(r)-theOrigin.r())*theCotLine; }
00043   float rAtZ (float z) const 
00044     { return (std::abs(theCotLine) > 1.e-4f) ? addTIP(theOrigin.r()+(z-theOrigin.z())/theCotLine) : 99999.f; }
00045 
00046 private:
00047   static float initCot (float dz, float dr)
00048     { return (std::abs(dr) > 1.e-4f)  ? dz/dr : 99999.f; }
00049   static float initTIP2 (float x1, float y1, float x2, float y2)
00050     {
00051       double l = y1 * (x2 - x1) - x1 * (y2 - y1);
00052       return l * l / ( (x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1) );
00053     }
00054 
00055   inline float addTIP (float val) const
00056     { return theTIP2 ? std::sqrt(val * val + theTIP2) : val; }
00057   inline float subTIP (float val) const
00058     {
00059       if (!theTIP2) return val;
00060       double val2 = val * val;
00061       return val2 > theTIP2 ? std::sqrt(val2 - theTIP2) : 0.;
00062     }
00063 
00064 private:
00065   float theTIP2;
00066   LineOrigin theOrigin;
00067   float theCotLine;
00068 };
00069 #endif