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
GenJetFlavourInfos in MiniAOD and Change in JetFlavour of LightJets to physicsPartons in CMSSW 92X #19048
GenJetFlavourInfos in MiniAOD and Change in JetFlavour of LightJets to physicsPartons in CMSSW 92X #19048
Changes from 5 commits
ca2abcf
649dfa8
0f4b578
9a6d45d
ea57cff
eeeaebd
632b72e
bdb574e
3ee6d5c
5355844
f3768ff
f37b635
73ee068
c783efc
eecae16
1ea8433
9a80eee
7d7b57f
9c0baa9
7914385
c5ed70c
19314ca
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -254,7 +254,7 @@ HadronAndPartonSelector::produce(edm::Event& iEvent, const edm::EventSetup& iSet | |
partonSelector_->run(particles,partons); | ||
for(reco::GenParticleCollection::const_iterator it = particles->begin(); it != particles->end(); ++it) | ||
{ | ||
if( !(it->status()==3 || (( partonMode_=="Pythia8" ) && (it->status()==23)))) continue; | ||
// if( !(it->status()==3 || (( partonMode_=="Pythia8" ) && (it->status()==23)))) continue; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it looks like this part will be modified to become configurable. |
||
if( !CandMCTagUtils::isParton( *it ) ) continue; // skip particle if not a parton | ||
physicsPartons->push_back( reco::GenParticleRef( particles, it - particles->begin() ) ); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import FWCore.ParameterSet.Config as cms | ||
|
||
|
||
ak4GenJetFlavourInfos = cms.EDProducer("JetFlavourClustering", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it will be easier to maintain if this instead clones from ak4JetFlavourInfos ak4GenJetFlavourInfos = ak4JetFlavourInfos.clone(jets = "ak4GenJetsNoNu") |
||
jets = cms.InputTag("ak4GenJetsNoNu"), | ||
bHadrons = cms.InputTag("selectedHadronsAndPartons","bHadrons"), | ||
cHadrons = cms.InputTag("selectedHadronsAndPartons","cHadrons"), | ||
partons = cms.InputTag("selectedHadronsAndPartons","physicsPartons"), | ||
leptons = cms.InputTag("selectedHadronsAndPartons","leptons"), | ||
jetAlgorithm = cms.string("AntiKt"), | ||
rParam = cms.double(0.4), | ||
ghostRescaling = cms.double(1e-18), | ||
hadronFlavourHasPriority = cms.bool(False) | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
jets = cms.InputTag("ak4PFJets"), | ||
bHadrons = cms.InputTag("selectedHadronsAndPartons","bHadrons"), | ||
cHadrons = cms.InputTag("selectedHadronsAndPartons","cHadrons"), | ||
partons = cms.InputTag("selectedHadronsAndPartons","algorithmicPartons"), | ||
partons = cms.InputTag("selectedHadronsAndPartons","physicsPartons"), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should the same be applied to other available instances of JetFlavourClustering in this package? |
||
leptons = cms.InputTag("selectedHadronsAndPartons","leptons"), | ||
jetAlgorithm = cms.string("AntiKt"), | ||
rParam = cms.double(0.4), | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
// | ||
// $Id: GenJetFlavourInfoPreserver.cc,v 1.0 2017/05/18 18:45:45 $ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please remove this line. |
||
// | ||
|
||
/** | ||
\class pat::GenJetFlavourInfoPreserver GenJetFlavourInfoPreserver.h "PhysicsTools/JetMCAlgos/interface/GenJetFlavourInfoPreserver.h" | ||
\brief Transfers the JetFlavourInfos from the original GenJets to the slimmedGenJets in MiniAOD | ||
|
||
\author Andrej Saibel | ||
*/ | ||
|
||
|
||
#include "FWCore/Framework/interface/Frameworkfwd.h" | ||
#include "FWCore/Framework/interface/stream/EDProducer.h" | ||
#include "FWCore/Framework/interface/Event.h" | ||
#include "FWCore/ParameterSet/interface/ParameterSet.h" | ||
#include "CommonTools/Utils/interface/StringCutObjectSelector.h" | ||
#include "DataFormats/Common/interface/Association.h" | ||
#include "DataFormats/Common/interface/RefToPtr.h" | ||
#include "DataFormats/PatCandidates/interface/PackedGenParticle.h" | ||
#include "DataFormats/JetReco/interface/GenJet.h" | ||
|
||
#include "DataFormats/JetReco/interface/Jet.h" | ||
#include "DataFormats/JetReco/interface/JetCollection.h" | ||
#include "SimDataFormats/JetMatching/interface/JetFlavourInfo.h" | ||
#include "SimDataFormats/JetMatching/interface/JetFlavourInfoMatching.h" | ||
#include "DataFormats/HepMCCandidate/interface/GenParticle.h" | ||
#include "DataFormats/HepMCCandidate/interface/GenParticleFwd.h" | ||
|
||
|
||
namespace pat { | ||
|
||
class GenJetFlavourInfoPreserver : public edm::stream::EDProducer<> { | ||
public: | ||
explicit GenJetFlavourInfoPreserver(const edm::ParameterSet & iConfig); | ||
virtual ~GenJetFlavourInfoPreserver() { } | ||
|
||
virtual void produce(edm::Event & iEvent, const edm::EventSetup & iSetup); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please add |
||
|
||
private: | ||
const edm::EDGetTokenT<edm::View<reco::GenJet> > GenJetsToken_; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. start local variables and data members with lower case letter. Capitalization is reserved for class names. |
||
const edm::EDGetTokenT<edm::View<reco::Jet> > slimmedGenJetsToken_; | ||
|
||
const StringCutObjectSelector<reco::GenJet> cut_; | ||
|
||
const edm::EDGetTokenT<reco::JetFlavourInfoMatchingCollection> ak4GenJetFlavourInfosToken_; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ak4 prefix should be removed here |
||
}; | ||
|
||
} // namespace | ||
|
||
pat::GenJetFlavourInfoPreserver::GenJetFlavourInfoPreserver(const edm::ParameterSet & iConfig) : | ||
GenJetsToken_(consumes<edm::View<reco::GenJet> >(iConfig.getParameter<edm::InputTag>("GenJets"))), | ||
slimmedGenJetsToken_(consumes<edm::View<reco::Jet> >(iConfig.getParameter<edm::InputTag>("slimmedGenJets"))), | ||
cut_(iConfig.getParameter<std::string>("cut")), | ||
ak4GenJetFlavourInfosToken_(consumes<reco::JetFlavourInfoMatchingCollection>(iConfig.getParameter<edm::InputTag>("GenJetFlavourInfos"))) | ||
{ | ||
produces<reco::JetFlavourInfoMatchingCollection>(); | ||
} | ||
|
||
void | ||
pat::GenJetFlavourInfoPreserver::produce(edm::Event & iEvent, const edm::EventSetup & iSetup) { | ||
using namespace edm; | ||
using namespace std; | ||
|
||
Handle<View<reco::GenJet> > GenJets; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. start local variables and data members with lower case letter. Capitalization is reserved for class names. |
||
iEvent.getByToken(GenJetsToken_, GenJets); | ||
|
||
Handle<View<reco::Jet> > slimmedGenJets; | ||
iEvent.getByToken(slimmedGenJetsToken_, slimmedGenJets); | ||
|
||
Handle<reco::JetFlavourInfoMatchingCollection> ak4GenJetFlavourInfos; | ||
iEvent.getByToken(ak4GenJetFlavourInfosToken_,ak4GenJetFlavourInfos); | ||
|
||
auto jetFlavourInfos = std::make_unique<reco::JetFlavourInfoMatchingCollection>(reco::JetRefBaseProd(slimmedGenJets)); | ||
|
||
|
||
uint slimmedId = 0; | ||
|
||
|
||
|
||
for (View<reco::GenJet>::const_iterator it = GenJets->begin(), ed = GenJets->end(); it != ed; ++it) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
auto jetIt = genJets->begin(), jetEnd = genJets->end();
auto jetInfoIt = genJetFlavourInfos->begin();
assert(genJets.size() == genJetFlavourInfos.size());
for(; jetIt != jetEnd; ++jetIt, ++jetInfoIt){
... |
||
if (!cut_(*it)) continue; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The part related to this loop and synchronization with the slimmedJets still needs a rewrite The following comments were not addressed: |
||
|
||
for(reco::JetFlavourInfoMatchingCollection::const_iterator JetInfo = ak4GenJetFlavourInfos->begin(); JetInfo != ak4GenJetFlavourInfos->end();++JetInfo){ | ||
|
||
if((JetInfo - ak4GenJetFlavourInfos->begin()) < (it - GenJets->begin())) continue; | ||
else if((JetInfo - ak4GenJetFlavourInfos->begin()) > (it - GenJets->begin())) continue; | ||
|
||
(*jetFlavourInfos)[slimmedGenJets->refAt(slimmedId)] = reco::JetFlavourInfo(JetInfo->second.getbHadrons(), JetInfo->second.getcHadrons(), JetInfo->second.getPartons(), JetInfo->second.getLeptons(), JetInfo->second.getHadronFlavour(), JetInfo->second.getPartonFlavour()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please add newlines to improve readability. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think that this synchronization with slimmed GenJet indexing via a copy-paste of |
||
|
||
break; | ||
|
||
} | ||
|
||
slimmedId++; | ||
} | ||
|
||
iEvent.put(std::move(jetFlavourInfos)); | ||
} | ||
|
||
#include "FWCore/Framework/interface/MakerMacros.h" | ||
using namespace pat; | ||
DEFINE_FWK_MODULE(GenJetFlavourInfoPreserver); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -80,6 +80,7 @@ | |
MicroEventContentMC.outputCommands += [ | ||
#'keep *_slimmedGenJets*_*_*', | ||
'keep *_slimmedGenJets_*_*', | ||
'keep *_slimmedGenJetsFlavourInfos*_*_*', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it appears that |
||
'keep *_slimmedGenJetsAK8_*_*', | ||
'keep patPackedGenParticles_packedGenParticles_*_*', | ||
'keep recoGenParticles_prunedGenParticles_*_*', | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -322,6 +322,12 @@ def miniAOD_customizeCommon(process): | |
|
||
|
||
def miniAOD_customizeMC(process): | ||
#GenJetFlavourInfos | ||
process.load("PhysicsTools.JetMCAlgos.HadronAndPartonSelector_cfi") | ||
|
||
process.selectedHadronsAndPartons.particles = "prunedGenParticles" | ||
process.load("PhysicsTools.JetMCAlgos.AK4GenJetFlavourInfos_cfi") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. selectedHadronsAndPartons and ak4GenJetFlavourInfos should be added to the task (as done below) |
||
|
||
#slimmed pileup information | ||
process.load('PhysicsTools.PatAlgos.slimming.slimmedAddPileupInfo_cfi') | ||
task = getPatAlgosToolsTask(process) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,12 @@ | |
dropSpecific = cms.bool(False), | ||
) | ||
|
||
slimmedGenJetsFlavourInfos = cms.EDProducer("GenJetFlavourInfoPreserver", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. cfi files are not meant for definitions of many types of module instances. Better yet is to implement a fillDescriptions method and let the framework create this file |
||
GenJets = cms.InputTag("ak4GenJetsNoNu"), | ||
slimmedGenJets = cms.InputTag("slimmedGenJets"), | ||
cut = cms.string("pt > 8"), #VERY IMPORTANT: cut needs to be the same as in slimmedGenJets above. | ||
GenJetFlavourInfos = cms.InputTag("ak4GenJetFlavourInfos") | ||
) | ||
|
||
slimmedGenJetsAK8 = cms.EDProducer("PATGenJetSlimmer", | ||
src = cms.InputTag("ak8GenJetsNoNu"), | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dear @Andrej-CMS,
I am wondering if commenting out this has any consequences not only in terms of file size but also in other places where HadronAndSelector is being used.
It is because if I understand correctly, without this condition, this will contain all partons including status 2 and also stable final particles. That will be a lot of particles. This will also introduce ambiguity issue.
Best Regards,
Taejeong
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @monttj ,
These changes were requested by the QGL Group, i.e. Paolo Azzuri. Unfortunately, I cannot find him on GitHub to comment on this.
You are right, the physicspartons will contain the whole chain. I will provide RelVal comparisons as soon as possible.
Kind regards,
Andrej
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you make that configurable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, I will do that.
Kind regards,
Andrej