CMS 3D CMS Logo

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

Go to the documentation of this file.
00001 #include "RecoHI/HiEgammaAlgos/interface/RxCalculator.h"
00002 
00003 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00004 
00005 #include "Geometry/Records/interface/IdealGeometryRecord.h"
00006 #include "Geometry/Records/interface/CaloGeometryRecord.h"
00007 #include "Geometry/CaloGeometry/interface/CaloSubdetectorGeometry.h"
00008 
00009 #include "DataFormats/Common/interface/Handle.h"
00010 #include "DataFormats/EgammaReco/interface/BasicCluster.h"
00011 #include "DataFormats/EgammaReco/interface/SuperCluster.h"
00012 
00013 
00014 using namespace edm;
00015 using namespace reco;
00016 
00017 #define PI 3.141592653589793238462643383279502884197169399375105820974945
00018 
00019 
00020 RxCalculator::RxCalculator (const edm::Event &iEvent, const edm::EventSetup &iSetup, edm::InputTag hbheLabel, edm::InputTag hfLabel, edm::InputTag hoLabel)
00021 {
00022    Handle<HFRecHitCollection> hfhandle;
00023    iEvent.getByLabel(hfLabel, hfhandle);
00024    if(hfhandle.isValid())
00025      fHFRecHits_ = hfhandle.product();
00026    else 
00027      fHFRecHits_ = NULL;
00028 
00029    Handle<HORecHitCollection> hohandle;
00030    iEvent.getByLabel(hoLabel, hohandle);
00031    if(hohandle.isValid())
00032      fHORecHits_ = hohandle.product();
00033    else
00034      fHORecHits_ = NULL;
00035 
00036    Handle<HBHERecHitCollection> hehbhandle;
00037    iEvent.getByLabel(hbheLabel, hehbhandle);
00038    if(hehbhandle.isValid())
00039      fHBHERecHits_ = hehbhandle.product();
00040    else 
00041      fHBHERecHits_ = NULL;
00042 
00043    ESHandle<CaloGeometry> geometryHandle;
00044    iSetup.get<CaloGeometryRecord>().get(geometryHandle);
00045    if(geometryHandle.isValid())
00046      geometry_ = geometryHandle.product();
00047    else 
00048      geometry_ = NULL;
00049 
00050 } 
00051 
00052 
00053 double RxCalculator::getRx(const reco::SuperClusterRef cluster, double x, double threshold, double innerR )
00054 {
00055    using namespace edm;
00056    using namespace reco;
00057 
00058    if(!fHBHERecHits_) {       
00059 //      LogError("RxCalculator") << "Error! Can't get HBHERecHits for event.";
00060      return -100;
00061    }
00062 
00063    double SClusterEta = cluster->eta();
00064    double SClusterPhi = cluster->phi();
00065    double TotalEt = 0;
00066 
00067    for(size_t index = 0; index < fHBHERecHits_->size(); index++) {
00068       const HBHERecHit &rechit = (*fHBHERecHits_)[index];
00069       const DetId &detid = rechit.id();
00070       const GlobalPoint& hitpoint = geometry_->getPosition(detid);
00071       double eta = hitpoint.eta();
00072       double phi = hitpoint.phi();
00073       double dEta = fabs(eta-SClusterEta);
00074       double dPhi = fabs(phi-SClusterPhi);
00075       while (dPhi>2*PI) dPhi-=2*PI;
00076       if (dPhi>PI) dPhi=2*PI-dPhi;
00077 
00078       if (dPhi>PI) dPhi=2*PI-dPhi;
00079 
00080       double dR = sqrt(dEta * dEta + dPhi * dPhi);
00081       // veto inner cone///////////////
00082       if ( dR < innerR )  continue;
00084       if (dR<x*0.1) {
00085          double et = rechit.energy()/cosh(eta);
00086          if (et<threshold) et=0;
00087          TotalEt += et;
00088       }
00089    }
00090 
00091    return TotalEt;
00092 }
00093 
00094 double RxCalculator::getROx(const reco::SuperClusterRef cluster, double x,double threshold)
00095 {
00096    using namespace edm;
00097    using namespace reco;
00098 
00099    if(!fHORecHits_) {       
00100 //       LogError("RxCalculator") << "Error! Can't get HORecHits for event.";
00101       return -100;
00102    }
00103 
00104    double SClusterEta = cluster->eta();
00105    double SClusterPhi = cluster->phi();
00106    double TotalEt = 0;
00107 
00108    for(size_t index = 0; index < fHORecHits_->size(); index++) {
00109       const HORecHit &rechit = (*fHORecHits_)[index];
00110       const DetId &detid = rechit.id();
00111       const GlobalPoint& hitpoint = geometry_->getPosition(detid);
00112       double eta = hitpoint.eta();
00113       double phi = hitpoint.phi();
00114       double dEta = fabs(eta-SClusterEta);
00115       double dPhi = fabs(phi-SClusterPhi);
00116       while (dPhi>2*PI) dPhi-=2*PI;
00117       if (dPhi>PI) dPhi=2*PI-dPhi;
00118 
00119       double dR = sqrt(dEta * dEta + dPhi * dPhi);
00120       if (dR<x*0.1) {
00121          double et = rechit.energy()/cosh(eta);
00122          if (et<threshold) et=0;
00123          TotalEt += et;
00124       }
00125    }
00126    return TotalEt;
00127 }
00128 
00129 double RxCalculator::getRFx(const reco::SuperClusterRef cluster, double x, double threshold)
00130 {
00131    using namespace edm;
00132    using namespace reco;
00133 
00134    if(!fHFRecHits_) {       
00135       LogError("RxCalculator") << "Error! Can't get HFRecHits for event.";
00136       return -100;
00137    }
00138 
00139    double SClusterEta = cluster->eta();
00140    double SClusterPhi = cluster->phi();
00141    double TotalEt = 0;
00142 
00143    for(size_t index = 0; index < fHFRecHits_->size(); index++) {
00144       const HFRecHit &rechit = (*fHFRecHits_)[index];
00145       const DetId &detid = rechit.id();
00146       const GlobalPoint& hitpoint = geometry_->getPosition(detid);
00147       double eta = hitpoint.eta();
00148       double phi = hitpoint.phi();
00149       double dEta = fabs(eta-SClusterEta);
00150       double dPhi = fabs(phi-SClusterPhi);
00151       while (dPhi>2*PI) dPhi-=2*PI;
00152       if (dPhi>PI) dPhi=2*PI-dPhi;
00153 
00154 
00155       double dR = sqrt(dEta * dEta + dPhi * dPhi);
00156       if (dR<x*0.1) {
00157          double et = rechit.energy()/cosh(eta);
00158          if (et<threshold) et=0;
00159          TotalEt += et;
00160       }
00161    }
00162 
00163 
00164 
00165    return TotalEt;
00166 }
00167 
00168 
00169 double RxCalculator::getCRx(const reco::SuperClusterRef cluster, double x, double threshold, double innerR )
00170 {
00171    using namespace edm;
00172    using namespace reco;
00173 
00174 
00175    if(!fHBHERecHits_) {       
00176 //       LogError("RxCalculator") << "Error! Can't get HBHERecHits for event.";
00177       return -100;
00178    }
00179 
00180    double SClusterEta = cluster->eta();
00181    double SClusterPhi = cluster->phi();
00182    double TotalEt = 0;
00183 
00184    for(size_t index = 0; index < fHBHERecHits_->size(); index++) {
00185       const HBHERecHit &rechit = (*fHBHERecHits_)[index];
00186       const DetId &detid = rechit.id();
00187       const GlobalPoint& hitpoint = geometry_->getPosition(detid);
00188       double eta = hitpoint.eta();
00189       double phi = hitpoint.phi();
00190       double dEta = fabs(eta-SClusterEta);
00191       double dPhi = fabs(phi-SClusterPhi);
00192       while (dPhi>2*PI) dPhi-=2*PI;
00193       if (dPhi>PI) dPhi=2*PI-dPhi;
00194 
00195       if (dEta<x*0.1) {
00196          double et = rechit.energy()/cosh(eta);
00197          if (et<threshold) et=0;
00198          TotalEt += et;
00199       }
00200    }
00201    
00202    double Rx = getRx(cluster,x,threshold,innerR);
00203    double CRx = Rx - TotalEt * (0.01*x*x - innerR*innerR) / (2 * 2 * 0.1 * x) ;
00204    
00205    return CRx;
00206 }