CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_1/src/DataFormats/TrackerRecHit2D/interface/BaseTrackerRecHit.h

Go to the documentation of this file.
00001 #ifndef BaseTrackerRecHit_H
00002 #define BaseTrackerRecHit_H
00003 
00004 #include "DataFormats/TrackingRecHit/interface/TrackingRecHit.h"
00005 #include "DataFormats/GeometrySurface/interface/LocalError.h"
00006 #include "DataFormats/GeometryVector/interface/LocalPoint.h"
00007 
00008 class OmniClusterRef;
00009 
00010 namespace trackerHitRTTI {
00011   // tracking hit can be : single (si1D, si2D, pix), projected, matched or multi
00012   enum RTTI { undef=0, single=1, proj=2, match=3, multi=4};
00013   inline RTTI rtti(TrackingRecHit const & hit)  { return RTTI(hit.getRTTI());}
00014   inline bool isUndef(TrackingRecHit const & hit) { return rtti(hit)==undef;}
00015   inline bool isSingle(TrackingRecHit const & hit)  { return rtti(hit)==single;}
00016   inline bool isProjected(TrackingRecHit const & hit)  { return rtti(hit)==proj;}
00017   inline bool isMatched(TrackingRecHit const & hit)  { return rtti(hit)==match;}
00018   inline bool isMulti(TrackingRecHit const & hit)  { return rtti(hit)==multi;}
00019 }
00020 
00021 class BaseTrackerRecHit : public TrackingRecHit { 
00022 public:
00023   BaseTrackerRecHit() {}
00024 
00025   virtual ~BaseTrackerRecHit() {}
00026 
00027   // no position (as in persistent)
00028   BaseTrackerRecHit(DetId id, trackerHitRTTI::RTTI rt) :  TrackingRecHit(id,(unsigned int)(rt)) {}
00029 
00030   BaseTrackerRecHit( const LocalPoint& p, const LocalError&e,
00031                      DetId id, trackerHitRTTI::RTTI rt) :  TrackingRecHit(id,(unsigned int)(rt)), pos_(p), err_(e){}
00032 
00033   trackerHitRTTI::RTTI rtti() const { return trackerHitRTTI::rtti(*this);}
00034   bool isSingle() const { return trackerHitRTTI::isSingle(*this);}
00035   bool isProjected() const { return trackerHitRTTI::isProjected(*this);}
00036   bool isMatched() const { return trackerHitRTTI::isMatched(*this);}
00037   bool isMulti() const { return trackerHitRTTI::isMulti(*this);}
00038 
00039  // used by trackMerger (to be improved)
00040   virtual OmniClusterRef const & firstClusterRef() const=0;
00041 
00042 
00043   // verify that hits can share clusters...
00044   inline bool sameDetModule(TrackingRecHit const & hit) const;
00045 
00046   virtual LocalPoint localPosition() const  GCC11_FINAL;
00047 
00048   virtual LocalError localPositionError() const  GCC11_FINAL;
00049 
00050   bool hasPositionAndError() const  GCC11_FINAL; 
00051  
00052   const LocalPoint & localPositionFast()      const { return pos_; }
00053   const LocalError & localPositionErrorFast() const { return err_; }
00054 
00055   // to be specialized for 1D and 2D
00056   virtual void getKfComponents( KfComponentsHolder & holder ) const=0;
00057   virtual int dimension() const=0; 
00058 
00059   void getKfComponents1D( KfComponentsHolder & holder ) const;
00060   void getKfComponents2D( KfComponentsHolder & holder ) const;
00061 
00062 
00063 public:
00064 
00065   // obsolete (for what tracker is concerned...) interface
00066   virtual AlgebraicVector parameters() const;
00067   virtual AlgebraicSymMatrix parametersError() const;
00068   virtual AlgebraicMatrix projectionMatrix() const;
00069 
00070  private:
00071   
00072   LocalPoint pos_;
00073   LocalError err_;
00074 };
00075 
00076 
00077 bool BaseTrackerRecHit::sameDetModule(TrackingRecHit const & hit) const {
00078   unsigned int myid = geographicalId().rawId();
00079   unsigned int mysubd = myid >> (DetId::kSubdetOffset);
00080 
00081   unsigned int id = hit.geographicalId().rawId();
00082   unsigned int subd = id >> (DetId::kSubdetOffset);
00083   
00084   if (mysubd!=subd) return false;
00085   
00086   //Protection against invalid hits
00087   if(!hit.isValid()) return false;
00088   
00089   const unsigned int limdet = 10;  // TIB=11
00090   
00091   if (mysubd>limdet) { // strip
00092     // mask glue and stereo
00093     myid|=3;
00094     id|=3;
00095   }
00096   return id==myid;
00097 
00098 }
00099 
00100 
00101 // Comparison operators
00102 inline bool operator<( const BaseTrackerRecHit& one, const BaseTrackerRecHit& other) {
00103   return ( one.geographicalId() < other.geographicalId() );
00104 }
00105 #endif  // BaseTrackerRecHit_H