CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_4_5_patch3/src/Calibration/Tools/plugins/ElectronSqPtTkIsolation.cc

Go to the documentation of this file.
00001 //C++ includes
00002 #include <vector>
00003 #include <functional>
00004 
00005 //ROOT includes
00006 #include <Math/VectorUtil.h>
00007 
00008 //CMSSW includes
00009 #include "Calibration/Tools/plugins/ElectronSqPtTkIsolation.h"
00010 #include "DataFormats/TrackReco/interface/TrackFwd.h"
00011 #include "TrackingTools/PatternTools/interface/Trajectory.h"
00012 #include "TrackingTools/TrajectoryState/interface/TrajectoryStateTransform.h"
00013 #include "DataFormats/GeometryVector/interface/GlobalPoint.h"
00014 #include "DataFormats/GeometryVector/interface/GlobalVector.h"
00015 #include "DataFormats/GsfTrackReco/interface/GsfTrack.h"
00016 
00017 using namespace ROOT::Math::VectorUtil ;
00018 
00019 
00020 ElectronSqPtTkIsolation::ElectronSqPtTkIsolation (double extRadius,
00021                           double intRadius,
00022                           double ptLow,
00023                           double lip,
00024                           const reco::TrackCollection* trackCollection)   :
00025   extRadius_(extRadius),
00026   intRadius_(intRadius),
00027   ptLow_(ptLow),
00028   lip_(lip),
00029   trackCollection_(trackCollection)  
00030 {
00031 }
00032 
00033 ElectronSqPtTkIsolation::~ElectronSqPtTkIsolation ()
00034 {
00035 }
00036 
00037 // unified acces to isolations
00038 std::pair<int,double> ElectronSqPtTkIsolation::getIso(const reco::GsfElectron* electron) const  
00039 {
00040   int counter  =0 ;
00041   double ptSum =0.;
00042   //Take the electron track
00043   reco::GsfTrackRef tmpTrack = electron->gsfTrack() ;
00044   math::XYZVector tmpElectronMomentumAtVtx = (*tmpTrack).momentum () ; 
00045 
00046   for ( reco::TrackCollection::const_iterator itrTr  = (*trackCollection_).begin() ; 
00047                                               itrTr != (*trackCollection_).end()   ; 
00048                                               ++itrTr ) 
00049     {
00050         math::XYZVector tmpTrackMomentumAtVtx = (*itrTr).momentum () ; 
00051         double this_pt  = (*itrTr).pt();
00052         if ( this_pt < ptLow_ ) 
00053           continue ;  
00054         if (fabs( (*itrTr).dz() - (*tmpTrack).dz() ) > lip_ )
00055           continue ;
00056         double dr = DeltaR(tmpTrackMomentumAtVtx,tmpElectronMomentumAtVtx) ;
00057         if ( fabs(dr) < extRadius_ && 
00058              fabs(dr) >= intRadius_ )
00059           {
00060             ++counter ;
00061             ptSum += this_pt*this_pt;    // sum of squared pT
00062           }
00063     }//end loop over tracks                 
00064 
00065   std::pair<int,double> retval;
00066   retval.first  = counter;
00067   retval.second = ptSum;
00068 
00069   return retval;
00070 }
00071 
00072 
00073 int ElectronSqPtTkIsolation::getNumberTracks (const reco::GsfElectron* electron) const
00074 {  
00075   //counter for the tracks in the isolation cone
00076   return getIso(electron).first ;
00077 }
00078 
00079 double ElectronSqPtTkIsolation::getPtTracks (const reco::GsfElectron* electron) const
00080 {
00081   return getIso(electron).second ;
00082 }