Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:24:54

0001 #ifndef EgammaIsolationAlgos_EgammaHcalIsolation_h
0002 #define EgammaIsolationAlgos_EgammaHcalIsolation_h
0003 //*****************************************************************************
0004 // File:      EgammaHcalIsolation.h
0005 // ----------------------------------------------------------------------------
0006 // OrigAuth:  Matthias Mozer
0007 // Institute: IIHE-VUB
0008 //=============================================================================
0009 //*****************************************************************************
0010 
0011 //C++ includes
0012 #include <array>
0013 
0014 //CMSSW includes
0015 #include "FWCore/Framework/interface/ESHandle.h"
0016 #include "DataFormats/RecoCandidate/interface/RecoCandidate.h"
0017 #include "Geometry/CaloGeometry/interface/CaloGeometry.h"
0018 #include "DataFormats/GeometryVector/interface/GlobalPoint.h"
0019 #include "DataFormats/GeometryVector/interface/GlobalVector.h"
0020 
0021 #include "DataFormats/EgammaReco/interface/SuperCluster.h"
0022 #include "DataFormats/EgammaReco/interface/SuperClusterFwd.h"
0023 
0024 #include "DataFormats/HcalRecHit/interface/HcalRecHitCollections.h"
0025 #include "Geometry/CaloTopology/interface/HcalTopology.h"
0026 #include "RecoLocalCalo/HcalRecAlgos/interface/HcalSeverityLevelComputer.h"
0027 #include "RecoLocalCalo/HcalRecAlgos/interface/HcalSeverityLevelComputerRcd.h"
0028 #include "CondFormats/DataRecord/interface/HcalPFCutsRcd.h"
0029 #include "CondTools/Hcal/interface/HcalPFCutsHandler.h"
0030 #include "CondFormats/HcalObjects/interface/HcalChannelQuality.h"
0031 #include "CondFormats/DataRecord/interface/HcalChannelQualityRcd.h"
0032 
0033 #include "Geometry/CaloTopology/interface/CaloTowerConstituentsMap.h"
0034 #include "RecoEgamma/EgammaIsolationAlgos/interface/EgammaHadTower.h"
0035 
0036 // sum helper functions
0037 double scaleToE(const double &eta);
0038 double scaleToEt(const double &eta);
0039 
0040 class EgammaHcalIsolation {
0041 public:
0042   enum class InclusionRule : int { withinConeAroundCluster = 0, isBehindClusterSeed = 1 };
0043   using arrayHB = std::array<double, 4>;
0044   using arrayHE = std::array<double, 7>;
0045 
0046   // constructors
0047   EgammaHcalIsolation(InclusionRule extIncRule,
0048                       double extRadius,
0049                       InclusionRule intIncRule,
0050                       double intRadius,
0051                       const arrayHB &eThresHB,
0052                       const arrayHB &etThresHB,
0053                       int maxSeverityHB,
0054                       const arrayHE &eThresHE,
0055                       const arrayHE &etThresHE,
0056                       int maxSeverityHE,
0057                       const HBHERecHitCollection &mhbhe,
0058                       edm::ESHandle<CaloGeometry> caloGeometry,
0059                       edm::ESHandle<HcalTopology> hcalTopology,
0060                       edm::ESHandle<HcalChannelQuality> hcalChStatus,
0061                       edm::ESHandle<HcalSeverityLevelComputer> hcalSevLvlComputer,
0062                       edm::ESHandle<CaloTowerConstituentsMap> towerMap);
0063 
0064   EgammaHcalIsolation(InclusionRule extIncRule,
0065                       double extRadius,
0066                       InclusionRule intIncRule,
0067                       double intRadius,
0068                       const arrayHB &eThresHB,
0069                       const arrayHB &etThresHB,
0070                       int maxSeverityHB,
0071                       const arrayHE &eThresHE,
0072                       const arrayHE &etThresHE,
0073                       int maxSeverityHE,
0074                       const HBHERecHitCollection &mhbhe,
0075                       const CaloGeometry &caloGeometry,
0076                       const HcalTopology &hcalTopology,
0077                       const HcalChannelQuality &hcalChStatus,
0078                       const HcalSeverityLevelComputer &hcalSevLvlComputer,
0079                       const CaloTowerConstituentsMap &towerMap);
0080 
0081   double getHcalESum(const reco::Candidate *c, int depth, const HcalPFCuts *hcalCuts) const {
0082     return getHcalESum(c->get<reco::SuperClusterRef>().get(), depth, hcalCuts);
0083   }
0084   double getHcalEtSum(const reco::Candidate *c, int depth, const HcalPFCuts *hcalCuts) const {
0085     return getHcalEtSum(c->get<reco::SuperClusterRef>().get(), depth, hcalCuts);
0086   }
0087   double getHcalESum(const reco::SuperCluster *sc, int depth, const HcalPFCuts *hcalCuts) const {
0088     return getHcalESum(sc->position(), depth, hcalCuts);
0089   }
0090   double getHcalEtSum(const reco::SuperCluster *sc, int depth, const HcalPFCuts *hcalCuts) const {
0091     return getHcalEtSum(sc->position(), depth, hcalCuts);
0092   }
0093   double getHcalESum(const math::XYZPoint &p, int depth, const HcalPFCuts *hcalCuts) const {
0094     return getHcalESum(GlobalPoint(p.x(), p.y(), p.z()), depth, hcalCuts);
0095   }
0096   double getHcalEtSum(const math::XYZPoint &p, int depth, const HcalPFCuts *hcalCuts) const {
0097     return getHcalEtSum(GlobalPoint(p.x(), p.y(), p.z()), depth, hcalCuts);
0098   }
0099   double getHcalESum(const GlobalPoint &pclu, int depth, const HcalPFCuts *hcalCuts) const {
0100     return getHcalSum(pclu, depth, 0, 0, 0, &scaleToE, hcalCuts);
0101   }
0102   double getHcalEtSum(const GlobalPoint &pclu, int depth, const HcalPFCuts *hcalCuts) const {
0103     return getHcalSum(pclu, depth, 0, 0, 0, &scaleToEt, hcalCuts);
0104   }
0105 
0106   double getHcalESumBc(const reco::Candidate *c, int depth, const HcalPFCuts *hcalCuts) const {
0107     return getHcalESumBc(c->get<reco::SuperClusterRef>().get(), depth, hcalCuts);
0108   }
0109   double getHcalEtSumBc(const reco::Candidate *c, int depth, const HcalPFCuts *hcalCuts) const {
0110     return getHcalEtSumBc(c->get<reco::SuperClusterRef>().get(), depth, hcalCuts);
0111   }
0112   double getHcalESumBc(const reco::SuperCluster *sc, int depth, const HcalPFCuts *hcalCuts) const {
0113     const auto tower = egamma::towerOf(*(sc->seed()), towerMap_);
0114 
0115     if (extIncRule_ == InclusionRule::isBehindClusterSeed and intIncRule_ == InclusionRule::withinConeAroundCluster)
0116       return getHcalESumBc(sc->position(), depth, tower.ieta(), tower.iphi(), -1, hcalCuts);
0117     else if (extIncRule_ == InclusionRule::withinConeAroundCluster and
0118              intIncRule_ == InclusionRule::isBehindClusterSeed)
0119       return getHcalESumBc(sc->position(), depth, tower.ieta(), tower.iphi(), 1, hcalCuts);
0120 
0121     return getHcalESumBc(sc->position(), depth, tower.ieta(), tower.iphi(), 0, hcalCuts);
0122   }
0123   double getHcalEtSumBc(const reco::SuperCluster *sc, int depth, const HcalPFCuts *hcalCuts) const {
0124     const auto tower = egamma::towerOf(*(sc->seed()), towerMap_);
0125 
0126     if (extIncRule_ == InclusionRule::isBehindClusterSeed and intIncRule_ == InclusionRule::withinConeAroundCluster)
0127       return getHcalEtSumBc(sc->position(), depth, tower.ieta(), tower.iphi(), -1, hcalCuts);
0128     else if (extIncRule_ == InclusionRule::withinConeAroundCluster and
0129              intIncRule_ == InclusionRule::isBehindClusterSeed)
0130       return getHcalEtSumBc(sc->position(), depth, tower.ieta(), tower.iphi(), 1, hcalCuts);
0131 
0132     return getHcalEtSumBc(sc->position(), depth, tower.ieta(), tower.iphi(), 0, hcalCuts);
0133   }
0134   double getHcalESumBc(const math::XYZPoint &p,
0135                        int depth,
0136                        int ieta,
0137                        int iphi,
0138                        int include_or_exclude,
0139                        const HcalPFCuts *hcalCuts) const {
0140     return getHcalESumBc(GlobalPoint(p.x(), p.y(), p.z()), depth, ieta, iphi, include_or_exclude, hcalCuts);
0141   }
0142   double getHcalEtSumBc(const math::XYZPoint &p,
0143                         int depth,
0144                         int ieta,
0145                         int iphi,
0146                         int include_or_exclude,
0147                         const HcalPFCuts *hcalCuts) const {
0148     return getHcalEtSumBc(GlobalPoint(p.x(), p.y(), p.z()), depth, ieta, iphi, include_or_exclude, hcalCuts);
0149   }
0150   double getHcalESumBc(const GlobalPoint &pclu,
0151                        int depth,
0152                        int ieta,
0153                        int iphi,
0154                        int include_or_exclude,
0155                        const HcalPFCuts *hcalCuts) const {
0156     return getHcalSum(pclu, depth, ieta, iphi, include_or_exclude, &scaleToE, hcalCuts);
0157   }
0158   double getHcalEtSumBc(const GlobalPoint &pclu,
0159                         int depth,
0160                         int ieta,
0161                         int iphi,
0162                         int include_or_exclude,
0163                         const HcalPFCuts *hcalCuts) const {
0164     return getHcalSum(pclu, depth, ieta, iphi, include_or_exclude, &scaleToEt, hcalCuts);
0165   }
0166 
0167 private:
0168   double goodHitEnergy(float pcluEta,
0169                        float pcluPhi,
0170                        const HBHERecHit &hit,
0171                        int depth,
0172                        int ieta,
0173                        int iphi,
0174                        int include_or_exclude,
0175                        double (*scale)(const double &),
0176                        const HcalPFCuts *hcalCuts) const;
0177 
0178   double getHcalSum(const GlobalPoint &pclu,
0179                     int depth,
0180                     int ieta,
0181                     int iphi,
0182                     int include_or_exclude,
0183                     double (*scale)(const double &),
0184                     const HcalPFCuts *hcalCuts) const;
0185 
0186   InclusionRule extIncRule_;
0187   double extRadius_;
0188   InclusionRule intIncRule_;
0189   double intRadius_;
0190 
0191   arrayHB eThresHB_;
0192   arrayHB etThresHB_;
0193   int maxSeverityHB_;
0194 
0195   arrayHE eThresHE_;
0196   arrayHE etThresHE_;
0197   int maxSeverityHE_;
0198 
0199   const HBHERecHitCollection &mhbhe_;
0200   const CaloGeometry &caloGeometry_;
0201   const HcalTopology &hcalTopology_;
0202   const HcalChannelQuality &hcalChStatus_;
0203   const HcalSeverityLevelComputer &hcalSevLvlComputer_;
0204   const CaloTowerConstituentsMap &towerMap_;
0205 };
0206 
0207 #endif