00001 #ifndef _TRACKER_CYLINDRICAL_ERROR_3D_H_
00002 #define _TRACKER_CYLINDRICAL_ERROR_3D_H_
00003
00004 #include "DataFormats/GeometryVector/interface/GlobalPoint.h"
00005 #include "DataFormats/GeometryCommonDetAlgo/interface/CartesianError3D.h"
00006 #include "DataFormats/GeometryCommonDetAlgo/interface/DeepCopyPointer.h"
00007 #include "DataFormats/CLHEP/interface/AlgebraicObjects.h"
00008
00009
00010
00011 #include "FWCore/Utilities/interface/Exception.h"
00012
00016 template <class T> class CylindricalError3D {
00017
00018 public:
00019
00020 CylindricalError3D(): theCylindricalError(new AlgebraicSymMatrix(3,0)) {}
00021
00022 CylindricalError3D(const CartesianError3D<T>& ge, const GlobalPoint& gp):
00023 theCylindricalError(new AlgebraicSymMatrix(3,0)) {
00024 T r=gp.r();
00025 T x=gp.x();
00026 T y=gp.y();
00027 T cxx=ge.cxx();
00028 T cxy=ge.cyx();
00029 T cyy=ge.cyy();
00030 T czx=ge.czx();
00031 T czy=ge.czy();
00032 (*theCylindricalError)(1,1)=(pow(x,2)*cxx+2*x*y*cxy+pow(y,2)*cyy)/pow(r,2);
00033 (*theCylindricalError)(2,1)=((cyy-cxx)*x*y+cxy*pow(r,2))/pow(r,3);
00034 (*theCylindricalError)(2,2)=(pow(x,2)*cyy-2*x*y*cxy+pow(y,2)*cxx)/pow(r,4);
00035 (*theCylindricalError)(3,1)=(x*czx+y*czy)/r;
00036 (*theCylindricalError)(3,2)=(x*czy-y*czx)/pow(r,2);
00037 (*theCylindricalError)(3,3)=ge.czz();
00038 }
00039
00040 CylindricalError3D(const AlgebraicSymMatrix & err) {
00041 if (err.num_row() == 3)
00042 theCylindricalError = new AlgebraicSymMatrix(err);
00043 else {
00044 theCylindricalError= 0;
00045
00046 throw cms::Exception("DetLogicError")<<"Not 3x3 Error Matrix: set pointer to 0\n";
00047 }
00048 }
00049
00050 CylindricalError3D(const AlgebraicSymMatrix33 & err) :
00051 theCylindricalError(new AlgebraicSymMatrix(asHepMatrix(err))) { }
00052
00053 ~CylindricalError3D() {}
00054
00055 T crr() const {
00056 return (*theCylindricalError)(1,1);
00057 }
00058
00059 T crphi() const {
00060 return (*theCylindricalError)(2,1);
00061 }
00062
00063 T cphiphi() const {
00064 return (*theCylindricalError)(2,2);
00065 }
00066
00067 T czr() const {
00068 return (*theCylindricalError)(3,1);
00069 }
00070
00071 T czphi() const {
00072 return (*theCylindricalError)(3,2);
00073 }
00074
00075 T czz() const {
00076 return (*theCylindricalError)(3,3);
00077 }
00078
00079 AlgebraicSymMatrix matrix() const {
00080 return *theCylindricalError;
00081 }
00082
00083 AlgebraicSymMatrix33 matrix_new() const {
00084 return asSMatrix<3>(*theCartesianError);
00085 }
00086
00087
00088 private:
00089
00090 DeepCopyPointer<AlgebraicSymMatrix> theCylindricalError;
00091
00092 };
00093
00094 #endif