CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_1/src/RecoHI/HiMuonAlgos/src/HICSeedMeasurementEstimator.cc

Go to the documentation of this file.
00001 #include "RecoHI/HiMuonAlgos/interface/HICSeedMeasurementEstimator.h"
00002 //#include "CLHEP/Units/GlobalPhysicalConstants.h"
00003 
00004 //#define DEBUG
00005 
00006 namespace cms {
00007 MeasurementEstimator::HitReturnType HICSeedMeasurementEstimator::estimate(const TrajectoryStateOnSurface& ts,
00008                                                                  const TransientTrackingRecHit& hit) const
00009 {
00010   double dfimean = 0.;
00011   double dzmean = 0.;
00012   double pi=4.*atan(1.);
00013   double twopi=8.*atan(1.);
00014 #ifdef DEBUG
00015    std::cout<<"  HICSeedMeasurementEstimator::estimate::start::eta "<<ts.freeTrajectoryState()->parameters().momentum().eta() <<std::endl;
00016 #endif
00017     
00018 //
00019 // For mixed are 0.8<|eta|<1.6 there is a shift for + and -
00020 //
00021   if( fabs(ts.freeTrajectoryState()->parameters().momentum().eta()) > 0.8 && 
00022       fabs(ts.freeTrajectoryState()->parameters().momentum().eta()) < 1.6 )
00023   {
00024      dfimean = -0.14;
00025      if( ts.freeTrajectoryState()->charge() > 0. ) dfimean = -0.24;
00026      dzmean = -10.;
00027   }
00028   if( fabs(ts.freeTrajectoryState()->parameters().momentum().eta()) > 1.6 )
00029   {
00030      dfimean = -0.02;
00031      if( ts.freeTrajectoryState()->charge() > 0. ) dfimean = -0.1776; 
00032   }
00033 
00034   if( !(hit.isValid()) ) {
00035 #ifdef DEBUG
00036    std::cout<<"  HICSeedMeasurementEstimator::estimate::hit is not valid " <<std::endl;
00037 #endif
00038     return HitReturnType(false,0.);
00039   }   
00040 
00041 #ifdef DEBUG
00042    std::cout<<"  HICSeedMeasurementEstimator::estimate::hit is valid " <<std::endl;
00043 #endif
00044 
00045 
00046   double dfi = fabs( ts.freeTrajectoryState()->parameters().position().phi()-
00047                                              hit.globalPosition().phi() + dfimean );
00048   if(dfi>pi) dfi=twopi-dfi;
00049 
00050   if(dfi>thePhi) {
00051 #ifdef DEBUG
00052    std::cout<<"HICSeedMeasurementEstimator::estimate::failed::phi hit::phi fts::thePhi "<<hit.globalPosition().phi()<<" "<<
00053    ts.freeTrajectoryState()->parameters().position().phi()<<" "<<dfi<<
00054    " "<<thePhi<<std::endl;
00055 #endif
00056 
00057    return HitReturnType(false,0.);
00058   }
00059   if( fabs(hit.globalPosition().z()) > 120.)
00060   {
00061   
00062   if(fabs(hit.globalPosition().perp()-ts.freeTrajectoryState()->parameters().position().perp())
00063                                                                                        >theZ) {
00064 #ifdef DEBUG
00065    std::cout<<"HICSeedMeasurementEstimator::estimate::failed::r hit::r fts::theZ "<<hit.globalPosition().perp()<<" "<<
00066    ts.freeTrajectoryState()->parameters().position().perp()<<
00067    " "<<theZ<<std::endl;
00068 #endif   
00069      return HitReturnType(false,0.);
00070    }
00071   }
00072    else
00073    {
00074    
00075       if(fabs(hit.globalPosition().z()-ts.freeTrajectoryState()->parameters().position().z() + dzmean)
00076                                                                                                     >theZ) {
00077 #ifdef DEBUG
00078    std::cout<<"HICSeedMeasurementEstimator::estimate::failed::z hit::z fts::theZ "<<hit.globalPosition().z()<<" "<<
00079    ts.freeTrajectoryState()->parameters().position().z()<<
00080    " "<<theZ<<std::endl;
00081 #endif
00082 
00083       return HitReturnType(false,0.);
00084      }
00085    }
00086 #ifdef DEBUG
00087    std::cout<<"HICSeedMeasurementEstimator::estimate::accepted::phi::r::z "<<hit.globalPosition().phi()<<" "<<
00088                                                                              hit.globalPosition().perp()<<" "<<
00089                                                                              hit.globalPosition().z()<<
00090    std::endl;
00091 #endif
00092 
00093 return HitReturnType(true,1.);                                       
00094 }
00095 
00096 MeasurementEstimator::SurfaceReturnType HICSeedMeasurementEstimator::estimate(const TrajectoryStateOnSurface& ts,
00097                                                         const BoundPlane& plane) const
00098 {
00099 
00100   double pi=4.*atan(1.);
00101   double twopi=8.*atan(1.);
00102 
00103 #ifdef DEBUG
00104    std::cout<<"HICSeedMeasurementEstimator::estimate::Det::start::r,phi,z "<<plane.position().perp()<<" "<<plane.position().phi()<<" "<<
00105    plane.position().z()<<std::endl;
00106    std::cout<<"HICSeedMeasurementEstimator::estimate::Track::r,phi,z "<<ts.freeTrajectoryState()->parameters().position().perp()<<" "<<
00107                                                                         ts.freeTrajectoryState()->parameters().position().phi()<<" "<<
00108                                                                         ts.freeTrajectoryState()->parameters().position().z()<<std::endl;
00109 #endif
00110    double length = plane.bounds().length();
00111    double width = plane.bounds().width();
00112    double deltafi = atan2( width , (double)plane.position().perp() );
00113    double phitrack = ts.freeTrajectoryState()->parameters().position().phi();
00114    double phiplane = plane.position().phi();
00115 
00116    if( phitrack < 0. ) phitrack = twopi + phitrack;
00117    if( phiplane < 0. ) phiplane = twopi + phiplane;
00118    
00119    double dphi = fabs(phitrack - phiplane);
00120 
00121    if( dphi > pi ) dphi = twopi - dphi;
00122    if( dphi >  thePhi + deltafi ) {
00123 #ifdef DEBUG
00124    std::cout<<"HICSeedMeasurementEstimator::estimate::Det::phi failed "<<dphi<<" "<<thePhi<<" "<<deltafi<<std::endl;
00125 #endif     
00126      return false;
00127    }
00128    if ( fabs( plane.position().z() ) < 111. )
00129    {
00130      // barrel
00131         if( fabs(ts.freeTrajectoryState()->parameters().position().z() - plane.position().z()) 
00132                                                                        >  theZ+length ) {
00133       
00134 #ifdef DEBUG
00135    double dz = fabs(ts.freeTrajectoryState()->parameters().position().z() - plane.position().z());
00136    std::cout<<"HICSeedMeasurementEstimator::estimate::Det::z failed "<<dz<<" "<<theZ<<" "<<length<<std::endl;
00137 #endif
00138 
00139                                                                        return false;
00140                                                                        }
00141    } 
00142      else
00143      {
00144       // forward
00145         if( fabs(ts.freeTrajectoryState()->parameters().position().perp() - plane.position().perp()) 
00146                                                                                     >  theZ + length ) {
00147 #ifdef DEBUG
00148    double dr = fabs(ts.freeTrajectoryState()->parameters().position().perp() - plane.position().perp());
00149    std::cout<<"HICSeedMeasurementEstimator::estimate::Det::r failed "<<dr<<" "<<theZ<<" "<<length<<std::endl;
00150 #endif
00151 
00152                                                                                     return false;
00153                                                                                     }
00154      }
00155 #ifdef DEBUG
00156      std::cout<<" Good detector "<<std::endl;
00157 #endif
00158    return true;                                  
00159 }
00160 
00161 MeasurementEstimator::Local2DVector 
00162 HICSeedMeasurementEstimator::maximalLocalDisplacement( const TrajectoryStateOnSurface& ts,
00163                                                         const BoundPlane& plane) const
00164 {
00165 #ifdef DEBUG
00166    std::cout<<"HICSeedMeasurementEstimator::malLocalDisplacement::start"
00167    <<ts.hasError()<<std::endl;
00168 #endif
00169 
00170   if ( ts.hasError()) {
00171     LocalError le = ts.localError().positionError();
00172 #ifdef DEBUG
00173    std::cout<<"HICSeedMeasurementEstimator::malLocalDisplacement::localerror::sigma"<<Local2DVector( sqrt(le.xx())*nSigmaCut(), sqrt(le.yy())*nSigmaCut())<<std::endl;
00174 #endif    
00175     return Local2DVector( sqrt(le.xx())*nSigmaCut(), sqrt(le.yy())*nSigmaCut());
00176   }
00177   else return Local2DVector(0,0);
00178 }
00179 }