00001 #include "RecoTracker/TransientTrackingRecHit/interface/TSiStripMatchedRecHit.h"
00002 #include "DataFormats/TrackerRecHit2D/interface/SiStripMatchedRecHit2D.h"
00003 #include "DataFormats/TrackerRecHit2D/interface/SiStripRecHit2D.h"
00004 #include "RecoLocalTracker/SiStripRecHitConverter/interface/SiStripRecHitMatcher.h"
00005 #include "Geometry/TrackerGeometryBuilder/interface/GluedGeomDet.h"
00006
00007 #include "RecoTracker/TransientTrackingRecHit/interface/TSiStripRecHit2DLocalPos.h"
00008
00009 #undef RecoTracker_TransientTrackingRecHit_TSiStripMatchedRecHit_RefitProj
00010 #undef RecoTracker_TransientTrackingRecHit_TSiStripMatchedRecHit_RefitLGL
00011 #ifdef RecoTracker_TransientTrackingRecHit_TSiStripMatchedRecHit_RefitLGL
00012
00013 inline LocalTrajectoryParameters gluedToStereo(const TrajectoryStateOnSurface &tsos, const GluedGeomDet *gdet) {
00014 const BoundPlane &stripPlane = gdet->stereoDet()->surface();
00015 LocalPoint lp = stripPlane.toLocal(tsos.globalPosition());
00016 LocalVector ld = stripPlane.toLocal(tsos.globalParameters().momentum());
00017 return LocalTrajectoryParameters(lp,ld,tsos.charge());
00018 }
00019 #elif defined(RecoTracker_TransientTrackingRecHit_TSiStripMatchedRecHit_RefitProj)
00020
00021 inline LocalTrajectoryParameters gluedToStereo(const TrajectoryStateOnSurface &tsos, const GluedGeomDet *gdet) {
00022 const BoundPlane &stripPlane = gdet->stereoDet()->surface();
00023 double delta = stripPlane.localZ( tsos.globalPosition());
00024 LocalVector ld = stripPlane.toLocal(tsos.globalParameters().momentum());
00025 LocalPoint lp = stripPlane.toLocal(tsos.globalPosition()) - ld*delta/ld.z();
00026 return LocalTrajectoryParameters(lp,ld,tsos.charge());
00027 }
00028 #else
00029
00030 inline const LocalTrajectoryParameters & gluedToStereo(const TrajectoryStateOnSurface &tsos, const GluedGeomDet *gdet) {
00031 return tsos.localParameters();
00032 }
00033 #endif
00034
00035 TSiStripMatchedRecHit::RecHitPointer
00036 TSiStripMatchedRecHit::clone( const TrajectoryStateOnSurface& ts) const
00037 {
00038 if (theMatcher != 0) {
00039 const SiStripMatchedRecHit2D *orig = static_cast<const SiStripMatchedRecHit2D *> (this->hit());
00040 const GeomDet *det = this->det();
00041 const GluedGeomDet *gdet = static_cast<const GluedGeomDet *> (det);
00042
00043 LocalVector tkDir = (ts.isValid() ? ts.localDirection() :
00044 det->surface().toLocal( det->position()-GlobalPoint(0,0,0)));
00045
00046 if(theCPE != 0){
00047
00048
00049
00050
00051 const SiStripMatchedRecHit2D* better;
00052
00053 if(!orig->monoHit()->cluster().isNull()){
00054 const SiStripCluster& monoclust = *orig->monoHit()->cluster();
00055 const SiStripCluster& stereoclust = *orig->stereoHit()->cluster();
00056
00057 StripClusterParameterEstimator::LocalValues lvMono =
00058 theCPE->localParameters( monoclust, *gdet->monoDet(), ts);
00059 StripClusterParameterEstimator::LocalValues lvStereo =
00060 theCPE->localParameters( stereoclust, *gdet->stereoDet(), gluedToStereo(ts, gdet));
00061
00062 SiStripRecHit2D monoHit = SiStripRecHit2D( lvMono.first, lvMono.second,
00063 gdet->monoDet()->geographicalId(),
00064 orig->monoHit()->cluster());
00065
00066 SiStripRecHit2D stereoHit = SiStripRecHit2D( lvStereo.first, lvStereo.second,
00067 gdet->stereoDet()->geographicalId(),
00068 orig->stereoHit()->cluster());
00069 better = theMatcher->match(&monoHit,&stereoHit,gdet,tkDir);
00070 }else{
00071 const SiStripCluster& monoclust = *orig->monoHit()->cluster_regional();
00072 const SiStripCluster& stereoclust = *orig->stereoHit()->cluster_regional();
00073 StripClusterParameterEstimator::LocalValues lvMono =
00074 theCPE->localParameters( monoclust, *gdet->monoDet(), ts);
00075 StripClusterParameterEstimator::LocalValues lvStereo =
00076 theCPE->localParameters( stereoclust, *gdet->stereoDet(), gluedToStereo(ts, gdet));
00077
00078 SiStripRecHit2D monoHit = SiStripRecHit2D( lvMono.first, lvMono.second,
00079 gdet->monoDet()->geographicalId(),
00080 orig->monoHit()->cluster_regional());
00081
00082 SiStripRecHit2D stereoHit = SiStripRecHit2D( lvStereo.first, lvStereo.second,
00083 gdet->stereoDet()->geographicalId(),
00084 orig->stereoHit()->cluster_regional());
00085 better = theMatcher->match(&monoHit,&stereoHit,gdet,tkDir);
00086 }
00087
00088 if (better == 0) {
00089
00090 return this->clone();
00091 }
00092
00093 RecHitPointer result = TSiStripMatchedRecHit::build( gdet, better, theMatcher,theCPE, weight(), getAnnealingFactor() );
00094 delete better;
00095 return result;
00096
00097 }else{
00098 const SiStripMatchedRecHit2D *better = theMatcher->match(orig,gdet,tkDir);
00099 if (better == 0) {
00100
00101 return this->clone();
00102 }
00103 RecHitPointer result = TSiStripMatchedRecHit::build( gdet, better, theMatcher,theCPE, weight(), getAnnealingFactor() );
00104 delete better;
00105 return result;
00106 }
00107 }
00108 return this->clone();
00109
00110 }
00111
00112
00113
00114 TransientTrackingRecHit::ConstRecHitContainer
00115 TSiStripMatchedRecHit::transientHits () const {
00116 ConstRecHitContainer result;
00117
00118 const GluedGeomDet *gdet = static_cast<const GluedGeomDet *> (this->det());
00119 const SiStripMatchedRecHit2D *orig = static_cast<const SiStripMatchedRecHit2D *> (this->hit());
00120
00121 result.push_back(TSiStripRecHit2DLocalPos::build( gdet->monoDet(),orig->monoHit(),theCPE));
00122 result.push_back(TSiStripRecHit2DLocalPos::build( gdet->stereoDet(),orig->stereoHit(),theCPE));
00123 return result;
00124 }