Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-09-14 22:43:16

0001 // Author: Sam Harper (RAL/CERN)
0002 // L1 track isolation producer for the HLT
0003 // A quick primer on how the E/gamma HLT works w.r.t to ID variables
0004 // 1. the supercluster is the primary object
0005 // 2. superclusters get id variables associated to them via association maps keyed
0006 //    to the supercluster
0007 // However here we also need to read in electron objects as we need to solve for which
0008 // GsfTrack associated to the supercluster to use for the isolation
0009 // The electron producer solves for this and assigns the electron the best GsfTrack
0010 // which we will use for the vz of the electron
0011 // One thing which Swagata Mukherjee pointed out is that we have to be careful of
0012 // is getting a bad GsfTrack with a bad vertex which  will give us a fake vz which then
0013 // leads to a perfectly isolated electron as that random vz is not a vertex
0014 
0015 #include "FWCore/Framework/interface/Frameworkfwd.h"
0016 #include "FWCore/Framework/interface/Event.h"
0017 #include "FWCore/Framework/interface/MakerMacros.h"
0018 #include "FWCore/Framework/interface/global/EDProducer.h"
0019 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0020 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0021 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0022 
0023 #include "DataFormats/EgammaCandidates/interface/Electron.h"
0024 #include "DataFormats/EgammaCandidates/interface/ElectronFwd.h"
0025 #include "DataFormats/RecoCandidate/interface/RecoEcalCandidate.h"
0026 #include "DataFormats/RecoCandidate/interface/RecoEcalCandidateFwd.h"
0027 #include "DataFormats/RecoCandidate/interface/RecoEcalCandidateIsolation.h"
0028 #include "DataFormats/TrackReco/interface/TrackFwd.h"
0029 #include "DataFormats/TrackReco/interface/Track.h"
0030 
0031 #include "RecoEgamma/EgammaIsolationAlgos/interface/EgammaL1TkIsolation.h"
0032 
0033 #include <memory>
0034 
0035 class EgammaHLTEleL1TrackIsolProducer : public edm::global::EDProducer<> {
0036 public:
0037   explicit EgammaHLTEleL1TrackIsolProducer(const edm::ParameterSet&);
0038   ~EgammaHLTEleL1TrackIsolProducer() override = default;
0039   void produce(edm::StreamID sid, edm::Event&, const edm::EventSetup&) const override;
0040   static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0041 
0042 private:
0043   const edm::EDGetTokenT<reco::RecoEcalCandidateCollection> ecalCandsToken_;
0044   const edm::EDGetTokenT<reco::ElectronCollection> elesToken_;
0045   const edm::EDGetTokenT<L1TrackCollection> l1TrksToken_;
0046   EgammaL1TkIsolation isolAlgo_;
0047 };
0048 
0049 EgammaHLTEleL1TrackIsolProducer::EgammaHLTEleL1TrackIsolProducer(const edm::ParameterSet& config)
0050     : ecalCandsToken_(consumes<reco::RecoEcalCandidateCollection>(config.getParameter<edm::InputTag>("ecalCands"))),
0051       elesToken_(consumes<reco::ElectronCollection>(config.getParameter<edm::InputTag>("eles"))),
0052       l1TrksToken_(consumes<L1TrackCollection>(config.getParameter<edm::InputTag>("l1Tracks"))),
0053       isolAlgo_(config.getParameter<edm::ParameterSet>("isolCfg")) {
0054   produces<reco::RecoEcalCandidateIsolationMap>();
0055 }
0056 
0057 void EgammaHLTEleL1TrackIsolProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0058   edm::ParameterSetDescription desc;
0059   desc.add<edm::InputTag>("ecalCands", edm::InputTag("hltEgammaCandidates"));
0060   desc.add<edm::InputTag>("eles", edm::InputTag("hltEgammaGsfElectrons"));
0061   desc.add<edm::InputTag>("l1Tracks", edm::InputTag("l1tTTTracksFromTrackletEmulation", "Level1TTTracks"));
0062   desc.add("isolCfg", EgammaL1TkIsolation::makePSetDescription());
0063   descriptions.add("hltEgammaHLTEleL1TrackIsolProducer", desc);
0064 }
0065 void EgammaHLTEleL1TrackIsolProducer::produce(edm::StreamID sid,
0066                                               edm::Event& iEvent,
0067                                               const edm::EventSetup& iSetup) const {
0068   auto ecalCands = iEvent.getHandle(ecalCandsToken_);
0069   auto eles = iEvent.getHandle(elesToken_);
0070   auto l1Trks = iEvent.getHandle(l1TrksToken_);
0071 
0072   auto recoEcalCandMap = std::make_unique<reco::RecoEcalCandidateIsolationMap>(ecalCands);
0073 
0074   for (size_t candNr = 0; candNr < ecalCands->size(); candNr++) {
0075     reco::RecoEcalCandidateRef recoEcalCandRef(ecalCands, candNr);
0076     reco::ElectronRef eleRef;
0077     for (size_t eleNr = 0; eleNr < eles->size(); eleNr++) {
0078       if ((*eles)[eleNr].superCluster() == recoEcalCandRef->superCluster()) {
0079         eleRef = reco::ElectronRef(eles, eleNr);
0080         break;
0081       }
0082     }
0083 
0084     float isol =
0085         eleRef.isNonnull() ? isolAlgo_.calIsol(*eleRef->gsfTrack(), *l1Trks).second : std::numeric_limits<float>::max();
0086 
0087     recoEcalCandMap->insert(recoEcalCandRef, isol);
0088   }
0089   iEvent.put(std::move(recoEcalCandMap));
0090 }
0091 
0092 #include "FWCore/Framework/interface/MakerMacros.h"
0093 DEFINE_FWK_MODULE(EgammaHLTEleL1TrackIsolProducer);