-
Notifications
You must be signed in to change notification settings - Fork 4.6k
[Mini from mini] v2-v4 to v6 full recipe #49098
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
Changes from 12 commits
b5d0e83
026c148
b299d7f
70f135a
574643a
1ba913b
deedc43
09fba89
da17bba
6c38aaf
7ced6f8
6c63a37
bc5a389
8c97130
52b2549
af42698
75569c8
f8fd039
1a552c6
2f221c7
c0069ea
18c67c3
6e062cf
514a8ca
51f24a9
8e9096d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| import FWCore.ParameterSet.Config as cms | ||
|
|
||
| patAlgosToolsTask = cms.Task() | ||
|
|
||
| from PhysicsTools.PatAlgos.slimming.miniAODFromMiniAOD_tools import miniAODFromMiniAOD_customizeAllData as miniAOD_customizeAllData | ||
| from PhysicsTools.PatAlgos.slimming.miniAODFromMiniAOD_tools import miniAODFromMiniAOD_customizeAllMC as miniAOD_customizeAllMC | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| #include "FWCore/Framework/interface/stream/EDProducer.h" | ||
| #include "FWCore/Framework/interface/Event.h" | ||
| #include "FWCore/ParameterSet/interface/ParameterSet.h" | ||
| #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" | ||
| #include "FWCore/ParameterSet/interface/ParameterSetDescription.h" | ||
| #include "FWCore/Utilities/interface/InputTag.h" | ||
| #include "DataFormats/Common/interface/View.h" | ||
|
|
||
| #include "DataFormats/PatCandidates/interface/Electron.h" | ||
| #include "DataFormats/PatCandidates/interface/PackedCandidate.h" | ||
|
|
||
| #include "DataFormats/Candidate/interface/CandidateFwd.h" | ||
|
|
||
| namespace pat { | ||
| class PATElectronCandidatesRekeyer : public edm::stream::EDProducer<> { | ||
| public: | ||
| explicit PATElectronCandidatesRekeyer(const edm::ParameterSet &iConfig); | ||
| ~PATElectronCandidatesRekeyer() override; | ||
|
|
||
| void produce(edm::Event &, const edm::EventSetup &) override; | ||
|
|
||
| private: | ||
| // configurables | ||
| edm::EDGetTokenT<std::vector<pat::Electron>> src_; | ||
| edm::EDGetTokenT<reco::CandidateView> pcNewCandViewToken_; | ||
| edm::EDGetTokenT<pat::PackedCandidateCollection> pcNewToken_; | ||
| }; | ||
|
|
||
| } // namespace pat | ||
|
|
||
| using namespace pat; | ||
|
|
||
| PATElectronCandidatesRekeyer::PATElectronCandidatesRekeyer(const edm::ParameterSet &iConfig) | ||
| : | ||
|
|
||
| src_(consumes<std::vector<pat::Electron>>(iConfig.getParameter<edm::InputTag>("src"))), | ||
| pcNewCandViewToken_(consumes<reco::CandidateView>(iConfig.getParameter<edm::InputTag>("packedPFCandidatesNew"))), | ||
| pcNewToken_( | ||
| consumes<pat::PackedCandidateCollection>(iConfig.getParameter<edm::InputTag>("packedPFCandidatesNew"))) { | ||
| produces<std::vector<pat::Electron>>(); | ||
| } | ||
|
|
||
| PATElectronCandidatesRekeyer::~PATElectronCandidatesRekeyer() {} | ||
|
|
||
| void PATElectronCandidatesRekeyer::produce(edm::Event &iEvent, edm::EventSetup const &) { | ||
| edm::Handle<std::vector<pat::Electron>> src; | ||
| iEvent.getByToken(src_, src); | ||
|
|
||
| edm::Handle<reco::CandidateView> pcNewCandViewHandle; | ||
| iEvent.getByToken(pcNewCandViewToken_, pcNewCandViewHandle); | ||
|
|
||
| edm::Handle<pat::PackedCandidateCollection> pcNewHandle; | ||
| iEvent.getByToken(pcNewToken_, pcNewHandle); | ||
|
|
||
| auto outPtrP = std::make_unique<std::vector<pat::Electron>>(); | ||
| outPtrP->reserve(src->size()); | ||
|
|
||
| for (size_t i = 0; i < src->size(); ++i) { | ||
| // copy original pat object and append to vector | ||
| outPtrP->emplace_back((*src)[i]); | ||
|
|
||
| std::vector<unsigned int> keys; | ||
| for (const edm::Ref<pat::PackedCandidateCollection> &ref : outPtrP->back().associatedPackedPFCandidates()) { | ||
| keys.push_back(ref.key()); | ||
| }; | ||
| outPtrP->back().setAssociatedPackedPFCandidates( | ||
| edm::RefProd<pat::PackedCandidateCollection>(pcNewHandle), keys.begin(), keys.end()); | ||
| if (keys.size() == 1) { | ||
| outPtrP->back().refToOrig_ = outPtrP->back().sourceCandidatePtr(0); | ||
| } else { | ||
| outPtrP->back().refToOrig_ = reco::CandidatePtr(pcNewHandle.id()); | ||
| } | ||
vlimant marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
| iEvent.put(std::move(outPtrP)); | ||
| } | ||
|
|
||
| #include "FWCore/Framework/interface/MakerMacros.h" | ||
| DEFINE_FWK_MODULE(PATElectronCandidatesRekeyer); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,110 @@ | ||
| #include "FWCore/Framework/interface/stream/EDProducer.h" | ||
| #include "FWCore/Framework/interface/Event.h" | ||
| #include "FWCore/ParameterSet/interface/ParameterSet.h" | ||
| #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" | ||
| #include "FWCore/ParameterSet/interface/ParameterSetDescription.h" | ||
| #include "FWCore/Utilities/interface/InputTag.h" | ||
| #include "DataFormats/Common/interface/View.h" | ||
|
|
||
| #include "DataFormats/PatCandidates/interface/Jet.h" | ||
| #include "DataFormats/PatCandidates/interface/PackedCandidate.h" | ||
|
|
||
| #include "DataFormats/Candidate/interface/CandidateFwd.h" | ||
|
|
||
| namespace pat { | ||
| class PATJetCandidatesRekeyer : public edm::stream::EDProducer<> { | ||
| public: | ||
| explicit PATJetCandidatesRekeyer(const edm::ParameterSet &iConfig); | ||
| ~PATJetCandidatesRekeyer() override; | ||
|
|
||
| void produce(edm::Event &, const edm::EventSetup &) override; | ||
|
|
||
| private: | ||
| // configurables | ||
| edm::EDGetTokenT<std::vector<pat::Jet>> src_; | ||
| edm::EDGetTokenT<reco::CandidateView> pcNewCandViewToken_; | ||
| edm::EDGetTokenT<pat::PackedCandidateCollection> pcNewToken_; | ||
| // std::string subjetLabel_; | ||
| }; | ||
| } // namespace pat | ||
|
|
||
| using namespace pat; | ||
|
|
||
| PATJetCandidatesRekeyer::PATJetCandidatesRekeyer(const edm::ParameterSet &iConfig) | ||
| : src_(consumes<std::vector<pat::Jet>>(iConfig.getParameter<edm::InputTag>("src"))), | ||
| pcNewCandViewToken_(consumes<reco::CandidateView>(iConfig.getParameter<edm::InputTag>("packedPFCandidatesNew"))), | ||
| pcNewToken_( | ||
| consumes<pat::PackedCandidateCollection>(iConfig.getParameter<edm::InputTag>("packedPFCandidatesNew"))) { | ||
| produces<std::vector<pat::Jet>>(); | ||
| produces<edm::OwnVector<reco::BaseTagInfo>>("tagInfos"); | ||
| } | ||
|
|
||
| PATJetCandidatesRekeyer::~PATJetCandidatesRekeyer() {} | ||
|
|
||
| void PATJetCandidatesRekeyer::produce(edm::Event &iEvent, edm::EventSetup const &) { | ||
| edm::Handle<std::vector<pat::Jet>> src; | ||
| iEvent.getByToken(src_, src); | ||
|
|
||
| edm::Handle<reco::CandidateView> pcNewCandViewHandle; | ||
| iEvent.getByToken(pcNewCandViewToken_, pcNewCandViewHandle); | ||
|
|
||
| edm::Handle<pat::PackedCandidateCollection> pcNewHandle; | ||
| iEvent.getByToken(pcNewToken_, pcNewHandle); | ||
|
|
||
| edm::RefProd<edm::OwnVector<reco::BaseTagInfo>> h_tagInfosOut = | ||
| iEvent.getRefBeforePut<edm::OwnVector<reco::BaseTagInfo>>("tagInfos"); | ||
| auto tagInfosOut = std::make_unique<edm::OwnVector<reco::BaseTagInfo>>(); | ||
|
|
||
| auto outPtrP = std::make_unique<std::vector<pat::Jet>>(); | ||
| outPtrP->reserve(src->size()); | ||
|
|
||
| // | ||
| // | ||
| // | ||
| for (std::vector<pat::Jet>::const_iterator ibegin = (*src).begin(), iend = (*src).end(), ijet = ibegin; ijet != iend; | ||
| ++ijet) { | ||
vlimant marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| for (TagInfoFwdPtrCollection::const_iterator iinfoBegin = ijet->tagInfosFwdPtr().begin(), | ||
| iinfoEnd = ijet->tagInfosFwdPtr().end(), | ||
| iinfo = iinfoBegin; | ||
| iinfo != iinfoEnd; | ||
| ++iinfo) { | ||
|
||
| tagInfosOut->push_back(**iinfo); | ||
| } | ||
| } | ||
|
|
||
| edm::OrphanHandle<edm::OwnVector<reco::BaseTagInfo>> oh_tagInfosOut = iEvent.put(std::move(tagInfosOut), "tagInfos"); | ||
|
|
||
| // | ||
| // | ||
| // | ||
| unsigned int tagInfoIndex = 0; | ||
|
|
||
| for (size_t i = 0; i < src->size(); ++i) { | ||
vlimant marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| // copy original pat object and append to vector | ||
| outPtrP->emplace_back((*src)[i]); | ||
|
|
||
| reco::CompositePtrCandidate::daughters old = outPtrP->back().daughterPtrVector(); | ||
| outPtrP->back().clearDaughters(); | ||
| for (const auto &dauItr : old) { | ||
| outPtrP->back().addDaughter(edm::Ptr<reco::Candidate>(pcNewHandle, dauItr.key())); | ||
| } | ||
|
|
||
| // Copy the tag infos | ||
| for (TagInfoFwdPtrCollection::const_iterator iinfoBegin = outPtrP->back().tagInfosFwdPtr().begin(), | ||
| iinfoEnd = outPtrP->back().tagInfosFwdPtr().end(), | ||
| iinfo = iinfoBegin; | ||
| iinfo != iinfoEnd; | ||
| ++iinfo) { | ||
| // Update the "forward" bit of the FwdPtr to point at the new collection. | ||
| // ptr to "this" info in the global list | ||
| edm::Ptr<reco::BaseTagInfo> outPtr(oh_tagInfosOut, tagInfoIndex); | ||
| outPtrP->back().updateFwdTagInfoFwdPtr(iinfo - iinfoBegin, outPtr); | ||
| ++tagInfoIndex; | ||
| } | ||
| } | ||
|
|
||
| iEvent.put(std::move(outPtrP)); | ||
| } | ||
|
|
||
| #include "FWCore/Framework/interface/MakerMacros.h" | ||
| DEFINE_FWK_MODULE(PATJetCandidatesRekeyer); | ||
Uh oh!
There was an error while loading. Please reload this page.