Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-07-15 08:47:52

0001 #include "RecoEgamma/EgammaElectronAlgos/interface/ElectronHcalHelper.h"
0002 #include "Geometry/Records/interface/CaloGeometryRecord.h"
0003 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0004 #include "FWCore/Framework/interface/ConsumesCollector.h"
0005 
0006 using namespace reco;
0007 
0008 ElectronHcalHelper::ElectronHcalHelper(const Configuration& cfg, edm::ConsumesCollector&& cc) : cfg_(cfg) {
0009   if (cfg_.hOverEConeSize == 0. and !cfg_.onlyBehindCluster) {
0010     return;
0011   }
0012 
0013   caloGeometryToken_ = cc.esConsumes();
0014   hcalTopologyToken_ = cc.esConsumes();
0015   hcalChannelQualityToken_ = cc.esConsumes(edm::ESInputTag("", "withTopo"));
0016   hcalSevLvlComputerToken_ = cc.esConsumes();
0017   towerMapToken_ = cc.esConsumes();
0018 }
0019 
0020 void ElectronHcalHelper::beginEvent(const edm::Event& evt, const edm::EventSetup& eventSetup) {
0021   if (cfg_.hOverEConeSize == 0. and !cfg_.onlyBehindCluster) {
0022     return;
0023   }
0024 
0025   hcalTopology_ = &eventSetup.getData(hcalTopologyToken_);
0026   hcalChannelQuality_ = &eventSetup.getData(hcalChannelQualityToken_);
0027   hcalSevLvlComputer_ = &eventSetup.getData(hcalSevLvlComputerToken_);
0028   towerMap_ = &eventSetup.getData(towerMapToken_);
0029 
0030   if (cfg_.onlyBehindCluster) {
0031     hcalIso_ = std::make_unique<EgammaHcalIsolation>(EgammaHcalIsolation::InclusionRule::isBehindClusterSeed,
0032                                                      0.,
0033                                                      EgammaHcalIsolation::InclusionRule::withinConeAroundCluster,
0034                                                      0.,
0035                                                      cfg_.eThresHB,
0036                                                      EgammaHcalIsolation::arrayHB{{0., 0., 0., 0.}},
0037                                                      cfg_.maxSeverityHB,
0038                                                      cfg_.eThresHE,
0039                                                      EgammaHcalIsolation::arrayHE{{0., 0., 0., 0., 0., 0., 0.}},
0040                                                      cfg_.maxSeverityHE,
0041                                                      evt.get(cfg_.hbheRecHits),
0042                                                      eventSetup.getHandle(caloGeometryToken_),
0043                                                      eventSetup.getHandle(hcalTopologyToken_),
0044                                                      eventSetup.getHandle(hcalChannelQualityToken_),
0045                                                      eventSetup.getHandle(hcalSevLvlComputerToken_),
0046                                                      towerMap_);
0047   } else {
0048     hcalIso_ = std::make_unique<EgammaHcalIsolation>(EgammaHcalIsolation::InclusionRule::withinConeAroundCluster,
0049                                                      cfg_.hOverEConeSize,
0050                                                      EgammaHcalIsolation::InclusionRule::withinConeAroundCluster,
0051                                                      0.,
0052                                                      cfg_.eThresHB,
0053                                                      EgammaHcalIsolation::arrayHB{{0., 0., 0., 0.}},
0054                                                      cfg_.maxSeverityHB,
0055                                                      cfg_.eThresHE,
0056                                                      EgammaHcalIsolation::arrayHE{{0., 0., 0., 0., 0., 0., 0.}},
0057                                                      cfg_.maxSeverityHE,
0058                                                      evt.get(cfg_.hbheRecHits),
0059                                                      eventSetup.getHandle(caloGeometryToken_),
0060                                                      eventSetup.getHandle(hcalTopologyToken_),
0061                                                      eventSetup.getHandle(hcalChannelQualityToken_),
0062                                                      eventSetup.getHandle(hcalSevLvlComputerToken_),
0063                                                      towerMap_);
0064   }
0065 }
0066 
0067 bool ElectronHcalHelper::hasActiveHcal(const reco::SuperCluster& sc) const {
0068   return (cfg_.checkHcalStatus)
0069              ? egamma::hasActiveHcal(hcalTowersBehindClusters(sc), *towerMap_, *hcalChannelQuality_, *hcalTopology_)
0070              : true;
0071 }
0072 
0073 double ElectronHcalHelper::hcalESum(const SuperCluster& sc, int depth) const {
0074   return (cfg_.onlyBehindCluster)     ? hcalIso_->getHcalESumBc(&sc, depth)
0075          : (cfg_.hOverEConeSize > 0.) ? hcalIso_->getHcalESum(&sc, depth)
0076                                       : 0.;
0077 }