CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_7/src/RecoEgamma/EgammaElectronAlgos/src/ForwardMeasurementEstimator.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:    EgammaElectronAlgos
00004 // Class:      ForwardMeasurementEstimator
00005 //
00013 //
00014 // Original Author:  Ursula Berthon, Claude Charlot
00015 //         Created:  Mon Mar 27 13:22:06 CEST 2006
00016 // $Id: ForwardMeasurementEstimator.cc,v 1.22 2012/05/25 15:09:18 muzaffar Exp $
00017 //
00018 //
00019 #include "RecoEgamma/EgammaElectronAlgos/interface/ForwardMeasurementEstimator.h"
00020 #include "RecoEgamma/EgammaElectronAlgos/interface/ElectronUtilities.h"
00021 #include "TrackingTools/TrajectoryParametrization/interface/GlobalTrajectoryParameters.h"
00022 #include "RecoTracker/TkTrackingRegions/interface/GlobalDetRangeRPhi.h"
00023 #include "TrackingTools/DetLayers/interface/rangesIntersect.h"
00024 #include "TrackingTools/DetLayers/interface/PhiLess.h"
00025 #include "TrackingTools/TransientTrackingRecHit/interface/TransientTrackingRecHit.h"
00026 // zero value indicates incompatible ts - hit pair
00027 std::pair<bool,double> ForwardMeasurementEstimator::estimate( const TrajectoryStateOnSurface& ts,
00028                                                               const TransientTrackingRecHit& hit) const {
00029   LocalPoint lp = hit.localPosition();
00030   GlobalPoint gp = hit.det()->surface().toGlobal( lp);
00031   return estimate(ts,gp);
00032 }
00033 
00034 std::pair<bool,double> ForwardMeasurementEstimator::estimate( const TrajectoryStateOnSurface& ts, GlobalPoint &gp) const {
00035 
00036   float tsR = ts.globalParameters().position().perp();
00037   float tsPhi = ts.globalParameters().position().phi();
00038 
00039   float rhPhi = gp.phi();
00040   float rhR = gp.perp();
00041 
00042   float myZ = gp.z();
00043 
00044   float rMin = theRMin;
00045   float rMax = theRMax;
00046   float myPhimin = thePhiMin;
00047   float myPhimax = thePhiMax;
00048 
00049   if(std::abs(myZ)> 70. &&  std::abs(myZ)<170.)
00050     {
00051       rMin = theRMinI;
00052       rMax = theRMaxI;
00053     }
00054 
00055   float phiDiff = tsPhi - rhPhi;
00056   if (phiDiff > pi) phiDiff -= twopi;
00057   if (phiDiff < -pi) phiDiff += twopi;
00058 
00059   float rDiff = tsR - rhR;
00060 
00061   if ( phiDiff < myPhimax && phiDiff > myPhimin &&
00062        rDiff < rMax && rDiff > rMin) {
00063     return std::pair<bool,double>(true,1.);
00064   } else {
00065     return std::pair<bool,double>(false,0.);
00066   }
00067 }
00068 
00069 std::pair<bool,double> ForwardMeasurementEstimator::estimate
00070  ( const GlobalPoint& vprim,
00071    const TrajectoryStateOnSurface& absolute_ts,
00072    GlobalPoint & absolute_gp ) const
00073  {
00074   GlobalVector ts = absolute_ts.globalParameters().position() - vprim ;
00075   GlobalVector gp = absolute_gp - vprim ;
00076 
00077   float tsR = ts.perp();
00078   float tsPhi = ts.phi();
00079 
00080   float rhPhi = gp.phi();
00081   float rhR = gp.perp();
00082 
00083   float myZ = gp.z();
00084 
00085   float rMin = theRMin;
00086   float rMax = theRMax;
00087   float myPhimin = thePhiMin;
00088   float myPhimax = thePhiMax;
00089 
00090   if(std::abs(myZ)> 70. &&  std::abs(myZ)<170.)
00091     {
00092       rMin = theRMinI;
00093       rMax = theRMaxI;
00094     }
00095 
00096   float phiDiff = normalized_phi(rhPhi - tsPhi) ;
00097   float rDiff = rhR - tsR;
00098 
00099   if ( phiDiff < myPhimax && phiDiff > myPhimin && rDiff < rMax && rDiff > rMin)
00100    { return std::pair<bool,double>(true,1.) ; }
00101   else
00102    { return std::pair<bool,double>(false,0.) ; }
00103 }
00104 
00105 bool ForwardMeasurementEstimator::estimate
00106  ( const TrajectoryStateOnSurface & ts,
00107    const BoundPlane & plane ) const
00108  {
00109   typedef std::pair<float,float> Range ;
00110 
00111   GlobalPoint trajPos(ts.globalParameters().position());
00112   GlobalDetRangeRPhi detRange(plane);
00113 
00114   float r1 = 0.;
00115   float r2 = 40.;
00116 
00117   Range trajRRange(trajPos.perp() - r1, trajPos.perp() + r2);
00118   Range trajPhiRange(trajPos.phi() - std::abs(thePhiMin), trajPos.phi() + std::abs(thePhiMax));
00119 
00120   if(rangesIntersect(trajRRange, detRange.rRange()) &&
00121      rangesIntersect(trajPhiRange, detRange.phiRange(), PhiLess()))
00122    { return true ; }
00123   else
00124    { return false ; }
00125 }
00126 
00127 MeasurementEstimator::Local2DVector
00128 ForwardMeasurementEstimator::maximalLocalDisplacement
00129  ( const TrajectoryStateOnSurface & ts,
00130    const BoundPlane & plane) const
00131  {
00132   float nSigmaCut = 3.;
00133   if ( ts.hasError())
00134    {
00135     LocalError le = ts.localError().positionError();
00136     return Local2DVector( sqrt(le.xx())*nSigmaCut, sqrt(le.yy())*nSigmaCut);
00137    }
00138   else
00139     return Local2DVector(999999,999999) ;
00140  }
00141 
00142 
00143