CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch9/src/RecoTracker/TransientTrackingRecHit/interface/TSiStripRecHit2DLocalPos.h

Go to the documentation of this file.
00001 #ifndef RECOTRACKER_TRANSIENTRACKINGRECHIT_TSiStripRecHit2DLocalPos_H
00002 #define RECOTRACKER_TRANSIENTRACKINGRECHIT_TSiStripRecHit2DLocalPos_H
00003 
00004 #include "DataFormats/TrackerRecHit2D/interface/SiStripRecHit2D.h"
00005 #include "TrackingTools/TransientTrackingRecHit/interface/TransientTrackingRecHit.h"
00006 #include "RecoLocalTracker/ClusterParameterEstimator/interface/StripClusterParameterEstimator.h"
00007 #include "TrackingTools/TransientTrackingRecHit/interface/HelpertRecHit2DLocalPos.h"
00008 #include "DataFormats/Common/interface/RefGetter.h"
00009 #include "Geometry/CommonDetUnit/interface/GeomDetUnit.h"
00010 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00011 
00012 class TSiStripRecHit2DLocalPos : public TransientTrackingRecHit{
00013 public:
00014 
00015   typedef SiStripRecHit2D::ClusterRef SiStripClusterRef;
00016   
00017   typedef edm::LazyGetter<SiStripCluster>::value_ref  SiStripRegionalClusterRef;
00018 
00019   virtual ~TSiStripRecHit2DLocalPos() {}
00020 
00021 
00022   virtual void getKfComponents( KfComponentsHolder & holder ) const {
00023       HelpertRecHit2DLocalPos().getKfComponents(holder, theHitData, *det()); 
00024   }
00025 
00026   virtual AlgebraicVector parameters() const {return theHitData.parameters();}
00027   virtual AlgebraicSymMatrix parametersError() const {
00028     return HelpertRecHit2DLocalPos().parError( theHitData.localPositionError(), *det()); 
00029     //    return theHitData->parametersError();
00030   }
00031   
00032   virtual AlgebraicMatrix projectionMatrix() const {return theHitData.projectionMatrix();}
00033   virtual int dimension() const {return theHitData.dimension();}
00034 
00035   virtual LocalPoint localPosition() const {return theHitData.localPosition();}
00036   virtual LocalError localPositionError() const {return theHitData.localPositionError();}
00037 
00038   virtual const TrackingRecHit * hit() const {return &theHitData;};
00039   
00040   virtual std::vector<const TrackingRecHit*> recHits() const {
00041     return hit()->recHits();
00042   }
00043   virtual std::vector<TrackingRecHit*> recHits() {
00044     return theHitData.recHits();
00045   }
00046 
00047   virtual const GeomDetUnit* detUnit() const;
00048 
00049   virtual bool canImproveWithTrack() const {return true;}
00050 
00051   //RC virtual TSiStripRecHit2DLocalPos* clone(const TrajectoryStateOnSurface& ts) const;
00052   virtual RecHitPointer clone(const TrajectoryStateOnSurface& ts) const;
00053 
00054   // Extension of the TransientTrackingRecHit interface
00055 
00056   const SiStripRecHit2D* specificHit() const {return &theHitData;};
00057   const StripClusterParameterEstimator* cpe() const {return theCPE;}
00058 
00059   static RecHitPointer build( const GeomDet * geom, const SiStripRecHit2D* rh,
00060                               const StripClusterParameterEstimator* cpe,
00061                               float weight=1., float annealing=1.,
00062                               bool computeCoarseLocalPosition=false) {
00063     return RecHitPointer( new TSiStripRecHit2DLocalPos( geom, rh, cpe, weight, annealing,computeCoarseLocalPosition));
00064   }
00065 
00066   static RecHitPointer build( const LocalPoint& pos, const LocalError& err,
00067                               const GeomDet* det,
00068                               const SiStripClusterRef clust,
00069                               const StripClusterParameterEstimator* cpe,
00070                               float weight=1., float annealing=1.) {
00071     return RecHitPointer( new TSiStripRecHit2DLocalPos( pos, err, det, clust, cpe, weight, annealing));
00072   }
00073 
00074   static RecHitPointer build( const LocalPoint& pos, const LocalError& err,
00075                               const GeomDet* det,
00076                               const SiStripRegionalClusterRef clust,
00077                               const StripClusterParameterEstimator* cpe,
00078                               float weight=1., float annealing=1.) {
00079     return RecHitPointer( new TSiStripRecHit2DLocalPos( pos, err, det, clust, cpe, weight, annealing));
00080   }
00081 
00082 
00083 
00084 private:
00085 
00086   SiStripRecHit2D              theHitData;
00087   const StripClusterParameterEstimator* theCPE;
00088 
00089   TSiStripRecHit2DLocalPos (const GeomDet * geom, const SiStripRecHit2D* rh,
00090                             const StripClusterParameterEstimator* cpe,
00091                             float weight, float annealing,
00092                             bool computeCoarseLocalPosition) : 
00093     TransientTrackingRecHit(geom, weight, annealing), theCPE(cpe) 
00094     {
00095       if (rh->hasPositionAndError() || !computeCoarseLocalPosition)
00096         theHitData = SiStripRecHit2D(*rh);
00097       else{
00098         if (computeCoarseLocalPosition && !cpe){
00099           edm::LogError("TSiStripRecHit2DLocalPos")<<" trying to compute coarse local position but CPE is not provided. Not computing local position from disk for the transient tracking rechit.";
00100           theHitData = SiStripRecHit2D(*rh);
00101         }
00102         else{
00103           const GeomDetUnit* gdu = dynamic_cast<const GeomDetUnit*>(geom);
00104           LogDebug("TSiStripRecHit2DLocalPos")<<"calculating coarse position/error.";
00105           if (gdu){
00106             if (rh->cluster().isNonnull()){
00107               StripClusterParameterEstimator::LocalValues lval= theCPE->localParameters(*rh->cluster(), *gdu);
00108               theHitData = SiStripRecHit2D(lval.first, lval.second, geom->geographicalId(),rh->cluster());
00109             }else{
00110               StripClusterParameterEstimator::LocalValues lval= theCPE->localParameters(*rh->cluster_regional(), *gdu);
00111               theHitData = SiStripRecHit2D(lval.first, lval.second, geom->geographicalId(),rh->cluster_regional());
00112             }
00113           }else{
00114             edm::LogError("TSiStripRecHit2DLocalPos")<<" geomdet does not cast into geomdet unit. cannot create strip local parameters.";
00115             theHitData = SiStripRecHit2D(*rh);
00116           }
00117         }
00118       }
00119     }
00120 
00122   TSiStripRecHit2DLocalPos( const LocalPoint& pos, const LocalError& err,
00123                             const GeomDet* det,
00124                             const SiStripClusterRef clust,
00125                             const StripClusterParameterEstimator* cpe,
00126                             float weight, float annealing) :
00127     TransientTrackingRecHit(det, weight, annealing), theHitData(pos, err, det->geographicalId(), clust), 
00128     theCPE(cpe){} 
00129 
00130   //  TSiStripRecHit2DLocalPos( const TSiStripRecHit2DLocalPos& other ) :
00131   //  TransientTrackingRecHit( other.det()), 
00132   //  theHitData( other.specificHit()->clone()),
00133   //  theCPE( other.cpe()) {}
00134 
00135   TSiStripRecHit2DLocalPos( const LocalPoint& pos, const LocalError& err,
00136                             const GeomDet* det,
00137                             const SiStripRegionalClusterRef clust,                          
00138                             const StripClusterParameterEstimator* cpe,
00139                             float weight, float annealing) :
00140     TransientTrackingRecHit(det, weight, annealing), theHitData(pos, err, det->geographicalId(), clust), 
00141     theCPE(cpe){} 
00142   
00143   
00144 
00145   virtual TSiStripRecHit2DLocalPos* clone() const {
00146     return new TSiStripRecHit2DLocalPos(*this);
00147   }
00148 
00149   virtual ConstRecHitContainer transientHits() const;
00150 
00151 };
00152 
00153 #endif