File indexing completed on 2024-04-06 12:24:55
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include "DataFormats/BeamSpot/interface/BeamSpot.h"
0010 #include "DataFormats/Common/interface/Handle.h"
0011 #include "DataFormats/EgammaCandidates/interface/GsfElectron.h"
0012 #include "FWCore/Framework/interface/Event.h"
0013 #include "FWCore/Framework/interface/EventSetup.h"
0014 #include "FWCore/Framework/interface/global/EDProducer.h"
0015 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0016 #include "RecoEgamma/EgammaIsolationAlgos/interface/ElectronTkIsolation.h"
0017
0018 class EgammaElectronTkIsolationProducer : public edm::global::EDProducer<> {
0019 public:
0020 explicit EgammaElectronTkIsolationProducer(const edm::ParameterSet&);
0021
0022 void produce(edm::StreamID, edm::Event&, const edm::EventSetup&) const override;
0023
0024 private:
0025 const edm::EDGetTokenT<reco::GsfElectronCollection> electronProducer_;
0026 const edm::EDGetTokenT<reco::TrackCollection> trackProducer_;
0027 const edm::EDGetTokenT<reco::BeamSpot> beamspotProducer_;
0028
0029 const double ptMin_;
0030 const double intRadiusBarrel_;
0031 const double intRadiusEndcap_;
0032 const double stripBarrel_;
0033 const double stripEndcap_;
0034 const double extRadius_;
0035 const double maxVtxDist_;
0036 const double drb_;
0037 };
0038
0039 #include "FWCore/Framework/interface/MakerMacros.h"
0040 DEFINE_FWK_MODULE(EgammaElectronTkIsolationProducer);
0041
0042 EgammaElectronTkIsolationProducer::EgammaElectronTkIsolationProducer(const edm::ParameterSet& config)
0043 : electronProducer_{consumes(config.getParameter<edm::InputTag>("electronProducer"))},
0044 trackProducer_{consumes(config.getParameter<edm::InputTag>("trackProducer"))},
0045 beamspotProducer_{consumes(config.getParameter<edm::InputTag>("BeamspotProducer"))},
0046
0047 ptMin_{config.getParameter<double>("ptMin")},
0048 intRadiusBarrel_{config.getParameter<double>("intRadiusBarrel")},
0049 intRadiusEndcap_{config.getParameter<double>("intRadiusEndcap")},
0050 stripBarrel_{config.getParameter<double>("stripBarrel")},
0051 stripEndcap_{config.getParameter<double>("stripEndcap")},
0052 extRadius_{config.getParameter<double>("extRadius")},
0053 maxVtxDist_{config.getParameter<double>("maxVtxDist")},
0054 drb_{config.getParameter<double>("maxVtxDistXY")}
0055
0056 {
0057 produces<edm::ValueMap<double>>();
0058 }
0059
0060 void EgammaElectronTkIsolationProducer::produce(edm::StreamID, edm::Event& iEvent, const edm::EventSetup&) const {
0061
0062 auto electronHandle = iEvent.getHandle(electronProducer_);
0063
0064
0065 auto isoMap = std::make_unique<edm::ValueMap<double>>();
0066 edm::ValueMap<double>::Filler filler(*isoMap);
0067 std::vector<double> retV(electronHandle->size(), 0);
0068
0069 ElectronTkIsolation myTkIsolation(extRadius_,
0070 intRadiusBarrel_,
0071 intRadiusEndcap_,
0072 stripBarrel_,
0073 stripEndcap_,
0074 ptMin_,
0075 maxVtxDist_,
0076 drb_,
0077 &iEvent.get(trackProducer_),
0078 iEvent.get(beamspotProducer_).position());
0079
0080 for (unsigned int i = 0; i < electronHandle->size(); ++i) {
0081 double isoValue = myTkIsolation.getPtTracks(&(electronHandle->at(i)));
0082 retV[i] = isoValue;
0083 }
0084
0085
0086 filler.insert(electronHandle, retV.begin(), retV.end());
0087 filler.fill();
0088 iEvent.put(std::move(isoMap));
0089 }