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:      EgammaHLTPhotonTrackIsolationProducersRegional
0005 //
0006 /**\class EgammaHLTPhotonTrackIsolationProducersRegional EgammaHLTPhotonTrackIsolationProducersRegional.cc RecoEgamma/EgammaHLTProducers/interface/EgammaHLTPhotonTrackIsolationProducersRegional.h
0007 */
0008 //
0009 // Original Author:  Monica Vazquez Acosta (CERN)
0010 //         Created:  Tue Jun 13 14:48:33 CEST 2006
0011 // $Id: EgammaHLTPhotonTrackIsolationProducersRegional.h,v 1.1 2007/03/23 17:22:54 ghezzi Exp $
0012 //
0013 //
0014 
0015 // system include files
0016 #include <memory>
0017 
0018 // user include files
0019 #include "FWCore/Framework/interface/Frameworkfwd.h"
0020 #include "FWCore/Framework/interface/global/EDProducer.h"
0021 
0022 #include "FWCore/Framework/interface/Event.h"
0023 #include "FWCore/Framework/interface/MakerMacros.h"
0024 
0025 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0026 
0027 #include "RecoEgamma/EgammaIsolationAlgos/interface/EgammaHLTTrackIsolation.h"
0028 #include "DataFormats/TrackReco/interface/TrackFwd.h"
0029 #include "DataFormats/TrackReco/interface/Track.h"
0030 
0031 #include "DataFormats/RecoCandidate/interface/RecoEcalCandidate.h"
0032 #include "DataFormats/RecoCandidate/interface/RecoEcalCandidateFwd.h"
0033 
0034 #include "DataFormats/RecoCandidate/interface/RecoEcalCandidateIsolation.h"
0035 
0036 #include "DataFormats/TrackingRecHit/interface/TrackingRecHit.h"
0037 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0038 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0039 
0040 class EgammaHLTPhotonTrackIsolationProducersRegional : public edm::global::EDProducer<> {
0041 public:
0042   explicit EgammaHLTPhotonTrackIsolationProducersRegional(const edm::ParameterSet&);
0043   ~EgammaHLTPhotonTrackIsolationProducersRegional() override;
0044 
0045   static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0046   void produce(edm::StreamID sid, edm::Event&, const edm::EventSetup&) const override;
0047 
0048 private:
0049   // ----------member data ---------------------------
0050 
0051   const edm::EDGetTokenT<reco::RecoEcalCandidateCollection> recoEcalCandidateProducer_;
0052   const edm::EDGetTokenT<reco::TrackCollection> trackProducer_;
0053 
0054   //edm::ParameterSet conf_;
0055 
0056   const bool countTracks_;
0057 
0058   const double egTrkIsoPtMin_;
0059   const double egTrkIsoConeSize_;
0060   const double egTrkIsoZSpan_;
0061   const double egTrkIsoRSpan_;
0062   const double egTrkIsoVetoConeSize_;
0063   const double egTrkIsoStripBarrel_;
0064   const double egTrkIsoStripEndcap_;
0065 
0066   EgammaHLTTrackIsolation* test_;
0067 };
0068 
0069 EgammaHLTPhotonTrackIsolationProducersRegional::EgammaHLTPhotonTrackIsolationProducersRegional(
0070     const edm::ParameterSet& config)
0071     : recoEcalCandidateProducer_(
0072           consumes<reco::RecoEcalCandidateCollection>(config.getParameter<edm::InputTag>("recoEcalCandidateProducer"))),
0073       trackProducer_(consumes<reco::TrackCollection>(config.getParameter<edm::InputTag>("trackProducer"))),
0074       countTracks_(config.getParameter<bool>("countTracks")),
0075       egTrkIsoPtMin_(config.getParameter<double>("egTrkIsoPtMin")),
0076       egTrkIsoConeSize_(config.getParameter<double>("egTrkIsoConeSize")),
0077       egTrkIsoZSpan_(config.getParameter<double>("egTrkIsoZSpan")),
0078       egTrkIsoRSpan_(config.getParameter<double>("egTrkIsoRSpan")),
0079       egTrkIsoVetoConeSize_(config.getParameter<double>("egTrkIsoVetoConeSize")),
0080       egTrkIsoStripBarrel_(config.getParameter<double>("egTrkIsoStripBarrel")),
0081       egTrkIsoStripEndcap_(config.getParameter<double>("egTrkIsoStripEndcap")) {
0082   test_ = new EgammaHLTTrackIsolation(egTrkIsoPtMin_,
0083                                       egTrkIsoConeSize_,
0084                                       egTrkIsoZSpan_,
0085                                       egTrkIsoRSpan_,
0086                                       egTrkIsoVetoConeSize_,
0087                                       egTrkIsoStripBarrel_,
0088                                       egTrkIsoStripEndcap_);
0089 
0090   //register your products
0091   produces<reco::RecoEcalCandidateIsolationMap>();
0092 }
0093 
0094 EgammaHLTPhotonTrackIsolationProducersRegional::~EgammaHLTPhotonTrackIsolationProducersRegional() { delete test_; }
0095 
0096 void EgammaHLTPhotonTrackIsolationProducersRegional::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0097   edm::ParameterSetDescription desc;
0098   desc.add<edm::InputTag>(("recoEcalCandidateProducer"), edm::InputTag("hltL1SeededRecoEcalCandidate"));
0099   desc.add<edm::InputTag>(("trackProducer"), edm::InputTag("hltL1SeededEgammaRegionalCTFFinalFitWithMaterial"));
0100   desc.add<bool>(("countTracks"), false);
0101   desc.add<double>(("egTrkIsoPtMin"), 1.0);
0102   desc.add<double>(("egTrkIsoConeSize"), 0.29);
0103   desc.add<double>(("egTrkIsoZSpan"), 999999.0);
0104   desc.add<double>(("egTrkIsoRSpan"), 999999.0);
0105   desc.add<double>(("egTrkIsoVetoConeSize"), 0.06);
0106   desc.add<double>(("egTrkIsoStripBarrel"), 0.03);
0107   desc.add<double>(("egTrkIsoStripEndcap"), 0.03);
0108   descriptions.add(("hltEgammaHLTPhotonTrackIsolationProducersRegional"), desc);
0109 }
0110 
0111 // ------------ method called to produce the data  ------------
0112 void EgammaHLTPhotonTrackIsolationProducersRegional::produce(edm::StreamID sid,
0113                                                              edm::Event& iEvent,
0114                                                              const edm::EventSetup&) const {
0115   // Get the HLT filtered objects
0116   edm::Handle<reco::RecoEcalCandidateCollection> recoecalcandHandle;
0117   iEvent.getByToken(recoEcalCandidateProducer_, recoecalcandHandle);
0118 
0119   // Get the barrel hcal hits
0120   edm::Handle<reco::TrackCollection> trackHandle;
0121   iEvent.getByToken(trackProducer_, trackHandle);
0122   const reco::TrackCollection* trackCollection = trackHandle.product();
0123 
0124   reco::RecoEcalCandidateIsolationMap isoMap(recoecalcandHandle);
0125 
0126   for (unsigned int iRecoEcalCand = 0; iRecoEcalCand < recoecalcandHandle->size(); iRecoEcalCand++) {
0127     reco::RecoEcalCandidateRef recoecalcandref(recoecalcandHandle, iRecoEcalCand);
0128 
0129     bool usePhotonVertex = false;
0130 
0131     float isol;
0132     if (countTracks_) {
0133       isol = test_->photonTrackCount(&(*recoecalcandref), trackCollection, usePhotonVertex);
0134     } else {
0135       isol = test_->photonPtSum(&(*recoecalcandref), trackCollection, usePhotonVertex);
0136     }
0137 
0138     isoMap.insert(recoecalcandref, isol);
0139   }
0140 
0141   iEvent.put(std::make_unique<reco::RecoEcalCandidateIsolationMap>(isoMap));
0142 }
0143 
0144 #include "FWCore/Framework/interface/MakerMacros.h"
0145 DEFINE_FWK_MODULE(EgammaHLTPhotonTrackIsolationProducersRegional);