CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_2_9/src/RecoEgamma/EgammaElectronAlgos/src/BarrelMeasurementEstimator.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:    EgammaElectronAlgos
00004 // Class:      BarrelMeasurementEstimator
00005 //
00013 //
00014 // Original Author:  Ursula Berthon, Claude Charlot
00015 //         Created:  Mon Mar 27 13:22:06 CEST 2006
00016 // $Id: BarrelMeasurementEstimator.cc,v 1.20 2010/09/21 17:06:14 chamont Exp $
00017 //
00018 //
00019 
00020 #include "RecoEgamma/EgammaElectronAlgos/interface/BarrelMeasurementEstimator.h"
00021 #include "RecoEgamma/EgammaElectronAlgos/interface/ElectronUtilities.h"
00022 #include "RecoTracker/TkTrackingRegions/interface/GlobalDetRangeZPhi.h"
00023 #include "TrackingTools/TrajectoryParametrization/interface/GlobalTrajectoryParameters.h"
00024 #include "TrackingTools/DetLayers/interface/rangesIntersect.h"
00025 #include "TrackingTools/DetLayers/interface/PhiLess.h"
00026 
00027 
00028 // zero value indicates incompatible ts - hit pair
00029 std::pair<bool,double> BarrelMeasurementEstimator::estimate( const TrajectoryStateOnSurface& ts,
00030                                                              const TransientTrackingRecHit& hit) const {
00031   LocalPoint lp = hit.localPosition();
00032   GlobalPoint gp = hit.det()->surface().toGlobal( lp);
00033   return this->estimate(ts,gp);
00034 }
00035 
00036 //usable in case we have no TransientTrackingRecHit
00037 std::pair<bool,double> BarrelMeasurementEstimator::estimate( const TrajectoryStateOnSurface& ts,
00038                                            GlobalPoint &gp) const {
00039   float tsPhi = ts.globalParameters().position().phi();
00040   float myR = gp.perp();
00041   float myZ = gp.z();
00042 
00043   float myZmax =  theZMax;
00044   float myZmin =  theZMin;
00045 
00046   if(std::abs(myZ)<30. && myR>8.)
00047     {
00048       myZmax = 0.09;
00049       myZmin = -0.09;
00050     }
00051 
00052   float rhPhi = gp.phi();
00053 
00054   float zDiff = ts.globalParameters().position().z() - gp.z();
00055   float phiDiff = tsPhi - rhPhi;
00056   if (phiDiff > pi) phiDiff -= twopi;
00057   if (phiDiff < -pi) phiDiff += twopi;
00058 
00059 
00060 
00061 
00062   if ( phiDiff < thePhiMax && phiDiff > thePhiMin &&
00063        zDiff < myZmax && zDiff > myZmin) {
00064 
00065     return std::pair<bool,double>(true,1.);
00066      } else {
00067 
00068     return std::pair<bool,double>(false,0.);
00069     }
00070 }
00071 
00072 
00073 std::pair<bool,double> BarrelMeasurementEstimator::estimate
00074  ( const GlobalPoint & vprim,
00075    const TrajectoryStateOnSurface & absolute_ts,
00076    GlobalPoint& absolute_gp ) const
00077  {
00078   GlobalVector ts = absolute_ts.globalParameters().position() - vprim ;
00079   GlobalVector gp = absolute_gp - vprim ;
00080 
00081   float tsPhi = ts.phi();
00082   float myR = gp.perp();
00083   float myZ = gp.z();
00084 
00085   float myZmax =  theZMax;
00086   float myZmin =  theZMin;
00087 
00088   if(std::abs(myZ)<30. && myR>8.)
00089     {
00090       myZmax = 0.09;
00091       myZmin = -0.09;
00092     }
00093 
00094   float rhPhi = gp.phi() ;
00095   float zDiff = gp.z()-ts.z() ;
00096   float phiDiff = normalized_phi(rhPhi-tsPhi) ;
00097 
00098   if ( phiDiff < thePhiMax && phiDiff > thePhiMin && zDiff < myZmax && zDiff > myZmin)
00099    { return std::pair<bool,double>(true,1.) ; }
00100   else
00101    { return std::pair<bool,double>(false,0.) ; }
00102  }
00103 
00104 bool BarrelMeasurementEstimator::estimate
00105  ( const TrajectoryStateOnSurface & ts,
00106    const BoundPlane& plane) const
00107  {
00108   typedef std::pair<float,float> Range;
00109 
00110 
00111   GlobalPoint trajPos(ts.globalParameters().position());
00112   GlobalDetRangeZPhi detRange(plane);
00113 
00114   Range trajZRange(trajPos.z() - std::abs(theZMin), trajPos.z() + std::abs(theZMax));
00115   Range trajPhiRange(trajPos.phi() - std::abs(thePhiMin), trajPos.phi() + std::abs(thePhiMax));
00116 
00117   if(rangesIntersect(trajZRange, detRange.zRange()) &&
00118      rangesIntersect(trajPhiRange, detRange.phiRange(), PhiLess()))
00119    {
00120     return true;
00121    }
00122   else
00123    {
00124     //     cout <<cout<<" barrel boundpl est returns false!!"<<endl;
00125     //     cout<<"BarrelMeasurementEstimator(estimate) :thePhiMin,thePhiMax, theZMin,theZMax "<<thePhiMin<<" "<<thePhiMax<<" "<< theZMin<<" "<<theZMax<<endl;
00126     //     cout<<" trajZRange "<<trajZRange.first<<" "<<trajZRange.second<<endl;
00127     //     cout<<" trajPhiRange "<<trajPhiRange.first<<" "<<trajPhiRange.second<<endl;
00128     //     cout<<" detZRange "<<detRange.zRange().first<<" "<<detRange.zRange().second<<endl;
00129     //     cout<<" detPhiRange "<<detRange.phiRange().first<<" "<<detRange.phiRange().second<<endl;
00130     //     cout<<" intersect z: "<<rangesIntersect(trajZRange, detRange.zRange())<<endl;
00131     //     cout<<" intersect phi: "<<rangesIntersect(trajPhiRange, detRange.phiRange(), PhiLess())<<endl;
00132     return false ;
00133    }
00134 
00135  }
00136 
00137 MeasurementEstimator::Local2DVector
00138 BarrelMeasurementEstimator::maximalLocalDisplacement
00139  ( const TrajectoryStateOnSurface & ts,
00140    const BoundPlane & plane) const
00141  {
00142   float nSigmaCut = 3. ;
00143   if ( ts.hasError())
00144    {
00145     LocalError le = ts.localError().positionError() ;
00146     return Local2DVector( sqrt(le.xx())*nSigmaCut, sqrt(le.yy())*nSigmaCut) ;
00147    }
00148   else return Local2DVector(99999,99999) ;
00149  }
00150 
00151 
00152