CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch9/src/RecoHI/HiEgammaAlgos/interface/TxyCalculator.h

Go to the documentation of this file.
00001 #ifndef TxyCalculator_h
00002 #define TxyCalculator_h
00003 
00004 #include "FWCore/Framework/interface/Event.h"
00005 #include "FWCore/Framework/interface/EventSetup.h"
00006 #include "FWCore/Framework/interface/ESHandle.h"
00007 
00008 #include "FWCore/Utilities/interface/InputTag.h"
00009 
00010 #include "DataFormats/EgammaReco/interface/BasicClusterFwd.h"
00011 #include "DataFormats/EgammaReco/interface/SuperClusterFwd.h"
00012 
00013 #include "Geometry/CaloGeometry/interface/CaloGeometry.h"
00014 #include "Geometry/Records/interface/IdealGeometryRecord.h"
00015 #include "RecoCaloTools/MetaCollections/interface/CaloRecHitMetaCollections.h"
00016 
00017 #include "DataFormats/Candidate/interface/CandidateFwd.h"
00018 #include "DataFormats/Candidate/interface/Candidate.h"
00019 
00020 #include "DataFormats/TrackReco/interface/Track.h"
00021 #include "DataFormats/TrackReco/interface/TrackFwd.h"
00022 
00023 #define PI 3.141592653
00024 
00025 class TxyCalculator
00026 {
00027 public:  
00028    TxyCalculator(const edm::Event &iEvent, const edm::EventSetup &iSetup, edm::InputTag trackLabel);
00029    double getTxy(const reco::SuperClusterRef p, double x, double y);
00030    int getNumAllTracks(double ptCut);
00031    int getNumLocalTracks(const reco::SuperClusterRef p, double detaCut, double ptCut);
00032    
00033 private:
00034 
00035    double dRDistance(double eta1,double phi1,double eta2,double phi2)
00036    {
00037       double deta = eta1 - eta2;
00038       double dphi = (calcDphi(phi1, phi2));
00039       
00040       return sqrt(deta * deta + dphi * dphi);
00041    }
00042 
00043    double calcDphi(double phi1_,double phi2_)
00044    {
00045        double dphi=phi1_-phi2_;
00046 
00047       if (dphi>0){
00048          while (dphi>2*PI) dphi-=2*PI;
00049          if (dphi>PI) dphi=2*PI-dphi; 
00050       } else {
00051          while (dphi<-2*PI) dphi+=2*PI;
00052          if (dphi<-PI) dphi=-2*PI-dphi;
00053       }
00054       return dphi;
00055    }
00056 
00057 private:
00058    edm::Handle<reco::TrackCollection>  recCollection;
00059 };
00060 
00061 #endif
00062