CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_3/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       
00052       const SiStripCluster& monoclust   = orig->monoCluster();  
00053       const SiStripCluster& stereoclust = orig->stereoCluster();
00054       
00055       StripClusterParameterEstimator::LocalValues lvMono = 
00056         theCPE->localParameters( monoclust, *gdet->monoDet(), ts);
00057       StripClusterParameterEstimator::LocalValues lvStereo = 
00058         theCPE->localParameters( stereoclust, *gdet->stereoDet(), gluedToStereo(ts, gdet));
00059       
00060       SiStripRecHit2D monoHit = SiStripRecHit2D( lvMono.first, lvMono.second,
00061                                                  gdet->monoDet()->geographicalId(),
00062                                                  orig->monoClusterRef());
00063       
00064       SiStripRecHit2D stereoHit = SiStripRecHit2D( lvStereo.first, lvStereo.second,
00065                                                    gdet->stereoDet()->geographicalId(),
00066                                                    orig->stereoClusterRef());
00067        const SiStripMatchedRecHit2D* better =  theMatcher->match(&monoHit,&stereoHit,gdet,tkDir);
00068       
00069       if (better == 0) {
00070         //dm::LogWarning("TSiStripMatchedRecHit") << "Refitting of a matched rechit returns NULL";
00071         return this->clone();
00072       }
00073 
00074       return RecHitPointer(new TSiStripMatchedRecHit( gdet, better, theMatcher,theCPE, false, DontCloneRecHit()));
00075       // delete better; //the ownership of the object is passed to the caller of the matcher
00076 
00077     }
00078     /*
00079     // not supported anymore....
00080     else{
00081        const SiStripMatchedRecHit2D *better = theMatcher->match(orig,gdet,tkDir);
00082        if (better == 0) {
00083         //edm::LogWarning("TSiStripMatchedRecHit") << "Refitting of a matched rechit returns NULL";
00084           return this->clone();        
00085         }
00086       return RecHitPointer(new TSiStripMatchedRecHit( gdet, better, theMatcher,theCPE, false, DontCloneRecHit()));
00087       // delete better; //the ownership of the object is passed to the caller of the matcher
00088     }
00089     */
00090   }
00091   return this->clone();
00092    
00093 }
00094 
00095 
00096 
00097 TransientTrackingRecHit::ConstRecHitContainer   
00098 TSiStripMatchedRecHit::transientHits () const {
00099   ConstRecHitContainer result;
00100 
00101   const GluedGeomDet *gdet = static_cast<const GluedGeomDet *> (this->det());
00102   const SiStripMatchedRecHit2D *orig = static_cast<const SiStripMatchedRecHit2D *> (this->hit());
00103 
00104   if (theCPE!=nullptr) {
00105     // this is at least the third place I read (write) this logic...
00106     const SiStripCluster& monoclust   = orig->monoCluster();  
00107     const SiStripCluster& stereoclust = orig->stereoCluster();
00108     
00109     StripClusterParameterEstimator::LocalValues lvMono = 
00110       theCPE->localParameters( monoclust, *gdet->monoDet());
00111     StripClusterParameterEstimator::LocalValues lvStereo = 
00112       theCPE->localParameters( stereoclust, *gdet->stereoDet());
00113     
00114     result.push_back(TSiStripRecHit2DLocalPos::build(lvMono.first, lvMono.second, gdet->monoDet(), 
00115                                                      orig->monoClusterRef(), theCPE));
00116     result.push_back(TSiStripRecHit2DLocalPos::build(lvStereo.first, lvStereo.second, gdet->stereoDet(), 
00117                                                      orig->stereoClusterRef(), theCPE));
00118   }
00119   else {
00120     auto m = orig->monoHit(); auto s = orig->stereoHit();
00121     result.push_back(TSiStripRecHit2DLocalPos::build( gdet->monoDet(),&m,theCPE));
00122     result.push_back(TSiStripRecHit2DLocalPos::build( gdet->stereoDet(),&s,theCPE));
00123   }
00124   return result;
00125 }
00126 
00127   void TSiStripMatchedRecHit::ComputeCoarseLocalPosition(){
00128   if (!theCPE || !theMatcher) return;
00129   const SiStripMatchedRecHit2D *orig = static_cast<const SiStripMatchedRecHit2D *> (trackingRecHit_);
00130   if ( (!orig)  ||  orig->hasPositionAndError()) return;
00131 
00132   LogDebug("TSiStripMatchedRecHit")<<"calculating coarse position/error.";
00133   const GeomDet *det = this->det();
00134   const GluedGeomDet *gdet = static_cast<const GluedGeomDet *> (det);
00135   LocalVector tkDir = det->surface().toLocal( det->position()-GlobalPoint(0,0,0));
00136   
00137   const SiStripCluster& monoclust   = orig->monoCluster();  
00138   const SiStripCluster& stereoclust = orig->stereoCluster();
00139   
00140   StripClusterParameterEstimator::LocalValues lvMono = 
00141     theCPE->localParameters( monoclust, *gdet->monoDet());
00142   StripClusterParameterEstimator::LocalValues lvStereo = 
00143     theCPE->localParameters( stereoclust, *gdet->stereoDet());
00144   
00145   SiStripRecHit2D monoHit = SiStripRecHit2D( lvMono.first, lvMono.second,
00146                                              gdet->monoDet()->geographicalId(),
00147                                              orig->monoClusterRef());
00148   
00149   SiStripRecHit2D stereoHit = SiStripRecHit2D( lvStereo.first, lvStereo.second,
00150                                                gdet->stereoDet()->geographicalId(),
00151                                                  orig->stereoClusterRef());
00152   SiStripMatchedRecHit2D* better =  theMatcher->match(&monoHit,&stereoHit,gdet,tkDir);
00153   
00154   if (!better) {
00155     edm::LogWarning("TSiStripMatchedRecHit")<<"could not get a matching rechit.";
00156   }else{
00157     delete trackingRecHit_;
00158     trackingRecHit_ = better;
00159   }
00160   
00161 }