CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/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::SuperClusterRef 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::SuperClusterRef p, double x, double y)
00059 {
00060    using namespace edm;
00061    using namespace reco;
00062 
00063    /*
00064    if(!recCollection)
00065    {
00066       LogError("TxyCalculator") << "Error! The track container is not found.";
00067       return -100;
00068    }
00069    */
00070    
00071 
00072    double eta1 = p->eta();
00073    double phi1 = p->phi();
00074    
00075    float txy = 0;
00076 
00077    for(reco::TrackCollection::const_iterator
00078           recTrack = recCollection->begin(); recTrack!= recCollection->end(); recTrack++)
00079    {
00080       double pt = recTrack->pt();
00081       double eta2 = recTrack->eta();
00082       double phi2 = recTrack->phi();
00083       
00084       if(dRDistance(eta1,phi1,eta2,phi2) >= 0.1 * x)
00085          continue;
00086 
00087       if(pt > y * 0.4)
00088          txy = txy + 1;
00089    }
00090 
00091    return txy;
00092 }
00093