File indexing completed on 2024-04-06 11:59:08
0001
0002
0003
0004
0005
0006 #include <vector>
0007 #include <memory>
0008 #include <algorithm>
0009
0010 #include "DataFormats/Common/interface/Handle.h"
0011 #include "DataFormats/Common/interface/Ref.h"
0012 #include "DataFormats/Common/interface/TriggerResults.h"
0013 #include "DataFormats/HcalIsolatedTrack/interface/IsolatedPixelTrackCandidate.h"
0014 #include "DataFormats/HcalIsolatedTrack/interface/IsolatedPixelTrackCandidateFwd.h"
0015 #include "DataFormats/HLTReco/interface/TriggerFilterObjectWithRefs.h"
0016 #include "DataFormats/Math/interface/deltaR.h"
0017 #include "DataFormats/TrackReco/interface/Track.h"
0018
0019
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/EventSetup.h"
0024 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0025 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0026 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0027 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0028 #include "FWCore/Utilities/interface/Exception.h"
0029
0030
0031
0032 #include "Math/GenVector/VectorUtil.h"
0033 #include "Math/GenVector/PxPyPzE4D.h"
0034
0035 class IPTCorrector : public edm::global::EDProducer<> {
0036 public:
0037 IPTCorrector(const edm::ParameterSet& ps);
0038
0039 static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0040
0041 void produce(edm::StreamID, edm::Event&, edm::EventSetup const&) const override;
0042
0043 private:
0044 const edm::EDGetTokenT<reco::TrackCollection> tok_cor_;
0045 const edm::EDGetTokenT<trigger::TriggerFilterObjectWithRefs> tok_uncor_;
0046 const double assocCone_;
0047 };
0048
0049 IPTCorrector::IPTCorrector(const edm::ParameterSet& config)
0050 : tok_cor_(consumes<reco::TrackCollection>(config.getParameter<edm::InputTag>("corTracksLabel"))),
0051 tok_uncor_(consumes<trigger::TriggerFilterObjectWithRefs>(config.getParameter<edm::InputTag>("filterLabel"))),
0052 assocCone_(config.getParameter<double>("associationCone")) {
0053
0054 produces<reco::IsolatedPixelTrackCandidateCollection>();
0055 }
0056
0057 void IPTCorrector::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0058 edm::ParameterSetDescription desc;
0059 desc.add<edm::InputTag>("corTracksLabel", edm::InputTag("hltIter0PFlowCtfWithMaterialTracks"));
0060 desc.add<edm::InputTag>("filterLabel", edm::InputTag("hltIsolPixelTrackL2Filter"));
0061 desc.add<double>("associationCone", 0.2);
0062 descriptions.add("iptCorrector", desc);
0063 }
0064
0065 void IPTCorrector::produce(edm::StreamID, edm::Event& theEvent, edm::EventSetup const&) const {
0066 auto trackCollection = std::make_unique<reco::IsolatedPixelTrackCandidateCollection>();
0067
0068 const edm::Handle<reco::TrackCollection>& corTracks = theEvent.getHandle(tok_cor_);
0069 const edm::Handle<trigger::TriggerFilterObjectWithRefs>& fiCand = theEvent.getHandle(tok_uncor_);
0070
0071 std::vector<edm::Ref<reco::IsolatedPixelTrackCandidateCollection> > isoPixTrackRefs;
0072
0073 fiCand->getObjects(trigger::TriggerTrack, isoPixTrackRefs);
0074
0075 int nCand = isoPixTrackRefs.size();
0076
0077
0078
0079 for (int p = 0; p < nCand; p++) {
0080 double iptEta = isoPixTrackRefs[p]->track()->eta();
0081 double iptPhi = isoPixTrackRefs[p]->track()->phi();
0082
0083 int ntrk = 0;
0084 double minDR = 100;
0085 reco::TrackCollection::const_iterator citSel;
0086
0087 for (reco::TrackCollection::const_iterator cit = corTracks->begin(); cit != corTracks->end(); cit++) {
0088 double dR = deltaR(cit->eta(), cit->phi(), iptEta, iptPhi);
0089 if (dR < minDR && dR < assocCone_) {
0090 minDR = dR;
0091 ntrk++;
0092 citSel = cit;
0093 }
0094 }
0095
0096 if (ntrk > 0) {
0097 reco::IsolatedPixelTrackCandidate newCandidate(reco::TrackRef(corTracks, citSel - corTracks->begin()),
0098 isoPixTrackRefs[p]->l1tau(),
0099 isoPixTrackRefs[p]->maxPtPxl(),
0100 isoPixTrackRefs[p]->sumPtPxl());
0101 newCandidate.setEnergyIn(isoPixTrackRefs[p]->energyIn());
0102 newCandidate.setEnergyOut(isoPixTrackRefs[p]->energyOut());
0103 newCandidate.setNHitIn(isoPixTrackRefs[p]->nHitIn());
0104 newCandidate.setNHitOut(isoPixTrackRefs[p]->nHitOut());
0105 if (isoPixTrackRefs[p]->etaPhiEcalValid()) {
0106 std::pair<double, double> etaphi = (isoPixTrackRefs[p]->etaPhiEcal());
0107 newCandidate.setEtaPhiEcal(etaphi.first, etaphi.second);
0108 }
0109 trackCollection->push_back(newCandidate);
0110 }
0111 }
0112
0113
0114 theEvent.put(std::move(trackCollection));
0115 }
0116
0117 #include "FWCore/PluginManager/interface/ModuleDef.h"
0118 #include "FWCore/Framework/interface/MakerMacros.h"
0119
0120 DEFINE_FWK_MODULE(IPTCorrector);