CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_14/src/DataFormats/TrackingRecHit/interface/KfComponentsHolder.h

Go to the documentation of this file.
00001 #ifndef DataFormats_TrackingRecHit_interface_KfComponentsHolder_h_
00002 #define DataFormats_TrackingRecHit_interface_KfComponentsHolder_h_
00003 
00004 
00005 #include "DataFormats/CLHEP/interface/AlgebraicObjects.h"
00006 #include "DataFormats/Math/interface/ProjectMatrix.h"
00007 #include <stdint.h>
00008 
00009 class TrackingRecHit;
00010 
00011 #define Debug_KfComponentsHolder
00012 
00013 class KfComponentsHolder {
00014     public:
00015   KfComponentsHolder() : params_(0), errors_(0), projection_(0), useProjFunc_(false)
00016         {
00017 #ifdef Debug_KfComponentsHolder
00018             size_ = 0;
00019 #endif
00020         }
00021 
00022         template <unsigned int D>
00023         void setup(
00024             typename AlgebraicROOTObject<D>::Vector       *params,
00025             typename AlgebraicROOTObject<D,D>::SymMatrix  *errors,
00026             typename AlgebraicROOTObject<D,5>::Matrix     *projection,
00027             ProjectMatrix<double,5,D>                     *projFunc, 
00028             typename AlgebraicROOTObject<D>::Vector       *measuredParams,
00029             typename AlgebraicROOTObject<D,D>::SymMatrix  *measuredErrors,
00030             const AlgebraicVector5 & tsosLocalParameters, 
00031             const AlgebraicSymMatrix55 & tsosLocalErrors 
00032         ) ;
00033 
00034 
00035   // backward compatible call
00036         template <unsigned int D>
00037         void setup(
00038             typename AlgebraicROOTObject<D>::Vector       *params,
00039             typename AlgebraicROOTObject<D,D>::SymMatrix  *errors,
00040             typename AlgebraicROOTObject<D,5>::Matrix     *projection,
00041             typename AlgebraicROOTObject<D>::Vector       *measuredParams,
00042             typename AlgebraicROOTObject<D,D>::SymMatrix  *measuredErrors,
00043             const AlgebraicVector5 & tsosLocalParameters, 
00044             const AlgebraicSymMatrix55 & tsosLocalErrors 
00045         ) ;
00046 
00047 
00048         template <unsigned int D>
00049         typename AlgebraicROOTObject<D>::Vector & params() { 
00050 #ifdef Debug_KfComponentsHolder
00051             assert(size_ == D);
00052 #endif
00053             return  * reinterpret_cast<typename AlgebraicROOTObject<D>::Vector *>(params_);
00054         }
00055 
00056         template <unsigned int D>
00057         typename AlgebraicROOTObject<D,D>::SymMatrix & errors() { 
00058 #ifdef Debug_KfComponentsHolder
00059             assert(size_ == D);
00060 #endif
00061             return  * reinterpret_cast<typename AlgebraicROOTObject<D,D>::SymMatrix *>(errors_);
00062         }
00063 
00064         template <unsigned int D>
00065         typename AlgebraicROOTObject<D,5>::Matrix & projection() { 
00066 #ifdef Debug_KfComponentsHolder
00067             assert(size_ == D);
00068 #endif
00069             return  * reinterpret_cast<typename AlgebraicROOTObject<D,5>::Matrix *>(projection_);
00070         }
00071 
00072         template <unsigned int D>
00073         ProjectMatrix<double,5,D> & projFunc() { 
00074 #ifdef Debug_KfComponentsHolder
00075             assert(size_ == D);
00076 #endif
00077             return  * reinterpret_cast< ProjectMatrix<double,5,D> *>(projFunc_);
00078         }
00079 
00081         void genericFill(const TrackingRecHit &hit); 
00082 
00083         template <unsigned int D>
00084         typename AlgebraicROOTObject<D>::Vector & measuredParams() { 
00085 #ifdef Debug_KfComponentsHolder
00086             assert(size_ == D);
00087 #endif
00088             return  * reinterpret_cast<typename AlgebraicROOTObject<D>::Vector *>(measuredParams_);
00089         }
00090 
00091         template <unsigned int D>
00092         typename AlgebraicROOTObject<D,D>::SymMatrix & measuredErrors() { 
00093 #ifdef Debug_KfComponentsHolder
00094             assert(size_ == D);
00095 #endif
00096             return  * reinterpret_cast<typename AlgebraicROOTObject<D,D>::SymMatrix *>(measuredErrors_);
00097         }
00098 
00099         const AlgebraicVector5     & tsosLocalParameters() const { return *tsosLocalParameters_; }
00100         const AlgebraicSymMatrix55 & tsosLocalErrors()     const { return *tsosLocalErrors_;     }
00101 
00102         bool useProjFunc() const { return useProjFunc_;}
00103         void doUseProjFunc() {  useProjFunc_ = true; }
00104 
00105         template<unsigned int D> void dump() ;
00106     private:
00107 #ifdef Debug_KfComponentsHolder
00108         uint16_t size_;
00109 #endif
00110   void *params_, *errors_, *projection_, *projFunc_, *measuredParams_, *measuredErrors_;
00111   const AlgebraicVector5 * tsosLocalParameters_;
00112   const AlgebraicSymMatrix55 * tsosLocalErrors_;
00113 
00114   bool useProjFunc_;
00115 
00116   template<unsigned int D>
00117   void genericFill_(const TrackingRecHit &hit);
00118 
00119         
00120 };
00121 
00122 
00123 template<unsigned int D>
00124 void KfComponentsHolder::setup(
00125         typename AlgebraicROOTObject<D>::Vector       *params,
00126         typename AlgebraicROOTObject<D,D>::SymMatrix  *errors,
00127         typename AlgebraicROOTObject<D,5>::Matrix     *projection,
00128         ProjectMatrix<double,5,D>                     *projFunc, 
00129         typename AlgebraicROOTObject<D>::Vector       *measuredParams,
00130         typename AlgebraicROOTObject<D,D>::SymMatrix  *measuredErrors,
00131         const AlgebraicVector5     & tsosLocalParameters, 
00132         const AlgebraicSymMatrix55 & tsosLocalErrors)
00133 {
00134 #ifdef Debug_KfComponentsHolder
00135     assert(size_ == 0); // which means it was uninitialized
00136     size_ = D;
00137 #endif
00138     params_     = params;
00139     errors_     = errors;
00140     projection_ = projection;
00141     projFunc_ = projFunc;
00142     measuredParams_ = measuredParams;
00143     measuredErrors_ = measuredErrors;
00144     tsosLocalParameters_ = & tsosLocalParameters;
00145     tsosLocalErrors_     = & tsosLocalErrors;
00146 }
00147 
00148 // backward compatible
00149 template<unsigned int D>
00150 void KfComponentsHolder::setup(
00151         typename AlgebraicROOTObject<D>::Vector       *params,
00152         typename AlgebraicROOTObject<D,D>::SymMatrix  *errors,
00153         typename AlgebraicROOTObject<D,5>::Matrix     *projection, 
00154         typename AlgebraicROOTObject<D>::Vector       *measuredParams,
00155         typename AlgebraicROOTObject<D,D>::SymMatrix  *measuredErrors,
00156         const AlgebraicVector5     & tsosLocalParameters, 
00157         const AlgebraicSymMatrix55 & tsosLocalErrors)
00158 {
00159 #ifdef Debug_KfComponentsHolder
00160     assert(size_ == 0); // which means it was uninitialized
00161     size_ = D;
00162 #endif
00163     static ProjectMatrix<double,5,D> dummy;
00164     params_     = params;
00165     errors_     = errors;
00166     projection_ = projection;
00167     projFunc_ = &dummy;
00168     measuredParams_ = measuredParams;
00169     measuredErrors_ = measuredErrors;
00170     tsosLocalParameters_ = & tsosLocalParameters;
00171     tsosLocalErrors_     = & tsosLocalErrors;
00172 }
00173 
00174 
00175 template<unsigned int D>
00176 void KfComponentsHolder::dump() {
00177     using namespace std;
00178     cout << "Params  my: " << params<D>() << endl;
00179     cout << "      tsos: " << tsosLocalParameters() << endl;
00180     cout << "      meas: " << measuredParams<D>() << endl;
00181     cout << "Errors  my:\n" << errors<D>() << endl;
00182     cout << "      tsos:\n" << tsosLocalErrors() << endl;
00183     cout << "      meas:\n" << measuredErrors<D>() << endl;
00184     cout << "Projection:\n" << projection<D>() << endl;
00185 }
00186 
00187 #ifdef Debug_KfComponentsHolder
00188 // undef it so we don't pollute someone else's code.
00189 #undef Debug_KfComponentsHolder
00190 #endif 
00191 
00192 #endif