Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-10-01 22:40:51

0001 // -*- C++ -*-
0002 //
0003 // Package:    EgammaHLTProducers
0004 // Class:      EgammaHLTClusterShapeProducer
0005 //
0006 /**\class EgammaHLTClusterShapeProducer EgammaHLTClusterShapeProducer.cc RecoEgamma/EgammaHLTProducers/interface/EgammaHLTClusterShapeProducer.h
0007 */
0008 //
0009 // Original Author:  Roberto Covarelli (CERN)
0010 //         Created:  Tue Jun 13 14:48:33 CEST 2006
0011 // $Id: EgammaHLTClusterShapeProducer.h,v 1.1 2009/01/15 14:28:27 covarell Exp $
0012 //
0013 //
0014 
0015 #include "FWCore/Framework/interface/Frameworkfwd.h"
0016 #include "FWCore/Framework/interface/global/EDProducer.h"
0017 #include "FWCore/Framework/interface/Event.h"
0018 #include "FWCore/Framework/interface/MakerMacros.h"
0019 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0020 #include "DataFormats/RecoCandidate/interface/RecoEcalCandidate.h"
0021 #include "DataFormats/RecoCandidate/interface/RecoEcalCandidateFwd.h"
0022 #include "DataFormats/RecoCandidate/interface/RecoEcalCandidateIsolation.h"
0023 #include "DataFormats/EgammaReco/interface/SuperCluster.h"
0024 #include "RecoEcal/EgammaCoreTools/interface/EcalClusterLazyTools.h"
0025 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0026 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0027 #include "RecoEcal/EgammaCoreTools/interface/EgammaLocalCovParamDefaults.h"
0028 
0029 class EgammaHLTClusterShapeProducer : public edm::global::EDProducer<> {
0030 public:
0031   explicit EgammaHLTClusterShapeProducer(const edm::ParameterSet&);
0032   ~EgammaHLTClusterShapeProducer() override;
0033 
0034   static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0035   void produce(edm::StreamID sid, edm::Event&, const edm::EventSetup&) const override;
0036 
0037 private:
0038   // ----------member data ---------------------------
0039 
0040   const edm::EDGetTokenT<reco::RecoEcalCandidateCollection> recoEcalCandidateProducer_;
0041   const edm::EDGetTokenT<EcalRecHitCollection> ecalRechitEBToken_;
0042   const edm::EDGetTokenT<EcalRecHitCollection> ecalRechitEEToken_;
0043   const EcalClusterLazyTools::ESGetTokens ecalClusterLazyToolsESGetTokens_;
0044   const edm::ESGetToken<EcalPFRecHitThresholds, EcalPFRecHitThresholdsRcd> ecalPFRechitThresholdsToken_;
0045   const bool useIEta_;
0046   const double multThresEB_;
0047   const double multThresEE_;
0048 };
0049 
0050 EgammaHLTClusterShapeProducer::EgammaHLTClusterShapeProducer(const edm::ParameterSet& config)
0051     : recoEcalCandidateProducer_(consumes(config.getParameter<edm::InputTag>("recoEcalCandidateProducer"))),
0052       ecalRechitEBToken_(consumes(config.getParameter<edm::InputTag>("ecalRechitEB"))),
0053       ecalRechitEEToken_(consumes(config.getParameter<edm::InputTag>("ecalRechitEE"))),
0054       ecalClusterLazyToolsESGetTokens_{consumesCollector()},
0055       ecalPFRechitThresholdsToken_{esConsumes()},
0056       useIEta_(config.getParameter<bool>("isIeta")),
0057       multThresEB_(config.getParameter<double>("multThresEB")),
0058       multThresEE_(config.getParameter<double>("multThresEE")) {
0059   //register your products
0060   produces<reco::RecoEcalCandidateIsolationMap>();
0061   produces<reco::RecoEcalCandidateIsolationMap>("sigmaIEtaIEta5x5");
0062   produces<reco::RecoEcalCandidateIsolationMap>("sigmaIEtaIEta5x5NoiseCleaned");
0063   produces<reco::RecoEcalCandidateIsolationMap>("sigmaIPhiIPhi");
0064   produces<reco::RecoEcalCandidateIsolationMap>("sigmaIPhiIPhi5x5");
0065   produces<reco::RecoEcalCandidateIsolationMap>("sigmaIPhiIPhi5x5NoiseCleaned");
0066 }
0067 
0068 EgammaHLTClusterShapeProducer::~EgammaHLTClusterShapeProducer() {}
0069 
0070 void EgammaHLTClusterShapeProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0071   edm::ParameterSetDescription desc;
0072   desc.add<edm::InputTag>(("recoEcalCandidateProducer"), edm::InputTag("hltL1SeededRecoEcalCandidate"));
0073   desc.add<edm::InputTag>(("ecalRechitEB"), edm::InputTag("hltEcalRegionalEgammaRecHit", "EcalRecHitsEB"));
0074   desc.add<edm::InputTag>(("ecalRechitEE"), edm::InputTag("hltEcalRegionalEgammaRecHit", "EcalRecHitsEE"));
0075   desc.add<bool>(("isIeta"), true);
0076   desc.add<double>(("multThresEB"), EgammaLocalCovParamDefaults::kMultThresEB);
0077   desc.add<double>(("multThresEE"), EgammaLocalCovParamDefaults::kMultThresEE);
0078   descriptions.add(("hltEgammaHLTClusterShapeProducer"), desc);
0079 }
0080 
0081 void EgammaHLTClusterShapeProducer::produce(edm::StreamID sid,
0082                                             edm::Event& iEvent,
0083                                             const edm::EventSetup& iSetup) const {
0084   // Get the HLT filtered objects
0085   edm::Handle<reco::RecoEcalCandidateCollection> recoecalcandHandle;
0086   iEvent.getByToken(recoEcalCandidateProducer_, recoecalcandHandle);
0087 
0088   auto const& ecalClusterLazyToolsESData = ecalClusterLazyToolsESGetTokens_.get(iSetup);
0089   auto const& thresholds = iSetup.getData(ecalPFRechitThresholdsToken_);
0090 
0091   EcalClusterLazyTools lazyTools(iEvent, ecalClusterLazyToolsESData, ecalRechitEBToken_, ecalRechitEEToken_);
0092   noZS::EcalClusterLazyTools lazyTools5x5(iEvent, ecalClusterLazyToolsESData, ecalRechitEBToken_, ecalRechitEEToken_);
0093 
0094   //Map is for sigmaIEtaIEta
0095   reco::RecoEcalCandidateIsolationMap clshMap(recoecalcandHandle);
0096   reco::RecoEcalCandidateIsolationMap clsh5x5Map(recoecalcandHandle);
0097   reco::RecoEcalCandidateIsolationMap clsh5x5NoiseCleanedMap(recoecalcandHandle);
0098 
0099   //Map2 is for sigmaIPhiIPhi
0100   reco::RecoEcalCandidateIsolationMap clshMap2(recoecalcandHandle);
0101   reco::RecoEcalCandidateIsolationMap clsh5x5Map2(recoecalcandHandle);
0102   reco::RecoEcalCandidateIsolationMap clsh5x5NoiseCleanedMap2(recoecalcandHandle);
0103 
0104   for (unsigned int iRecoEcalCand = 0; iRecoEcalCand < recoecalcandHandle->size(); iRecoEcalCand++) {
0105     reco::RecoEcalCandidateRef recoecalcandref(recoecalcandHandle, iRecoEcalCand);
0106     if (recoecalcandref->superCluster()->seed()->seed().det() != DetId::Ecal) {  //HGCAL, skip for now
0107       clshMap.insert(recoecalcandref, 0);
0108       clsh5x5Map.insert(recoecalcandref, 0);
0109       clsh5x5NoiseCleanedMap.insert(recoecalcandref, 0);
0110 
0111       clshMap2.insert(recoecalcandref, 0);
0112       clsh5x5Map2.insert(recoecalcandref, 0);
0113       clsh5x5NoiseCleanedMap2.insert(recoecalcandref, 0);
0114 
0115       continue;
0116     }
0117 
0118     double sigmaee;
0119     double sigmapp;  //sigmaIphiIphi, needed in e/gamma HLT regression setup
0120     if (useIEta_) {
0121       //this is fractional showershape (sigmaIEtaIEta / sigmaIPhiIPhi)
0122       const auto& vCov = lazyTools.localCovariances(*(recoecalcandref->superCluster()->seed()));
0123       sigmaee = sqrt(vCov[0]);
0124       sigmapp = sqrt(vCov[2]);
0125     } else {
0126       //this is showershape using absolute geometry (sigmaEtaEta / sigmaPhiPhi)
0127       //generally not used anymore
0128       const auto& vCov = lazyTools.covariances(*(recoecalcandref->superCluster()->seed()));
0129       sigmaee = sqrt(vCov[0]);
0130       sigmapp = sqrt(vCov[2]);
0131       double EtaSC = recoecalcandref->eta();
0132       if (EtaSC > 1.479)
0133         sigmaee = sigmaee - 0.02 * (EtaSC - 2.3);
0134     }
0135 
0136     //this is full5x5 showershape
0137     auto const ecalCandLocalCov = lazyTools5x5.localCovariances(*(recoecalcandref->superCluster()->seed()));
0138     auto const sigmaee5x5 = sqrt(ecalCandLocalCov[0]);
0139     auto const sigmapp5x5 = sqrt(ecalCandLocalCov[2]);
0140 
0141     auto const ecalCandLocalCovNoiseCleaned = lazyTools5x5.localCovariances(*(recoecalcandref->superCluster()->seed()),
0142                                                                             EgammaLocalCovParamDefaults::kRelEnCut,
0143                                                                             &thresholds,
0144                                                                             multThresEB_,
0145                                                                             multThresEE_);
0146     auto const sigmaee5x5NoiseCleaned = sqrt(ecalCandLocalCovNoiseCleaned[0]);
0147     auto const sigmapp5x5NoiseCleaned = sqrt(ecalCandLocalCovNoiseCleaned[2]);
0148 
0149     clshMap.insert(recoecalcandref, sigmaee);
0150     clsh5x5Map.insert(recoecalcandref, sigmaee5x5);
0151     clsh5x5NoiseCleanedMap.insert(recoecalcandref, sigmaee5x5NoiseCleaned);
0152 
0153     clshMap2.insert(recoecalcandref, sigmapp);
0154     clsh5x5Map2.insert(recoecalcandref, sigmapp5x5);
0155     clsh5x5NoiseCleanedMap2.insert(recoecalcandref, sigmapp5x5NoiseCleaned);
0156   }
0157 
0158   iEvent.put(std::make_unique<reco::RecoEcalCandidateIsolationMap>(clshMap));
0159   iEvent.put(std::make_unique<reco::RecoEcalCandidateIsolationMap>(clsh5x5Map), "sigmaIEtaIEta5x5");
0160   iEvent.put(std::make_unique<reco::RecoEcalCandidateIsolationMap>(clsh5x5NoiseCleanedMap),
0161              "sigmaIEtaIEta5x5NoiseCleaned");
0162 
0163   iEvent.put(std::make_unique<reco::RecoEcalCandidateIsolationMap>(clshMap2), "sigmaIPhiIPhi");
0164   iEvent.put(std::make_unique<reco::RecoEcalCandidateIsolationMap>(clsh5x5Map2), "sigmaIPhiIPhi5x5");
0165   iEvent.put(std::make_unique<reco::RecoEcalCandidateIsolationMap>(clsh5x5NoiseCleanedMap2),
0166              "sigmaIPhiIPhi5x5NoiseCleaned");
0167 }
0168 
0169 #include "FWCore/Framework/interface/MakerMacros.h"
0170 DEFINE_FWK_MODULE(EgammaHLTClusterShapeProducer);