Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-11-04 03:24:59

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/HcalObjects/interface/HcalChannelQuality.h"
0029 #include "CondFormats/DataRecord/interface/HcalChannelQualityRcd.h"
0030 
0031 #include "Geometry/CaloTopology/interface/CaloTowerConstituentsMap.h"
0032 #include "RecoEgamma/EgammaIsolationAlgos/interface/EgammaHadTower.h"
0033 
0034 // sum helper functions
0035 double scaleToE(const double &eta);
0036 double scaleToEt(const double &eta);
0037 
0038 class EgammaHcalIsolation {
0039 public:
0040   enum class InclusionRule : int { withinConeAroundCluster = 0, isBehindClusterSeed = 1 };
0041   using arrayHB = std::array<double, 4>;
0042   using arrayHE = std::array<double, 7>;
0043 
0044   // constructors
0045   EgammaHcalIsolation(InclusionRule extIncRule,
0046                       double extRadius,
0047                       InclusionRule intIncRule,
0048                       double intRadius,
0049                       const arrayHB &eThresHB,
0050                       const arrayHB &etThresHB,
0051                       int maxSeverityHB,
0052                       const arrayHE &eThresHE,
0053                       const arrayHE &etThresHE,
0054                       int maxSeverityHE,
0055                       const HBHERecHitCollection &mhbhe,
0056                       edm::ESHandle<CaloGeometry> caloGeometry,
0057                       edm::ESHandle<HcalTopology> hcalTopology,
0058                       edm::ESHandle<HcalChannelQuality> hcalChStatus,
0059                       edm::ESHandle<HcalSeverityLevelComputer> hcalSevLvlComputer,
0060                       edm::ESHandle<CaloTowerConstituentsMap> towerMap);
0061 
0062   EgammaHcalIsolation(InclusionRule extIncRule,
0063                       double extRadius,
0064                       InclusionRule intIncRule,
0065                       double intRadius,
0066                       const arrayHB &eThresHB,
0067                       const arrayHB &etThresHB,
0068                       int maxSeverityHB,
0069                       const arrayHE &eThresHE,
0070                       const arrayHE &etThresHE,
0071                       int maxSeverityHE,
0072                       const HBHERecHitCollection &mhbhe,
0073                       const CaloGeometry &caloGeometry,
0074                       const HcalTopology &hcalTopology,
0075                       const HcalChannelQuality &hcalChStatus,
0076                       const HcalSeverityLevelComputer &hcalSevLvlComputer,
0077                       const CaloTowerConstituentsMap &towerMap);
0078 
0079   double getHcalESum(const reco::Candidate *c, int depth) const {
0080     return getHcalESum(c->get<reco::SuperClusterRef>().get(), depth);
0081   }
0082   double getHcalEtSum(const reco::Candidate *c, int depth) const {
0083     return getHcalEtSum(c->get<reco::SuperClusterRef>().get(), depth);
0084   }
0085   double getHcalESum(const reco::SuperCluster *sc, int depth) const { return getHcalESum(sc->position(), depth); }
0086   double getHcalEtSum(const reco::SuperCluster *sc, int depth) const { return getHcalEtSum(sc->position(), depth); }
0087   double getHcalESum(const math::XYZPoint &p, int depth) const {
0088     return getHcalESum(GlobalPoint(p.x(), p.y(), p.z()), depth);
0089   }
0090   double getHcalEtSum(const math::XYZPoint &p, int depth) const {
0091     return getHcalEtSum(GlobalPoint(p.x(), p.y(), p.z()), depth);
0092   }
0093   double getHcalESum(const GlobalPoint &pclu, int depth) const { return getHcalSum(pclu, depth, 0, 0, 0, &scaleToE); }
0094   double getHcalEtSum(const GlobalPoint &pclu, int depth) const { return getHcalSum(pclu, depth, 0, 0, 0, &scaleToEt); }
0095 
0096   double getHcalESumBc(const reco::Candidate *c, int depth) const {
0097     return getHcalESumBc(c->get<reco::SuperClusterRef>().get(), depth);
0098   }
0099   double getHcalEtSumBc(const reco::Candidate *c, int depth) const {
0100     return getHcalEtSumBc(c->get<reco::SuperClusterRef>().get(), depth);
0101   }
0102   double getHcalESumBc(const reco::SuperCluster *sc, int depth) const {
0103     const auto tower = egamma::towerOf(*(sc->seed()), towerMap_);
0104 
0105     if (extIncRule_ == InclusionRule::isBehindClusterSeed and intIncRule_ == InclusionRule::withinConeAroundCluster)
0106       return getHcalESumBc(sc->position(), depth, tower.ieta(), tower.iphi(), -1);
0107     else if (extIncRule_ == InclusionRule::withinConeAroundCluster and
0108              intIncRule_ == InclusionRule::isBehindClusterSeed)
0109       return getHcalESumBc(sc->position(), depth, tower.ieta(), tower.iphi(), 1);
0110 
0111     return getHcalESumBc(sc->position(), depth, tower.ieta(), tower.iphi(), 0);
0112   }
0113   double getHcalEtSumBc(const reco::SuperCluster *sc, int depth) const {
0114     const auto tower = egamma::towerOf(*(sc->seed()), towerMap_);
0115 
0116     if (extIncRule_ == InclusionRule::isBehindClusterSeed and intIncRule_ == InclusionRule::withinConeAroundCluster)
0117       return getHcalEtSumBc(sc->position(), depth, tower.ieta(), tower.iphi(), -1);
0118     else if (extIncRule_ == InclusionRule::withinConeAroundCluster and
0119              intIncRule_ == InclusionRule::isBehindClusterSeed)
0120       return getHcalEtSumBc(sc->position(), depth, tower.ieta(), tower.iphi(), 1);
0121 
0122     return getHcalEtSumBc(sc->position(), depth, tower.ieta(), tower.iphi(), 0);
0123   }
0124   double getHcalESumBc(const math::XYZPoint &p, int depth, int ieta, int iphi, int include_or_exclude) const {
0125     return getHcalESumBc(GlobalPoint(p.x(), p.y(), p.z()), depth, ieta, iphi, include_or_exclude);
0126   }
0127   double getHcalEtSumBc(const math::XYZPoint &p, int depth, int ieta, int iphi, int include_or_exclude) const {
0128     return getHcalEtSumBc(GlobalPoint(p.x(), p.y(), p.z()), depth, ieta, iphi, include_or_exclude);
0129   }
0130   double getHcalESumBc(const GlobalPoint &pclu, int depth, int ieta, int iphi, int include_or_exclude) const {
0131     return getHcalSum(pclu, depth, ieta, iphi, include_or_exclude, &scaleToE);
0132   }
0133   double getHcalEtSumBc(const GlobalPoint &pclu, int depth, int ieta, int iphi, int include_or_exclude) const {
0134     return getHcalSum(pclu, depth, ieta, iphi, include_or_exclude, &scaleToEt);
0135   }
0136 
0137 private:
0138   double goodHitEnergy(float pcluEta,
0139                        float pcluPhi,
0140                        const HBHERecHit &hit,
0141                        int depth,
0142                        int ieta,
0143                        int iphi,
0144                        int include_or_exclude,
0145                        double (*scale)(const double &)) const;
0146 
0147   double getHcalSum(const GlobalPoint &pclu,
0148                     int depth,
0149                     int ieta,
0150                     int iphi,
0151                     int include_or_exclude,
0152                     double (*scale)(const double &)) const;
0153 
0154   InclusionRule extIncRule_;
0155   double extRadius_;
0156   InclusionRule intIncRule_;
0157   double intRadius_;
0158 
0159   arrayHB eThresHB_;
0160   arrayHB etThresHB_;
0161   int maxSeverityHB_;
0162 
0163   arrayHE eThresHE_;
0164   arrayHE etThresHE_;
0165   int maxSeverityHE_;
0166 
0167   const HBHERecHitCollection &mhbhe_;
0168   const CaloGeometry &caloGeometry_;
0169   const HcalTopology &hcalTopology_;
0170   const HcalChannelQuality &hcalChStatus_;
0171   const HcalSeverityLevelComputer &hcalSevLvlComputer_;
0172   const CaloTowerConstituentsMap &towerMap_;
0173 };
0174 
0175 #endif