CMS 3D CMS Logo

CMSSW_4_4_3_patch1/src/RecoTracker/TransientTrackingRecHit/src/TSiStripMatchedRecHit.cc

Go to the documentation of this file.
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 //#include "FWCore/MessageLogger/interface/MessageLogger.h"
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 // Local lo Global lo Local
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 // A la RecHitProjector
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 // Dummy
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     //if ((orig == 0) || (gdet == 0)) return this->clone(); // or just die ?
00043     LocalVector tkDir = (ts.isValid() ? ts.localDirection() : 
00044                          det->surface().toLocal( det->position()-GlobalPoint(0,0,0)));
00045     
00046     if(theCPE != 0){    
00047       //approximation: the ts parameter on the glued surface are used on the mono
00048       // and stereo surface to re-evaluate cluster parameter. A further propagation 
00049       //is slow// and useless (?) in this case.
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         //dm::LogWarning("TSiStripMatchedRecHit") << "Refitting of a matched rechit returns NULL";
00090         return this->clone();
00091       }
00092 
00093       return RecHitPointer(new TSiStripMatchedRecHit( gdet, better, theMatcher,theCPE, weight(), getAnnealingFactor(), false, DontCloneRecHit()));
00094       // delete better; //the ownership of the object is passed to the caller of the matcher
00095 
00096     }else{
00097       const SiStripMatchedRecHit2D *better = theMatcher->match(orig,gdet,tkDir);
00098       if (better == 0) {
00099         //edm::LogWarning("TSiStripMatchedRecHit") << "Refitting of a matched rechit returns NULL";
00100         return this->clone();        
00101       }
00102       return RecHitPointer(new TSiStripMatchedRecHit( gdet, better, theMatcher,theCPE, weight(), getAnnealingFactor(), false, DontCloneRecHit()));
00103       // delete better; //the ownership of the object is passed to the caller of the matcher
00104     }
00105   }
00106   return this->clone();
00107    
00108 }
00109 
00110 
00111 
00112 TransientTrackingRecHit::ConstRecHitContainer   
00113 TSiStripMatchedRecHit::transientHits () const {
00114   ConstRecHitContainer result;
00115 
00116   const GluedGeomDet *gdet = static_cast<const GluedGeomDet *> (this->det());
00117   const SiStripMatchedRecHit2D *orig = static_cast<const SiStripMatchedRecHit2D *> (this->hit());
00118 
00119   result.push_back(TSiStripRecHit2DLocalPos::build( gdet->monoDet(),orig->monoHit(),theCPE));
00120   result.push_back(TSiStripRecHit2DLocalPos::build( gdet->stereoDet(),orig->stereoHit(),theCPE));
00121   return result;
00122 }