Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:34:24

0001 #include "RecoEgamma/EgammaTools/interface/HoECalculator.h"
0002 
0003 #include "DataFormats/Common/interface/Handle.h"
0004 #include "Geometry/Records/interface/CaloGeometryRecord.h"
0005 #include "Geometry/CaloGeometry/interface/CaloSubdetectorGeometry.h"
0006 
0007 HoECalculator::HoECalculator() : theCaloGeom_(nullptr) {}
0008 HoECalculator::HoECalculator(const edm::ESHandle<CaloGeometry>& caloGeom) : theCaloGeom_(caloGeom) {}
0009 
0010 double HoECalculator::operator()(const reco::BasicCluster* clus, const edm::Event& e, const edm::EventSetup& c) {
0011   return getHoE(GlobalPoint(clus->x(), clus->y(), clus->z()), clus->energy(), e, c);
0012 }
0013 
0014 double HoECalculator::operator()(const reco::SuperCluster* clus, const edm::Event& e, const edm::EventSetup& c) {
0015   return getHoE(GlobalPoint(clus->x(), clus->y(), clus->z()), clus->energy(), e, c);
0016 }
0017 
0018 /*
0019 double HoECalculator::operator() ( const reco::SuperCluster* clus, 
0020                    HBHERecHitMetaCollection *mhbhe, int ialgo) {
0021   double HoE=0.;
0022   switch (ialgo) {
0023     case 1:
0024       for (reco::CaloCluster_iterator bc=clus->clustersBegin(); bc!=clus->clustersEnd(); bc++) {
0025     double HoEi = getHoE(GlobalPoint((*bc)->x(),(*bc)->y(),(*bc)->z()),clus->energy(), mhbhe);
0026     if (HoEi > HoE) HoE = HoEi;
0027       }
0028       break;
0029     case 2:
0030       HoE = getHoE(GlobalPoint(clus->x(),clus->y(),clus->z()), clus->energy(), mhbhe);
0031       break;
0032     default:
0033       std::cout << "!!! algo for HoE should be 1 or 2 " << std::endl;
0034   } 
0035   return HoE;   
0036 }
0037 
0038 double HoECalculator::operator() ( const reco::BasicCluster* clus, 
0039                  HBHERecHitMetaCollection *mhbhe) {
0040   return getHoE(GlobalPoint(clus->x(),clus->y(),clus->z()), clus->energy(), mhbhe);
0041 }
0042 
0043 */
0044 
0045 double HoECalculator::getHoE(GlobalPoint pclu, float ecalEnergy, const edm::Event& e, const edm::EventSetup& c) {
0046   if (!theCaloGeom_.isValid())
0047     c.get<CaloGeometryRecord>().get(theCaloGeom_);
0048 
0049   //product the geometry
0050   theCaloGeom_.product();
0051 
0052   //Create a HBHERecHitCollection
0053   edm::Handle<HBHERecHitCollection> hbhe;
0054   e.getByLabel("hbhereco", "", hbhe);
0055   const HBHERecHitCollection* hithbhe_ = hbhe.product();
0056 
0057   double HoE = 0.;
0058   const CaloGeometry& geometry = *theCaloGeom_;
0059   const CaloSubdetectorGeometry* geometry_p;
0060   geometry_p = geometry.getSubdetectorGeometry(DetId::Hcal, 4);
0061   DetId hcalDetId;
0062   hcalDetId = geometry_p->getClosestCell(pclu);
0063   double hcalEnergy = 0;
0064 
0065   HBHERecHitCollection::const_iterator iterRecHit;
0066   iterRecHit = hithbhe_->find(hcalDetId);
0067   if (iterRecHit != hithbhe_->end()) {
0068     hcalEnergy = iterRecHit->energy();
0069     HoE = hcalEnergy / ecalEnergy;
0070   }
0071 
0072   return HoE;
0073 }
0074 
0075 /*
0076 double HoECalculator::getHoE(GlobalPoint pos, float energy,
0077                  HBHERecHitMetaCollection *mhbhe) {
0078   
0079   double HoE=0.;
0080   
0081   if (mhbhe) {
0082     const CaloSubdetectorGeometry *geometry_p ; 
0083     geometry_p =  theCaloGeom_->getSubdetectorGeometry (DetId::Hcal,4) ;
0084     HcalDetId dB= geometry_p->getClosestCell(pos);
0085     CaloRecHitMetaCollectionV::const_iterator i=mhbhe->find(dB);
0086     if (i!=mhbhe->end()) {
0087       HoE =  i->energy()/energy;
0088     }
0089   }
0090   return HoE ;
0091 }
0092 */