File indexing completed on 2024-04-06 12:24:54
0001 #ifndef RecoEgamam_EgammaIsolationAlgos_EGHcalRecHitSelector_h
0002 #define RecoEgamam_EgammaIsolationAlgos_EGHcalRecHitSelector_h
0003
0004 #include "FWCore/Framework/interface/ESHandle.h"
0005 #include "FWCore/Framework/interface/EventSetup.h"
0006 #include "FWCore/Framework/interface/ConsumesCollector.h"
0007 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0008 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0009 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0010 #include "FWCore/Utilities/interface/ESGetToken.h"
0011
0012 #include "Geometry/CaloTopology/interface/CaloTowerConstituentsMap.h"
0013 #include "Geometry/Records/interface/CaloGeometryRecord.h"
0014
0015 #include "DataFormats/EgammaReco/interface/SuperCluster.h"
0016 #include "DataFormats/HcalRecHit/interface/HcalRecHitCollections.h"
0017 #include "DataFormats/EgammaReco/interface/SuperClusterFwd.h"
0018
0019 class EGHcalRecHitSelector {
0020 public:
0021 explicit EGHcalRecHitSelector(const edm::ParameterSet& config, edm::ConsumesCollector);
0022 ~EGHcalRecHitSelector() {}
0023
0024 template <typename CollType>
0025 void addDetIds(const reco::SuperCluster& superClus,
0026 const HBHERecHitCollection& recHits,
0027 CollType& detIdsToStore) const;
0028
0029 void setup(const edm::EventSetup& iSetup) { towerMap_ = iSetup.getHandle(towerMapToken_); }
0030
0031 static edm::ParameterSetDescription makePSetDescription();
0032
0033 private:
0034 static int calDIPhi(int iPhi1, int iPhi2);
0035 static int calDIEta(int iEta1, int iEta2);
0036 float getMinEnergyHCAL_(HcalDetId id) const;
0037
0038 int maxDIEta_;
0039 int maxDIPhi_;
0040 float minEnergyHB_;
0041 float minEnergyHEDepth1_;
0042 float minEnergyHEDefault_;
0043
0044 edm::ESHandle<CaloTowerConstituentsMap> towerMap_;
0045 edm::ESGetToken<CaloTowerConstituentsMap, CaloGeometryRecord> towerMapToken_;
0046 };
0047
0048 template <typename CollType>
0049 void EGHcalRecHitSelector::addDetIds(const reco::SuperCluster& superClus,
0050 const HBHERecHitCollection& recHits,
0051 CollType& detIdsToStore) const {
0052 DetId seedId = superClus.seed()->seed();
0053 if (seedId.det() != DetId::Ecal && seedId.det() != DetId::Forward) {
0054 edm::LogError("EgammaIsoHcalDetIdCollectionProducerError")
0055 << "Somehow the supercluster has a seed which is not ECAL, something is badly wrong";
0056 return;
0057 }
0058
0059
0060 if (seedId.det() == DetId::Forward)
0061 return;
0062
0063 CaloTowerDetId towerId(towerMap_->towerOf(seedId));
0064 int seedHcalIEta = towerId.ieta();
0065 int seedHcalIPhi = towerId.iphi();
0066
0067 for (auto& recHit : recHits) {
0068 int dIEtaAbs = std::abs(calDIEta(seedHcalIEta, recHit.id().ieta()));
0069 int dIPhiAbs = std::abs(calDIPhi(seedHcalIPhi, recHit.id().iphi()));
0070
0071 if (dIEtaAbs <= maxDIEta_ && dIPhiAbs <= maxDIPhi_ && recHit.energy() > getMinEnergyHCAL_(recHit.id()))
0072 detIdsToStore.insert(detIdsToStore.end(), recHit.id().rawId());
0073 }
0074 }
0075
0076 #endif