Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:34:08

0001 // -*- C++ -*-
0002 //
0003 // Package:    EgammaHLTProducers
0004 // Class:      EgammaHLTR9IDProducer
0005 //
0006 /**\class EgammaHLTR9IDProducer EgammaHLTR9IDProducer.cc RecoEgamma/EgammaHLTProducers/interface/EgammaHLTR9IDProducer.h
0007 */
0008 //
0009 // Original Author:  Roberto Covarelli (CERN)
0010 //         Created:  Tue Jun 13 14:48:33 CEST 2006
0011 // $Id: EgammaHLTR9Producer.h,v 1.2 2010/06/10 16:19:31 ghezzi Exp $
0012 //         modified by Chris Tully (Princeton)
0013 //
0014 //
0015 
0016 // system include files
0017 #include <memory>
0018 
0019 // user include files
0020 #include "FWCore/Framework/interface/Frameworkfwd.h"
0021 #include "FWCore/Framework/interface/global/EDProducer.h"
0022 #include "FWCore/Framework/interface/Event.h"
0023 #include "FWCore/Framework/interface/MakerMacros.h"
0024 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0025 
0026 #include "DataFormats/RecoCandidate/interface/RecoEcalCandidate.h"
0027 #include "DataFormats/RecoCandidate/interface/RecoEcalCandidateIsolation.h"
0028 
0029 #include "RecoEcal/EgammaCoreTools/interface/EcalClusterLazyTools.h"
0030 
0031 // Framework
0032 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0033 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0034 
0035 #include "RecoEcal/EgammaCoreTools/interface/EcalClusterLazyTools.h"
0036 #include "RecoLocalCalo/EcalRecAlgos/interface/EcalSeverityLevelAlgo.h"
0037 
0038 class EgammaHLTR9IDProducer : public edm::global::EDProducer<> {
0039 public:
0040   explicit EgammaHLTR9IDProducer(const edm::ParameterSet&);
0041 
0042   static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0043   void produce(edm::StreamID sid, edm::Event&, const edm::EventSetup&) const override;
0044 
0045 private:
0046   // ----------member data ---------------------------
0047 
0048   const edm::EDGetTokenT<reco::RecoEcalCandidateCollection> recoEcalCandidateProducer_;
0049   const edm::EDGetTokenT<EcalRecHitCollection> ecalRechitEBToken_;
0050   const edm::EDGetTokenT<EcalRecHitCollection> ecalRechitEEToken_;
0051   const EcalClusterLazyTools::ESGetTokens ecalClusterToolsESGetTokens_;
0052 };
0053 
0054 EgammaHLTR9IDProducer::EgammaHLTR9IDProducer(const edm::ParameterSet& config)
0055     : recoEcalCandidateProducer_(consumes(config.getParameter<edm::InputTag>("recoEcalCandidateProducer"))),
0056       ecalRechitEBToken_(consumes(config.getParameter<edm::InputTag>("ecalRechitEB"))),
0057       ecalRechitEEToken_(consumes(config.getParameter<edm::InputTag>("ecalRechitEE"))),
0058       ecalClusterToolsESGetTokens_{consumesCollector()} {
0059   //register your products
0060   produces<reco::RecoEcalCandidateIsolationMap>();
0061   produces<reco::RecoEcalCandidateIsolationMap>("r95x5");
0062 }
0063 
0064 void EgammaHLTR9IDProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0065   edm::ParameterSetDescription desc;
0066   desc.add<edm::InputTag>(("recoEcalCandidateProducer"), edm::InputTag("hltRecoEcalCandidate"));
0067   desc.add<edm::InputTag>(("ecalRechitEB"), edm::InputTag("hltEcalRegionalEgammaRecHit", "EcalRecHitsEB"));
0068   desc.add<edm::InputTag>(("ecalRechitEE"), edm::InputTag("hltEcalRegionalEgammaRecHit", "EcalRecHitsEE"));
0069   descriptions.add(("hltEgammaHLTR9IDProducer"), desc);
0070 }
0071 
0072 // ------------ method called to produce the data  ------------
0073 void EgammaHLTR9IDProducer::produce(edm::StreamID sid, edm::Event& iEvent, const edm::EventSetup& iSetup) const {
0074   // Get the HLT filtered objects
0075   edm::Handle<reco::RecoEcalCandidateCollection> recoecalcandHandle;
0076   iEvent.getByToken(recoEcalCandidateProducer_, recoecalcandHandle);
0077 
0078   auto const& ecalClusterToolsESData = ecalClusterToolsESGetTokens_.get(iSetup);
0079   EcalClusterLazyTools lazyTools(iEvent, ecalClusterToolsESData, ecalRechitEBToken_, ecalRechitEEToken_);
0080   noZS::EcalClusterLazyTools lazyTools5x5(iEvent, ecalClusterToolsESData, ecalRechitEBToken_, ecalRechitEEToken_);
0081   reco::RecoEcalCandidateIsolationMap r9Map(recoecalcandHandle);
0082   reco::RecoEcalCandidateIsolationMap r95x5Map(recoecalcandHandle);
0083   for (unsigned int iRecoEcalCand = 0; iRecoEcalCand < recoecalcandHandle->size(); iRecoEcalCand++) {
0084     reco::RecoEcalCandidateRef recoecalcandref(recoecalcandHandle, iRecoEcalCand);  //-recoecalcandHandle->begin());
0085 
0086     float r9 = -1;
0087     float r95x5 = -1;
0088 
0089     float e9 = lazyTools.e3x3(*(recoecalcandref->superCluster()->seed()));
0090     float e95x5 = lazyTools5x5.e3x3(*(recoecalcandref->superCluster()->seed()));
0091 
0092     float eraw = recoecalcandref->superCluster()->rawEnergy();
0093     if (eraw > 0.) {
0094       r9 = e9 / eraw;
0095       r95x5 = e95x5 / eraw;
0096     }
0097 
0098     r9Map.insert(recoecalcandref, r9);
0099     r95x5Map.insert(recoecalcandref, r95x5);
0100   }
0101 
0102   iEvent.put(std::make_unique<reco::RecoEcalCandidateIsolationMap>(r9Map));
0103 
0104   iEvent.put(std::make_unique<reco::RecoEcalCandidateIsolationMap>(r95x5Map), "r95x5");
0105 }
0106 
0107 #include "FWCore/Framework/interface/MakerMacros.h"
0108 DEFINE_FWK_MODULE(EgammaHLTR9IDProducer);