-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Adding unbiased superclusters to miniAOD and EGM nano #46423
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
d84f4de
add unbiased SCs pt > 5 GeV to miniAOD
SanghyunKo 9c6091b
differentiate supercluster Pt cut and linking Pt cut
SanghyunKo af375a2
propagate SC collection to the EGM flavor nano
SanghyunKo d0d570d
minimize the file size increase of miniAOD
SanghyunKo 3f7ea82
replace the ratio of corr/uncorr variable to the uncorrected pt (to a…
SanghyunKo d4762a9
apply code-checks
SanghyunKo 3e9b4b4
reflect changes in #3f7ea82 to nanoDQM plots
SanghyunKo 7275316
incorporate SC trk isolation from #42007
SanghyunKo 6340fac
apply code-checks
SanghyunKo b2c2152
lower the SC pt threshold to accommodate a possible future development
SanghyunKo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
RecoEgamma/EgammaIsolationAlgos/interface/SuperclusTkIsolFromCands.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| #ifndef RecoEgamma_EgammaIsolationAlgos_SuperclusTkIsolFromCands_h | ||
| #define RecoEgamma_EgammaIsolationAlgos_SuperclusTkIsolFromCands_h | ||
|
|
||
| #include "CommonTools/Utils/interface/KinematicColumns.h" | ||
| #include "DataFormats/TrackReco/interface/TrackBase.h" | ||
| #include "DataFormats/TrackReco/interface/TrackFwd.h" | ||
| #include "DataFormats/PatCandidates/interface/PackedCandidate.h" | ||
| #include "DataFormats/Math/interface/Point3D.h" | ||
| #include "DataFormats/EgammaReco/interface/SuperCluster.h" | ||
| #include "FWCore/SOA/interface/Table.h" | ||
| #include "FWCore/ParameterSet/interface/ParameterSet.h" | ||
| #include "FWCore/ParameterSet/interface/ParameterSetDescription.h" | ||
| #include "RecoEgamma/EgammaIsolationAlgos/interface/EleTkIsolFromCands.h" | ||
|
|
||
| class SuperclusTkIsolFromCands : public EleTkIsolFromCands { | ||
| public: | ||
| explicit SuperclusTkIsolFromCands(Configuration const& cfg, reco::TrackCollection const& tracks) | ||
| : EleTkIsolFromCands(cfg, tracks) {} | ||
| explicit SuperclusTkIsolFromCands(Configuration const& cfg, | ||
| pat::PackedCandidateCollection const& cands, | ||
| PIDVeto pidVeto = PIDVeto::NONE) | ||
| : EleTkIsolFromCands(cfg, cands, pidVeto) {} | ||
|
|
||
| Output operator()(const reco::SuperCluster& sc, const math::XYZPoint& vtx); | ||
| }; | ||
|
|
||
| #endif |
129 changes: 129 additions & 0 deletions
129
RecoEgamma/EgammaIsolationAlgos/plugins/SuperclusValueMapProducer.cc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,129 @@ | ||
| #include "FWCore/Framework/interface/Frameworkfwd.h" | ||
| #include "FWCore/Framework/interface/stream/EDProducer.h" | ||
| #include "FWCore/Framework/interface/Event.h" | ||
| #include "FWCore/Framework/interface/ESHandle.h" | ||
| #include "FWCore/Framework/interface/MakerMacros.h" | ||
| #include "FWCore/ParameterSet/interface/ParameterSet.h" | ||
|
|
||
| #include "DataFormats/Common/interface/ValueMap.h" | ||
| #include "DataFormats/Common/interface/View.h" | ||
| #include "DataFormats/Common/interface/Handle.h" | ||
| #include "DataFormats/Math/interface/Point3D.h" | ||
| #include "DataFormats/PatCandidates/interface/PackedCandidate.h" | ||
|
|
||
| #include "RecoEgamma/EgammaIsolationAlgos/interface/SuperclusTkIsolFromCands.h" | ||
|
|
||
| // copy-pasted from ElectronHEEPIDValueMapProducer | ||
|
|
||
| class SuperclusValueMapProducer : public edm::stream::EDProducer<> { | ||
| public: | ||
| explicit SuperclusValueMapProducer(const edm::ParameterSet&); | ||
| ~SuperclusValueMapProducer() = default; | ||
|
|
||
| private: | ||
| void produce(edm::Event&, const edm::EventSetup&) override; | ||
|
|
||
| std::vector<edm::EDGetTokenT<pat::PackedCandidateCollection>> setTokens(const std::vector<edm::InputTag>& tags); | ||
|
|
||
| template <typename T> | ||
| static void writeValueMap(edm::Event& iEvent, | ||
| const edm::Handle<edm::View<reco::SuperCluster>>& handle, | ||
| const std::vector<T>& values, | ||
| const std::string& label); | ||
|
|
||
| std::vector<SuperclusTkIsolFromCands::PIDVeto> candVetos_; | ||
|
|
||
| const std::vector<edm::InputTag> candTags_; | ||
| const std::vector<edm::EDGetTokenT<pat::PackedCandidateCollection>> candTokens_; | ||
| const edm::EDGetTokenT<edm::View<reco::SuperCluster>> scToken_; | ||
| const edm::EDGetTokenT<edm::View<reco::Vertex>> pvToken_; | ||
| const edm::EDGetTokenT<reco::BeamSpot> bsToken_; | ||
|
|
||
| const SuperclusTkIsolFromCands::Configuration trkIsoCalcCfg_; | ||
|
|
||
| const std::string superclusTkIsoLabel_ = "superclusTkIso"; | ||
| }; | ||
|
|
||
| SuperclusValueMapProducer::SuperclusValueMapProducer(const edm::ParameterSet& iConfig) | ||
| : candTags_(iConfig.getParameter<std::vector<edm::InputTag>>("cands")), | ||
| candTokens_(setTokens(candTags_)), | ||
| scToken_(consumes<edm::View<reco::SuperCluster>>(iConfig.getParameter<edm::InputTag>("srcSc"))), | ||
| pvToken_(consumes<edm::View<reco::Vertex>>(iConfig.getParameter<edm::InputTag>("srcPv"))), | ||
| bsToken_(consumes<reco::BeamSpot>(iConfig.getParameter<edm::InputTag>("srcBs"))), | ||
| trkIsoCalcCfg_(iConfig.getParameter<edm::ParameterSet>("trkIsoConfig")) { | ||
| auto fillVetos = [](const auto& in, auto& out) { | ||
| std::transform(in.begin(), in.end(), std::back_inserter(out), SuperclusTkIsolFromCands::pidVetoFromStr); | ||
| }; | ||
|
|
||
| fillVetos(iConfig.getParameter<std::vector<std::string>>("candVetos"), candVetos_); | ||
|
|
||
| if (candVetos_.size() != candTags_.size()) | ||
| throw cms::Exception("ConfigError") << "Error candVetos should be the same size as cands" << std::endl; | ||
|
|
||
| produces<edm::ValueMap<float>>(superclusTkIsoLabel_); | ||
| } | ||
|
|
||
| void SuperclusValueMapProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) { | ||
| edm::Handle<edm::View<reco::SuperCluster>> scHandle; | ||
| iEvent.getByToken(scToken_, scHandle); | ||
|
|
||
| edm::Handle<edm::View<reco::Vertex>> pvHandle; | ||
| iEvent.getByToken(pvToken_, pvHandle); | ||
|
|
||
| edm::Handle<reco::BeamSpot> bsHandle; | ||
| iEvent.getByToken(bsToken_, bsHandle); | ||
|
|
||
| math::XYZPoint pos; | ||
|
|
||
| if (pvHandle.isValid() && !pvHandle->empty()) | ||
| pos = pvHandle->front().position(); // first try PV | ||
| else | ||
| pos = (*bsHandle).position(); // fall back to BS | ||
|
|
||
| std::vector<edm::Handle<pat::PackedCandidateCollection>> candHandles(candTokens_.size()); | ||
| std::vector<std::unique_ptr<SuperclusTkIsolFromCands>> tkIsoCalc; | ||
|
|
||
| for (unsigned idx = 0; idx < candTokens_.size(); idx++) { | ||
| iEvent.getByToken(candTokens_.at(idx), candHandles.at(idx)); | ||
| tkIsoCalc.push_back( | ||
| std::make_unique<SuperclusTkIsolFromCands>(trkIsoCalcCfg_, *(candHandles.at(idx)), candVetos_.at(idx))); | ||
| } | ||
|
|
||
| std::vector<float> vecTkIso; | ||
| vecTkIso.reserve(scHandle->size()); | ||
|
|
||
| for (const auto& sc : *scHandle) { | ||
| float tkIso = 0.; | ||
|
|
||
| for (auto& calc : tkIsoCalc) | ||
| tkIso += (*calc)(sc, pos).ptSum; | ||
|
|
||
| vecTkIso.push_back(tkIso); | ||
| } | ||
|
|
||
| writeValueMap(iEvent, scHandle, vecTkIso, superclusTkIsoLabel_); | ||
| } | ||
|
|
||
| std::vector<edm::EDGetTokenT<pat::PackedCandidateCollection>> SuperclusValueMapProducer::setTokens( | ||
| const std::vector<edm::InputTag>& tags) { | ||
| std::vector<edm::EDGetTokenT<pat::PackedCandidateCollection>> out; | ||
|
|
||
| for (const auto& tag : tags) | ||
| out.push_back(consumes<pat::PackedCandidateCollection>(tag)); | ||
|
|
||
| return out; | ||
| } | ||
|
|
||
| template <typename T> | ||
| void SuperclusValueMapProducer::writeValueMap(edm::Event& iEvent, | ||
| const edm::Handle<edm::View<reco::SuperCluster>>& handle, | ||
| const std::vector<T>& values, | ||
| const std::string& label) { | ||
| std::unique_ptr<edm::ValueMap<T>> valMap(new edm::ValueMap<T>()); | ||
| typename edm::ValueMap<T>::Filler filler(*valMap); | ||
| filler.insert(handle, values.begin(), values.end()); | ||
| filler.fill(); | ||
| iEvent.put(std::move(valMap), label); | ||
| } | ||
|
|
||
| DEFINE_FWK_MODULE(SuperclusValueMapProducer); |
33 changes: 33 additions & 0 deletions
33
RecoEgamma/EgammaIsolationAlgos/python/superclusValueMapProducer_cfi.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| import FWCore.ParameterSet.Config as cms | ||
|
|
||
| from RecoEgamma.EgammaIsolationAlgos.electronTrackIsolations_cfi import trkIsol04CfgV2 | ||
|
|
||
| # supposed to be calculated from AOD (see https://github.com/cms-sw/cmssw/pull/42007) | ||
| # but since we didn't create the new PAT version of SC | ||
| # trk iso values are calculated on-the-fly from miniAOD | ||
| # parameters are inherited from HEEP trk iso | ||
|
|
||
| # instead, we use fairly loose inner cone & strip veto from EgammaHLTTrackIsolation | ||
| # to avoid strong bias due to the tight trk isolation | ||
| # e.g. see hltEgammaHollowTrackIsoL1Seeded filter | ||
|
|
||
| scTrkIso04 = cms.PSet( | ||
| barrelCuts = trkIsol04CfgV2.barrelCuts.clone( | ||
| minDR = 0.06, | ||
| minDEta = 0.03 | ||
| ), | ||
| endcapCuts = trkIsol04CfgV2.endcapCuts.clone( | ||
| minDR = 0.06, | ||
| minDEta = 0.03 | ||
| ) | ||
| ) | ||
|
|
||
| superclusValueMaps = cms.EDProducer("SuperclusValueMapProducer", | ||
| srcBs = cms.InputTag("offlineBeamSpot"), | ||
| srcPv = cms.InputTag("offlineSlimmedPrimaryVertices"), | ||
| srcSc = cms.InputTag("reducedEgamma:reducedSuperClusters"), | ||
| cands = cms.VInputTag("packedPFCandidates", | ||
| "lostTracks"), # do not count electron tracks in the trk iso | ||
| candVetos = cms.vstring("ELES","NONE"), | ||
| trkIsoConfig = scTrkIso04, | ||
| ) |
33 changes: 33 additions & 0 deletions
33
RecoEgamma/EgammaIsolationAlgos/src/SuperclusTkIsolFromCands.cc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| #include "RecoEgamma/EgammaIsolationAlgos/interface/SuperclusTkIsolFromCands.h" | ||
| #include "DataFormats/TrackReco/interface/Track.h" | ||
| #include "DataFormats/Math/interface/deltaR.h" | ||
|
|
||
| SuperclusTkIsolFromCands::Output SuperclusTkIsolFromCands::operator()(const reco::SuperCluster& sc, | ||
| const math::XYZPoint& vtx) { | ||
| using namespace edm::soa::col; | ||
|
|
||
| float ptSum = 0.; | ||
| int nrTrks = 0; | ||
|
|
||
| const float scEta = sc.eta(); | ||
| const float scPhi = sc.phi(); | ||
| const float vtxVz = vtx.z(); | ||
|
|
||
| const bool isBarrelSC = std::abs(scEta) < 1.5; | ||
|
|
||
| auto const& preselectedTracks = getPreselectedTracks(isBarrelSC); | ||
| auto const& cuts = isBarrelSC ? cfg_.barrelCuts : cfg_.endcapCuts; | ||
|
|
||
| for (auto const& trk : preselectedTracks) { | ||
| const float dR2 = reco::deltaR2(scEta, scPhi, trk.get<Eta>(), trk.get<Phi>()); | ||
| const float dEta = trk.get<Eta>() - scEta; | ||
| const float dZ = vtxVz - trk.get<Vz>(); | ||
|
|
||
| if (dR2 >= cuts.minDR2 && dR2 <= cuts.maxDR2 && std::abs(dEta) >= cuts.minDEta && std::abs(dZ) < cuts.maxDZ) { | ||
| ptSum += trk.get<Pt>(); | ||
| nrTrks++; | ||
| } | ||
| } | ||
|
|
||
| return {nrTrks, ptSum}; | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.