00001 #include "RecoEgamma/EgammaTools/interface/HoECalculator.h"
00002
00003 #include "DataFormats/Common/interface/Handle.h"
00004 #include "Geometry/Records/interface/CaloGeometryRecord.h"
00005 #include "Geometry/CaloGeometry/interface/CaloSubdetectorGeometry.h"
00006 #include "RecoCaloTools/MetaCollections/interface/CaloRecHitMetaCollection.h"
00007
00008 HoECalculator::HoECalculator () :
00009 theCaloGeom_(0)
00010 {
00011 }
00012 HoECalculator::HoECalculator (const edm::ESHandle<CaloGeometry> &caloGeom) :
00013 theCaloGeom_(caloGeom)
00014 {
00015 }
00016
00017 double HoECalculator::operator() ( const reco::BasicCluster* clus , const edm::Event& e , const edm::EventSetup& c)
00018 {
00019 return getHoE(GlobalPoint(clus->x(),clus->y(),clus->z()), clus->energy(), e,c);
00020 }
00021
00022 double HoECalculator::operator() ( const reco::SuperCluster* clus , const edm::Event& e , const edm::EventSetup& c)
00023 {
00024 return getHoE(GlobalPoint(clus->x(),clus->y(),clus->z()), clus->energy(), e,c);
00025 }
00026
00027 double HoECalculator::operator() ( const reco::SuperCluster* clus,
00028 HBHERecHitMetaCollection *mhbhe) {
00029
00030 float HoEmax = 0.;
00031 for (reco::BasicClusterRefVector::iterator bc=clus->clustersBegin(); bc!=clus->clustersEnd(); bc++) {
00032 float HoE = getHoE(GlobalPoint((*bc)->x(),(*bc)->y(),(*bc)->z()),clus->energy(), mhbhe);
00033 if (HoE > HoEmax) HoEmax = HoE;
00034 }
00035 return HoEmax;
00036 }
00037
00038
00039 double HoECalculator::operator() ( const reco::BasicCluster* clus,
00040 HBHERecHitMetaCollection *mhbhe) {
00041 return getHoE(GlobalPoint(clus->x(),clus->y(),clus->z()), clus->energy(), mhbhe);
00042 }
00043
00044 double HoECalculator::getHoE(GlobalPoint pclu, float ecalEnergy, const edm::Event& e , const edm::EventSetup& c )
00045 {
00046 if ( !theCaloGeom_.isValid() )
00047 c.get<CaloGeometryRecord>().get(theCaloGeom_) ;
00048
00049
00050 theCaloGeom_.product() ;
00051
00052
00053 edm::Handle< HBHERecHitCollection > hbhe ;
00054 e.getByLabel("hbhereco","",hbhe);
00055 const HBHERecHitCollection* hithbhe_ = hbhe.product();
00056
00057 double HoE=0.;
00058 const CaloGeometry& geometry = *theCaloGeom_ ;
00059 const CaloSubdetectorGeometry *geometry_p ;
00060 geometry_p = geometry.getSubdetectorGeometry (DetId::Hcal,4) ;
00061 DetId hcalDetId ;
00062 hcalDetId = geometry_p->getClosestCell(pclu) ;
00063 double hcalEnergy = 0 ;
00064 CaloRecHitMetaCollection f;
00065 f.add(hithbhe_);
00066 CaloRecHitMetaCollection::const_iterator iterRecHit ;
00067 iterRecHit = f.find(hcalDetId) ;
00068 if (iterRecHit!=f.end()) {
00069 hcalEnergy = iterRecHit->energy() ;
00070 HoE = hcalEnergy/ecalEnergy ;
00071 }
00072
00073 return HoE ;
00074 }
00075
00076 double HoECalculator::getHoE(GlobalPoint pos, float energy,
00077 HBHERecHitMetaCollection *mhbhe) {
00078
00079 double HoE=0.;
00080
00081 if (mhbhe) {
00082 const CaloSubdetectorGeometry *geometry_p ;
00083 geometry_p = theCaloGeom_->getSubdetectorGeometry (DetId::Hcal,4) ;
00084 HcalDetId dB= geometry_p->getClosestCell(pos);
00085 CaloRecHitMetaCollectionV::const_iterator i=mhbhe->find(dB);
00086 if (i!=mhbhe->end()) {
00087 HoE = i->energy()/energy;
00088 }
00089 }
00090 return HoE ;
00091
00092 }