CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_0/src/DataFormats/TrackerRecHit2D/src/BaseTrackerRecHit.cc

Go to the documentation of this file.
00001 #include "DataFormats/TrackerRecHit2D/interface/BaseTrackerRecHit.h"
00002 #include "DataFormats/Math/interface/ProjectMatrix.h"
00003 #include "FWCore/Utilities/interface/Exception.h"
00004 
00005 
00006 
00007 namespace {
00008   void
00009   throwExceptionUninitialized(const char *where)
00010   {
00011     throw cms::Exception("BaseTrackerRecHit") << 
00012       "Trying to access " << where << " for a RecHit that was read from disk, but since CMSSW_2_1_X local positions are transient.\n" <<
00013       "If you want to get coarse position/error estimation from disk, please set: ComputeCoarseLocalPositionFromDisk = True \n " <<
00014       " to the TransientTrackingRecHitBuilder you are using from RecoTracker/TransientTrackingRecHit/python/TTRHBuilders_cff.py";
00015   }
00016   
00017   void obsolete() {
00018     throw cms::Exception("BaseTrackerRecHit") << "CLHEP is obsolete for Tracker Hits";
00019   }
00020 }
00021 
00022 
00023 bool BaseTrackerRecHit::hasPositionAndError() const {
00024     return (err_.xx() != 0) || (err_.yy() != 0) || (err_.xy() != 0) ||
00025            (pos_.x()  != 0) || (pos_.y()  != 0) || (pos_.z()  != 0);
00026 }
00027 
00028 LocalPoint BaseTrackerRecHit::localPosition() const {
00029     if (!hasPositionAndError()) throwExceptionUninitialized("localPosition");
00030     return pos_;
00031 }
00032 
00033 LocalError BaseTrackerRecHit::localPositionError() const{ 
00034     if (!hasPositionAndError()) throwExceptionUninitialized("localPositionError");
00035     return err_;
00036 }
00037 
00038 
00039 
00040 void
00041 BaseTrackerRecHit::getKfComponents1D( KfComponentsHolder & holder ) const 
00042 {
00043   if (!hasPositionAndError()) throwExceptionUninitialized("getKfComponents");
00044   AlgebraicVector1 & pars = holder.params<1>();
00045   pars[0] = pos_.x(); 
00046   
00047   AlgebraicSymMatrix11 & errs = holder.errors<1>();
00048   errs(0,0) = err_.xx();
00049   
00050   AlgebraicMatrix15 & proj = holder.projection<1>();
00051   proj(0,3) = 1;
00052   
00053    holder.measuredParams<1>() = AlgebraicVector1( holder.tsosLocalParameters().At(3) );
00054    holder.measuredErrors<1>() = holder.tsosLocalErrors().Sub<AlgebraicSymMatrix11>( 3, 3 );
00055 }
00056 
00057 void
00058 BaseTrackerRecHit::getKfComponents2D( KfComponentsHolder & holder ) const 
00059 {
00060   if (!hasPositionAndError()) throwExceptionUninitialized("getKfComponents");
00061    AlgebraicVector2 & pars = holder.params<2>();
00062    pars[0] = pos_.x(); 
00063    pars[1] = pos_.y();
00064 
00065    AlgebraicSymMatrix22 & errs = holder.errors<2>();
00066    errs(0,0) = err_.xx();
00067    errs(0,1) = err_.xy();
00068    errs(1,1) = err_.yy();
00069 
00070    
00071    AlgebraicMatrix25 & proj = holder.projection<2>();
00072    proj(0,3) = 1;
00073    proj(1,4) = 1;
00074 
00075    ProjectMatrix<double,5,2>  & pf = holder.projFunc<2>();
00076    pf.index[0] = 3;
00077    pf.index[1] = 4;
00078    holder.doUseProjFunc();
00079 
00080    holder.measuredParams<2>() = AlgebraicVector2( & holder.tsosLocalParameters().At(3), 2 );
00081    holder.measuredErrors<2>() = holder.tsosLocalErrors().Sub<AlgebraicSymMatrix22>( 3, 3 );
00082 
00083 }
00084 
00085  // obsolete (for what tracker is concerned...) interface
00086 AlgebraicVector BaseTrackerRecHit::parameters() const {
00087   obsolete();
00088   return AlgebraicVector();
00089 }
00090 
00091 AlgebraicSymMatrix BaseTrackerRecHit::parametersError() const {
00092   obsolete();
00093   return AlgebraicSymMatrix();
00094 }
00095 
00096 
00097 AlgebraicMatrix BaseTrackerRecHit::projectionMatrix() const {
00098   obsolete();
00099   return AlgebraicMatrix();
00100 }