CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_10_patch2/src/RecoEgamma/EgammaIsolationAlgos/src/PhotonTkIsolation.cc

Go to the documentation of this file.
00001 //*****************************************************************************
00002 // File:      PhotonTkIsolation.cc
00003 // ----------------------------------------------------------------------------
00004 // OrigAuth:  Matthias Mozer
00005 // Institute: IIHE-VUB
00006 //=============================================================================
00007 //*****************************************************************************
00008 //C++ includes
00009 #include <vector>
00010 #include <functional>
00011 
00012 //ROOT includes
00013 #include <Math/VectorUtil.h>
00014 
00015 //CMSSW includes
00016 #include "RecoEgamma/EgammaIsolationAlgos/interface/PhotonTkIsolation.h"
00017 #include "DataFormats/TrackReco/interface/TrackFwd.h"
00018 #include "TrackingTools/PatternTools/interface/Trajectory.h"
00019 #include "TrackingTools/TrajectoryState/interface/TrajectoryStateTransform.h"
00020 #include "DataFormats/GeometryVector/interface/GlobalPoint.h"
00021 #include "DataFormats/GeometryVector/interface/GlobalVector.h"
00022 #include "DataFormats/RecoCandidate/interface/RecoCandidate.h"
00023 #include "DataFormats/EgammaReco/interface/SuperCluster.h"
00024 #include "DataFormats/EgammaReco/interface/SuperClusterFwd.h"
00025 #include "DataFormats/GsfTrackReco/interface/GsfTrack.h"
00026 #include "DataFormats/VertexReco/interface/Vertex.h"
00027 #include "DataFormats/Candidate/interface/Particle.h"
00028 
00029 using namespace ROOT::Math::VectorUtil;
00030 
00031 
00032 PhotonTkIsolation::PhotonTkIsolation (double extRadius,
00033                                       double intRadiusBarrel,
00034                                       double intRadiusEndcap,
00035                                       double stripBarrel,
00036                                       double stripEndcap,
00037                                       double etLow,
00038                                       double lip,
00039                                       double drb,
00040                                       const reco::TrackCollection* trackCollection,
00041                                       reco::TrackBase::Point beamPoint,
00042                                       const std::string &dzOptionString) :
00043   extRadius_(extRadius),
00044   intRadiusBarrel_(intRadiusBarrel),
00045   intRadiusEndcap_(intRadiusEndcap),
00046   stripBarrel_(stripBarrel),
00047   stripEndcap_(stripEndcap),
00048   etLow_(etLow),
00049   lip_(lip),
00050   drb_(drb),
00051   trackCollection_(trackCollection),
00052   beamPoint_(beamPoint)
00053 {
00054     setDzOption(dzOptionString);
00055 }
00056 
00057 PhotonTkIsolation::~PhotonTkIsolation ()
00058 {
00059 }
00060 
00061 
00062 
00063 // unified acces to isolations
00064 std::pair<int,double> PhotonTkIsolation::getIso(const reco::Candidate* photon ) const  
00065 {
00066   int counter  =0 ;
00067   double ptSum =0.;
00068 
00069 
00070   //Take the photon position
00071   math::XYZVector mom= photon->momentum();
00072   double photonEta = photon->eta();
00073 
00074   //loop over tracks
00075   for(reco::TrackCollection::const_iterator trItr = trackCollection_->begin(); trItr != trackCollection_->end(); ++trItr){
00076 
00077     //check z-distance of vertex 
00078     double dzCut = 0;
00079     switch( dzOption_ ) {
00080         case egammaisolation::EgammaTrackSelector::dz : dzCut = fabs( (*trItr).dz() - photon->vertex().z() ); break;
00081         case egammaisolation::EgammaTrackSelector::vz : dzCut = fabs( (*trItr).vz() - photon->vertex().z() ); break;
00082         case egammaisolation::EgammaTrackSelector::bs : dzCut = fabs( (*trItr).dz(beamPoint_) - photon->vertex().z() ); break;
00083         case egammaisolation::EgammaTrackSelector::vtx: dzCut = fabs( (*trItr).dz(photon->vertex())); break;
00084         default : dzCut = fabs( (*trItr).vz() - photon->vertex().z() ); break;
00085     }
00086     if (dzCut > lip_ ) continue;
00087 
00088     math::XYZVector tmpTrackMomentumAtVtx = (*trItr).momentum () ;
00089     double this_pt  = (*trItr).pt();
00090     if ( this_pt < etLow_ ) continue ;  
00091     if (fabs( (*trItr).dxy(beamPoint_) ) > drb_   ) continue;// only consider tracks from the main vertex 
00092     double dr = ROOT::Math::VectorUtil::DeltaR(tmpTrackMomentumAtVtx,mom) ;
00093     double deta = (*trItr).eta() - photonEta ;
00094     if (fabs(photonEta) < 1.479) {
00095         if(fabs(dr) < extRadius_ && fabs(dr) >= intRadiusBarrel_ && fabs(deta) >= stripBarrel_) 
00096         {
00097             ++counter;
00098             ptSum += this_pt;
00099         }
00100     }
00101     else {
00102         if(fabs(dr) < extRadius_ && fabs(dr) >= intRadiusEndcap_ && fabs(deta) >= stripEndcap_)
00103         {
00104             ++counter;
00105             ptSum += this_pt;
00106         }
00107     }
00108 
00109   }//end loop over tracks
00110 
00111   std::pair<int,double> retval;
00112   retval.first  = counter;
00113   retval.second = ptSum;  
00114   return retval;
00115 }
00116 
00117 int PhotonTkIsolation::getNumberTracks (const reco::Candidate* photon) const
00118 {  
00119   //counter for the tracks in the isolation cone
00120   return getIso(photon).first ;
00121 }
00122 
00123 double PhotonTkIsolation::getPtTracks (const reco::Candidate* photon) const
00124 {
00125   return getIso(photon).second ;
00126 }
00127