Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:54:50

0001 //#define DO_THROW_UNINITIALIZED
0002 #include "DataFormats/TrackerRecHit2D/interface/BaseTrackerRecHit.h"
0003 #include "DataFormats/TrackingRecHit/interface/KfComponentsHolder.h"
0004 #include "DataFormats/Math/interface/ProjectMatrix.h"
0005 #include "FWCore/Utilities/interface/Exception.h"
0006 
0007 namespace {
0008 #if defined(DO_THROW_UNINITIALIZED) || defined(DO_INTERNAL_CHECKS_BTR)
0009   inline void throwExceptionUninitialized(const char *where) {
0010     throw cms::Exception("BaseTrackerRecHit")
0011         << "Trying to access " << where
0012         << " for a RecHit that was read from disk, but since CMSSW_2_1_X local positions are transient.\n"
0013         << "If you want to get coarse position/error estimation from disk, please set: "
0014            "ComputeCoarseLocalPositionFromDisk = True \n "
0015         << " to the TransientTrackingRecHitBuilder you are using from "
0016            "RecoTracker/TransientTrackingRecHit/python/TTRHBuilders_cff.py";
0017   }
0018 #endif
0019   void obsolete() { throw cms::Exception("BaseTrackerRecHit") << "CLHEP is obsolete for Tracker Hits"; }
0020 }  // namespace
0021 
0022 #if !defined(VI_DEBUG) && defined(DO_INTERNAL_CHECKS_BTR)
0023 void BaseTrackerRecHit::check() const {
0024   if (!hasPositionAndError())
0025     throwExceptionUninitialized("localPosition or Error");
0026 }
0027 #endif
0028 
0029 bool BaseTrackerRecHit::hasPositionAndError() const {
0030   //if det is present pos&err are available as well.
0031   //    //if det() is not present (null) the hit has been read from file and not updated
0032   return det();
0033 }
0034 
0035 void BaseTrackerRecHit::getKfComponents1D(KfComponentsHolder &holder) const {
0036 #if defined(DO_THROW_UNINITIALIZED)
0037   if (!hasPositionAndError())
0038     throwExceptionUninitialized("getKfComponents");
0039 #endif
0040   AlgebraicVector1 &pars = holder.params<1>();
0041   pars[0] = pos_.x();
0042 
0043   AlgebraicSymMatrix11 &errs = holder.errors<1>();
0044   errs(0, 0) = err_.xx();
0045 
0046   ProjectMatrix<double, 5, 1> &pf = holder.projFunc<1>();
0047   pf.index[0] = 3;
0048 
0049   holder.measuredParams<1>() = AlgebraicVector1(holder.tsosLocalParameters().At(3));
0050   holder.measuredErrors<1>() = holder.tsosLocalErrors().Sub<AlgebraicSymMatrix11>(3, 3);
0051 }
0052 
0053 void BaseTrackerRecHit::getKfComponents2D(KfComponentsHolder &holder) const {
0054 #if defined(DO_THROW_UNINITIALIZED)
0055   if (!hasPositionAndError())
0056     throwExceptionUninitialized("getKfComponents");
0057 #endif
0058   AlgebraicVector2 &pars = holder.params<2>();
0059   pars[0] = pos_.x();
0060   pars[1] = pos_.y();
0061 
0062   AlgebraicSymMatrix22 &errs = holder.errors<2>();
0063   errs(0, 0) = err_.xx();
0064   errs(0, 1) = err_.xy();
0065   errs(1, 1) = err_.yy();
0066 
0067   ProjectMatrix<double, 5, 2> &pf = holder.projFunc<2>();
0068   pf.index[0] = 3;
0069   pf.index[1] = 4;
0070 
0071   holder.measuredParams<2>() = AlgebraicVector2(&holder.tsosLocalParameters().At(3), 2);
0072   holder.measuredErrors<2>() = holder.tsosLocalErrors().Sub<AlgebraicSymMatrix22>(3, 3);
0073 }
0074 
0075 // obsolete (for what tracker is concerned...) interface
0076 AlgebraicVector BaseTrackerRecHit::parameters() const {
0077   obsolete();
0078   return AlgebraicVector();
0079 }
0080 
0081 AlgebraicSymMatrix BaseTrackerRecHit::parametersError() const {
0082   obsolete();
0083   return AlgebraicSymMatrix();
0084 }
0085 
0086 AlgebraicMatrix BaseTrackerRecHit::projectionMatrix() const {
0087   obsolete();
0088   return AlgebraicMatrix();
0089 }