CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_1/src/RecoHI/HiEgammaAlgos/src/dRxyCalculator.cc

Go to the documentation of this file.
00001 #include "RecoHI/HiEgammaAlgos/interface/dRxyCalculator.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 dRxyCalculator::dRxyCalculator(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 double dRxyCalculator::getDRxy(const reco::Photon p, double x, double y)
00022 {
00023    using namespace edm;
00024    using namespace reco;
00025 
00026    double eta1 = p.eta();
00027    double phi1 = p.phi();
00028 
00029    std::vector<double> Rxy;
00030 
00031    for(reco::TrackCollection::const_iterator
00032           recTrack = recCollection->begin(); recTrack!= recCollection->end(); recTrack++)
00033    {
00034       double pt = recTrack->pt();
00035       double eta2 = recTrack->eta();
00036       double phi2 = recTrack->phi();
00037       
00038       if(pt < x * 0.4)
00039          continue;
00040 
00041       double dR = dRDistance(eta1,phi1,eta2,phi2);
00042 
00043       if(Rxy.size() < y+1)
00044       {  
00045          Rxy.push_back(dR);
00046          sort(Rxy.begin(), Rxy.end());
00047          continue;
00048       }
00049 
00050       if(dR < Rxy[Rxy.size()-1])
00051       {  
00052          Rxy[Rxy.size()-1] = dR;
00053          sort(Rxy.begin(), Rxy.end());
00054       }
00055    }
00056    
00057    double rxy = 4;
00058    if (Rxy.size()<y) rxy=4; else rxy = Rxy[(int)y-1];
00059    Rxy.clear();
00060    return rxy;
00061 }
00062