CMS 3D CMS Logo

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