| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

AlignTraj.cpp

Go to the documentation of this file.
00001 // $Id: AlignTraj.cpp,v 1.6 2008/12/09 16:54:07 lnicolas Exp $
00002 
00003 #include "Kernel/AlignTraj.h"
00004 #include "GaudiKernel/GenericMatrixTypes.h"
00005 
00006 #include "Math/Rotation3D.h"
00007 
00008 #include <math.h>
00009 
00010 using LHCb::AlignTraj;
00011 
00012 // tiny helpers to make assignements from Vectors to SMatrix rows less painfull...
00013 namespace {
00014     template <typename T>
00015     class Column {
00016     public:
00017        Column(T& t, unsigned c) : m_t(t),m_c(c) {}
00018        template <typename V> Column<T>& operator=(const V& v) { m_t(0,m_c)=v.X();m_t(1,m_c)=v.Y(),m_t(2,m_c)=v.Z(); return *this;}
00019     private:
00020        T&  m_t;
00021        unsigned m_c;
00022     };
00023 
00024     template <typename T>
00025     class Diag {
00026     public:
00027        Diag(T& t,unsigned begin=0,unsigned end=T::kRows) : m_t(t), m_b(begin), m_e(end) {}
00028        Diag<T>& operator=(double x) { for (unsigned i=m_b;i<m_e;++i) m_t(i,i) = x ; return *this; }
00029     private:
00030        T& m_t;
00031        unsigned m_b,m_e;
00032     };
00033 
00034     // some helper functions for the helper classes to avoid having to explicitly specify types...
00035     template <typename T> Column<T> column(T& t,unsigned c) 
00036     { return Column<T>(t,c); }
00037 
00038     template <typename T> Diag<T>   diag(T& t,unsigned begin=0, unsigned end=T::kRows) 
00039     { return Diag<T>(t,begin,end);}
00040 }
00041 
00042 std::auto_ptr<LHCb::Trajectory> AlignTraj::clone() const
00043 {
00044   return std::auto_ptr<LHCb::Trajectory>(new AlignTraj(*this));
00045 }
00046 
00047 
00048 AlignTraj::Parameters 
00049 AlignTraj::parameters() const
00050 {
00051     return Parameters(m_trans.X(), m_trans.Y(), m_trans.Z(),
00052                       m_rx.Angle(),m_ry.Angle(),m_rz.Angle());
00053 }
00054 
00055 AlignTraj&
00056 AlignTraj::operator+=(const Parameters& delta)
00057 {
00058     m_trans += Vector(delta(0),delta(1),delta(2));
00059     m_rx *= ROOT::Math::RotationX(delta(3));
00060     m_ry *= ROOT::Math::RotationY(delta(4));
00061     m_rz *= ROOT::Math::RotationZ(delta(5));
00062     return *this;
00063 }
00064 
00065 AlignTraj::Derivative 
00066 AlignTraj::derivative( double arclength ) const 
00067 {
00068 
00069     Derivative d;
00070     // first, the derivatives wrt m_trans:
00071     diag(d,0,3) = 1;
00072     // next, the derivatives wrt. rx, ry, and rz:
00073     Vector v = position(arclength)-m_pivot;
00074     //FIXME: Set{X,Y,Z} return void instead of reference to *this.
00075     //       so we are forced to introduce an explicit temporary
00076     //       and uglify the code...
00077     //       Lorenzo promised to fix this in the next ROOT release (i.e.
00078     //          once we use post 5.18 releases this can be simplified)
00079     Vector temp = m_ry(m_rz(v)); temp.SetX(0);
00080     column(d,3)=(m_rx*ROOT::Math::RotationX(M_PI_2))(temp); 
00081     temp = m_rz(v); temp.SetY(0);
00082     column(d,4)=m_rx((m_ry*ROOT::Math::RotationY(M_PI_2))(temp));
00083     temp = v; temp.SetZ(0);
00084     column(d,5)=m_rx(m_ry((m_rz*ROOT::Math::RotationZ(M_PI_2))(temp)));
00085     return d;
00086 }
00087 
00088 AlignTraj::Point 
00089 AlignTraj::position( double s ) const 
00090 {
00091     // rotate around pivot, then translate
00092     return m_pivot + rotate(m_traj->position(s)-m_pivot) + m_trans ;
00093 }
00094 
00095 AlignTraj::Vector 
00096 AlignTraj::direction( double s ) const 
00097 {
00098     return rotate(m_traj->direction(s));
00099 }
00100 
00101 AlignTraj::Vector 
00102 AlignTraj::curvature( double s ) const 
00103 {
00104     return rotate(m_traj->curvature(s));
00105 }
00106 
00107 void 
00108 AlignTraj::expansion( double s,
00109                       Point &p,
00110                       Vector &dp,
00111                       Vector &ddp) const 
00112 {
00113     m_traj->expansion(s,p,dp,ddp);
00114     p   = m_pivot + m_trans + rotate(p-m_pivot);
00115     dp  = rotate(dp);
00116     ddp = rotate(ddp);
00117 }
00118 
00119 double 
00120 AlignTraj::muEstimate( const Point& p) const 
00121 {
00122     // apply inverse transformation to Point, and forward...
00123     return m_traj->arclength( m_pivot + invRotate(p - m_pivot - m_trans) );
00124 }
00125 
00126 double 
00127 AlignTraj::distTo1stError( double arclength,
00128                            double tolerance, 
00129                            int pathDirection ) const 
00130 {
00131     return m_traj->distTo1stError(arclength,tolerance,pathDirection);    
00132 }
00133 
00134 double 
00135 AlignTraj::distTo2ndError( double arclength,
00136                            double tolerance, 
00137                            int pathDirection ) const 
00138 {
00139     return m_traj->distTo2ndError(arclength,tolerance,pathDirection);    
00140 }
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Mon Apr 11 20:03:13 2011 for LHCbKernel by doxygen 1.4.7