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