CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_4_5_patch3/src/RecoHI/HiEgammaAlgos/src/TxyCalculator.cc

Go to the documentation of this file.
00001 #include "RecoHI/HiEgammaAlgos/interface/TxyCalculator.h"
00002 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00003 #include "Geometry/Records/interface/IdealGeometryRecord.h"
00004 #include "Geometry/CaloGeometry/interface/CaloSubdetectorGeometry.h"
00005 #include "DataFormats/Common/interface/Handle.h"
00006 #include "DataFormats/EgammaReco/interface/BasicCluster.h"
00007 #include "DataFormats/EgammaReco/interface/SuperCluster.h"
00008 #include "DataFormats/Candidate/interface/Candidate.h"
00009 #include "DataFormats/PatCandidates/interface/Photon.h"
00010 
00011 using namespace edm;
00012 using namespace reco;
00013 
00014 TxyCalculator::TxyCalculator(const edm::Event &iEvent, const edm::EventSetup &iSetup, edm::InputTag trackLabel)
00015 { 
00016    // Get reconstructed tracks
00017    iEvent.getByLabel(trackLabel, recCollection); // !!
00018 } 
00019 
00020 
00021 int TxyCalculator::getNumAllTracks(double ptCut)
00022 {
00023   using namespace edm;
00024   using namespace reco;
00025 
00026   int nTracks = 0;
00027   
00028   for(reco::TrackCollection::const_iterator
00029         recTrack = recCollection->begin(); recTrack!= recCollection->end(); recTrack++)
00030     {
00031       double pt = recTrack->pt();
00032       if ( pt > ptCut)  
00033         nTracks = nTracks +1;
00034     }
00035   return nTracks;
00036 }
00037 
00038 
00039 int TxyCalculator::getNumLocalTracks(const reco::Photon p, double detaCut, double ptCut)
00040 {
00041   using namespace edm;
00042   using namespace reco;
00043 
00044   int nTracks = 0;
00045 
00046   double eta1 = p.eta();
00047   double phi1 = p.phi();
00048 
00049   for(reco::TrackCollection::const_iterator
00050         recTrack = recCollection->begin(); recTrack!= recCollection->end(); recTrack++)
00051     {
00052       double pt = recTrack->pt();
00053       if ( (pt > ptCut) && ( fabs(eta1 - recTrack->eta()) < detaCut) && ( fabs(calcDphi(recTrack->phi(),phi1)) < 3.141592/2. ) )
00054         nTracks= nTracks +1;
00055     }
00056   return nTracks;
00057 }
00058 
00059 double TxyCalculator::getTxy(const reco::Photon p, double x, double y)
00060 {
00061    using namespace edm;
00062    using namespace reco;
00063 
00064    //   if(!recCollection)
00065    //    {
00066    //    LogError("TxyCalculator") << "Error! The track container is not found.";
00067    //    return -100;
00068    //   }
00069    
00070 
00071    double eta1 = p.eta();
00072    double phi1 = p.phi();
00073    
00074    float txy = 0;
00075 
00076    for(reco::TrackCollection::const_iterator
00077           recTrack = recCollection->begin(); recTrack!= recCollection->end(); recTrack++)
00078    {
00079       double pt = recTrack->pt();
00080       double eta2 = recTrack->eta();
00081       double phi2 = recTrack->phi();
00082       
00083       if(dRDistance(eta1,phi1,eta2,phi2) >= 0.1 * x)
00084          continue;
00085 
00086       if(pt > y * 0.4)
00087          txy = txy + 1;
00088    }
00089 
00090    return txy;
00091 }
00092 
00093 double TxyCalculator::getHollSxy(const reco::Photon p, double thePtCut, double outerR, double innerR)
00094 {
00095    using namespace edm;
00096    using namespace reco;
00097    
00098    double eta1 = p.eta();
00099    double phi1 = p.phi();
00100 
00101    double ptSum = 0;
00102 
00103    for(reco::TrackCollection::const_iterator
00104           recTrack = recCollection->begin(); recTrack!= recCollection->end(); recTrack++)
00105       {
00106          double pt = recTrack->pt();
00107          double eta2 = recTrack->eta();
00108          double phi2 = recTrack->phi();
00109          if (dRDistance(eta1,phi1,eta2,phi2) >= outerR)
00110             continue;
00111          if (dRDistance(eta1,phi1,eta2,phi2) <= innerR)
00112             continue;
00113          if(pt > thePtCut)
00114             ptSum = ptSum + pt;
00115       }
00116    
00117    return ptSum;
00118 }