CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_10_patch1/src/DataFormats/TrackerRecHit2D/src/BaseSiTrackerRecHit2DLocalPos.cc

Go to the documentation of this file.
00001 #include "DataFormats/TrackerRecHit2D/interface/BaseSiTrackerRecHit2DLocalPos.h"
00002 #include "DataFormats/Math/interface/ProjectMatrix.h"
00003 #include "FWCore/Utilities/interface/Exception.h"
00004 
00005 bool BaseSiTrackerRecHit2DLocalPos::hasPositionAndError() const {
00006     return (err_.xx() != 0) || (err_.yy() != 0) || (err_.xy() != 0) ||
00007            (pos_.x()  != 0) || (pos_.y()  != 0) || (pos_.z()  != 0);
00008 }
00009 
00010 LocalPoint BaseSiTrackerRecHit2DLocalPos::localPosition() const {
00011     if (!hasPositionAndError()) throwExceptionUninitialized("localPosition");
00012     return pos_;
00013 }
00014 
00015 LocalError BaseSiTrackerRecHit2DLocalPos::localPositionError() const{ 
00016     if (!hasPositionAndError()) throwExceptionUninitialized("localPositionError");
00017     return err_;
00018 }
00019 
00020 
00021 void 
00022 BaseSiTrackerRecHit2DLocalPos::getKfComponents( KfComponentsHolder & holder ) const 
00023 {
00024    if (!hasPositionAndError()) throwExceptionUninitialized("getKfComponents");
00025    //std::cout << "Call to KfComponentsHolder::genericFill should be optimized here " << std::endl;
00026    AlgebraicVector2 & pars = holder.params<2>();
00027    pars[0] = pos_.x(); 
00028    pars[1] = pos_.y();
00029 
00030    AlgebraicSymMatrix22 & errs = holder.errors<2>();
00031    errs(0,0) = err_.xx();
00032    errs(0,1) = err_.xy();
00033    errs(1,1) = err_.yy();
00034 
00035    
00036    AlgebraicMatrix25 & proj = holder.projection<2>();
00037    proj(0,3) = 1;
00038    proj(1,4) = 1;
00039 
00040    ProjectMatrix<double,5,2>  & pf = holder.projFunc<2>();
00041    pf.index[0] = 3;
00042    pf.index[1] = 4;
00043    holder.doUseProjFunc();
00044 
00045    holder.measuredParams<2>() = AlgebraicVector2( & holder.tsosLocalParameters().At(3), 2 );
00046    holder.measuredErrors<2>() = holder.tsosLocalErrors().Sub<AlgebraicSymMatrix22>( 3, 3 );
00047 
00048    //std::cout << "======== MYSELF ==========" << std::endl;
00049    //holder.dump<2>();
00050    //std::cout << "======== GENERIC ==========" << std::endl;
00051    //holder.genericFill(*this);
00052    //holder.dump<2>();
00053 }
00054 
00055 void
00056 BaseSiTrackerRecHit2DLocalPos::throwExceptionUninitialized(const char *where) const
00057 {
00058    throw cms::Exception("BaseSiTrackerRecHit2DLocalPos") << 
00059      "Trying to access " << where << " for a RecHit that was read from disk, but since CMSSW_2_1_X local positions are transient.\n" <<
00060      "If you want to get coarse position/error estimation from disk, please set: ComputeCoarseLocalPositionFromDisk = True \n " <<
00061      " to the TransientTrackingRecHitBuilder you are using from RecoTracker/TransientTrackingRecHit/python/TTRHBuilders_cff.py";
00062 }
00063