CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_10_patch2/src/RecoEgamma/EgammaPhotonAlgos/src/ConversionBarrelEstimator.cc

Go to the documentation of this file.
00001 #include "CLHEP/Units/GlobalPhysicalConstants.h"
00002 #include "RecoEgamma/EgammaPhotonAlgos/interface/ConversionBarrelEstimator.h"
00003 #include "TrackingTools/TrajectoryState/interface/TrajectoryStateOnSurface.h"
00004 #include "TrackingTools/TrajectoryParametrization/interface/GlobalTrajectoryParameters.h"
00005 #include "TrackingTools/TransientTrackingRecHit/interface/TransientTrackingRecHit.h" 
00006 #include "TrackingTools/DetLayers/interface/PhiLess.h"
00007 #include "TrackingTools/DetLayers/interface/rangesIntersect.h"
00008 #include "RecoTracker/TkTrackingRegions/interface/GlobalDetRangeZPhi.h"
00009 
00010 
00011   // zero value indicates incompatible ts - hit pair
00012 std::pair<bool,double> ConversionBarrelEstimator::estimate( const TrajectoryStateOnSurface& ts, 
00013                                                             const TransientTrackingRecHit& hit) const {
00014   std::pair<bool,double> result;
00015   
00016   //std::cout << "  ConversionBarrelEstimator::estimate( const TrajectoryStateOnSurface& ts, const TransientTrackingRecHit& hit) " << std::endl;
00017  
00018   float tsPhi = ts.globalParameters().position().phi();
00019   GlobalPoint gp = hit.globalPosition();
00020   float rhPhi = gp.phi();
00021   
00022   // allow a z fudge of 2 sigma
00023   float dz = 2. * sqrt(hit.localPositionError().yy()) ;
00024   float zDiff = ts.globalParameters().position().z() - gp.z(); 
00025   float phiDiff = tsPhi - rhPhi;
00026   if (phiDiff > pi) phiDiff -= twopi;
00027   if (phiDiff < -pi) phiDiff += twopi; 
00028   
00029   // add the errors on the window and the point in quadrature
00030   float zrange = sqrt(theZRangeMax*theZRangeMax + dz*dz);
00031   
00032   /*
00033   std::cout << "  BarrelEstimator ts local error " <<ts.localError().positionError()  << " hit local error " << hit.localPositionError() << std::endl; 
00034   std::cout << "  BarrelEstimator:  RecHit at " << gp << " phi " << rhPhi << " eta " << gp.eta() <<  std::endl;
00035   std::cout << "  BarrelEstimator:  ts at " << ts.globalParameters().position() << " phi " <<ts.globalParameters().position().phi() << " eta " << ts.globalParameters().position().eta()<<  std::endl;
00036   std::cout << "                    zrange = +/-" << zrange << ", zDiff = " << zDiff << std::endl;
00037   std::cout << "                    thePhiRangeMin = " << thePhiRangeMin << ", thePhiRangeMax = " << thePhiRangeMax << ", phiDiff = " << phiDiff << std::endl;
00038   */
00039 
00040   
00041   
00042   if ( phiDiff < thePhiRangeMax && phiDiff > thePhiRangeMin && 
00043        zDiff < zrange && zDiff > -zrange) {
00044     
00045     //    std::cout << "      estimator returns 1 with phiDiff " << thePhiRangeMin << " < " << phiDiff << " < "
00046     //    << thePhiRangeMax << " and zDiff " << zDiff << " < " << zrange << std::endl;
00047     // std::cout << " YES " << phiDiff << " " << zDiff << std::endl;
00048     // std::cout << "                  => RECHIT ACCEPTED " << std::endl;
00049     
00050     result.first=true;
00051     result.second=phiDiff;
00052   } else {
00053     
00054     //     std::cout << "      estimator returns NOT ACCEPTED  with phiDiff " << thePhiRangeMin << " < " << phiDiff << " < "
00055     //<< thePhiRangeMax << " and zDiff " << zDiff << " < " << theZRangeMax+dz << std::endl;
00056     
00057     result.first=false;
00058     result.second=0;
00059     
00060   }
00061   
00062   return result;
00063   
00064 }
00065 
00066 
00067 
00068 bool ConversionBarrelEstimator::estimate( const TrajectoryStateOnSurface& ts, 
00069                                                        const BoundPlane& plane) const {
00070   
00071   typedef     std::pair<float,float>   Range;
00072   //  std::cout << "  ConversionBarrelEstimator::estimate( const TrajectoryStateOnSurface& ts, const BoundPlane& plane) " << std::endl;
00073 
00074   GlobalPoint trajPos(ts.globalParameters().position());
00075   GlobalDetRangeZPhi detRange(plane);
00076   Range trajZRange(trajPos.z() - 2.*theZRangeMax, trajPos.z() + 2.*theZRangeMax);
00077   Range trajPhiRange(trajPos.phi() + thePhiRangeMin, trajPos.phi() + thePhiRangeMax);
00078 
00079 
00080    if(rangesIntersect(trajZRange, detRange.zRange()) &&
00081       rangesIntersect(trajPhiRange, detRange.phiRange(), PhiLess())) {
00082      //     std::cout << "   ConversionBarrelEstimator::estimate( const TrajectoryStateOnSurface& ts, const BoundPlane& plane)  IN RANGE " << std::endl;  
00083     return true;   
00084 
00085 
00086 
00087   } else {
00088 
00089     //    std::cout << "   ConversionBarrelEstimator::estimate( const TrajectoryStateOnSurface& ts, const BoundPlane& plane) NOT IN RANGE " << std::endl;  
00090     return false;
00091 
00092   }
00093 
00094 
00095 }
00096 
00097 
00098 MeasurementEstimator::Local2DVector
00099 ConversionBarrelEstimator::maximalLocalDisplacement( const TrajectoryStateOnSurface& ts,
00100                                                         const BoundPlane& plane) const
00101 {
00102   
00103 
00104   
00105   /* 
00106   if ( ts.hasError() ) {
00107     LocalError le = ts.localError().positionError();
00108     std::cout << "  ConversionBarrelEstimator::maximalLocalDisplacent local error " << sqrt(le.xx()) << " " << sqrt(le.yy()) << " nSigma " << nSigmaCut() << " sqrt(le.xx())*nSigmaCut() " << sqrt(le.xx())*nSigmaCut()  << "  sqrt(le.yy())*nSigmaCut() " <<  sqrt(le.yy())*nSigmaCut() << std::endl;
00109     return Local2DVector( sqrt(le.xx())*nSigmaCut(), sqrt(le.yy())*nSigmaCut());
00110   }
00111 
00112   else return Local2DVector(9999,9999);
00113   */
00114 return Local2DVector(9999,9999);
00115 
00116 }
00117 
00118