File indexing completed on 2024-04-06 12:24:51
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016 #include <memory>
0017
0018
0019 #include "FWCore/Framework/interface/Frameworkfwd.h"
0020 #include "FWCore/Framework/interface/global/EDProducer.h"
0021 #include "FWCore/Framework/interface/Event.h"
0022 #include "FWCore/Framework/interface/MakerMacros.h"
0023 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0024
0025 #include "DataFormats/EgammaCandidates/interface/Electron.h"
0026 #include "DataFormats/RecoCandidate/interface/RecoEcalCandidate.h"
0027 #include "DataFormats/EgammaCandidates/interface/ElectronFwd.h"
0028 #include "DataFormats/RecoCandidate/interface/RecoEcalCandidateFwd.h"
0029 #include "DataFormats/TrackReco/interface/TrackFwd.h"
0030 #include "DataFormats/TrackReco/interface/Track.h"
0031
0032 #include "DataFormats/EgammaCandidates/interface/ElectronIsolationAssociation.h"
0033 #include "DataFormats/RecoCandidate/interface/RecoEcalCandidateIsolation.h"
0034 #include "DataFormats/TrackingRecHit/interface/TrackingRecHit.h"
0035
0036 #include "RecoEgamma/EgammaIsolationAlgos/interface/ElectronTkIsolation.h"
0037 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0038 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0039
0040 class EgammaHLTElectronTrackIsolationProducers : public edm::global::EDProducer<> {
0041 public:
0042 explicit EgammaHLTElectronTrackIsolationProducers(const edm::ParameterSet&);
0043 ~EgammaHLTElectronTrackIsolationProducers() override;
0044 void produce(edm::StreamID sid, edm::Event&, const edm::EventSetup&) const override;
0045 static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0046
0047 private:
0048 const edm::EDGetTokenT<reco::ElectronCollection> electronProducer_;
0049 const edm::EDGetTokenT<reco::TrackCollection> trackProducer_;
0050 const edm::EDGetTokenT<reco::RecoEcalCandidateCollection> recoEcalCandidateProducer_;
0051 const edm::EDGetTokenT<reco::BeamSpot> beamSpotProducer_;
0052
0053 const bool useGsfTrack_;
0054 const bool useSCRefs_;
0055
0056 const double egTrkIsoPtMin_;
0057 const double egTrkIsoConeSize_;
0058 const double egTrkIsoZSpan_;
0059 const double egTrkIsoRSpan_;
0060 const double egTrkIsoVetoConeSizeBarrel_;
0061 const double egTrkIsoVetoConeSizeEndcap_;
0062 const double egTrkIsoStripBarrel_;
0063 const double egTrkIsoStripEndcap_;
0064 };
0065
0066 EgammaHLTElectronTrackIsolationProducers::EgammaHLTElectronTrackIsolationProducers(const edm::ParameterSet& config)
0067 : electronProducer_(consumes<reco::ElectronCollection>(config.getParameter<edm::InputTag>("electronProducer"))),
0068 trackProducer_(consumes<reco::TrackCollection>(config.getParameter<edm::InputTag>("trackProducer"))),
0069 recoEcalCandidateProducer_(
0070 consumes<reco::RecoEcalCandidateCollection>(config.getParameter<edm::InputTag>("recoEcalCandidateProducer"))),
0071 beamSpotProducer_(consumes<reco::BeamSpot>(config.getParameter<edm::InputTag>("beamSpotProducer"))),
0072 useGsfTrack_(config.getParameter<bool>("useGsfTrack")),
0073 useSCRefs_(config.getParameter<bool>("useSCRefs")),
0074 egTrkIsoPtMin_(config.getParameter<double>("egTrkIsoPtMin")),
0075 egTrkIsoConeSize_(config.getParameter<double>("egTrkIsoConeSize")),
0076 egTrkIsoZSpan_(config.getParameter<double>("egTrkIsoZSpan")),
0077 egTrkIsoRSpan_(config.getParameter<double>("egTrkIsoRSpan")),
0078 egTrkIsoVetoConeSizeBarrel_(config.getParameter<double>("egTrkIsoVetoConeSizeBarrel")),
0079 egTrkIsoVetoConeSizeEndcap_(config.getParameter<double>("egTrkIsoVetoConeSizeEndcap")),
0080 egTrkIsoStripBarrel_(config.getParameter<double>("egTrkIsoStripBarrel")),
0081 egTrkIsoStripEndcap_(config.getParameter<double>("egTrkIsoStripEndcap")) {
0082
0083 if (useSCRefs_)
0084 produces<reco::RecoEcalCandidateIsolationMap>();
0085 else
0086 produces<reco::ElectronIsolationMap>();
0087 }
0088
0089 EgammaHLTElectronTrackIsolationProducers::~EgammaHLTElectronTrackIsolationProducers() {}
0090
0091 void EgammaHLTElectronTrackIsolationProducers::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0092 edm::ParameterSetDescription desc;
0093 desc.add<edm::InputTag>("electronProducer", edm::InputTag("hltEleAnyWP80PixelMatchElectronsL1Seeded"));
0094 desc.add<edm::InputTag>("trackProducer", edm::InputTag("hltL1SeededEgammaRegionalCTFFinalFitWithMaterial"));
0095 desc.add<edm::InputTag>("recoEcalCandidateProducer", edm::InputTag());
0096 desc.add<edm::InputTag>("beamSpotProducer", edm::InputTag("hltOnlineBeamSpot"));
0097 desc.add<double>("egTrkIsoPtMin", 1.0);
0098 desc.add<double>("egTrkIsoConeSize", 0.3);
0099 desc.add<double>("egTrkIsoZSpan", 0.15);
0100 desc.add<double>("egTrkIsoRSpan", 999999.0);
0101 desc.add<double>("egTrkIsoVetoConeSizeBarrel", 0.03);
0102 desc.add<double>("egTrkIsoVetoConeSizeEndcap", 0.03);
0103 desc.add<double>("egTrkIsoStripBarrel", 0.03);
0104 desc.add<double>("egTrkIsoStripEndcap", 0.03);
0105 desc.add<bool>("useGsfTrack", false);
0106 desc.add<bool>("useSCRefs", false);
0107
0108 descriptions.add("hltEgammaHLTElectronTrackIsolationProducers", desc);
0109 }
0110 void EgammaHLTElectronTrackIsolationProducers::produce(edm::StreamID sid,
0111 edm::Event& iEvent,
0112 const edm::EventSetup&) const {
0113 edm::Handle<reco::ElectronCollection> electronHandle;
0114 iEvent.getByToken(electronProducer_, electronHandle);
0115
0116
0117 edm::Handle<reco::TrackCollection> trackHandle;
0118 iEvent.getByToken(trackProducer_, trackHandle);
0119 const reco::TrackCollection* trackCollection = trackHandle.product();
0120
0121 reco::ElectronIsolationMap eleMap(electronHandle);
0122
0123 edm::Handle<reco::BeamSpot> recoBeamSpotHandle;
0124 iEvent.getByToken(beamSpotProducer_, recoBeamSpotHandle);
0125
0126 const reco::BeamSpot::Point& beamSpotPosition = recoBeamSpotHandle->position();
0127
0128 ElectronTkIsolation isoAlgo(egTrkIsoConeSize_,
0129 egTrkIsoVetoConeSizeBarrel_,
0130 egTrkIsoVetoConeSizeEndcap_,
0131 egTrkIsoStripBarrel_,
0132 egTrkIsoStripEndcap_,
0133 egTrkIsoPtMin_,
0134 egTrkIsoZSpan_,
0135 egTrkIsoRSpan_,
0136 trackCollection,
0137 beamSpotPosition);
0138
0139 if (useSCRefs_) {
0140 edm::Handle<reco::RecoEcalCandidateCollection> recoEcalCandHandle;
0141 iEvent.getByToken(recoEcalCandidateProducer_, recoEcalCandHandle);
0142 reco::RecoEcalCandidateIsolationMap recoEcalCandMap(recoEcalCandHandle);
0143
0144 for (reco::RecoEcalCandidateCollection::const_iterator iRecoEcalCand = recoEcalCandHandle->begin();
0145 iRecoEcalCand != recoEcalCandHandle->end();
0146 iRecoEcalCand++) {
0147 reco::RecoEcalCandidateRef recoEcalCandRef(recoEcalCandHandle, iRecoEcalCand - recoEcalCandHandle->begin());
0148
0149 reco::ElectronRef eleRef;
0150 for (reco::ElectronCollection::const_iterator eleIt = electronHandle->begin(); eleIt != electronHandle->end();
0151 eleIt++) {
0152 if (eleIt->superCluster() == recoEcalCandRef->superCluster()) {
0153 eleRef = reco::ElectronRef(electronHandle, eleIt - electronHandle->begin());
0154 break;
0155 }
0156 }
0157 float isol = 999999;
0158 if (eleRef.isNonnull()) {
0159 const reco::Track* eleTrk = useGsfTrack_ ? &*eleRef->gsfTrack() : &*eleRef->track();
0160 isol = isoAlgo.getIso(eleTrk).second;
0161 }
0162 recoEcalCandMap.insert(recoEcalCandRef, isol);
0163 }
0164
0165 iEvent.put(std::make_unique<reco::RecoEcalCandidateIsolationMap>(recoEcalCandMap));
0166
0167 } else {
0168 for (reco::ElectronCollection::const_iterator iElectron = electronHandle->begin();
0169 iElectron != electronHandle->end();
0170 iElectron++) {
0171 reco::ElectronRef eleRef(reco::ElectronRef(electronHandle, iElectron - electronHandle->begin()));
0172 const reco::Track* eleTrk = useGsfTrack_ ? &*eleRef->gsfTrack() : &*eleRef->track();
0173 float isol = isoAlgo.getIso(eleTrk).second;
0174 eleMap.insert(eleRef, isol);
0175 }
0176
0177 iEvent.put(std::make_unique<reco::ElectronIsolationMap>(eleMap));
0178 }
0179 }
0180
0181 #include "FWCore/Framework/interface/MakerMacros.h"
0182 DEFINE_FWK_MODULE(EgammaHLTElectronTrackIsolationProducers);