Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-10-23 02:29:58

0001 #ifndef RecoJets_JetProducers_interface_JetIDHelper_h
0002 #define RecoJets_JetProducers_interface_JetIDHelper_h
0003 
0004 #include <atomic>
0005 
0006 #include "DataFormats/HcalRecHit/interface/HcalRecHitCollections.h"
0007 #include "DataFormats/HcalRecHit/interface/HcalRecHitDefs.h"
0008 #include "DataFormats/EcalRecHit/interface/EcalRecHitCollections.h"
0009 #include "DataFormats/EcalDetId/interface/EcalDetIdCollections.h"
0010 
0011 #include "FWCore/Framework/interface/ConsumesCollector.h"
0012 #include "FWCore/Framework/interface/Frameworkfwd.h"
0013 #include "FWCore/Framework/interface/Event.h"
0014 #include "FWCore/Framework/interface/ESHandle.h"
0015 #include "DataFormats/JetReco/interface/CaloJet.h"
0016 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0017 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0018 
0019 class HcalTopology;
0020 class HcalRecNumberingRecord;
0021 
0022 namespace reco {
0023 
0024   namespace helper {
0025 
0026     class JetIDHelper {
0027     public:
0028       // construction
0029       JetIDHelper() {}
0030       JetIDHelper(edm::ParameterSet const &pset, edm::ConsumesCollector &&iC);
0031       ~JetIDHelper() {}
0032 
0033       void fillDescription(edm::ParameterSetDescription &iDesc);
0034 
0035       void initValues();
0036 
0037       // interface
0038       void calculate(const edm::Event &event,
0039                      const edm::EventSetup &setup,
0040                      const reco::CaloJet &jet,
0041                      const int iDbg = 0);
0042 
0043       // member access
0044 
0045       // these require RecHits, so can not be evaluated from AOD
0046       double fHPD() const { return fHPD_; }
0047       double fRBX() const { return fRBX_; }
0048       int n90Hits() const { return n90Hits_; }
0049       double fSubDetector1() const { return fSubDetector1_; }
0050       double fSubDetector2() const { return fSubDetector2_; }
0051       double fSubDetector3() const { return fSubDetector3_; }
0052       double fSubDetector4() const { return fSubDetector4_; }
0053       double fEB() const { return fEB_; }
0054       double fEE() const { return fEE_; }
0055       double fHB() const { return fHB_; }
0056       double fHE() const { return fHE_; }
0057       double fHO() const { return fHO_; }
0058       double fLong() const { return fLong_; }
0059       double fShort() const { return fShort_; }
0060       double fLSbad() const { return fLS_; }
0061       double fHFOOT() const { return fHFOOT_; }
0062       // these are tower based
0063       double restrictedEMF() const { return restrictedEMF_; }
0064       int nHCALTowers() const { return nHCALTowers_; }
0065       int nECALTowers() const { return nECALTowers_; }
0066       // tower based approximations / inferior options
0067       double approximatefHPD() const { return approximatefHPD_; }
0068       double approximatefRBX() const { return approximatefRBX_; }
0069       int hitsInN90() const { return hitsInN90_; }
0070 
0071       struct subtower {  // contents of a sub-detector's tower
0072         double E;
0073         int Nhit;
0074 
0075         subtower(double xE, int xN) {
0076           E = xE;
0077           Nhit = xN;
0078         }
0079       };
0080 
0081     private:
0082       // helper functions
0083       void classifyJetComponents(const edm::Event &event,
0084                                  const edm::EventSetup &setup,
0085                                  const reco::CaloJet &jet,
0086                                  std::vector<double> &energies,
0087                                  std::vector<double> &subdet_energies,
0088                                  std::vector<double> &Ecal_energies,
0089                                  std::vector<double> &Hcal_energies,
0090                                  std::vector<double> &HO_energies,
0091                                  std::vector<double> &HPD_energies,
0092                                  std::vector<double> &RBX_energies,
0093                                  double &LS_bad_energy,
0094                                  double &HF_OOT_energy,
0095                                  const int iDbg = 0);
0096 
0097       void classifyJetTowers(const edm::Event &event,
0098                              const reco::CaloJet &jet,
0099                              std::vector<subtower> &subtowers,
0100                              std::vector<subtower> &Ecal_subtowers,
0101                              std::vector<subtower> &Hcal_subtowers,
0102                              std::vector<subtower> &HO_subtowers,
0103                              std::vector<double> &HPD_energies,
0104                              std::vector<double> &RBX_energies,
0105                              const int iDbg = 0);
0106 
0107       unsigned int nCarrying(double fraction, const std::vector<double> &descending_energies);
0108       unsigned int hitsInNCarrying(double fraction, const std::vector<subtower> &descending_towers);
0109 
0110       enum Region { unknown_region = -1, HFneg, HEneg, HBneg, HBpos, HEpos, HFpos };
0111 
0112       int HBHE_oddness(int iEta, int depth);
0113       Region HBHE_region(uint32_t);
0114       // tower-based. -1 means can't figure it out
0115       int HBHE_oddness(int iEta);
0116       Region region(int iEta);
0117 
0118       double fHPD_;
0119       double fRBX_;
0120       int n90Hits_;
0121       double fSubDetector1_;
0122       double fSubDetector2_;
0123       double fSubDetector3_;
0124       double fSubDetector4_;
0125       double restrictedEMF_;
0126       int nHCALTowers_;
0127       int nECALTowers_;
0128       double approximatefHPD_;
0129       double approximatefRBX_;
0130       int hitsInN90_;
0131       double approximatefSubDetector1_;
0132       double approximatefSubDetector2_;
0133       double approximatefSubDetector3_;
0134       double approximatefSubDetector4_;
0135 
0136       double fEB_, fEE_, fHB_, fHE_, fHO_, fLong_, fShort_;
0137       double fLS_, fHFOOT_;
0138 
0139       bool useRecHits_;
0140       edm::InputTag hbheRecHitsColl_;
0141       edm::InputTag hoRecHitsColl_;
0142       edm::InputTag hfRecHitsColl_;
0143       edm::InputTag ebRecHitsColl_;
0144       edm::InputTag eeRecHitsColl_;
0145 
0146       static std::atomic<int> sanity_checks_left_;
0147 
0148       edm::EDGetTokenT<HBHERecHitCollection> input_HBHERecHits_token_;
0149       edm::EDGetTokenT<HORecHitCollection> input_HORecHits_token_;
0150       edm::EDGetTokenT<HFRecHitCollection> input_HFRecHits_token_;
0151       edm::EDGetTokenT<EBRecHitCollection> input_EBRecHits_token_;
0152       edm::EDGetTokenT<EERecHitCollection> input_EERecHits_token_;
0153 
0154       edm::ESGetToken<HcalTopology, HcalRecNumberingRecord> hcal_topo_token_;
0155     };
0156   }  // namespace helper
0157 }  // namespace reco
0158 #endif