CMS 3D CMS Logo

CartesianError3D.h

Go to the documentation of this file.
00001 #ifndef _TRACKER_CARTESIAN_ERROR_3D_H_
00002 #define _TRACKER_CARTESIAN_ERROR_3D_H_
00003 
00004 #include "DataFormats/GeometryCommonDetAlgo/interface/DeepCopyPointer.h"
00005 #include "DataFormats/CLHEP/interface/AlgebraicObjects.h"
00006 #include "DataFormats/GeometryVector/interface/GlobalPoint.h"
00007 
00008 //
00009 // Exceptions
00010 //
00011 #include "FWCore/Utilities/interface/Exception.h"
00012 
00016 template <class T> class CartesianError3D {
00017 
00018 public:
00019 
00020   CartesianError3D(): theCartesianError(new AlgebraicSymMatrix(3,0)) {}
00021 
00022   // CartesianError3D is stored as a lower triangular matrix
00023   CartesianError3D(T c11, T c21, T c22, T c31, T c32, T c33):
00024                    theCartesianError(new AlgebraicSymMatrix(3,0)) {
00025     (*theCartesianError)(1,1)=c11;
00026     (*theCartesianError)(2,1)=c21;
00027     (*theCartesianError)(2,2)=c22;
00028     (*theCartesianError)(3,1)=c31;
00029     (*theCartesianError)(3,2)=c32;
00030     (*theCartesianError)(3,3)=c33;
00031   }
00032   
00033   CartesianError3D(const AlgebraicSymMatrix & err) {
00034     if (err.num_row() == 3)
00035       theCartesianError = new AlgebraicSymMatrix(err);
00036     else {
00037       theCartesianError = 0;
00038       //throw DetLogicError("Not 3x3 Error Matrix: set pointer to 0");
00039       throw cms::Exception("DetLogicError")<<"Not 3x3 Error Matrix: set pointer to 0\n";
00040     }
00041   }
00042 
00043   CartesianError3D(const AlgebraicSymMatrix33 & err) :
00044     theCartesianError(new AlgebraicSymMatrix(asHepMatrix(err))) { }
00045  
00046   ~CartesianError3D() {}
00047 
00048   T cxx() const {
00049     return (*theCartesianError)(1,1);
00050   }
00051   
00052   T cyx() const {
00053     return (*theCartesianError)(2,1);
00054   }
00055   
00056   T cyy() const {
00057     return (*theCartesianError)(2,2);
00058   }
00059   
00060   T czx() const {
00061     return (*theCartesianError)(3,1);
00062   }
00063   
00064   T czy() const {
00065     return (*theCartesianError)(3,2);
00066   }
00067   
00068   T czz() const {
00069     return (*theCartesianError)(3,3);
00070   }
00071   
00072   AlgebraicSymMatrix matrix() const {
00073     return *theCartesianError;
00074   }
00075 
00076   AlgebraicSymMatrix33 matrix_new() const {
00077     return asSMatrix<3>(*theCartesianError);
00078   }
00079 
00080 
00081   T rerr(const GlobalPoint& aPoint) const {
00082     T r2 = T(0.);
00083     if(aPoint.x() > T(0.) || aPoint.y() > T(0.))
00084       r2 = aPoint.perp2();
00085     T x2 = aPoint.x()*aPoint.x();
00086     T y2 = aPoint.y()*aPoint.y();
00087     T xy = aPoint.x()*aPoint.y();
00088     if(r2 > T(0.)) 
00089       return (1./r2)*(x2*cxx() + 2.*xy*cyx() + y2*cyy());
00090     else 
00091       return 0.5*(cxx() + cyy());  
00092   }
00093 
00094   T phierr(const GlobalPoint& aPoint) const {
00095     T r2 = T(0.);
00096     if(aPoint.x() > T(0.) || aPoint.y() > T(0.))
00097       r2 = aPoint.perp2();
00098     T x2 = aPoint.x()*aPoint.x();
00099     T y2 = aPoint.y()*aPoint.y();
00100     T xy = aPoint.x()*aPoint.y();
00101     if(r2 > T(0.)) 
00102       return (1./(r2*r2))*(y2*cxx() - 2.*xy*cyx() + x2*cyy());
00103     else
00104       return T(0.);
00105   }
00106 
00107   CartesianError3D operator+ (const CartesianError3D& err) const {
00108     return CartesianError3D( this->cxx()+err.cxx(), 
00109                            this->cyx()+err.cyx(),
00110                            this->cyy()+err.cyy(),
00111                            this->czx()+err.czx(),
00112                            this->czy()+err.czy(),
00113                            this->czz()+err.czz());
00114   }
00115   CartesianError3D operator- (const CartesianError3D& err) const {
00116     return CartesianError3D( this->cxx()-err.cxx(), 
00117                            this->cyx()-err.cyx(),
00118                            this->cyy()-err.cyy(),
00119                            this->czx()-err.czx(),
00120                            this->czy()-err.czy(),
00121                            this->czz()-err.czz());
00122   }
00123  
00124 private:
00125 
00126   DeepCopyPointer<AlgebraicSymMatrix> theCartesianError;
00127 
00128 };
00129 
00130 #endif
00131 
00132 

Generated on Tue Jun 9 17:30:49 2009 for CMSSW by  doxygen 1.5.4