00001 #ifndef DataFormats_TrackingRecHit_interface_KfComponentsHolder_h_
00002 #define DataFormats_TrackingRecHit_interface_KfComponentsHolder_h_
00003
00004 #include "DataFormats/CLHEP/interface/AlgebraicObjects.h"
00005
00006 class TrackingRecHit;
00007
00008 #define Debug_KfComponentsHolder
00009
00010 class KfComponentsHolder {
00011 public:
00012 KfComponentsHolder() : params_(0), errors_(0), projection_(0)
00013 {
00014 #ifdef Debug_KfComponentsHolder
00015 size_ = 0;
00016 #endif
00017 }
00018
00019 template <unsigned int D>
00020 void setup(
00021 typename AlgebraicROOTObject<D>::Vector *params,
00022 typename AlgebraicROOTObject<D,D>::SymMatrix *errors,
00023 typename AlgebraicROOTObject<D,5>::Matrix *projection,
00024 typename AlgebraicROOTObject<D>::Vector *measuredParams,
00025 typename AlgebraicROOTObject<D,D>::SymMatrix *measuredErrors,
00026 const AlgebraicVector5 & tsosLocalParameters,
00027 const AlgebraicSymMatrix55 & tsosLocalErrors
00028 ) ;
00029
00030
00031 template <unsigned int D>
00032 typename AlgebraicROOTObject<D>::Vector & params() {
00033 #ifdef Debug_KfComponentsHolder
00034 assert(size_ == D);
00035 #endif
00036 return * reinterpret_cast<typename AlgebraicROOTObject<D>::Vector *>(params_);
00037 }
00038
00039 template <unsigned int D>
00040 typename AlgebraicROOTObject<D,D>::SymMatrix & errors() {
00041 #ifdef Debug_KfComponentsHolder
00042 assert(size_ == D);
00043 #endif
00044 return * reinterpret_cast<typename AlgebraicROOTObject<D,D>::SymMatrix *>(errors_);
00045 }
00046
00047 template <unsigned int D>
00048 typename AlgebraicROOTObject<D,5>::Matrix & projection() {
00049 #ifdef Debug_KfComponentsHolder
00050 assert(size_ == D);
00051 #endif
00052 return * reinterpret_cast<typename AlgebraicROOTObject<D,5>::Matrix *>(projection_);
00053 }
00054
00056 void genericFill(const TrackingRecHit &hit);
00057
00058 template <unsigned int D>
00059 typename AlgebraicROOTObject<D>::Vector & measuredParams() {
00060 #ifdef Debug_KfComponentsHolder
00061 assert(size_ == D);
00062 #endif
00063 return * reinterpret_cast<typename AlgebraicROOTObject<D>::Vector *>(measuredParams_);
00064 }
00065
00066 template <unsigned int D>
00067 typename AlgebraicROOTObject<D,D>::SymMatrix & measuredErrors() {
00068 #ifdef Debug_KfComponentsHolder
00069 assert(size_ == D);
00070 #endif
00071 return * reinterpret_cast<typename AlgebraicROOTObject<D,D>::SymMatrix *>(measuredErrors_);
00072 }
00073
00074 const AlgebraicVector5 & tsosLocalParameters() const { return *tsosLocalParameters_; }
00075 const AlgebraicSymMatrix55 & tsosLocalErrors() const { return *tsosLocalErrors_; }
00076
00077 template<unsigned int D> void dump() ;
00078 private:
00079 #ifdef Debug_KfComponentsHolder
00080 uint16_t size_;
00081 #endif
00082 void *params_, *errors_, *projection_, *measuredParams_, *measuredErrors_;
00083 const AlgebraicVector5 * tsosLocalParameters_;
00084 const AlgebraicSymMatrix55 * tsosLocalErrors_;
00085
00086 template<unsigned int D>
00087 void genericFill_(const TrackingRecHit &hit);
00088
00089
00090 };
00091
00092
00093 template<unsigned int D>
00094 void KfComponentsHolder::setup(
00095 typename AlgebraicROOTObject<D>::Vector *params,
00096 typename AlgebraicROOTObject<D,D>::SymMatrix *errors,
00097 typename AlgebraicROOTObject<D,5>::Matrix *projection,
00098 typename AlgebraicROOTObject<D>::Vector *measuredParams,
00099 typename AlgebraicROOTObject<D,D>::SymMatrix *measuredErrors,
00100 const AlgebraicVector5 & tsosLocalParameters,
00101 const AlgebraicSymMatrix55 & tsosLocalErrors)
00102 {
00103 #ifdef Debug_KfComponentsHolder
00104 assert(size_ == 0);
00105 size_ = D;
00106 #endif
00107 params_ = params;
00108 errors_ = errors;
00109 projection_ = projection;
00110 measuredParams_ = measuredParams;
00111 measuredErrors_ = measuredErrors;
00112 tsosLocalParameters_ = & tsosLocalParameters;
00113 tsosLocalErrors_ = & tsosLocalErrors;
00114 }
00115
00116 template<unsigned int D>
00117 void KfComponentsHolder::dump() {
00118 using namespace std;
00119 cout << "Params my: " << params<D>() << endl;
00120 cout << " tsos: " << tsosLocalParameters() << endl;
00121 cout << " meas: " << measuredParams<D>() << endl;
00122 cout << "Errors my:\n" << errors<D>() << endl;
00123 cout << " tsos:\n" << tsosLocalErrors() << endl;
00124 cout << " meas:\n" << measuredErrors<D>() << endl;
00125 cout << "Projection:\n" << projection<D>() << endl;
00126 }
00127
00128 #ifdef Debug_KfComponentsHolder
00129
00130 #undef Debug_KfComponentsHolder
00131 #endif
00132
00133 #endif