#'/store/mc/Phys14DR/TTJets_MSDecaysCKM_central_Tune4C_13TeV-madgraph-tauola/MINIAODSIM/PU20bx25_PHYS14_25_V1-v1/00000/00C90EFC-3074-E411-A845-002590DB9262.root' #'/store/mc/Spring14miniaod/TTbarH_M-125_13TeV_amcatnlo-pythia8-tauola/MINIAODSIM/PU20bx25_POSTLS170_V5-v1/00000/1E4F9BDC-3E1E-E411-A56C-001E67396EAA.root' #'/store/mc/Spring14miniaod/TTJets_MSDecaysCKM_central_Tune4C_13TeV-madgraph-tauola/MINIAODSIM/PU20bx25_POSTLS170_V5-v2/00000/004C6DA7-FB03-E411-96BD-0025905A497A.root' )) ############### #### tt+X ############### # Setting input particle collections to be used by the tools genJetCollection = 'ak4GenJetsCustom' genParticleCollection = 'prunedGenParticles' genJetInputParticleCollection = 'packedGenParticles' ## producing a subset of particles to be used for jet clustering from RecoJets.Configuration.GenJetParticles_cff import genParticlesForJetsNoNu process.genParticlesForJetsNoNu = genParticlesForJetsNoNu.clone( src=genJetInputParticleCollection) # Supplies PDG ID to real name resolution of MC particles process.load("SimGeneral.HepPDTESSource.pythiapdt_cfi") # Producing own jets for testing purposes from RecoJets.JetProducers.ak4GenJets_cfi import ak4GenJets process.ak4GenJetsCustom = ak4GenJets.clone( src='genParticlesForJetsNoNu', # src = genJetInputParticleCollection, rParam=cms.double(0.4), jetAlgorithm=cms.string("AntiKt")) # Ghost particle collection used for Hadron-Jet association # MUST use proper input particle collection from PhysicsTools.JetMCAlgos.HadronAndPartonSelector_cfi import selectedHadronsAndPartons
## Define maximum number of events to loop over process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(1000) ) process.task = cms.Task() ## Set input particle collections to be used by the tools genParticleCollection = '' genJetCollection = '' if options.runOnAOD: genParticleCollection = 'genParticles' genJetCollection = 'ak4GenJetsCustom' ## producing a subset of genParticles to be used for jet clustering in AOD from RecoJets.Configuration.GenJetParticles_cff import genParticlesForJetsNoNu process.genParticlesForJetsCustom = genParticlesForJetsNoNu.clone() process.task.add(process.genParticlesForJetsCustom) ## Produce own jets (re-clustering in miniAOD needed at present to avoid crash) from RecoJets.JetProducers.ak4GenJets_cfi import ak4GenJets process.ak4GenJetsCustom = ak4GenJets.clone( src = 'genParticlesForJetsCustom', rParam = cms.double(0.4), jetAlgorithm = cms.string("AntiKt") ) process.task.add(process.ak4GenJetsCustom) else: genParticleCollection = 'prunedGenParticles' genJetCollection = 'slimmedGenJets' ## Supplies PDG ID to real name resolution of MC particles process.load("SimGeneral.HepPDTESSource.pythiapdt_cfi")
'pythia8CommonSettings', 'pythia8CP5Settings', 'pythia8aMCatNLOSettings', #'pythia8PSweightsSettings', 'processParameters'))) from RecoJets.Configuration.GenJetParticles_cff import genParticlesForJetsNoNu from RecoJets.Configuration.RecoGenJets_cff import ak4GenJetsNoNu # Filter out PromptFinalState photons process.genParticlesNoGamma = cms.EDFilter( 'CandPtrSelector', src=cms.InputTag('genParticles'), cut=cms.string('pdgId != 22 || !isPromptFinalState')) process.genParticlesForJetsNoNuNoGamma = genParticlesForJetsNoNu.clone( src=cms.InputTag("genParticlesNoGamma")) process.ak4GenJetsNoNuNoGamma = ak4GenJetsNoNu.clone( src=cms.InputTag("genParticlesForJetsNoNuNoGamma")) process.vbfGenJetFilterD = cms.EDFilter( "VBFGenJetFilter", inputTag_GenJetCollection=cms.untracked.InputTag("ak4GenJetsNoNuNoGamma"), maxEta=cms.untracked.double(99999.0), minEta=cms.untracked.double(-99999.0), minInvMass=cms.untracked.double(400.), minPt=cms.untracked.double(30.)) from GeneratorInterface.Core.generatorSmeared_cfi import generatorSmeared from PhysicsTools.HepMCCandAlgos.genParticles_cfi import genParticles
def genHFTool(process, useMiniAOD=True): # Setting input particle collections to be used by the tools genParticleCollection = '' genJetCollection = 'ak4GenJetsCustom' if useMiniAOD: genParticleCollection = 'prunedGenParticles' genJetCollection = 'slimmedGenJets' else: genParticleCollection = 'genParticles' ## producing a subset of genParticles to be used for jet reclustering from RecoJets.Configuration.GenJetParticles_cff import genParticlesForJetsNoNu process.genParticlesForJetsCustom = genParticlesForJetsNoNu.clone( src=genParticleCollection) # Producing own jets for testing purposes from RecoJets.JetProducers.ak4GenJets_cfi import ak4GenJets process.ak4GenJetsCustom = ak4GenJets.clone( src='genParticlesForJetsCustom', rParam=cms.double(0.4), jetAlgorithm=cms.string("AntiKt")) # Supplies PDG ID to real name resolution of MC particles process.load("SimGeneral.HepPDTESSource.pythiapdt_cfi") # Ghost particle collection used for Hadron-Jet association # MUST use proper input particle collection process.load("PhysicsTools.JetMCAlgos.HadronAndPartonSelector_cfi") process.selectedHadronsAndPartons.particles = genParticleCollection ## Input particle collection for matching to gen jets (partons + leptons) # MUST use use proper input jet collection: the jets to which hadrons should be associated # rParam and jetAlgorithm MUST match those used for jets to be associated with hadrons # More details on the tool: https://twiki.cern.ch/twiki/bin/view/CMSPublic/SWGuideBTagMCTools#New_jet_flavour_definition from PhysicsTools.JetMCAlgos.AK4PFJetsMCFlavourInfos_cfi import ak4JetFlavourInfos process.genJetFlavourInfos = ak4JetFlavourInfos.clone( jets=genJetCollection) #for cmssw_7_6_X, not ready for 74x #process.load("PhysicsTools.JetMCAlgos.GenHFHadronMatcher_cff") #added the 3-lines instead of GenHFHadronMatcher_cff from PhysicsTools.JetMCAlgos.GenHFHadronMatcher_cfi import matchGenHFHadron process.matchGenBHadron = matchGenHFHadron.clone(flavour=5) process.matchGenCHadron = matchGenHFHadron.clone(flavour=4) ## Plugin for analysing B hadrons # MUST use the same particle collection as in selectedHadronsAndPartons process.matchGenBHadron.genParticles = genParticleCollection process.matchGenBHadron.jetFlavourInfos = "genJetFlavourInfos" ## Plugin for analysing C hadrons # MUST use the same particle collection as in selectedHadronsAndPartons process.matchGenCHadron.genParticles = genParticleCollection process.matchGenCHadron.jetFlavourInfos = "genJetFlavourInfos" process.load("TopQuarkAnalysis.TopTools.GenTtbarCategorizer_cfi") process.GenTtbarCategories = process.categorizeGenTtbar.clone( genJets=cms.InputTag(genJetCollection), genJetPtMin=cms.double(20.)) process.GenTtbarCategories30 = process.categorizeGenTtbar.clone( genJets=cms.InputTag(genJetCollection), genJetPtMin=cms.double(30.)) process.GenTtbarCategories40 = process.categorizeGenTtbar.clone( genJets=cms.InputTag(genJetCollection), genJetPtMin=cms.double(40.)) process.catGenTops.genJetLabel = genJetCollection process.catGenTops.mcParticleLabel = genParticleCollection
process.source.lumisToProcess = LumiList.LumiList(filename = '../data/Cert_246908-260627_13TeV_PromptReco_Collisions15_25ns_JSON.txt').getVLuminosityBlockRange() if isMC : ############### #### tt+X ############### # Setting input particle collections to be used by the tools genJetCollection = 'ak4GenJetsCustom' genParticleCollection = 'prunedGenParticles' genJetInputParticleCollection = 'packedGenParticles' ## producing a subset of particles to be used for jet clustering from RecoJets.Configuration.GenJetParticles_cff import genParticlesForJetsNoNu process.genParticlesForJetsNoNu = genParticlesForJetsNoNu.clone( src = genJetInputParticleCollection ) # Supplies PDG ID to real name resolution of MC particles process.load("SimGeneral.HepPDTESSource.pythiapdt_cfi") # Producing own jets for testing purposes from RecoJets.JetProducers.ak4GenJets_cfi import ak4GenJets process.ak4GenJetsCustom = ak4GenJets.clone( src = 'genParticlesForJetsNoNu', # src = genJetInputParticleCollection, rParam = cms.double(0.4), jetAlgorithm = cms.string("AntiKt") ) # Ghost particle collection used for Hadron-Jet association
## define maximal number of events to loop over process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(1000) ) # Setting input particle/jet collections to be used by the tools genParticleCollection = '' genJetCollection = 'ak4GenJetsCustom' if options.runOnAOD: genParticleCollection = 'genParticles' ## producing a subset of genParticles to be used for jet reclustering from RecoJets.Configuration.GenJetParticles_cff import genParticlesForJetsNoNu process.genParticlesForJetsCustom = genParticlesForJetsNoNu.clone( src = genParticleCollection ) # Producing own jets for testing purposes from RecoJets.JetProducers.ak4GenJets_cfi import ak4GenJets process.ak4GenJetsCustom = ak4GenJets.clone( src = 'genParticlesForJetsCustom', rParam = cms.double(0.4), jetAlgorithm = cms.string("AntiKt") ) else: genParticleCollection = 'prunedGenParticles' genJetCollection = 'slimmedGenJets' # Supplies PDG ID to real name resolution of MC particles process.load("SimGeneral.HepPDTESSource.pythiapdt_cfi")
skipEvents=cms.untracked.uint32(0)) ## Define maximum number of events to loop over process.maxEvents = cms.untracked.PSet(input=cms.untracked.int32(1000)) process.task = cms.Task() ## Set input particle collections to be used by the tools genParticleCollection = '' genJetCollection = '' if options.runOnAOD: genParticleCollection = 'genParticles' genJetCollection = 'ak4GenJetsCustom' ## producing a subset of genParticles to be used for jet clustering in AOD from RecoJets.Configuration.GenJetParticles_cff import genParticlesForJetsNoNu process.genParticlesForJetsCustom = genParticlesForJetsNoNu.clone() process.task.add(process.genParticlesForJetsCustom) ## Produce own jets (re-clustering in miniAOD needed at present to avoid crash) from RecoJets.JetProducers.ak4GenJets_cfi import ak4GenJets process.ak4GenJetsCustom = ak4GenJets.clone( src='genParticlesForJetsCustom', rParam=cms.double(0.4), jetAlgorithm=cms.string("AntiKt")) process.task.add(process.ak4GenJetsCustom) else: genParticleCollection = 'prunedGenParticles' genJetCollection = 'slimmedGenJets' ## Supplies PDG ID to real name resolution of MC particles process.load("SimGeneral.HepPDTESSource.pythiapdt_cfi")
def addLeptonSubtractedPFCands(process, era, useFakeable, puMethod, runOnMC): assert (era in ["2016", "2017", "2018"]) assert (puMethod in ['chs', 'puppi']) suffix = "Fakeable" if useFakeable else "Loose" #---------------------------------------------------------------------------- # produce collections of electrons and muons passing loose or fakeable lepton selection of ttH multilepton+tau analysis (HIG-18-019) electronCollectionTTH_str = 'electronCollectionTTH%s' % suffix if not hasattr(process, electronCollectionTTH_str): setattr( process, electronCollectionTTH_str, cms.EDProducer("PATElectronSelector%s" % suffix, src=cms.InputTag("linkedObjects", "electrons"), src_mvaTTH=cms.InputTag("electronMVATTH"), era=cms.string(era), debug=cms.bool(False))) muonCollectionTTH_str = 'muonCollectionTTH%s' % suffix if not hasattr(process, muonCollectionTTH_str): setattr( process, muonCollectionTTH_str, cms.EDProducer("PATMuonSelector%s" % suffix, src=cms.InputTag("linkedObjects", "muons"), src_mvaTTH=cms.InputTag("muonMVATTH"), era=cms.string(era), debug=cms.bool(False))) #---------------------------------------------------------------------------- #---------------------------------------------------------------------------- # produce collection of packedPFCandidates not associated to loose or fakeable electrons or muons leptonLessPFProducer_str = 'leptonLessPFProducer%s' % suffix if not hasattr(process, leptonLessPFProducer_str): setattr( process, leptonLessPFProducer_str, cms.EDProducer( 'LeptonLessPFProducer', src_pfCands=cms.InputTag("packedPFCandidates"), src_electrons=cms.InputTag(electronCollectionTTH_str), src_muons=cms.InputTag(muonCollectionTTH_str), debug=cms.bool(False))) leptonLessPU_str = 'leptonLess%s%s' % (puMethod, suffix) if puMethod == 'puppi': # run PUPPI algorithm (arXiv:1407.6013) on cleaned packedPFCandidates collection # cf. https://twiki.cern.ch/twiki/bin/view/CMS/JetToolbox#New_PF_Collection if not hasattr(process, leptonLessPU_str): setattr( process, leptonLessPU_str, puppi.clone( candName=cms.InputTag(leptonLessPFProducer_str), vertexName=cms.InputTag("offlineSlimmedPrimaryVertices"), useExistingWeights=cms.bool(True))) elif puMethod == 'chs': leptonLessCands_tmp1 = '%stmp1' % leptonLessPU_str leptonLessCands_tmp2 = '%stmp2' % leptonLessPU_str setattr( process, leptonLessCands_tmp1, cms.EDFilter( "CandPtrSelector", src=cms.InputTag("packedPFCandidates"), cut=cms.string("fromPV"), )) setattr( process, leptonLessCands_tmp2, cms.EDProducer( "CandPtrProjector", src=cms.InputTag(leptonLessCands_tmp1), veto=cms.InputTag(muonCollectionTTH_str), )) setattr( process, leptonLessPU_str, cms.EDProducer( "CandPtrProjector", src=cms.InputTag(leptonLessCands_tmp2), veto=cms.InputTag(electronCollectionTTH_str), )) else: raise RuntimeError("Invalid PU method: %s" % puMethod) #---------------------------------------------------------------------------- #---------------------------------------------------------------------------- # produce collection of generator-level particles excluding prompt leptons and leptons from tau decays # (used to produce lepton-subtracted generator-level jets) # NB.: Selection taken from the Higgs->tautau twiki # https://twiki.cern.ch/twiki/bin/viewauth/CMS/HiggsToTauTauWorking2016#MC_Matching if runOnMC: if not hasattr(process, GENPARTICLESFORJETSNONU_STR): setattr( process, GENPARTICLESFORJETSNONU_STR, genParticlesForJetsNoNu.clone( src=cms.InputTag("prunedGenParticles"), )) if not hasattr(process, LEPTONLESSGENPARTICLEPRODUCER_STR): setattr( process, LEPTONLESSGENPARTICLEPRODUCER_STR, cms.EDFilter( "CandPtrSelector", src=cms.InputTag(GENPARTICLESFORJETSNONU_STR), cut=cms.string( '!(pt > 8 & (abs(pdgId) = 11 | abs(pdgId) = 13) & (isPromptFinalState | isDirectPromptTauDecayProductFinalState))' ), stableOnly=cms.bool(True), filter=cms.bool(False), )) #---------------------------------------------------------------------------- leptonSubtractedPFCandsSequence_str = 'leptonSubtractedPFCandsSequence%s%s' % ( puMethod, suffix) if not hasattr(process, leptonSubtractedPFCandsSequence_str): if puMethod == 'puppi': setattr(process, leptonSubtractedPFCandsSequence_str, cms.Sequence( getattr(process, electronCollectionTTH_str) + getattr(process, muonCollectionTTH_str) + \ getattr(process, leptonLessPFProducer_str) + getattr(process, leptonLessPU_str) ) ) elif puMethod == 'chs': setattr(process, leptonSubtractedPFCandsSequence_str, cms.Sequence( getattr(process, electronCollectionTTH_str) + getattr(process, muonCollectionTTH_str) + \ getattr(process, leptonLessPFProducer_str) + getattr(process, leptonLessCands_tmp1) + \ getattr(process, leptonLessCands_tmp2) + getattr(process, leptonLessPU_str) ) ) else: raise RuntimeError("Invalid PU method: %s" % puMethod) if runOnMC: leptonSubtractedPFCandsSequence = getattr( process, leptonSubtractedPFCandsSequence_str) leptonSubtractedPFCandsSequence += getattr(process, GENPARTICLESFORJETSNONU_STR) + \ getattr(process, LEPTONLESSGENPARTICLEPRODUCER_STR) return (getattr(process, leptonSubtractedPFCandsSequence_str), leptonLessPU_str)
# '/store/mc/RunIISpring15DR74/TT_TuneCUETP8M1_13TeV-powheg-pythia8/MINIAODSIM/Asympt50ns_MCRUN2_74_V9A-v4/10000/00D2A247-2910-E511-9F3D-0CC47A4DEDD2.root', ), skipEvents=cms.untracked.uint32(0)) ## define maximal number of events to loop over process.maxEvents = cms.untracked.PSet(input=cms.untracked.int32(1000)) # Setting input particle/jet collections to be used by the tools genParticleCollection = '' genJetCollection = 'ak4GenJetsCustom' if options.runOnAOD: genParticleCollection = 'genParticles' ## producing a subset of genParticles to be used for jet reclustering from RecoJets.Configuration.GenJetParticles_cff import genParticlesForJetsNoNu process.genParticlesForJetsCustom = genParticlesForJetsNoNu.clone( src=genParticleCollection) patAlgosToolsTask.add(process.genParticlesForJetsCustom) # Producing own jets for testing purposes from RecoJets.JetProducers.ak4GenJets_cfi import ak4GenJets process.ak4GenJetsCustom = ak4GenJets.clone( src='genParticlesForJetsCustom', rParam=cms.double(0.4), jetAlgorithm=cms.string("AntiKt")) patAlgosToolsTask.add(process.ak4GenJetsCustom) else: genParticleCollection = 'prunedGenParticles' genJetCollection = 'slimmedGenJets' # Supplies PDG ID to real name resolution of MC particles process.load("SimGeneral.HepPDTESSource.pythiapdt_cfi")