CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

dRxyCalculator Class Reference

#include <dRxyCalculator.h>

List of all members.

Public Member Functions

 dRxyCalculator (const edm::Event &iEvent, const edm::EventSetup &iSetup, edm::InputTag trackLabel)
double getDRxy (const reco::Photon cluster, double x, double y)

Private Member Functions

double calcDphi (double phi1_, double phi2_)
double dRDistance (double eta1, double phi1, double eta2, double phi2)

Private Attributes

edm::Handle
< reco::TrackCollection
recCollection

Detailed Description

Definition at line 26 of file dRxyCalculator.h.


Constructor & Destructor Documentation

dRxyCalculator::dRxyCalculator ( const edm::Event iEvent,
const edm::EventSetup iSetup,
edm::InputTag  trackLabel 
)

Definition at line 13 of file dRxyCalculator.cc.

References edm::Event::getByLabel().

{
   // Get reconstructed tracks
   iEvent.getByLabel(trackLabel, recCollection); // !!

} 

Member Function Documentation

double dRxyCalculator::calcDphi ( double  phi1_,
double  phi2_ 
) [inline, private]

Definition at line 41 of file dRxyCalculator.h.

References PI.

Referenced by dRDistance().

   {
       double dphi=phi1_-phi2_;

      if (dphi>0){
         while (dphi>2*PI) dphi-=2*PI;
         if (dphi>PI) dphi=2*PI-dphi; 
      } else {
         while (dphi<-2*PI) dphi+=2*PI;
         if (dphi<-PI) dphi=-2*PI-dphi;
      }
      return dphi;
   }
double dRxyCalculator::dRDistance ( double  eta1,
double  phi1,
double  eta2,
double  phi2 
) [inline, private]

Definition at line 33 of file dRxyCalculator.h.

References calcDphi(), and mathSSE::sqrt().

   {
      double deta = eta1 - eta2;
      double dphi = (calcDphi(phi1, phi2));
      
      return sqrt(deta * deta + dphi * dphi);
   }
double dRxyCalculator::getDRxy ( const reco::Photon  cluster,
double  x,
double  y 
)

Definition at line 20 of file dRxyCalculator.cc.

References PFRecoTauDiscriminationAgainstElectronDeadECAL_cfi::dR, reco::LeafCandidate::eta(), reco::LeafCandidate::phi(), L1Trigger_dataformats::reco, python::multivaluedict::sort(), and detailsBasic3DVector::y.

Referenced by HiEgammaIsolationProducer::produce().

{
   using namespace edm;
   using namespace reco;

   double eta1 = p.eta();
   double phi1 = p.phi();

   std::vector<double> Rxy;

   for(reco::TrackCollection::const_iterator
          recTrack = recCollection->begin(); recTrack!= recCollection->end(); recTrack++)
   {
      double pt = recTrack->pt();
      double eta2 = recTrack->eta();
      double phi2 = recTrack->phi();
      
      if(pt < x * 0.4)
         continue;

      double dR = dRDistance(eta1,phi1,eta2,phi2);

      if(Rxy.size() < y+1)
      {  
         Rxy.push_back(dR);
         sort(Rxy.begin(), Rxy.end());
         continue;
      }

      if(dR < Rxy[Rxy.size()-1])
      {  
         Rxy[Rxy.size()-1] = dR;
         sort(Rxy.begin(), Rxy.end());
      }
   }
   
   double rxy = 4;
   if (Rxy.size()<y) rxy=4; else rxy = Rxy[(int)y-1];
   Rxy.clear();
   return rxy;
}

Member Data Documentation

Definition at line 56 of file dRxyCalculator.h.