def removeMCMatchingPF2PAT(process, postfix="", outputModules=['out']): from PhysicsTools.PatAlgos.tools.coreTools import removeMCMatching removeIfInSequence(process, "genForPF2PATSequence", "patDefaultSequence", postfix) removeMCMatching(process, names=['All'], postfix=postfix, outputModules=outputModules)
def removeMCUse(process): # Remove anything that requires MC truth. from PhysicsTools.PatAlgos.tools.coreTools import removeMCMatching removeMCMatching(process, ['All']) # removeMCMatching(process, ['METs'], postfix='TC') removeMCMatching(process, ['METs'], postfix='PF') #removeMuonMCClassification(process) removeSimLeptons(process)
def enableRECO(process,mode="MC",type="HI"): if type=="HI": # trk process.dj_reco_extra*=process.hiGoodTracksSelection # pat jet process.load('PhysicsTools.PatAlgos.patHeavyIonSequences_cff') process.patJetCorrFactors.src = cms.InputTag("iterativeConePu5CaloJets") process.patJetCorrFactors.levels = cms.vstring('L2Relative','L3Absolute') process.patJetCorrFactors.payload = cms.string('IC5Calo') process.patJets.jetSource = cms.InputTag("iterativeConePu5CaloJets") process.patJets.addBTagInfo = False process.patJets.addTagInfos = False process.patJets.addDiscriminators = False process.patJets.addAssociatedTracks = False process.patJets.addJetCharge = False process.patJets.addJetID = False process.patJets.getJetMCFlavour = False process.patJets.addGenPartonMatch = True process.patJets.addGenJetMatch = True process.patJets.embedGenJetMatch = True process.patJets.embedGenPartonMatch = True process.patJets.embedCaloTowers = False process.dj_reco_extra *= process.heavyIon*process.makeHeavyIonJets if mode=="Data": from Saved.Skim.customise_cfi import removePatMCMatch removePatMCMatch(process) process.dj_reco_extra.remove(process.heavyIon) if type=="pp": process.load('PhysicsTools.PatAlgos.patSequences_cff') process.dj_reco_extra *= process.makePatJets if mode=="Data": from PhysicsTools.PatAlgos.tools.coreTools import removeMCMatching removeMCMatching(process, ['All']) # turn off MC matching for data # JEC Set #from PhysicsTools.PatAlgos.tools.jetTools import switchJECSet #switchJECSet( process, "Spring10") # Spring10 is the new default, not needed in 39X+ when reading Corr from DB for i,m in enumerate([process.djcalo, process.djcalo_tower, process.djcalo_genp, process.djgen]): if m!=process.djgen: m.jetsrc = "patJets" m.refjetsrc = "patJets" process.djcalo.trksrc = "hiGoodTracks"
def Pat(self) : from PhysicsTools.PatAlgos.tools.coreTools import removeMCMatching,removeCleaning,restrictInputToAOD,removeAllPATObjectsBut from PhysicsTools.PatAlgos.tools.jetTools import switchJetCollection from PhysicsTools.PatAlgos.tools.jetTools import addJetCollection if self.options.isData: removeMCMatching(self.process, ['All']) restrictInputToAOD(self.process) removeCleaning(self.process) removeAllPATObjectsBut(self.process, ['Jets','METs','Muons']) addJetCollection(self.process, cms.InputTag('ak5CaloJets'), 'AK5', 'Calo', jetCorrLabel = ('AK5Calo',self.options.jetCorrections), genJetCollection = cms.InputTag('ak5GenJets'), doType1MET = False, ) switchJetCollection(self.process, cms.InputTag('ak5PFJets'), doJTA = True, doBTagging = True, doJetID = True, jetCorrLabel = ('AK5PF',self.options.jetCorrections), genJetCollection = cms.InputTag('ak5GenJets'), doType1MET = False, jetIdLabel = 'ak5pf' ) self.process.selectedPatJets.cut = cms.string("pt > 30 && \ abs(eta) < 3.0 && \ neutralHadronEnergyFraction < 0.9 && \ neutralEmEnergyFraction < 0.90 && \ nConstituents > 1 && \ (? abs(eta)<2.4 ? chargedHadronEnergyFraction : 1) > 0 && \ (? abs(eta)<2.4 ? chargedHadronMultiplicity : 1) > 0 && \ (? abs(eta)<2.4 ? chargedEmEnergyFraction : 0) < 0.99") del self.process.out del self.process.outpath return self.process.patDefaultSequence
def switchToData(process): #remove MC matching from standard PAT sequences #from AnalysisSpace.TreeMaker.SwitchToData import switchToData # remove MC matching coreTools.runOnData(process, outputInProcess=False) #coreTools.removeMCMatching(process, ["All"], outputInProcess = False) coreTools.removeMCMatching(process, ['METs'], "TC", outputInProcess=False) coreTools.removeMCMatching(process, ['METs'], "PF", outputInProcess=False) coreTools.removeMCMatching(process, ['METs'], "AK5Calo", outputInProcess=False) process.patDefaultSequence.remove(process.patJetPartonMatch) process.patDefaultSequence.remove(process.patJetPartonMatchAK5PF) process.patDefaultSequence.remove(process.patJetPartonMatchAK5Calo) process.patDefaultSequence.remove(process.patJetGenJetMatchAK5PF) process.patDefaultSequence.remove(process.patJetGenJetMatchAK5Calo) process.patDefaultSequence.remove(process.patJetFlavourId) process.patDefaultSequence.remove(process.patJetPartons) process.patDefaultSequence.remove(process.patJetPartonAssociation) process.patDefaultSequence.remove(process.patJetPartonAssociationAK5PF) process.patDefaultSequence.remove(process.patJetPartonAssociationAK5Calo) process.patDefaultSequence.remove(process.patJetFlavourAssociation) process.patDefaultSequence.remove(process.patJetFlavourAssociationAK5PF) process.patDefaultSequence.remove(process.patJetFlavourAssociationAK5Calo)
def removeMCUse(process): # Remove anything that requires MC truth. from PhysicsTools.PatAlgos.tools.coreTools import removeMCMatching removeMCMatching(process, ['All']) removeMCMatching(process, ['METs'], postfix='TC') removeMCMatching(process, ['METs'], postfix='PF') removeMuonMCClassification(process) removeSimLeptons(process) removePrunedMCLeptons(process)
def addC8Jets(p, runOnMC): p2 = p.replace('AK5', 'CA8') ############################### ###### Bare CA 0.8 jets ####### ############################### setattr(process, "ca8PFJets" + p2, ca4PFJets.clone( rParam = cms.double(0.8), src = cms.InputTag('pfNoElectron' + p), doAreaFastjet = cms.bool(True), doRhoFastjet = cms.bool(True), Rho_EtaMax = cms.double(6.0), Ghost_EtaMax = cms.double(7.0), srcPVs = cms.InputTag("goodOfflinePrimaryVertices") )) # Add ca8PFJets to the main process path getattr(process, "patPF2PATSequence" + p).replace( getattr(process, "pfNoElectron" + p), getattr(process, "pfNoElectron" + p) * getattr(process, "ca8PFJets" + p2) ) addJetCollection(process, cms.InputTag('ca8PFJets' + p2), 'CA8', 'PFchs' if 'chs' in p else 'PF', doJTA = True, doBTagging = True, jetCorrLabel = ('AK7PFchs', ['L1FastJet', 'L2Relative', 'L3Absolute']), doType1MET = True, doL1Cleaning = False, doL1Counters = False, genJetCollection = cms.InputTag("ca8GenJetsNoNu"), doJetID = True, ) if not runOnMC: # Remove MC Matching removeMCMatching(process, names = ["All"])
def switchToData(process): #remove MC matching from standard PAT sequences #from AnalysisSpace.TreeMaker.SwitchToData import switchToData # remove MC matching coreTools.runOnData(process, outputModules = []) #coreTools.removeMCMatching(process, ["All"], outputModules = []) coreTools.removeMCMatching(process, ['METs'], "TC", outputModules = []) coreTools.removeMCMatching(process, ['METs'], "PF", outputModules = []) coreTools.removeMCMatching(process, ['METs'], "AK5Calo", outputModules = []) process.patDefaultSequence.remove(process.patJetPartonMatch) process.patDefaultSequence.remove(process.patJetPartonMatchAK5PF) process.patDefaultSequence.remove(process.patJetPartonMatchAK5Calo) process.patDefaultSequence.remove(process.patJetGenJetMatchAK5PF) process.patDefaultSequence.remove(process.patJetGenJetMatchAK5Calo) process.patDefaultSequence.remove(process.patJetFlavourId) process.patDefaultSequence.remove(process.patJetPartons) process.patDefaultSequence.remove(process.patJetPartonAssociation) process.patDefaultSequence.remove(process.patJetPartonAssociationAK5PF) process.patDefaultSequence.remove(process.patJetPartonAssociationAK5Calo) process.patDefaultSequence.remove(process.patJetFlavourAssociation) process.patDefaultSequence.remove(process.patJetFlavourAssociationAK5PF) process.patDefaultSequence.remove(process.patJetFlavourAssociationAK5Calo)
def createProcess(runOnMC, runCHS, correctMETWithT1, processCaloJets, processCA8Jets, globalTag): ## import skeleton process from PhysicsTools.PatAlgos.patTemplate_cfg import process # load the PAT config process.load("PhysicsTools.PatAlgos.patSequences_cff") process.load("JetMETCorrections.Configuration.JetCorrectionProducers_cff") # Do some CHS stuff process.ak5PFchsL1Fastjet = process.ak5PFL1Fastjet.clone(algorithm = 'AK5PFchs') process.ak5PFchsL2Relative = process.ak5PFL2Relative.clone(algorithm = 'AK5PFchs') process.ak5PFchsL3Absolute = process.ak5PFL3Absolute.clone(algorithm = 'AK5PFchs') process.ak5PFchsResidual = process.ak5PFResidual.clone(algorithm = 'AK5PFchs') process.ak5PFchsL1FastL2L3 = cms.ESProducer( 'JetCorrectionESChain', correctors = cms.vstring('ak5PFchsL1Fastjet', 'ak5PFchsL2Relative','ak5PFchsL3Absolute') ) from PhysicsTools.SelectorUtils.pvSelector_cfi import pvSelector ## The good primary vertex filter ____________________________________________|| ## This filter throw events with no primary vertex process.primaryVertexFilter = cms.EDFilter( "VertexSelector", src = cms.InputTag("offlinePrimaryVertices"), cut = cms.string("!isFake && ndof > 4 && abs(z) <= 24 && position.Rho <= 2"), filter = cms.bool(True) ) process.goodOfflinePrimaryVertices = cms.EDFilter("PrimaryVertexObjectFilter", filterParams = pvSelector.clone( minNdof = cms.double(4.0), maxZ = cms.double(24.0) ), src = cms.InputTag('offlinePrimaryVertices') ) # Configure PAT to use PF2PAT instead of AOD sources # this function will modify the PAT sequences. from PhysicsTools.PatAlgos.tools.coreTools import removeSpecificPATObjects, removeMCMatching from PhysicsTools.PatAlgos.tools.pfTools import usePF2PAT, adaptPFIsoElectrons, adaptPVs, usePFIso #from PhysicsTools.PatAlgos.tools.metTools import * def usePF2PATForAnalysis(jetAlgo, postfix, useTypeIMET, usePFNoPU): # Jet corrections # No L2L3 Residual on purpose if usePFNoPU: jetCorrections = ("%sPFchs" % algo, ['L1FastJet', 'L2Relative', 'L3Absolute']) postfix += "chs" else: jetCorrections = ("%sPF" % algo, ['L1FastJet', 'L2Relative', 'L3Absolute']) #if not runOnMC: # jetCorrections[1].append('L2L3Residual') p = postfix usePF2PAT(process, runPF2PAT=True, jetAlgo=jetAlgo, runOnMC=runOnMC, postfix=p, jetCorrections=jetCorrections, typeIMetCorrections = useTypeIMET) getattr(process, "pfPileUp" + p).Enable = True getattr(process, "pfPileUp" + p).Vertices = 'goodOfflinePrimaryVertices' getattr(process, "pfPileUp" + p).checkClosestZVertex = cms.bool(False) getattr(process, "pfJets" + p).doAreaFastjet = cms.bool(True) getattr(process, "pfJets" + p).doRhoFastjet = False getattr(process, 'patJetCorrFactors' + p).rho = cms.InputTag("kt6PFJets", "rho") # Do not use kt6PFJetsPFlowAK5, it's not ok for L1FastJet. # top projections in PF2PAT: getattr(process,"pfNoPileUp" + p).enable = cms.bool(usePFNoPU) getattr(process,"pfNoMuon" + p).enable = True getattr(process,"pfNoElectron" + p).enable = True getattr(process,"pfNoTau" + p).enable = True getattr(process,"pfNoJet" + p).enable = True getattr(process,"patElectrons" + p).embedTrack = True getattr(process,"patMuons" + p).embedTrack = True # enable delta beta correction for muon selection in PF2PAT? getattr(process,"pfIsolatedMuons" + p).doDeltaBetaCorrection = True getattr(process, "patJets" + p).embedPFCandidates = False # Keep only jets with pt > 2 Gev getattr(process, "selectedPatJets" + p).cut = "pt > 2"; # Use a cone of 0.3 for photon isolation #adaptPFIsoPhotons(process, applyPostfix(process, "patPhotons", postfix), postfix, "03") # 2012 Photon ID # Electron conversion setattr(process, "patConversions" + p, cms.EDProducer("PATConversionProducer", # input collection electronSource = cms.InputTag("selectedPatElectrons" + p) )) # Switch electron isolation to dR = 0.3, for PF2PAT getattr(process, "pfIsolatedElectrons" + p).isolationValueMapsCharged = cms.VInputTag(cms.InputTag("elPFIsoValueCharged03PFId" + p)) getattr(process, "pfIsolatedElectrons" + p).deltaBetaIsolationValueMap = cms.InputTag("elPFIsoValuePU03PFId" + p) getattr(process, "pfIsolatedElectrons" + p).isolationValueMapsNeutral = cms.VInputTag(cms.InputTag("elPFIsoValueNeutral03PFId" + p), cms.InputTag("elPFIsoValueGamma03PFId" + p)) getattr(process, "pfElectrons" + p).isolationValueMapsCharged = cms.VInputTag(cms.InputTag("elPFIsoValueCharged03PFId" + p)) getattr(process, "pfElectrons" + p).deltaBetaIsolationValueMap = cms.InputTag("elPFIsoValuePU03PFId" + p) getattr(process, "pfElectrons" + p).isolationValueMapsNeutral = cms.VInputTag(cms.InputTag( "elPFIsoValueNeutral03PFId" + p), cms.InputTag("elPFIsoValueGamma03PFId" + p)) # ... And for PAT adaptPFIsoElectrons(process, getattr(process, "pfElectrons" + p), p, "03") if runOnMC: cloneProcessingSnippet(process, getattr(process, "makePatMuons" + p), "Loose" + p, p) getattr(process, "muonMatchLoose" + p).src = cms.InputTag("pfMuons" + p) getattr(process, "patMuonsLoose" + p).pfMuonSource = cms.InputTag("pfMuons" + p) getattr(process, "patDefaultSequence" + p).replace(getattr(process, "makePatMuons" + p), getattr(process, "makePatMuons" + p) + getattr(process, "makePatMuonsLoose" + p)) else: setattr(process, "patMuonsLoose" + p, getattr(process, "patMuons" + p).clone( pfMuonSource = cms.InputTag("pfMuons" + p) ) ) setattr(process, "selectedPatMuonsLoose" + p, getattr(process, "selectedPatMuons" + p).clone( src = cms.InputTag("patMuonsLoose" + p) ) ) sequence = getattr(process, "patDefaultSequence" + p) if not runOnMC: sequence += getattr(process, "patMuonsLoose" + p) sequence += (getattr(process, "selectedPatMuonsLoose" + p)) setattr(process, "patElectronsLoose" + p, getattr(process, "patElectrons" + p).clone( pfElectronSource = cms.InputTag("pfElectrons" + p) ) ) setattr(process, "selectedPatElectronsLoose" + p, getattr(process, "selectedPatElectrons" + p).clone( src = cms.InputTag("patElectronsLoose" + p) ) ) adaptPFIsoElectrons(process, getattr(process, "patElectronsLoose" + p), postfix, "03") sequence = getattr(process, "patDefaultSequence" + p) sequence += (getattr(process, "patElectronsLoose" + p) * getattr(process, "selectedPatElectronsLoose" + p)) #giulia turn off qg tagger ## Setup quark gluon tagger #process.load('QuarkGluonTagger.EightTeV.QGTagger_RecoJets_cff') #cloneProcessingSnippet(process, process.QuarkGluonTagger, p) #getattr(process, "QGTagger" + p).srcJets = cms.InputTag("selectedPatJets" + p) #getattr(process, "QGTagger" + p).isPatJet = cms.untracked.bool(True) #getattr(process, "QGTagger" + p).useCHS = cms.untracked.bool(usePFNoPU) ## Remove the processing of primary vertices, as it's already what we do here #getattr(process, 'QGTagger' + p).srcPV = cms.InputTag('goodOfflinePrimaryVertices') #getattr(process, 'QuarkGluonTagger' + p).remove(getattr(process, 'goodOfflinePrimaryVerticesQG' + p)) if not runOnMC: if 'L2L3Residual' in jetCorrections: getattr(process, 'patPFJetMETtype1p2Corr' + p).jetCorrLabel = 'L2L3Residual' getattr(process, 'patPFMet' + p).addGenMET = cms.bool(False) names = ["Taus"] #if jetAlgo != "AK5": #names += ["Electrons", "Muons"] if len(names) > 0: removeSpecificPATObjects(process, names = names, outputModules = ['out'], postfix = p) adaptPVs(process, pvCollection = cms.InputTag("goodOfflinePrimaryVertices"), postfix = p) getattr(process, "patDefaultSequence" + p).replace(getattr(process, "selectedPatElectrons" + p), getattr(process, "selectedPatElectrons" + p) + getattr(process, "patConversions" + p)) #getattr(process, "patDefaultSequence" + p).replace(getattr(process, "selectedPatJets" + p), getattr(process, "selectedPatJets" + p) + getattr(process, "QuarkGluonTagger" + p)) return getattr(process, "patPF2PATSequence" + p) if correctMETWithT1: process.load("PhysicsTools.PatUtils.patPFMETCorrections_cff") from PhysicsTools.PatAlgos.tools.helpers import cloneProcessingSnippet print "##########################" print "PF jets with PF2PAT" print "Using Type I met" if correctMETWithT1 else "NOT using Type I met" print "##########################" #runCHS = False postfixes = {'PFlowAK5': 'AK5'} #postfixes = {'PFlowAK5': 'AK5', 'PFlowAK7': 'AK7', 'PFlowCA8': 'CA8'} #postfixes = {'PFlowCA8': 'CA8'} ##giulia turn off qg tagger ## Setup quark gluon tagger #process.load('QuarkGluonTagger.EightTeV.QGTagger_RecoJets_cff') process.sequence_chs = cms.Sequence() process.sequence_nochs = cms.Sequence() for p, algo in postfixes.items(): process.sequence_nochs += usePF2PATForAnalysis(jetAlgo=algo, postfix=p, usePFNoPU=False, useTypeIMET=correctMETWithT1) if runCHS: process.sequence_chs += usePF2PATForAnalysis(jetAlgo=algo, postfix=p, usePFNoPU=True, useTypeIMET=correctMETWithT1) # setattr(process, 'QGTagger' + p, process.QGTagger.clone()) # getattr(process, "QGTagger" + p).srcJets = cms.InputTag("selectedPatJets" + p) # getattr(process, "QGTagger" + p).isPatJet = cms.untracked.bool(True) # getattr(process, "QGTagger" + p).useCHS = cms.untracked.bool(False) # # process.QuarkGluonTagger.replace(process.QGTagger, getattr(process, 'QGTagger' + p)) if runCHS: chsP = p + "chs" # setattr(process, 'QGTagger' + chsP, process.QGTagger.clone()) # getattr(process, "QGTagger" + chsP).srcJets = cms.InputTag("selectedPatJets" + chsP) # getattr(process, "QGTagger" + chsP).isPatJet = cms.untracked.bool(True) # getattr(process, "QGTagger" + chsP).useCHS = cms.untracked.bool(True) # process.QuarkGluonTagger.replace(getattr(process, 'QGTagger' + p), getattr(process, 'QGTagger' + p) + getattr(process, 'QGTagger' + chsP)) print "##########################" print "Calo jets" if processCaloJets else "No processing of calo jets" print "##########################" usePFIso(process, "") #adaptPFIsoPhotons(process, process.patPhotons, "", "03") # chiara init ---------------------------------- print "##########################" print "CA8 Jets" if processCA8Jets else "No processing of CA8 jets collection" print "##########################" if processCA8Jets: from PhysicsTools.PatAlgos.tools.jetTools import addJetCollection # Reco CA 0.8 jets # non sapendo quali parametri usare esattamente lascerei i default della reco per ora. # Per doAreaFastjet e doRhoFastjet per il momento usiamo quanto e' ridefinito sopra from RecoJets.JetProducers.ca4PFJets_cfi import ca4PFJets process.ca8PFJetsPFlow = ca4PFJets.clone( rParam = cms.double(0.8) # src = cms.InputTag('pfNoElectron'+postfix), # doAreaFastjet = cms.bool(True), # doRhoFastjet = cms.bool(True), # Rho_EtaMax = cms.double(6.0), # Ghost_EtaMax = cms.double(7.0) ) # Gen CA 0.8 jets from RecoJets.JetProducers.ca4GenJets_cfi import ca4GenJets process.ca8GenJetsNoNu = ca4GenJets.clone( rParam = cms.double(0.8), src = cms.InputTag("genParticlesForJetsNoNu") ) # chiara end ---------------------------------- if processCaloJets: # No L2L3 Residual on purpose jetCorrections = ('AK5Calo', ['L1Offset', 'L2Relative', 'L3Absolute']) addJetCollection(process, cms.InputTag('ak7CaloJets'), 'AK7', 'Calo', doJTA = True, doBTagging = True, jetCorrLabel = jetCorrections, doType1MET = correctMETWithT1, doL1Cleaning = False, doL1Counters = False, genJetCollection = cms.InputTag("ak7GenJets"), doJetID = True, jetIdLabel = "ak7" ) switchJetCollection(process, cms.InputTag('ak5CaloJets'), doJTA = True, doBTagging = True, jetCorrLabel = jetCorrections, doType1MET = correctMETWithT1, genJetCollection = cms.InputTag("ak5GenJets"), doJetID = True, jetIdLabel = "ak5" ) process.selectedPatJets.cut = "pt > 2" process.selectedPatJetsAK7Calo.cut = "pt > 2" else: removeSpecificPATObjects(process, names = ['Jets', 'METs']) if not runOnMC: # Remove MC Matching removeMCMatching(process, names = ["All"]) removeSpecificPATObjects(process, names = ['Electrons', 'Muons', 'Taus']) if runCHS: print "##########################" print "Running CHS sequence" print "##########################" process.analysisSequence = cms.Sequence() process.analysisSequence *= process.sequence_nochs #if runCHS: # process.analysisSequence *= process.sequence_chs # chiara init ---------------------------------- if processCA8Jets: process.analysisSequence *= process.ca8PFJetsPFlow print("done process.ca8PFJetsPFlow") process.analysisSequence *= process.ca8GenJetsNoNu print("done process.ca8GenJetsNoNu") # nuovo # chiara end ---------------------------------- #GIULIA # Quark Gluon tagging #process.analysisSequence *= process.QuarkGluonTagger # Add default pat sequence to our path # This brings to life TcMET, Calo jets and Photons ########process.analysisSequence *= process.patDefaultSequence # Add our PhotonIsolationProducer to the analysisSequence. This producer compute pf isolations # for our photons process.photonPFIsolation = cms.EDProducer("PhotonIsolationProducer", src = cms.InputTag("selectedPatPhotons") ) ##########process.analysisSequence *= process.photonPFIsolation # Filtering # require physics declared process.load('HLTrigger.special.hltPhysicsDeclared_cfi') process.hltPhysicsDeclared.L1GtReadoutRecordTag = 'gtDigis' # require scraping filter process.scrapingVeto = cms.EDFilter("FilterOutScraping", applyfilter = cms.untracked.bool(True), debugOn = cms.untracked.bool(False), numtrack = cms.untracked.uint32(10), thresh = cms.untracked.double(0.25) ) # Count events process.nEventsTotal = cms.EDProducer("EventCountProducer") process.nEventsFiltered = cms.EDProducer("EventCountProducer") # MET Filters process.load("RecoMET.METFilters.metFilters_cff") # HCAL Laser filter : work only on Winter13 rereco process.load("EventFilter.HcalRawToDigi.hcallaserFilterFromTriggerResult_cff") # Let it run process.p = cms.Path( process.nEventsTotal + # Filters process.hcalfilter + process.primaryVertexFilter + process.scrapingVeto + process.metFilters + process.goodOfflinePrimaryVertices + # Physics process.analysisSequence + process.nEventsFiltered ) if runOnMC: process.p.remove(process.hcalfilter) process.p.remove(process.scrapingVeto) # Add PF2PAT output to the created file from PhysicsTools.PatAlgos.patEventContent_cff import patEventContentNoCleaning #process.load("CommonTools.ParticleFlow.PF2PAT_EventContent_cff") process.out.outputCommands = cms.untracked.vstring('drop *', #process.out.outputCommands = cms.untracked.vstring('keep *') #'drop *', 'keep *_*_*_SIM', 'keep *_*_*_HLT', 'keep *_*_*_RECO', 'keep *_*ca8*_*_PAT') #'keep *_photonCore_*_*', #'keep double_kt6*Jets*_rho_*', #'keep *_goodOfflinePrimaryVertices_*_*', #'keep recoPFCandidates_particleFlow_*_*', # Content of *patEventContentNoCleaning #'keep *_selectedPatPhotons*_*_*', 'keep *_selectedPatElectrons*_*_*', 'keep *_selectedPatMuons*_*_*', 'keep *_selectedPatTaus*_*_*', 'keep *_selectedPatJets*_*_*', 'drop *_selectedPatJets_pfCandidates_*', 'drop *_*PF_caloTowers_*', 'drop *_*JPT_pfCandidates_*', 'drop *_*Calo_pfCandidates_*', 'keep *_patMETs*_*_*', 'keep *_selectedPatPFParticles*_*_*', 'keep *_selectedPatTrackCands*_*_*', #'keep *_cleanPatPhotons*_*_*', 'keep *_cleanPatElectrons*_*_*', 'keep *_cleanPatMuons*_*_*', 'keep *_cleanPatTaus*_*_*', #'keep *_cleanPatJets*_*_*', 'keep *_cleanPatHemispheres*_*_*', 'keep *_cleanPatPFParticles*_*_*', #'keep *_cleanPatTrackCands*_*_*', #'drop *_*PFlow_caloTowers_*', # Type I residual #'drop *_selectedPatJetsForMET*_*_PAT', #'keep *_patPFMet*_*_PAT', # Keep raw met # Trigger #'keep *_TriggerResults_*_HLT', # Debug #'keep *_pf*_*_PAT' # Photon ID #'keep *_patConversions*_*_*', #'keep *_photonPFIsolation*_*_*', # Quark Gluon tagging #'keep *_QGTagger*_*_*', #'drop *_kt6PFJetsIsoQG_*_PAT', #'drop *_kt6PFJetsQG_*_PAT', # MC truth #'keep *_genParticles_*_*' #) if runOnMC: process.out.outputCommands.extend(['keep *_addPileupInfo_*_*', 'keep *_generator_*_*']) # switch on PAT trigger # from PhysicsTools.PatAlgos.tools.trigTools import switchOnTrigger # switchOnTrigger( process ) ## ------------------------------------------------------ # In addition you usually want to change the following # parameters: ## ------------------------------------------------------ # process.GlobalTag.globaltag = "%s::All" % (globalTag) ## (according to https://twiki.cern.ch/twiki/bin/view/CMS/SWGuideFrontierConditions) # ## #process.source.fileNames = cms.untracked.vstring('file:input_data.root') ## (e.g. 'file:AOD.root') # ## #process.maxEvents.input = 2500 process.maxEvents.input = 5000 # ## # process.out.outputCommands = [ ... ] ## (e.g. taken from PhysicsTools/PatAlgos/python/patEventContent_cff.py) # ## process.options.wantSummary = False ## (to suppress the long output at the end of the job) process.MessageLogger.cerr.FwkReport.reportEvery = 1000 # Remove annoying ecalLaser messages process.MessageLogger.suppressError = cms.untracked.vstring ('ecalLaserCorrFilter') return process
## Input files process.source.fileNames.append( '/store/data/Run2012B/DoubleMu/AOD/29Jun2012-v1/0001/C46FD2A9-3FC3-E111-A1A8-485B39800C00.root' ) ## Maximal Number of Events process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(-1) ) ## Apply the json file jsonfile = '/afs/cern.ch/cms/CAF/CMSCOMM/COMM_DQM/certification/Collisions12/8TeV/Reprocessing/Cert_190456-196531_8TeV_29Jun2012ReReco_Collisions12_JSON.txt' json.apply(jsonfile, process.source) ## Standard PAT Configuration File # process.load("PhysicsTools.PatAlgos.patSequences_cff") ## The HtoZg sequence process.load('HtoZg.MuonAnalysis.skimSequence_cff') patcore.removeAllPATObjectsBut(process, ['Muons', 'Photons']) patcore.removeMCMatching(process) ## TFileService for the ntuple output process.load('HtoZg.CommonAnalysis.TFileService_cfi') process.TFileService.fileName = 'data.root' process.p = cms.Path(process.skimSequence) if __name__ == '__main__': ## Adds tab-completion and history for interactive testing. import user
################################################################################ ################################################################################ ################## create ntuple for ECAL alignment purposes ################### #-------------------------- #Define PAT sequence #-------------------------- # Standard PAT Configuration File process.load("PhysicsTools.PatAlgos.patSequences_cff") process.patElectrons.addElectronID = cms.bool(False) # ---- remove MC references ---- from PhysicsTools.PatAlgos.tools.coreTools import removeMCMatching removeMCMatching(process, ['All'], outputModules=[], postfix="") #removeMCMatching(process, ['All']) #process.makePatElectrons.remove(process.electronMatch) #process.makePatMuons.remove(process.muonMatch) #process.patCandidates.remove(process.makePatTaus) #process.makePatTaus.remove(process.tauMatch) #process.makePatTaus.remove(process.tauGenJets) #process.makePatTaus.remove(process.tauGenJetsSelectorAllHadrons) #process.makePatTaus.remove(process.tauGenJetMatch) process.cleanPatTaus.preselection = cms.string( 'tauID("decayModeFinding") > 0.5 & tauID("byLooseCombinedIsolationDeltaBetaCorr3Hits") > 0.5 & tauID("againstMuonTight3") > 0.5 ' ) process.patMETs.addGenMET = cms.bool(False)
CfgTypes.VLuminosityBlockRange()) process.source.lumisToProcess.extend(myLumis) #GT if runOnMC: process.GlobalTag.globaltag = 'START53_V27::All' else: process.GlobalTag.globaltag = 'FT_53_V21_AN6::All' ## Source process.source = cms.Source("PoolSource", fileNames=files) ## Maximal Number of Events process.maxEvents = cms.untracked.PSet(input=cms.untracked.int32(nevents)) #objects from PhysicsTools.PatAlgos.tools.coreTools import removeMCMatching if not runOnMC: removeMCMatching(process, ['All']) from PhysicsTools.PatAlgos.tools.trigTools import * switchOnTrigger(process, sequence='patDefaultSequence', hltProcess='*') from UserCode.zbb_louvain.PATconfig.vertex_cff import * setupGoodVertex(process) from UserCode.zbb_louvain.PATconfig.muon_cff import * setupPatMuons(process, runOnMC, muPt) from UserCode.zbb_louvain.PATconfig.electron_cff import * setupPatElectrons(process, runOnMC, elePt) from UserCode.zbb_louvain.PATconfig.tau_cff import * setupPatTaus(process) from UserCode.zbb_louvain.PATconfig.jet_cff import * setupPatJets(process, runOnMC) from UserCode.zbb_louvain.PATconfig.subjet_cff import * setupPatSubJets(process, runOnMC) from UserCode.zbb_louvain.PATconfig.met_cff import *
def addPat(process, isData, doRECO, doTTEffShrinkingConePFTau): sequence = cms.Sequence() # If running together with RECO # We get another kt6PFJets from PAT, and as-is they clash producing an exception runningWithReco = hasattr(process, "recoAllPFJets") if runningWithReco: process.recoAllPFJets.remove(process.kt6PFJets) process.recoPFJets.remove(process.kt6PFJets) process.load("PhysicsTools.PatAlgos.patSequences_cff") if runningWithReco: process.recoAllPFJets.replace(process.kt4PFJets, process.kt4PFJets*process.kt6PFJets) process.recoPFJets.replace(process.kt4PFJets, process.kt4PFJets*process.kt6PFJets) # process.load("PhysicsTools.PatAlgos.producersLayer1.patCandidates_cff") # Calculate PF isolation of the muon #process.muonPFIsolationSequence = MuonPFIsolation.addMuonPFIsolation(process, "muons", process.patMuons) #sequence += process.muonPFIsolationSequence if doRECO: process.pfPileUpIso.PFCandidates = "particleFlowTmp" # I don't know why I have to do this process.pfNoPileUpIso.bottomCollection = "particleFlowTmp" jetCorr = ["L1FastJet", "L2Relative", "L3Absolute"] if isData: jetCorr.append("L2L3Residual") # coreTools.removeMCMatching(process, ["All"], outputInProcess=False) coreTools.removeMCMatching(process, ["All"], outputModules = []) #### coreTools.removeCleaning(process, False) coreTools.removeCleaning(process, outputModules = []) #### coreTools.removeSpecificPATObjects(process, ["Electrons", "Photons", "METs"], False) coreTools.removeSpecificPATObjects(process, ["Electrons", "Photons", "METs"], outputModules = []) tauTools.addTauCollection(process, cms.InputTag('hpsPFTauProducer'), algoLabel = "hps", typeLabel = "PFTau") jetTools.switchJetCollection(process, cms.InputTag('ak5PFJets'), doJTA = True, doBTagging = True, jetCorrLabel = ('AK5PF', jetCorr), doType1MET = False, genJetCollection = cms.InputTag("ak5GenJets"), doJetID = False, jetIdLabel = "ak5", outputModules = []) # If the reference tau should be the old TTEff shrinking cone # if doTTEffShrinkingConePFTau: # process.patTaus.tauSource = "TTEffShrinkingConePFTauProducer" # for module in [process.tauIsoDepositPFCandidates, process.tauIsoDepositPFChargedHadrons, process.tauIsoDepositPFGammas, process.tauIsoDepositPFNeutralHadrons]: # module.src = "TTEffShrinkingConePFTauProducer" # module.ExtractorPSet.tauSource = "TTEffShrinkingConePFTauProducer" # process.tauMatch.src = "TTEffShrinkingConePFTauProducer" # process.patTaus.tauIDSources.leadingPionPtCut = "TTEffPFTauDiscriminationByLeadingPionPtCut" # process.patTaus.tauIDSources.byIsolationUsingLeadingPion = "TTEffPFTauDiscriminationByIsolationUsingLeadingPion" # process.patTaus.tauIDSources.leadingTrackFinding = "TTEffPFTauDiscriminationByLeadingTrackFinding" # process.patTaus.tauIDSources.againstMuon = "TTEffPFTauDiscriminationAgainstMuon" # process.patTaus.tauIDSources.againstElectron = "TTEffPFTauDiscriminationAgainstElectron" # process.selectedPatTaus.cut = "pt() > 15 && abs(eta()) < 2.5 && tauID('leadingPionPtCut')" sequence += process.patDefaultSequence return sequence
def jetToolbox( proc, jetType, jetSequence, outputFile, newPFCollection=False, nameNewPFCollection = '', PUMethod='CHS', #### Options: Puppi, CS, SK, Plain miniAOD=True, runOnMC=True, JETCorrPayload='', JETCorrLevels = [ 'None' ], GetJetMCFlavour=True, Cut = '', bTagDiscriminators = None, subJETCorrPayload='', subJETCorrLevels = [ 'None' ], GetSubjetMCFlavour=False, CutSubjet = '', addPruning=False, zCut=0.1, rCut=0.5, addPrunedSubjets=False, addSoftDrop=False, betaCut=0.0, zCutSD=0.1, addSoftDropSubjets=False, addTrimming=False, rFiltTrim=0.2, ptFrac=0.03, addFiltering=False, rfilt=0.3, nfilt=3, addCMSTopTagger=False, addMassDrop=False, addHEPTopTagger=False, addNsub=False, maxTau=4, addPUJetID=False, addQJets=False, addQGTagger=False, QGjetsLabel='chs', addEnergyCorrFunc=False, ecfBeta = 1.0, maxECF=3, ): runOnData = not runOnMC if runOnData: GetJetMCFlavour = False GetSubjetMCFlavour = False ############################################################################### ####### Verifying some inputs and defining variables ############################################################################### print '|---- jetToolbox: Initialyzing collection...' if newPFCollection: print '|---- jetToolBox: Using '+ nameNewPFCollection +' as PFCandidates collection' supportedJetAlgos = { 'ak': 'AntiKt', 'ca' : 'CambridgeAachen', 'kt' : 'Kt' } recommendedJetAlgos = [ 'ak4', 'ak8', 'ca4', 'ca8', 'ca10' ] payloadList = [ 'None', 'AK1PFchs', 'AK2PFchs', 'AK3PFchs', 'AK4PFchs', 'AK5PFchs', 'AK6PFchs', 'AK7PFchs', 'AK8PFchs', 'AK9PFchs', 'AK10PFchs', 'AK1PFPUPPI', 'AK2PFPUPPI', 'AK3PFPUPPI', 'AK4PFPUPPI', 'AK5PFPUPPI', 'AK6PFPUPPI', 'AK7PFPUPPI', 'AK8PFPUPPI', 'AK9PFPUPPI', 'AK10PFPUPPI', 'AK1PFSK', 'AK2PFSK', 'AK3PFSK', 'AK4PFSK', 'AK5PFSK', 'AK6PFSK', 'AK7PFSK', 'AK8PFSK', 'AK9PFSK', 'AK10PFSK', 'AK1PF', 'AK2PF', 'AK3PF', 'AK4PF', 'AK5PF', 'AK6PF', 'AK7PF', 'AK8PF', 'AK9PF', 'AK10PF' ] JECLevels = [ 'L1Offset', 'L1FastJet', 'L1JPTOffset', 'L2Relative', 'L3Absolute', 'L5Falvour', 'L7Parton' ] if runOnData: JECLevels += ['L2L3Residual'] jetAlgo = '' algorithm = '' size = '' for type, tmpAlgo in supportedJetAlgos.iteritems(): if type in jetType.lower(): jetAlgo = type algorithm = tmpAlgo size = jetType.replace( type, '' ) jetSize = 0. if int(size) in range(0, 20): jetSize = int(size)/10. else: print '|---- jetToolBox: jetSize has not a valid value. Insert a number between 1 and 20 after algorithm, like: AK8' ### Trick for uppercase/lowercase algo name jetALGO = jetAlgo.upper()+size jetalgo = jetAlgo.lower()+size if jetalgo not in recommendedJetAlgos: print '|---- jetToolBox: CMS recommends the following jet algoritms: '+' '.join(recommendedJetAlgos)+'. You are using', jetalgo,'.' ################################################################################# ####### Toolbox start ################################################################################# elemToKeep = [] jetSeq = cms.Sequence() genParticlesLabel = '' pvLabel = '' tvLabel = '' toolsUsed = [] #### For MiniAOD if miniAOD: print '|---- jetToolBox: JETTOOLBOX RUNNING ON MiniAOD FOR '+jetALGO+' JETS USING '+PUMethod genParticlesLabel = 'prunedGenParticles' pvLabel = 'offlineSlimmedPrimaryVertices' svLabel = 'slimmedSecondaryVertices' tvLabel = 'unpackedTracksAndVertices' pfCand = nameNewPFCollection if newPFCollection else 'packedPFCandidates' if runOnMC: ## Filter out neutrinos from packed GenParticles setattr( proc, 'packedGenParticlesForJetsNoNu', cms.EDFilter("CandPtrSelector", src = cms.InputTag("packedGenParticles"), cut = cms.string("abs(pdgId) != 12 && abs(pdgId) != 14 && abs(pdgId) != 16") )) jetSeq += getattr(proc, 'packedGenParticlesForJetsNoNu' ) setattr( proc, jetalgo+'GenJetsNoNu', ak4GenJets.clone( src = 'packedGenParticlesForJetsNoNu', rParam = jetSize, jetAlgorithm = algorithm ) ) jetSeq += getattr(proc, jetalgo+'GenJetsNoNu' ) #for Inclusive Vertex Finder proc.load('PhysicsTools.PatAlgos.slimming.unpackedTracksAndVertices_cfi') #### For AOD else: print '|---- jetToolBox: JETTOOLBOX RUNNING ON AOD FOR '+jetALGO+' JETS USING '+PUMethod genParticlesLabel = 'genParticles' pvLabel = 'offlinePrimaryVertices' tvLabel = 'generalTracks' pfCand = nameNewPFCollection if newPFCollection else 'particleFlow' svLabel = 'inclusiveCandidateSecondaryVertices' if runOnMC: proc.load('RecoJets.Configuration.GenJetParticles_cff') setattr( proc, jetalgo+'GenJetsNoNu', ak4GenJets.clone( src = 'genParticlesForJetsNoNu', rParam = jetSize, jetAlgorithm = algorithm ) ) jetSeq += getattr(proc, jetalgo+'GenJetsNoNu' ) ## b-tag discriminators if bTagDiscriminators is None: bTagDiscriminators = [ 'pfTrackCountingHighEffBJetTags', 'pfTrackCountingHighPurBJetTags', 'pfJetProbabilityBJetTags', 'pfJetBProbabilityBJetTags', 'pfSimpleSecondaryVertexHighEffBJetTags', 'pfSimpleSecondaryVertexHighPurBJetTags', 'pfCombinedSecondaryVertexV2BJetTags', 'pfCombinedInclusiveSecondaryVertexV2BJetTags' ] ### Jet Corrections if not set(JETCorrLevels).issubset(set(JECLevels)): if ( 'CHS' in PUMethod ) or ( 'Plain' in PUMethod ): JETCorrLevels = ['L1FastJet','L2Relative', 'L3Absolute'] else: JETCorrLevels = [ 'L2Relative', 'L3Absolute'] if runOnData: JETCorrLevels.append('L2L3Residual') if not set(subJETCorrLevels).issubset(set(JECLevels)): if ( 'CHS' in PUMethod ) or ( 'Plain' in PUMethod ): subJETCorrLevels = ['L1FastJet','L2Relative', 'L3Absolute'] else: subJETCorrLevels = [ 'L2Relative', 'L3Absolute'] if runOnData: subJETCorrLevels.append('L2L3Residual') #### Creating PATjets tmpPfCandName = pfCand.lower() if 'Puppi' in PUMethod: if ('puppi' in tmpPfCandName): srcForPFJets = pfCand print '|---- jetToolBox: Not running puppi algorithm because keyword puppi was specified in nameNewPFCollection, but applying puppi corrections.' else: proc.load('CommonTools.PileupAlgos.Puppi_cff') puppi.candName = cms.InputTag( pfCand ) if miniAOD: puppi.vertexName = cms.InputTag('offlineSlimmedPrimaryVertices') jetSeq += getattr(proc, 'puppi' ) srcForPFJets = 'puppi' from RecoJets.JetProducers.ak4PFJetsPuppi_cfi import ak4PFJetsPuppi setattr( proc, jetalgo+'PFJetsPuppi', ak4PFJetsPuppi.clone( src = cms.InputTag( srcForPFJets ), doAreaFastjet = True, rParam = jetSize, jetAlgorithm = algorithm ) ) jetSeq += getattr(proc, jetalgo+'PFJetsPuppi' ) if JETCorrPayload not in payloadList: JETCorrPayload = 'AK'+size+'PFPuppi' if subJETCorrPayload not in payloadList: subJETCorrPayload = 'AK4PFPuppi' elif 'CS' in PUMethod: from RecoJets.JetProducers.ak4PFJetsCS_cfi import ak4PFJetsCS setattr( proc, jetalgo+'PFJetsCS', ak4PFJetsCS.clone( doAreaFastjet = True, csRParam = cms.double(jetSize), jetAlgorithm = algorithm ) ) if miniAOD: getattr( proc, jetalgo+'PFJetsCS').src = pfCand #setattr( proc, jetalgo+'PFJetsCSConstituents', ak8PFJetsCSConstituents.clone( src = cms.InputTag(jetalgo+'PFJetsCS') ) ) jetSeq += getattr(proc, jetalgo+'PFJetsCS' ) #setattr( proc, jetalgo+'PFJetsCSConstituents', ak8PFJetsCSConstituents.clone( src = cms.InputTag(jetalgo+'PFJetsCS') ) ) jetSeq += getattr(proc, jetalgo+'PFJetsCS' ) if JETCorrPayload not in payloadList: JETCorrPayload = 'AK'+size+'PFCS' if subJETCorrPayload not in payloadList: subJETCorrPayload = 'AK4PFCS' elif 'SK' in PUMethod: if ('sk' in tmpPfCandName): srcForPFJets = pfCand print '|---- jetToolBox: Not running softkiller algorithm because keyword SK was specified in nameNewPFCollection, but applying SK corrections.' else: proc.load('CommonTools.PileupAlgos.softKiller_cfi') getattr( proc, 'softKiller' ).PFCandidates = cms.InputTag( pfCand ) jetSeq += getattr(proc, 'softKiller' ) srcForPFJets = 'softKiller' from RecoJets.JetProducers.ak4PFJetsSK_cfi import ak4PFJetsSK setattr( proc, jetalgo+'PFJetsSK', ak4PFJetsSK.clone( src = cms.InputTag( srcForPFJets ), rParam = jetSize, jetAlgorithm = algorithm ) ) jetSeq += getattr(proc, jetalgo+'PFJetsSK' ) if JETCorrPayload not in payloadList: JETCorrPayload = 'AK'+size+'PFSK' if subJETCorrPayload not in payloadList: subJETCorrPayload = 'AK4PFSK' elif 'CHS' in PUMethod: if miniAOD: if ('chs' in tmpPfCandName): srcForPFJets = pfCand print '|---- jetToolBox: Not running CHS algorithm because keyword CHS was specified in nameNewPFCollection, but applying CHS corrections.' else: setattr( proc, 'chs', cms.EDFilter('CandPtrSelector', src = cms.InputTag( pfCand ), cut = cms.string('fromPV')) ) jetSeq += getattr(proc, 'chs') srcForPFJets = 'chs' else: if ( pfCand == 'particleFlow' ): from RecoParticleFlow.PFProducer.particleFlowTmpPtrs_cfi import particleFlowTmpPtrs setattr( proc, 'newParticleFlowTmpPtrs', particleFlowTmpPtrs.clone( src = pfCand ) ) jetSeq += getattr(proc, 'newParticleFlowTmpPtrs') from CommonTools.ParticleFlow.pfNoPileUpJME_cff import pfPileUpJME, pfNoPileUpJME proc.load('CommonTools.ParticleFlow.goodOfflinePrimaryVertices_cfi') setattr( proc, 'newPfPileUpJME', pfPileUpJME.clone( PFCandidates= 'newParticleFlowTmpPtrs' ) ) jetSeq += getattr(proc, 'newPfPileUpJME') setattr( proc, 'newPfNoPileUpJME', pfNoPileUpJME.clone( topCollection='newPfPileUpJME', bottomCollection= 'newParticleFlowTmpPtrs' ) ) jetSeq += getattr(proc, 'newPfNoPileUpJME') srcForPFJets = 'newPfNoPileUpJME' else: proc.load('CommonTools.ParticleFlow.pfNoPileUpJME_cff') srcForPFJets = 'pfNoPileUpJME' setattr( proc, jetalgo+'PFJetsCHS', ak4PFJetsCHS.clone( src = cms.InputTag( srcForPFJets ), doAreaFastjet = True, rParam = jetSize, jetAlgorithm = algorithm ) ) jetSeq += getattr(proc, jetalgo+'PFJetsCHS' ) if JETCorrPayload not in payloadList: JETCorrPayload = 'AK'+size+'PFchs' if subJETCorrPayload not in payloadList: subJETCorrPayload = 'AK4PFchs' else: PUMethod = '' setattr( proc, jetalgo+'PFJets', ak4PFJets.clone( doAreaFastjet = True, rParam = jetSize, jetAlgorithm = algorithm ) ) if miniAOD: getattr( proc, jetalgo+'PFJets').src = pfCand jetSeq += getattr(proc, jetalgo+'PFJets' ) if JETCorrPayload not in payloadList: JETCorrPayload = 'AK'+size+'PF' if subJETCorrPayload not in payloadList: subJETCorrPayload = 'AK4PF' if 'None' in JETCorrPayload: JEC = None else: JEC = ( JETCorrPayload.replace('CS','chs').replace('SK','chs') , JETCorrLevels, 'None' ) ### temporary #else: JEC = ( JETCorrPayload., JETCorrLevels, 'None' ) print '|---- jetToolBox: Applying this corrections: '+str(JEC) if addPrunedSubjets or addSoftDropSubjets or addCMSTopTagger: if 'None' in subJETCorrPayload: subJEC = None else: subJEC = ( subJETCorrPayload.replace('CS','chs').replace('SK','chs') , subJETCorrLevels, 'None' ) ### temporary if ( 'CHS' in PUMethod ) and miniAOD: setattr( proc, jetalgo+'PFJets'+PUMethod+'Constituents', cms.EDFilter("MiniAODJetConstituentSelector", src = cms.InputTag( jetalgo+'PFJets'+PUMethod ), cut = cms.string( Cut ) )) else: setattr( proc, jetalgo+'PFJets'+PUMethod+'Constituents', cms.EDFilter("PFJetConstituentSelector", src = cms.InputTag( jetalgo+'PFJets'+PUMethod ), cut = cms.string( Cut ) )) jetSeq += getattr(proc, jetalgo+'PFJets'+PUMethod+'Constituents' ) addJetCollection( proc, labelName = jetALGO+'PF'+PUMethod, jetSource = cms.InputTag( jetalgo+'PFJets'+PUMethod), algo = jetalgo, rParam = jetSize, jetCorrections = JEC if JEC is not None else None, pfCandidates = cms.InputTag( pfCand ), svSource = cms.InputTag( svLabel ), genJetCollection = cms.InputTag( jetalgo+'GenJetsNoNu'), pvSource = cms.InputTag( pvLabel ), btagDiscriminators = bTagDiscriminators, getJetMCFlavour = GetJetMCFlavour, genParticles = cms.InputTag(genParticlesLabel), outputModules = ['outputFile'] ) if 'CS' in PUMethod: getattr( proc, 'patJets'+jetALGO+'PF'+PUMethod ).getJetMCFlavour = False # CS jets cannot be re-clustered from their constituents #### Groomers if addSoftDrop or addSoftDropSubjets: setattr( proc, jetalgo+'PFJets'+PUMethod+'SoftDrop', ak8PFJetsCHSSoftDrop.clone( src = cms.InputTag( jetalgo+'PFJets'+PUMethod+'Constituents', 'constituents' ), rParam = jetSize, jetAlgorithm = algorithm, useExplicitGhosts=True, R0= cms.double(jetSize), #zcut=zCutSD, beta=betaCut, writeCompound = cms.bool(True), jetCollInstanceName=cms.string('SubJets') ) ) setattr( proc, jetalgo+'PFJets'+PUMethod+'SoftDropMass', ak8PFJetsCHSSoftDropMass.clone( src = cms.InputTag( jetalgo+'PFJets'+PUMethod), matched = cms.InputTag( jetalgo+'PFJets'+PUMethod+'SoftDrop'), distMax = cms.double( jetSize ) ) ) elemToKeep += [ 'keep *_'+jetalgo+'PFJets'+PUMethod+'SoftDropMass_*_*'] jetSeq += getattr(proc, jetalgo+'PFJets'+PUMethod+'SoftDrop' ) jetSeq += getattr(proc, jetalgo+'PFJets'+PUMethod+'SoftDropMass' ) getattr( proc, 'patJets'+jetALGO+'PF'+PUMethod).userData.userFloats.src += [ jetalgo+'PFJets'+PUMethod+'SoftDropMass'] toolsUsed.append( jetalgo+'PFJets'+PUMethod+'SoftDropMass' ) if addSoftDropSubjets: if runOnMC: setattr( proc, jetalgo+'GenJetsNoNuSoftDrop', ak4GenJets.clone( SubJetParameters, useSoftDrop = cms.bool(True), rParam = jetSize, jetAlgorithm = algorithm, useExplicitGhosts=cms.bool(True), #zcut=cms.double(zCutSD), R0= cms.double(jetSize), beta=cms.double(betaCut), writeCompound = cms.bool(True), jetCollInstanceName=cms.string('SubJets') )) if miniAOD: getattr( proc, jetalgo+'GenJetsNoNuSoftDrop' ).src = 'packedGenParticlesForJetsNoNu' jetSeq += getattr(proc, jetalgo+'GenJetsNoNuSoftDrop' ) addJetCollection( proc, labelName = jetALGO+'PF'+PUMethod+'SoftDrop', jetSource = cms.InputTag( jetalgo+'PFJets'+PUMethod+'SoftDrop'), algo = jetalgo, rParam = jetSize, jetCorrections = JEC if JEC is not None else None, pvSource = cms.InputTag( pvLabel ), btagDiscriminators = ['None'], genJetCollection = cms.InputTag( jetalgo+'GenJetsNoNu'), getJetMCFlavour = False, # jet flavor should always be disabled for groomed jets genParticles = cms.InputTag(genParticlesLabel), outputModules = ['outputFile'] ) setattr( proc, 'selectedPatJets'+jetALGO+'PF'+PUMethod+'SoftDrop', selectedPatJets.clone( src = 'patJets'+jetALGO+'PF'+PUMethod+'SoftDrop', cut = Cut ) ) addJetCollection( proc, labelName = jetALGO+'PF'+PUMethod+'SoftDropSubjets', jetSource = cms.InputTag( jetalgo+'PFJets'+PUMethod+'SoftDrop', 'SubJets'), algo = jetalgo, # needed for subjet b tagging rParam = jetSize, # needed for subjet b tagging jetCorrections = subJEC if subJEC is not None else None, pfCandidates = cms.InputTag( pfCand ), pvSource = cms.InputTag( pvLabel), svSource = cms.InputTag( svLabel ), btagDiscriminators = bTagDiscriminators, genJetCollection = cms.InputTag( jetalgo+'GenJetsNoNuSoftDrop','SubJets'), getJetMCFlavour = GetSubjetMCFlavour, genParticles = cms.InputTag(genParticlesLabel), explicitJTA = True, # needed for subjet b tagging svClustering = True, # needed for subjet b tagging fatJets=cms.InputTag(jetalgo+'PFJets'+PUMethod), # needed for subjet flavor clustering groomedFatJets=cms.InputTag(jetalgo+'PFJets'+PUMethod+'SoftDrop'), # needed for subjet flavor clustering outputModules = ['outputFile'] ) setattr( proc, 'selectedPatJets'+jetALGO+'PF'+PUMethod+'SoftDropSubjets', selectedPatJets.clone( src = 'patJets'+jetALGO+'PF'+PUMethod+'SoftDropSubjets', cut = Cut )) ## Establish references between PATified fat jets and subjets using the BoostedJetMerger setattr( proc, 'selectedPatJets'+jetALGO+'PF'+PUMethod+'SoftDropPacked', cms.EDProducer("BoostedJetMerger", jetSrc=cms.InputTag('selectedPatJets'+jetALGO+'PF'+PUMethod+'SoftDrop'), subjetSrc=cms.InputTag('selectedPatJets'+jetALGO+'PF'+PUMethod+'SoftDropSubjets') )) jetSeq += getattr(proc, 'selectedPatJets'+jetALGO+'PF'+PUMethod+'SoftDropPacked' ) elemToKeep += [ 'keep *_selectedPatJets'+jetALGO+'PF'+PUMethod+'SoftDropPacked_*_*' ] toolsUsed.append( 'selectedPatJets'+jetALGO+'PF'+PUMethod+'SoftDropPacked' ) toolsUsed.append( 'selectedPatJets'+jetALGO+'PF'+PUMethod+'SoftDropSubjets' ) if addPruning or addPrunedSubjets: setattr( proc, jetalgo+'PFJets'+PUMethod+'Pruned', ak8PFJetsCHSPruned.clone( src = cms.InputTag( jetalgo+'PFJets'+PUMethod+'Constituents', 'constituents' ), rParam = jetSize, jetAlgorithm = algorithm, zcut=zCut, rcut_factor=rCut, writeCompound = cms.bool(True), doAreaFastjet = cms.bool(True), jetCollInstanceName=cms.string('SubJets') ) ) setattr( proc, jetalgo+'PFJets'+PUMethod+'PrunedMass', ak8PFJetsCHSPrunedMass.clone( src = cms.InputTag( jetalgo+'PFJets'+PUMethod), matched = cms.InputTag( jetalgo+'PFJets'+PUMethod+'Pruned'), distMax = cms.double( jetSize ) ) ) jetSeq += getattr(proc, jetalgo+'PFJets'+PUMethod+'Pruned' ) jetSeq += getattr(proc, jetalgo+'PFJets'+PUMethod+'PrunedMass' ) getattr( proc, 'patJets'+jetALGO+'PF'+PUMethod).userData.userFloats.src += [ jetalgo+'PFJets'+PUMethod+'PrunedMass'] elemToKeep += [ 'keep *_'+jetalgo+'PFJets'+PUMethod+'PrunedMass_*_*'] toolsUsed.append( jetalgo+'PFJets'+PUMethod+'PrunedMass' ) if addPrunedSubjets: if runOnMC: setattr( proc, jetalgo+'GenJetsNoNuPruned', ak4GenJets.clone( SubJetParameters, rParam = jetSize, usePruning = cms.bool(True), writeCompound = cms.bool(True), jetCollInstanceName=cms.string('SubJets') )) if miniAOD: getattr( proc, jetalgo+'GenJetsNoNuPruned' ).src = 'packedGenParticlesForJetsNoNu' jetSeq += getattr(proc, jetalgo+'GenJetsNoNuPruned' ) addJetCollection( proc, labelName = jetALGO+'PF'+PUMethod+'Pruned', jetSource = cms.InputTag( jetalgo+'PFJets'+PUMethod+'Pruned'), algo = jetalgo, rParam = jetSize, jetCorrections = JEC if JEC is not None else None, pvSource = cms.InputTag( pvLabel ), btagDiscriminators = ['None'], genJetCollection = cms.InputTag( jetalgo+'GenJetsNoNu'), getJetMCFlavour = False, # jet flavor should always be disabled for groomed jets genParticles = cms.InputTag(genParticlesLabel), outputModules = ['outputFile'] ) setattr( proc, 'selectedPatJets'+jetALGO+'PF'+PUMethod+'Pruned', selectedPatJets.clone( src = 'patJets'+jetALGO+'PF'+PUMethod+'Pruned', cut = Cut ) ) addJetCollection( proc, labelName = jetALGO+'PF'+PUMethod+'PrunedSubjets', jetSource = cms.InputTag( jetalgo+'PFJets'+PUMethod+'Pruned', 'SubJets'), algo = jetalgo, # needed for subjet b tagging rParam = jetSize, # needed for subjet b tagging jetCorrections = subJEC if subJEC is not None else None, pfCandidates = cms.InputTag( pfCand ), pvSource = cms.InputTag( pvLabel), svSource = cms.InputTag( svLabel ), getJetMCFlavour = GetSubjetMCFlavour, genParticles = cms.InputTag(genParticlesLabel), btagDiscriminators = bTagDiscriminators, genJetCollection = cms.InputTag( jetalgo+'GenJetsNoNuPruned','SubJets'), explicitJTA = True, # needed for subjet b tagging svClustering = True, # needed for subjet b tagging fatJets=cms.InputTag(jetalgo+'PFJets'+PUMethod), # needed for subjet flavor clustering groomedFatJets=cms.InputTag(jetalgo+'PFJets'+PUMethod+'Pruned'), # needed for subjet flavor clustering outputModules = ['outputFile'] ) setattr( proc, 'selectedPatJets'+jetALGO+'PF'+PUMethod+'PrunedSubjets', selectedPatJets.clone( src = 'patJets'+jetALGO+'PF'+PUMethod+'PrunedSubjets', cut = Cut ) ) ## Establish references between PATified fat jets and subjets using the BoostedJetMerger setattr( proc, 'selectedPatJets'+jetALGO+'PF'+PUMethod+'PrunedPacked', cms.EDProducer("BoostedJetMerger", jetSrc=cms.InputTag('selectedPatJets'+jetALGO+'PF'+PUMethod+'Pruned'), subjetSrc=cms.InputTag('selectedPatJets'+jetALGO+'PF'+PUMethod+'PrunedSubjets') )) jetSeq += getattr(proc, 'selectedPatJets'+jetALGO+'PF'+PUMethod+'PrunedPacked' ) elemToKeep += [ 'keep *_selectedPatJets'+jetALGO+'PF'+PUMethod+'PrunedPacked_*_*' ] toolsUsed.append( 'selectedPatJets'+jetALGO+'PF'+PUMethod+'PrunedPacked' ) toolsUsed.append( 'selectedPatJets'+jetALGO+'PF'+PUMethod+'PrunedSubjets' ) if addTrimming: setattr( proc, jetalgo+'PFJets'+PUMethod+'Trimmed', ak8PFJetsCHSTrimmed.clone( rParam = jetSize, src = cms.InputTag( jetalgo+'PFJets'+PUMethod+'Constituents', 'constituents'), jetAlgorithm = algorithm, rFilt= rFiltTrim, trimPtFracMin= ptFrac) ) setattr( proc, jetalgo+'PFJets'+PUMethod+'TrimmedMass', ak8PFJetsCHSTrimmedMass.clone( src = cms.InputTag( jetalgo+'PFJets'+PUMethod), matched = cms.InputTag( jetalgo+'PFJets'+PUMethod+'Trimmed'), distMax = cms.double( jetSize ) ) ) elemToKeep += [ 'keep *_'+jetalgo+'PFJets'+PUMethod+'TrimmedMass_*_*'] jetSeq += getattr(proc, jetalgo+'PFJets'+PUMethod+'Trimmed' ) jetSeq += getattr(proc, jetalgo+'PFJets'+PUMethod+'TrimmedMass' ) getattr( proc, 'patJets'+jetALGO+'PF'+PUMethod).userData.userFloats.src += [ jetalgo+'PFJets'+PUMethod+'TrimmedMass'] toolsUsed.append( jetalgo+'PFJets'+PUMethod+'TrimmedMass' ) if addFiltering: setattr( proc, jetalgo+'PFJets'+PUMethod+'Filtered', ak8PFJetsCHSFiltered.clone( src = cms.InputTag( jetalgo+'PFJets'+PUMethod+'Constituents', 'constituents' ), rParam = jetSize, jetAlgorithm = algorithm, rFilt= rfilt, nFilt= nfilt ) ) setattr( proc, jetalgo+'PFJets'+PUMethod+'FilteredMass', ak8PFJetsCHSFilteredMass.clone( src = cms.InputTag( jetalgo+'PFJets'+PUMethod), matched = cms.InputTag( jetalgo+'PFJets'+PUMethod+'Filtered'), distMax = cms.double( jetSize ) ) ) elemToKeep += [ 'keep *_'+jetalgo+'PFJets'+PUMethod+'FilteredMass_*_*'] jetSeq += getattr(proc, jetalgo+'PFJets'+PUMethod+'Filtered' ) jetSeq += getattr(proc, jetalgo+'PFJets'+PUMethod+'FilteredMass' ) getattr( proc, 'patJets'+jetALGO+'PF'+PUMethod).userData.userFloats.src += [ jetalgo+'PFJets'+PUMethod+'FilteredMass'] toolsUsed.append( jetalgo+'PFJets'+PUMethod+'FilteredMass' ) if addCMSTopTagger : if 'CA' in jetALGO : setattr( proc, 'cmsTopTagPFJets'+PUMethod, cms.EDProducer("CATopJetProducer", PFJetParameters.clone( src = cms.InputTag( jetalgo+'PFJets'+PUMethod+'Constituents', 'constituents' ), doAreaFastjet = cms.bool(True), doRhoFastjet = cms.bool(False), jetPtMin = cms.double(100.0) ), AnomalousCellParameters, CATopJetParameters.clone( jetCollInstanceName = cms.string("SubJets"), verbose = cms.bool(False), algorithm = cms.int32(1), # 0 = KT, 1 = CA, 2 = anti-KT tagAlgo = cms.int32(0), #0=legacy top useAdjacency = cms.int32(2), # modified adjacency centralEtaCut = cms.double(2.5), # eta for defining "central" jets sumEtBins = cms.vdouble(0,1600,2600), # sumEt bins over which cuts vary. vector={bin 0 lower bound, bin 1 lower bound, ...} rBins = cms.vdouble(0.8,0.8,0.8), # Jet distance paramter R. R values depend on sumEt bins. ptFracBins = cms.vdouble(0.05,0.05,0.05), # minimum fraction of central jet pt for subjets (deltap) deltarBins = cms.vdouble(0.19,0.19,0.19), # Applicable only if useAdjacency=1. deltar adjacency values for each sumEtBin nCellBins = cms.vdouble(1.9,1.9,1.9), ), jetAlgorithm = cms.string("CambridgeAachen"), rParam = cms.double(jetSize), writeCompound = cms.bool(True) ) ) setattr( proc, "CATopTagInfos", cms.EDProducer("CATopJetTagger", src = cms.InputTag('cmsTopTagPFJets'+PUMethod), TopMass = cms.double(171), TopMassMin = cms.double(0.), TopMassMax = cms.double(250.), WMass = cms.double(80.4), WMassMin = cms.double(0.0), WMassMax = cms.double(200.0), MinMassMin = cms.double(0.0), MinMassMax = cms.double(200.0), verbose = cms.bool(False) ) ) addJetCollection( proc, labelName = 'CMSTopTag'+PUMethod, jetSource = cms.InputTag('cmsTopTagPFJets'+PUMethod), jetCorrections = JEC if JEC is not None else None, pfCandidates = cms.InputTag( pfCand ), pvSource = cms.InputTag( pvLabel), svSource = cms.InputTag( svLabel ), btagDiscriminators = bTagDiscriminators, genJetCollection = cms.InputTag(jetalgo+'GenJetsNoNu'), getJetMCFlavour = False, # jet flavor should always be disabled for groomed jets genParticles = cms.InputTag(genParticlesLabel) ) getattr(proc,'patJetsCMSTopTag'+PUMethod).addTagInfos = True getattr(proc,'patJetsCMSTopTag'+PUMethod).tagInfoSources = cms.VInputTag( cms.InputTag('CATopTagInfos')) setattr( proc, 'selectedPatJetsCMSTopTag'+PUMethod, selectedPatJets.clone( src = 'patJetsCMSTopTag'+PUMethod, cut = Cut ) ) addJetCollection( proc, labelName = 'CMSTopTag'+PUMethod+'Subjets', jetSource = cms.InputTag('cmsTopTagPFJets'+PUMethod, 'SubJets'), algo = jetalgo, # needed for subjet b tagging rParam = jetSize, # needed for subjet b tagging jetCorrections = subJEC if subJEC is not None else None, pfCandidates = cms.InputTag( pfCand ), pvSource = cms.InputTag( pvLabel), svSource = cms.InputTag( svLabel ), btagDiscriminators = bTagDiscriminators, genJetCollection = cms.InputTag( jetalgo+'GenJetsNoNu'), getJetMCFlavour = GetSubjetMCFlavour, explicitJTA = True, # needed for subjet b tagging svClustering = True, # needed for subjet b tagging fatJets=cms.InputTag(jetalgo+'PFJets'+PUMethod), # needed for subjet flavor clustering groomedFatJets=cms.InputTag('patJetsCMSTopTag'+PUMethod), # needed for subjet flavor clustering genParticles = cms.InputTag(genParticlesLabel) ) setattr( proc, 'selectedPatJetsCMSTopTag'+PUMethod+'Subjets', selectedPatJets.clone( src = 'patJetsCMSTopTag'+PUMethod+'Subjets', cut = Cut ) ) setattr( proc, 'patJetsCMSTopTag'+PUMethod+'Packed', cms.EDProducer("BoostedJetMerger", jetSrc=cms.InputTag('patJetsCMSTopTag'+PUMethod ), subjetSrc=cms.InputTag('patJetsCMSTopTag'+PUMethod+'Subjets') )) jetSeq += getattr(proc, 'patJetsCMSTopTag'+PUMethod+'Packed' ) elemToKeep += [ 'keep *_patJetsCMSTopTag'+PUMethod+'Packed_*_*' ] toolsUsed.append( 'patJetsCMSTopTag'+PUMethod+'Packed' ) else: print '|---- jetToolBox: CMS recommends CambridgeAachen for CMS Top Tagger, you are using '+algorithm+'. JetToolbox will not run CMS Top Tagger.' if addMassDrop : if 'CA' in jetALGO : setattr( proc, jetalgo+'PFJets'+PUMethod+'MassDropFiltered', ca15PFJetsCHSMassDropFiltered.clone( rParam = jetSize, src = cms.InputTag( jetalgo+'PFJets'+PUMethod+'Constituents', 'constituents' ), ) ) setattr( proc, jetalgo+'PFJets'+PUMethod+'MassDropFilteredMass', ak8PFJetsCHSPrunedMass.clone( src = cms.InputTag( jetalgo+'PFJets'+PUMethod), matched = cms.InputTag(jetalgo+'PFJets'+PUMethod+'MassDropFiltered'), distMax = cms.double( jetSize ) ) ) elemToKeep += [ 'keep *_'+jetalgo+'PFJets'+PUMethod+'MassDropFilteredMass_*_*' ] getattr( proc, 'patJets'+jetALGO+'PF'+PUMethod).userData.userFloats.src += [ jetalgo+'PFJets'+PUMethod+'MassDropFilteredMass' ] jetSeq += getattr(proc, jetalgo+'PFJets'+PUMethod+'MassDropFiltered' ) jetSeq += getattr(proc, jetalgo+'PFJets'+PUMethod+'MassDropFilteredMass' ) else: print '|---- jetToolBox: CMS recommends CambridgeAachen for Mass Drop, you are using '+algorithm+'. JetToolbox will not run Mass Drop.' toolsUsed.append( jetalgo+'PFJets'+PUMethod+'MassDropFilteredMass' ) if addHEPTopTagger: if ( jetSize >= 1. ) and ( 'CA' in jetALGO ): setattr( proc, 'hepTopTagPFJets'+PUMethod, hepTopTagPFJetsCHS.clone( src = cms.InputTag( jetalgo+'PFJets'+PUMethod+'Constituents', 'constituents' ) ) ) setattr( proc, 'hepTopTagPFJets'+PUMethod+'Mass'+jetALGO, ak8PFJetsCHSPrunedMass.clone( src = cms.InputTag( jetalgo+'PFJets'+PUMethod), matched = cms.InputTag("hepTopTagPFJets"+PUMethod), distMax = cms.double( jetSize ) ) ) elemToKeep += [ 'keep *_hepTopTagPFJets'+PUMethod+'Mass'+jetALGO+'_*_*' ] getattr( proc, 'patJets'+jetALGO+'PF'+PUMethod).userData.userFloats.src += [ 'hepTopTagPFJets'+PUMethod+'Mass'+jetALGO ] jetSeq += getattr(proc, 'hepTopTagPFJets'+PUMethod ) jetSeq += getattr(proc, 'hepTopTagPFJets'+PUMethod+'Mass'+jetALGO ) toolsUsed.append( 'hepTopTagPFJets'+PUMethod+'Mass'+jetALGO ) else: print '|---- jetToolBox: CMS recommends CambridgeAachen for HEPTopTagger, you are using '+algorithm+', and a jet cone size bigger than 1. JetToolbox will not run HEP TopTagger.' ####### Nsubjettiness if addNsub: from RecoJets.JetProducers.nJettinessAdder_cfi import Njettiness rangeTau = range(1,maxTau+1) setattr( proc, 'Njettiness'+jetALGO+PUMethod, Njettiness.clone( src = cms.InputTag( jetalgo+'PFJets'+PUMethod), Njets=cms.vuint32(rangeTau), # compute 1-, 2-, 3-, 4- subjettiness # variables for measure definition : measureDefinition = cms.uint32( 0 ), # CMS default is normalized measure beta = cms.double(1.0), # CMS default is 1 R0 = cms.double( jetSize ), # CMS default is jet cone size Rcutoff = cms.double( -999.0), # not used by default # variables for axes definition : axesDefinition = cms.uint32( 6 ), # CMS default is 1-pass KT axes nPass = cms.int32(-999), # not used by default akAxesR0 = cms.double(-999.0) ) ) # not used by default elemToKeep += [ 'keep *_Njettiness'+jetALGO+PUMethod+'_*_*' ] for tau in rangeTau: getattr( proc, 'patJets'+jetALGO+'PF'+PUMethod).userData.userFloats.src += ['Njettiness'+jetALGO+PUMethod+':tau'+str(tau) ] jetSeq += getattr(proc, 'Njettiness'+jetALGO+PUMethod ) toolsUsed.append( 'Njettiness'+jetALGO+PUMethod ) ###### QJetsAdder ''' if addQJets: ### there must be a better way to do this random number introduction setattr( proc, 'RandomNumberGeneratorService', cms.Service("RandomNumberGeneratorService", QJetsAdderCA8 = cms.PSet(initialSeed = cms.untracked.uint32(7)), QJetsAdderAK8 = cms.PSet(initialSeed = cms.untracked.uint32(31)), QJetsAdderCA15 = cms.PSet(initialSeed = cms.untracked.uint32(76)), ) ) from RecoJets.JetProducers.qjetsadder_cfi import QJetsAdder setattr( proc, 'QJetsAdder'+jetALGO, QJetsAdder.clone( src = cms.InputTag(jetalgo+'PFJets'+PUMethod), jetRad = cms.double( jetSize ), jetAlgo = cms.string( jetALGO[0:2] ))) elemToKeep += [ 'keep *_QJetsAdder'+jetALGO+'_*_*' ] getattr( proc, 'patJets'+jetALGO+'PF'+PUMethod).userData.userFloats.src += ['QJetsAdder'+jetALGO+':QjetsVolatility'] jetSeq += getattr(proc, 'QJetsAdder'+jetALGO ) toolsUsed.append( 'QJetsAdder'+jetALGO ) ''' ###### QGTagger if addQGTagger: if ( 'ak4' in jetalgo ) and ( PUMethod not in ['Puppi','CS','SK'] ) : from RecoJets.JetProducers.QGTagger_cfi import QGTagger proc.load('RecoJets.JetProducers.QGTagger_cfi') ## In 74X you need to run some stuff before. setattr( proc, 'QGTagger'+jetALGO+'PF'+PUMethod, QGTagger.clone( srcJets = cms.InputTag(jetalgo+'PFJets'+PUMethod), # Could be reco::PFJetCollection or pat::JetCollection (both AOD and miniAOD) jetsLabel = cms.string('QGL_AK4PF'+QGjetsLabel) # Other options (might need to add an ESSource for it): see https://twiki.cern.ch/twiki/bin/viewauth/CMS/QGDataBaseVersion ) ) elemToKeep += [ 'keep *_QGTagger'+jetALGO+'PF'+PUMethod+'_*_*' ] getattr( proc, 'patJets'+jetALGO+'PF'+PUMethod).userData.userFloats.src += ['QGTagger'+jetALGO+'PF'+PUMethod+':qgLikelihood'] jetSeq += getattr(proc, 'QGTagger'+jetALGO+'PF'+PUMethod ) toolsUsed.append( 'QGTagger'+jetALGO+'PF'+PUMethod ) else: print '|---- jetToolBox: QGTagger is optimized for ak4 jets with CHS. NOT running QGTagger' ####### Pileup JetID if addPUJetID: if ( 'ak4' in jetalgo ) and ( 'CHS' in PUMethod ): from RecoJets.JetProducers.pileupjetidproducer_cfi import pileupJetIdCalculator,pileupJetIdEvaluator setattr( proc, jetALGO+'PF'+PUMethod+'pileupJetIdCalculator', pileupJetIdCalculator.clone( jets = cms.InputTag(jetalgo+'PFJets'+PUMethod), rho = cms.InputTag("fixedGridRhoFastjetAll"), vertexes = cms.InputTag(pvLabel), applyJec = cms.bool(True), inputIsCorrected = cms.bool(False) )) setattr( proc, jetALGO+'PF'+PUMethod+'pileupJetIdEvaluator', pileupJetIdEvaluator.clone( jetids = cms.InputTag(jetALGO+'PF'+PUMethod+'pileupJetIdCalculator'), jets = cms.InputTag(jetalgo+'PFJets'+PUMethod), rho = cms.InputTag("fixedGridRhoFastjetAll"), vertexes = cms.InputTag(pvLabel) ) ) getattr( proc, 'patJets'+jetALGO+'PF'+PUMethod).userData.userFloats.src += [jetALGO+'PF'+PUMethod+'pileupJetIdEvaluator:fullDiscriminant'] getattr( proc, 'patJets'+jetALGO+'PF'+PUMethod).userData.userInts.src += [jetALGO+'PF'+PUMethod+'pileupJetIdEvaluator:cutbasedId',jetALGO+'PF'+PUMethod+'pileupJetIdEvaluator:fullId'] elemToKeep += ['keep *_'+jetALGO+'PF'+PUMethod+'pileupJetIdEvaluator_*_*'] toolsUsed.append( jetALGO+'PF'+PUMethod+'pileupJetIdEvaluator' ) else: print '|---- jetToolBox: PUJetID is optimized for ak4 PFjets with CHS. NOT running PUJetID.' ###### Energy Correlation Functions if addEnergyCorrFunc: from RecoJets.JetProducers.ECF_cfi import ECF rangeECF = range(1,maxECF+1) setattr( proc, jetalgo+'PFJets'+PUMethod+'ECF', ECF.clone( src = cms.InputTag(jetalgo+'PFJets'+PUMethod), Njets = cms.vuint32( rangeECF ), beta = cms.double( ecfBeta ) )) elemToKeep += [ 'keep *_'+jetalgo+'PFJets'+PUMethod+'ECF_*_*'] for ecf in rangeECF: getattr( proc, 'patJets'+jetALGO+'PF'+PUMethod).userData.userFloats.src += [ jetalgo+'PFJets'+PUMethod+'ECF:ecf'+str(ecf) ] jetSeq += getattr(proc, jetalgo+'PFJets'+PUMethod+'ECF' ) toolsUsed.append( jetalgo+'PFJets'+PUMethod+'ECF' ) if hasattr(proc, 'patJetPartons'): proc.patJetPartons.particles = genParticlesLabel setattr( proc, 'selectedPatJets'+jetALGO+'PF'+PUMethod, selectedPatJets.clone( src = 'patJets'+jetALGO+'PF'+PUMethod, cut = Cut ) ) elemToKeep += [ 'keep *_selectedPatJets'+jetALGO+'PF'+PUMethod+'_*_*' ] elemToKeep += [ 'drop *_selectedPatJets'+jetALGO+'PF'+PUMethod+'_calo*_*' ] elemToKeep += [ 'drop *_selectedPatJets'+jetALGO+'PF'+PUMethod+'_tagInfos_*' ] if len(toolsUsed) > 0 : print '|---- jetToolBox: Running '+', '.join(toolsUsed)+'.' print '|---- jetToolBox: Creating selectedPatJets'+jetALGO+'PF'+PUMethod+' collection.' ### "return" setattr(proc, jetSequence, jetSeq) if hasattr(proc, outputFile): getattr(proc, outputFile).outputCommands += elemToKeep else: setattr( proc, outputFile, cms.OutputModule('PoolOutputModule', fileName = cms.untracked.string('jettoolbox.root'), outputCommands = cms.untracked.vstring( elemToKeep ) ) ) if runOnData: from PhysicsTools.PatAlgos.tools.coreTools import removeMCMatching removeMCMatching(proc, names=['Jets'], outputModules=[outputFile])
################################################################################ ################## create ntuple for ECAL alignment purposes ################### #-------------------------- #Define PAT sequence #-------------------------- # Standard PAT Configuration File process.load("PhysicsTools.PatAlgos.patSequences_cff") process.patElectrons.addElectronID = cms.bool(False) # ---- remove MC references ---- from PhysicsTools.PatAlgos.tools.coreTools import removeMCMatching removeMCMatching(process, ['All'], outputModules=[], postfix="") #removeMCMatching(process, ['All']) #process.makePatElectrons.remove(process.electronMatch) #process.makePatMuons.remove(process.muonMatch) #process.patCandidates.remove(process.makePatTaus) #process.makePatTaus.remove(process.tauMatch) #process.makePatTaus.remove(process.tauGenJets) #process.makePatTaus.remove(process.tauGenJetsSelectorAllHadrons) #process.makePatTaus.remove(process.tauGenJetMatch) process.cleanPatTaus.preselection = cms.string('tauID("decayModeFinding") > 0.5 & tauID("byLooseCombinedIsolationDeltaBetaCorr3Hits") > 0.5 & tauID("againstMuonTight3") > 0.5 ')
def jetToolbox( proc, jetType, jetSequence, outputFile, updateCollection='', updateCollectionSubjets='', newPFCollection=False, nameNewPFCollection = '', PUMethod='CHS', miniAOD=True, runOnMC=True, JETCorrPayload='', JETCorrLevels = [ 'None' ], GetJetMCFlavour=True, Cut = '', postFix='', # blank means default list of discriminators, None means none bTagDiscriminators = '', bTagInfos = None, subjetBTagDiscriminators = '', subjetBTagInfos = None, subJETCorrPayload='', subJETCorrLevels = [ 'None' ], GetSubjetMCFlavour=True, CutSubjet = '', addPruning=False, zCut=0.1, rCut=0.5, addPrunedSubjets=False, addSoftDrop=False, betaCut=0.0, zCutSD=0.1, addSoftDropSubjets=False, addTrimming=False, rFiltTrim=0.2, ptFrac=0.03, addFiltering=False, rfilt=0.3, nfilt=3, addCMSTopTagger=False, addMassDrop=False, addHEPTopTagger=False, addNsub=False, maxTau=4, addNsubSubjets=False, subjetMaxTau=4, addPUJetID=False, addQGTagger=False, QGjetsLabel='chs', addEnergyCorrFunc=False, addEnergyCorrFuncSubjets=False, # set this to false to disable creation of jettoolbox.root # then you need to associate the jetTask to a Path or EndPath manually in your config associateTask=True, # 0 = no printouts, 1 = warnings only, 2 = warnings & info, 3 = warnings, info, debug verbosity=2, ): runOnData = not runOnMC if runOnData: GetJetMCFlavour = False GetSubjetMCFlavour = False ############################################################################### ####### Verifying some inputs and defining variables ############################################################################### if verbosity>=1: print('|---- jetToolbox: Initializing collection... (with postfix '+postFix+')') if newPFCollection and verbosity>=2: print('|---- jetToolBox: Using '+ nameNewPFCollection +' as PFCandidates collection') supportedJetAlgos = { 'ak': 'AntiKt', 'ca' : 'CambridgeAachen', 'kt' : 'Kt' } recommendedJetAlgos = [ 'ak4', 'ak8', 'ca4', 'ca8', 'ca10', 'ca15' ] payloadList = [ 'None', 'AK1PFchs', 'AK2PFchs', 'AK3PFchs', 'AK4PFchs', 'AK5PFchs', 'AK6PFchs', 'AK7PFchs', 'AK8PFchs', 'AK9PFchs', 'AK10PFchs', 'AK1PFPuppi', 'AK2PFPuppi', 'AK3PFPuppi', 'AK4PFPuppi', 'AK5PFPuppi', 'AK6PFPuppi', 'AK7PFPuppi', 'AK8PFPuppi', 'AK9PFPuppi', 'AK10PFPuppi', 'AK1PFSK', 'AK2PFSK', 'AK3PFSK', 'AK4PFSK', 'AK5PFSK', 'AK6PFSK', 'AK7PFSK', 'AK8PFSK', 'AK9PFSK', 'AK10PFSK', 'AK1PF', 'AK2PF', 'AK3PF', 'AK4PF', 'AK5PF', 'AK6PF', 'AK7PF', 'AK8PF', 'AK9PF', 'AK10PF' ] JECLevels = [ 'L1Offset', 'L1FastJet', 'L1JPTOffset', 'L2Relative', 'L3Absolute', 'L5Falvour', 'L7Parton' ] if runOnData: JECLevels += ['L2L3Residual'] jetAlgo = '' algorithm = '' size = '' for TYPE, tmpAlgo in supportedJetAlgos.iteritems(): if TYPE in jetType.lower(): jetAlgo = TYPE algorithm = tmpAlgo size = jetType.replace( TYPE, '' ) jetSize = 0. if int(size) in range(0, 20): jetSize = int(size)/10. else: raise ValueError('|---- jetToolBox: jetSize has not a valid value. Insert a number between 1 and 20 after algorithm, like: AK8') ### Trick for uppercase/lowercase algo name jetALGO = jetAlgo.upper()+size jetalgo = jetAlgo.lower()+size if jetalgo not in recommendedJetAlgos and verbosity>=1: print('|---- jetToolBox: CMS recommends the following jet algorithms: '+' '.join(recommendedJetAlgos)+'. You are using '+jetalgo+' .') ################################################################################# ####### Toolbox start ################################################################################# elemToKeep = [] jetSeq = cms.Sequence() genParticlesLabel = '' pvLabel = '' tvLabel = '' toolsUsed = [] mod = OrderedDict() ### List of Jet Corrections if not set(JETCorrLevels).issubset(set(JECLevels)): if ( 'CHS' in PUMethod ) or ( 'Plain' in PUMethod ): JETCorrLevels = ['L1FastJet','L2Relative', 'L3Absolute'] else: JETCorrLevels = [ 'L2Relative', 'L3Absolute'] if runOnData: JETCorrLevels.append('L2L3Residual') if not set(subJETCorrLevels).issubset(set(JECLevels)): if ( 'CHS' in PUMethod ) or ( 'Plain' in PUMethod ): subJETCorrLevels = ['L1FastJet','L2Relative', 'L3Absolute'] else: subJETCorrLevels = [ 'L2Relative', 'L3Absolute'] if runOnData: subJETCorrLevels.append('L2L3Residual') ## b-tag discriminators defaultBTagDiscriminators = [ 'pfTrackCountingHighEffBJetTags', 'pfTrackCountingHighPurBJetTags', 'pfJetProbabilityBJetTags', 'pfJetBProbabilityBJetTags', 'pfSimpleSecondaryVertexHighEffBJetTags', 'pfSimpleSecondaryVertexHighPurBJetTags', 'pfCombinedSecondaryVertexV2BJetTags', 'pfCombinedInclusiveSecondaryVertexV2BJetTags', 'pfCombinedMVAV2BJetTags' ] if bTagDiscriminators is '': bTagDiscriminators = defaultBTagDiscriminators if subjetBTagDiscriminators is '': subjetBTagDiscriminators = defaultBTagDiscriminators if updateCollection and 'Puppi' in updateCollection: PUMethod='Puppi' mod["PATJetsLabel"] = jetALGO+'PF'+PUMethod mod["PATJetsLabelPost"] = mod["PATJetsLabel"]+postFix # some substructure quantities don't include the 'PF' in the name mod["SubstructureLabel"] = jetALGO+PUMethod+postFix if not updateCollection: mod["GenJetsNoNu"] = jetalgo+'GenJetsNoNu' #### For MiniAOD if miniAOD: if verbosity>=2: print('|---- jetToolBox: JETTOOLBOX RUNNING ON MiniAOD FOR '+jetALGO+' JETS USING '+PUMethod) genParticlesLabel = 'prunedGenParticles' pvLabel = 'offlineSlimmedPrimaryVertices' svLabel = 'slimmedSecondaryVertices' tvLabel = 'unpackedTracksAndVertices' muLabel = 'slimmedMuons' elLabel = 'slimmedElectrons' pfCand = nameNewPFCollection if newPFCollection else 'packedPFCandidates' if runOnMC: ## Filter out neutrinos from packed GenParticles mod["GenParticlesNoNu"] = 'packedGenParticlesForJetsNoNu' _addProcessAndTask(proc, mod["GenParticlesNoNu"], cms.EDFilter("CandPtrSelector", src = cms.InputTag("packedGenParticles"), cut = cms.string("abs(pdgId) != 12 && abs(pdgId) != 14 && abs(pdgId) != 16") )) jetSeq += getattr(proc, mod["GenParticlesNoNu"]) _addProcessAndTask(proc, mod["GenJetsNoNu"], ak4GenJets.clone( src = mod["GenParticlesNoNu"], rParam = jetSize, jetAlgorithm = algorithm ) ) jetSeq += getattr(proc, mod["GenJetsNoNu"]) #for Inclusive Vertex Finder proc.load('PhysicsTools.PatAlgos.slimming.unpackedTracksAndVertices_cfi') #### For AOD else: if verbosity>=2: print('|---- jetToolBox: JETTOOLBOX RUNNING ON AOD FOR '+jetALGO+' JETS USING '+PUMethod) genParticlesLabel = 'genParticles' pvLabel = 'offlinePrimaryVertices' tvLabel = 'generalTracks' muLabel = 'muons' elLabel = 'gedGsfElectrons' pfCand = nameNewPFCollection if newPFCollection else 'particleFlow' svLabel = 'inclusiveCandidateSecondaryVertices' if runOnMC: proc.load('RecoJets.Configuration.GenJetParticles_cff') _addProcessAndTask(proc, mod["GenJetsNoNu"], ak4GenJets.clone(src='genParticlesForJetsNoNu', rParam=jetSize, jetAlgorithm=algorithm)) jetSeq += getattr(proc, mod["GenJetsNoNu"]) #### Creating PATjets tmpPfCandName = pfCand.lower() mod["PFJets"] = "" if 'Puppi' in PUMethod: if ('puppi' in tmpPfCandName): srcForPFJets = pfCand if verbosity>=1: print('|---- jetToolBox: Not running puppi algorithm because keyword puppi was specified in nameNewPFCollection, but applying puppi corrections.') else: proc.load('CommonTools.PileupAlgos.Puppi_cff') puppi.candName = cms.InputTag( pfCand ) if miniAOD: puppi.vertexName = cms.InputTag('offlineSlimmedPrimaryVertices') puppi.clonePackedCands = cms.bool(True) puppi.useExistingWeights = cms.bool(True) _addProcessAndTask(proc, 'puppi', getattr(proc, 'puppi')) jetSeq += getattr(proc, 'puppi' ) srcForPFJets = 'puppi' from RecoJets.JetProducers.ak4PFJets_cfi import ak4PFJetsPuppi mod["PFJets"] = jetalgo+'PFJetsPuppi'+postFix _addProcessAndTask(proc, mod["PFJets"], ak4PFJetsPuppi.clone( src = cms.InputTag( srcForPFJets ), doAreaFastjet = True, rParam = jetSize, jetAlgorithm = algorithm ) ) jetSeq += getattr(proc, mod["PFJets"]) if JETCorrPayload not in payloadList: JETCorrPayload = 'AK'+size+'PFPuppi' if subJETCorrPayload not in payloadList: subJETCorrPayload = 'AK4PFPuppi' elif 'SK' in PUMethod: if ('sk' in tmpPfCandName): srcForPFJets = pfCand if verbosity>=1: print('|---- jetToolBox: Not running softkiller algorithm because keyword SK was specified in nameNewPFCollection, but applying SK corrections.') else: proc.load('CommonTools.PileupAlgos.softKiller_cfi') getattr( proc, 'softKiller' ).PFCandidates = cms.InputTag( pfCand ) _addProcessAndTask(proc, 'softKiller', getattr(proc, 'softKiller')) jetSeq += getattr(proc, 'softKiller' ) srcForPFJets = 'softKiller' from RecoJets.JetProducers.ak4PFJetsSK_cfi import ak4PFJetsSK mod["PFJets"] = jetalgo+'PFJetsSK'+postFix _addProcessAndTask(proc, mod["PFJets"], ak4PFJetsSK.clone( src = cms.InputTag( srcForPFJets ), rParam = jetSize, jetAlgorithm = algorithm ) ) jetSeq += getattr(proc, mod["PFJets"]) if JETCorrPayload not in payloadList: JETCorrPayload = 'AK'+size+'PFSK' if subJETCorrPayload not in payloadList: subJETCorrPayload = 'AK4PFSK' elif 'CS' in PUMethod: from RecoJets.JetProducers.ak4PFJetsCHSCS_cfi import ak4PFJetsCHSCS mod["PFJets"] = jetalgo+'PFJetsCS'+postFix _addProcessAndTask(proc, mod["PFJets"], ak4PFJetsCHSCS.clone( doAreaFastjet = True, src = cms.InputTag( pfCand ), #srcForPFJets ), csRParam = cms.double(jetSize), jetAlgorithm = algorithm ) ) if miniAOD: getattr( proc, mod["PFJets"]).src = pfCand jetSeq += getattr(proc, mod["PFJets"]) if JETCorrPayload not in payloadList: JETCorrPayload = 'AK'+size+'PFCS' if subJETCorrPayload not in payloadList: subJETCorrPayload = 'AK4PFCS' elif 'CHS' in PUMethod: if miniAOD: if ('chs' in tmpPfCandName): srcForPFJets = pfCand if verbosity>=1: print('|---- jetToolBox: Not running CHS algorithm because keyword CHS was specified in nameNewPFCollection, but applying CHS corrections.') else: _addProcessAndTask(proc, 'chs', cms.EDFilter('CandPtrSelector', src=cms.InputTag(pfCand), cut=cms.string('fromPV'))) jetSeq += getattr(proc, 'chs') srcForPFJets = 'chs' else: if ( pfCand == 'particleFlow' ): from RecoParticleFlow.PFProducer.particleFlowTmpPtrs_cfi import particleFlowTmpPtrs _addProcessAndTask(proc, 'newParticleFlowTmpPtrs', particleFlowTmpPtrs.clone(src=pfCand)) jetSeq += getattr(proc, 'newParticleFlowTmpPtrs') from CommonTools.ParticleFlow.pfNoPileUpJME_cff import pfPileUpJME, pfNoPileUpJME proc.load('CommonTools.ParticleFlow.goodOfflinePrimaryVertices_cfi') _addProcessAndTask(proc, 'newPfPileUpJME', pfPileUpJME.clone(PFCandidates='newParticleFlowTmpPtrs')) jetSeq += getattr(proc, 'newPfPileUpJME') _addProcessAndTask(proc, 'newPfNoPileUpJME', pfNoPileUpJME.clone(topCollection='newPfPileUpJME', bottomCollection='newParticleFlowTmpPtrs')) jetSeq += getattr(proc, 'newPfNoPileUpJME') srcForPFJets = 'newPfNoPileUpJME' else: proc.load('CommonTools.ParticleFlow.pfNoPileUpJME_cff') srcForPFJets = 'pfNoPileUpJME' mod["PFJets"] = jetalgo+'PFJetsCHS'+postFix _addProcessAndTask(proc, mod["PFJets"], ak4PFJetsCHS.clone( src = cms.InputTag( srcForPFJets ), doAreaFastjet = True, rParam = jetSize, jetAlgorithm = algorithm ) ) jetSeq += getattr(proc, mod["PFJets"]) if JETCorrPayload not in payloadList: JETCorrPayload = 'AK'+size+'PFchs' if subJETCorrPayload not in payloadList: subJETCorrPayload = 'AK4PFchs' else: PUMethod = '' mod["PFJets"] = jetalgo+'PFJets'+postFix _addProcessAndTask(proc, mod["PFJets"], ak4PFJets.clone( doAreaFastjet = True, rParam = jetSize, jetAlgorithm = algorithm ) ) if miniAOD: getattr( proc, mod["PFJets"]).src = pfCand jetSeq += getattr(proc, mod["PFJets"]) if JETCorrPayload not in payloadList: JETCorrPayload = 'AK'+size+'PF' if subJETCorrPayload not in payloadList: subJETCorrPayload = 'AK4PF' if 'None' in JETCorrPayload: JEC = None else: JEC = ( JETCorrPayload.replace('CS','chs').replace('SK','chs') , JETCorrLevels, 'None' ) ### temporary #else: JEC = ( JETCorrPayload., JETCorrLevels, 'None' ) if verbosity>=2: print('|---- jetToolBox: Applying these corrections: '+str(JEC)) if addPrunedSubjets or addSoftDropSubjets or addCMSTopTagger: if 'None' in subJETCorrPayload: subJEC = None else: subJEC = ( subJETCorrPayload.replace('CS','chs').replace('SK','chs') , subJETCorrLevels, 'None' ) ### temporary mod["PFJetsConstituents"] = mod["PFJets"]+'Constituents' mod["PFJetsConstituentsColon"] = mod["PFJets"]+'Constituents:constituents' mod["PFJetsConstituentsColonOrUpdate"] = mod["PFJetsConstituentsColon"] if not updateCollection else updateCollection if (PUMethod in [ 'CHS', 'CS', 'Puppi' ]) and miniAOD: _addProcessAndTask(proc, mod["PFJetsConstituents"], cms.EDProducer("MiniAODJetConstituentSelector", src=cms.InputTag(mod["PFJets"]), cut=cms.string(Cut))) else: _addProcessAndTask(proc, mod["PFJetsConstituents"], cms.EDProducer("PFJetConstituentSelector", src=cms.InputTag(mod["PFJets"]), cut=cms.string(Cut))) jetSeq += getattr(proc, mod["PFJetsConstituents"]) addJetCollection( proc, labelName = mod["PATJetsLabel"], jetSource = cms.InputTag(mod["PFJets"]), postfix = postFix, algo = jetalgo, rParam = jetSize, jetCorrections = JEC if JEC is not None else None, pfCandidates = cms.InputTag( pfCand ), svSource = cms.InputTag( svLabel ), genJetCollection = cms.InputTag(mod["GenJetsNoNu"]), pvSource = cms.InputTag( pvLabel ), muSource = cms.InputTag( muLabel ), elSource = cms.InputTag( elLabel ), btagDiscriminators = bTagDiscriminators, btagInfos = bTagInfos, getJetMCFlavour = GetJetMCFlavour, genParticles = cms.InputTag(genParticlesLabel), outputModules = ['outputFile'] ) patJets = 'patJets' patSubJets = '' selPatJets = 'selectedPatJets' mod["PATJets"] = patJets+mod["PATJetsLabelPost"] mod["selPATJets"] = selPatJets+mod["PATJetsLabelPost"] getattr(proc, mod["PATJets"]).addTagInfos = cms.bool(True) if 'CS' in PUMethod: getattr( proc, mod["PATJets"] ).getJetMCFlavour = False # CS jets cannot be re-clustered from their constituents else: if verbosity>=2: print('|---- jetToolBox: JETTOOLBOX IS UPDATING '+updateCollection+' collection') genParticlesLabel = 'prunedGenParticles' pvLabel = 'offlineSlimmedPrimaryVertices' svLabel = 'slimmedSecondaryVertices' tvLabel = 'unpackedTracksAndVertices' muLabel = 'slimmedMuons' elLabel = 'slimmedElectrons' if not JETCorrPayload: raise ValueError('|---- jetToolBox: updateCollection option requires to add JETCorrPayload.') JEC = ( JETCorrPayload, JETCorrLevels, 'None' ) ### temporary if verbosity>=2: print('|---- jetToolBox: Applying these corrections: '+str(JEC)) updateJetCollection( proc, postfix = postFix, jetSource = cms.InputTag( updateCollection ), labelName = mod["PATJetsLabel"], jetCorrections = JEC, btagDiscriminators = bTagDiscriminators, ) mod["PATJetsCorrFactors"] = 'patJetCorrFactors'+mod["PATJetsLabelPost"] getattr( proc, mod["PATJetsCorrFactors"] ).payload = JETCorrPayload getattr( proc, mod["PATJetsCorrFactors"] ).levels = JETCorrLevels patJets = 'updatedPatJets' patSubJets = '' selPatJets = 'selectedPatJets' mod["PATJets"] = patJets+mod["PATJetsLabelPost"] mod["selPATJets"] = selPatJets+mod["PATJetsLabelPost"] if updateCollectionSubjets: if verbosity>=2: print('|---- jetToolBox: JETTOOLBOX IS UPDATING '+updateCollectionSubjets+' collection for subjets/groomers.') if 'SoftDrop' in updateCollectionSubjets: updateSubjetLabel = 'SoftDrop' else: updateSubjetLabel = 'Pruned' mod["PATSubjetsLabel"] = jetALGO+'PF'+PUMethod+postFix+updateSubjetLabel+'Packed' updateJetCollection( proc, jetSource = cms.InputTag( updateCollectionSubjets ), labelName = mod["PATSubjetsLabel"], jetCorrections = JEC, explicitJTA = True, fatJets = cms.InputTag( updateCollection ), rParam = jetSize, algo = jetALGO, btagDiscriminators = subjetBTagDiscriminators, ) mod["PATSubjetsCorrFactors"] = 'patJetCorrFactors'+mod["PATSubjetsLabel"] getattr( proc, mod["PATSubjetsCorrFactors"] ).payload = subJETCorrPayload getattr( proc, mod["PATSubjetsCorrFactors"] ).levels = subJETCorrLevels patSubJets = 'updatedPatJets'+mod["PATSubjetsLabel"] if addPrunedSubjets or addSoftDropSubjets or addCMSTopTagger or addMassDrop or addHEPTopTagger or addPruning or addSoftDrop: if verbosity>=1: print('|---- jetToolBox: You are trying to add a groomer variable into a clustered jet collection. THIS IS NOT RECOMMENDED, it is recommended to recluster jets instead using a plain jetToolbox configuration. Please use this feature at your own risk.') mod["PFJetsOrUpdate"] = mod["PFJets"] if not updateCollection else updateCollection if bTagDiscriminators and verbosity>=2: print('|---- jetToolBox: Adding these btag discriminators: '+str(bTagDiscriminators)+' in the jet collection.') if ( (addPrunedSubjets or addSoftDropSubjets) or (updateCollection and updateCollectionSubjets) ) and subjetBTagDiscriminators and verbosity>=2: print('|---- jetToolBox: Adding these btag discriminators: '+str(subjetBTagDiscriminators)+' in the subjet collection.') #### Groomers if addSoftDrop or addSoftDropSubjets: mod["PFJetsSoftDrop"] = mod["PFJets"]+'SoftDrop' mod["SoftDropMass"] = mod["PFJets"]+'SoftDropMass' _addProcessAndTask(proc, mod["PFJetsSoftDrop"], ak8PFJetsCHSSoftDrop.clone( src = cms.InputTag( mod["PFJetsConstituentsColonOrUpdate"] ), rParam = jetSize, jetAlgorithm = algorithm, useExplicitGhosts=True, R0= cms.double(jetSize), zcut=zCutSD, beta=betaCut, doAreaFastjet = cms.bool(True), writeCompound = cms.bool(True), jetCollInstanceName=cms.string('SubJets') ) ) _addProcessAndTask(proc, mod["SoftDropMass"], ak8PFJetsCHSSoftDropMass.clone( src = cms.InputTag( mod["PFJetsOrUpdate"] ), matched = cms.InputTag( mod["PFJetsSoftDrop"] ), distMax = cms.double( jetSize ) ) ) elemToKeep += [ 'keep *_'+mod["SoftDropMass"]+'_*_*'] jetSeq += getattr(proc, mod["PFJetsSoftDrop"] ) jetSeq += getattr(proc, mod["SoftDropMass"] ) getattr( proc, mod["PATJets"]).userData.userFloats.src += [ mod["SoftDropMass"] ] toolsUsed.append( mod["SoftDropMass"] ) if addSoftDropSubjets: mod["GenJetsNoNuSoftDrop"] = mod["GenJetsNoNu"]+'SoftDrop' if runOnMC: _addProcessAndTask(proc, mod["GenJetsNoNuSoftDrop"], ak4GenJets.clone( SubJetParameters, useSoftDrop = cms.bool(True), rParam = jetSize, jetAlgorithm = algorithm, useExplicitGhosts=cms.bool(True), #zcut=cms.double(zCutSD), R0= cms.double(jetSize), beta=cms.double(betaCut), writeCompound = cms.bool(True), jetCollInstanceName=cms.string('SubJets') )) if miniAOD: getattr( proc, mod["GenJetsNoNuSoftDrop"] ).src = mod["GenParticlesNoNu"] jetSeq += getattr(proc, mod["GenJetsNoNuSoftDrop"] ) mod["PATJetsSoftDropLabel"] = mod["PATJetsLabelPost"]+'SoftDrop' addJetCollection( proc, labelName = mod["PATJetsSoftDropLabel"], jetSource = cms.InputTag( mod["PFJetsSoftDrop"]), algo = jetalgo, rParam = jetSize, jetCorrections = JEC if JEC is not None else None, pvSource = cms.InputTag( pvLabel ), btagDiscriminators = ['None'], genJetCollection = cms.InputTag( mod["GenJetsNoNu"]), getJetMCFlavour = False, # jet flavor should always be disabled for groomed jets genParticles = cms.InputTag(genParticlesLabel), outputModules = ['outputFile'] ) mod["PATJetsSoftDrop"] = patJets+mod["PATJetsSoftDropLabel"] mod["selPATJetsSoftDrop"] = selPatJets+mod["PATJetsSoftDropLabel"] _addProcessAndTask(proc, mod["selPATJetsSoftDrop"], selectedPatJets.clone(src=mod["PATJetsSoftDrop"], cut=Cut)) mod["PATSubjetsSoftDropLabel"] = mod["PATJetsSoftDropLabel"]+'Subjets' addJetCollection( proc, labelName = mod["PATSubjetsSoftDropLabel"], jetSource = cms.InputTag( mod["PFJetsSoftDrop"], 'SubJets'), algo = jetalgo, # needed for subjet b tagging rParam = jetSize, # needed for subjet b tagging jetCorrections = subJEC if subJEC is not None else None, pfCandidates = cms.InputTag( pfCand ), pvSource = cms.InputTag( pvLabel), svSource = cms.InputTag( svLabel ), muSource = cms.InputTag( muLabel ), elSource = cms.InputTag( elLabel ), btagDiscriminators = subjetBTagDiscriminators, btagInfos = bTagInfos, genJetCollection = cms.InputTag( mod["GenJetsNoNuSoftDrop"],'SubJets'), getJetMCFlavour = GetSubjetMCFlavour, genParticles = cms.InputTag(genParticlesLabel), explicitJTA = True, # needed for subjet b tagging svClustering = True, # needed for subjet b tagging fatJets=cms.InputTag(mod["PFJets"]), # needed for subjet flavor clustering groomedFatJets=cms.InputTag(mod["PFJetsSoftDrop"]), # needed for subjet flavor clustering outputModules = ['outputFile'] ) mod["PATSubjetsSoftDrop"] = patJets+mod["PATSubjetsSoftDropLabel"] mod["selPATSubjetsSoftDrop"] = selPatJets+mod["PATSubjetsSoftDropLabel"] _addProcessAndTask(proc, mod["selPATSubjetsSoftDrop"], selectedPatJets.clone(src=mod["PATSubjetsSoftDrop"], cut=CutSubjet)) # Establish references between PATified fat jets and subjets using the BoostedJetMerger mod["selPATJetsSoftDropPacked"] = mod["selPATJetsSoftDrop"]+'Packed' _addProcessAndTask(proc, mod["selPATJetsSoftDropPacked"], cms.EDProducer("BoostedJetMerger", jetSrc=cms.InputTag(mod["selPATJetsSoftDrop"]), subjetSrc=cms.InputTag(mod["selPATSubjetsSoftDrop"]) )) jetSeq += getattr(proc, mod["selPATJetsSoftDropPacked"] ) elemToKeep += [ 'keep *_'+mod["selPATJetsSoftDropPacked"]+'_SubJets_*' ] toolsUsed.append( mod["selPATJetsSoftDropPacked"]+':SubJets' ) ## Pack fat jets with subjets mod["packedPATJetsSoftDrop"] = 'packedPatJets'+mod["PATJetsSoftDropLabel"] _addProcessAndTask(proc, mod["packedPATJetsSoftDrop"], cms.EDProducer("JetSubstructurePacker", jetSrc=cms.InputTag(mod["selPATJets"]), distMax = cms.double( jetSize ), fixDaughters = cms.bool(False), algoTags = cms.VInputTag( cms.InputTag(mod["selPATJetsSoftDropPacked"]) ), algoLabels =cms.vstring('SoftDrop') ) ) jetSeq += getattr(proc, mod["packedPATJetsSoftDrop"]) elemToKeep += [ 'keep *_'+mod["packedPATJetsSoftDrop"]+'_*_*' ] if verbosity>=2: print('|---- jetToolBox: Creating '+mod["packedPATJetsSoftDrop"]+' collection with SoftDrop subjets.') if addPruning or addPrunedSubjets: mod["PFJetsPruned"] = mod["PFJets"]+'Pruned' mod["PrunedMass"] = mod["PFJets"]+'PrunedMass' _addProcessAndTask(proc, mod["PFJetsPruned"], ak8PFJetsCHSPruned.clone( src = cms.InputTag( mod["PFJetsConstituentsColonOrUpdate"] ), rParam = jetSize, jetAlgorithm = algorithm, zcut=zCut, rcut_factor=rCut, writeCompound = cms.bool(True), doAreaFastjet = cms.bool(True), jetCollInstanceName=cms.string('SubJets') ) ) _addProcessAndTask(proc, mod["PrunedMass"], ak8PFJetsCHSPrunedMass.clone( src = cms.InputTag( mod["PFJetsOrUpdate"] ), matched = cms.InputTag( mod["PFJetsPruned"]), distMax = cms.double( jetSize ) ) ) jetSeq += getattr(proc, mod["PFJetsPruned"]) jetSeq += getattr(proc, mod["PrunedMass"]) getattr( proc, mod["PATJets"]).userData.userFloats.src += [ mod["PrunedMass"] ] elemToKeep += [ 'keep *_'+mod["PrunedMass"]+'_*_*'] toolsUsed.append( mod["PrunedMass"] ) if addPrunedSubjets: if runOnMC: mod["GenJetsNoNuPruned"] = mod["GenJetsNoNu"]+'Pruned' _addProcessAndTask(proc, mod["GenJetsNoNuPruned"], ak4GenJets.clone( SubJetParameters, rParam = jetSize, usePruning = cms.bool(True), writeCompound = cms.bool(True), jetCollInstanceName=cms.string('SubJets') )) if miniAOD: getattr( proc, mod["GenJetsNoNuPruned"] ).src = mod["GenParticlesNoNu"] jetSeq += getattr(proc, mod["GenJetsNoNuPruned"]) mod["PATJetsPrunedLabel"] = mod["PATJetsLabelPost"]+'Pruned' addJetCollection( proc, labelName = mod["PATJetsPrunedLabel"], jetSource = cms.InputTag( mod["PFJetsPruned"]), algo = jetalgo, rParam = jetSize, jetCorrections = JEC if JEC is not None else None, pvSource = cms.InputTag( pvLabel ), btagDiscriminators = ['None'], genJetCollection = cms.InputTag( mod["GenJetsNoNu"]), getJetMCFlavour = False, # jet flavor should always be disabled for groomed jets genParticles = cms.InputTag(genParticlesLabel), outputModules = ['outputFile'] ) mod["PATJetsPruned"] = patJets+mod["PATJetsPrunedLabel"] mod["selPATJetsPruned"] = selPatJets+mod["PATJetsPrunedLabel"] _addProcessAndTask(proc, mod["selPATJetsPruned"], selectedPatJets.clone(src=mod["PATJetsPruned"], cut=Cut)) mod["PATSubjetsPrunedLabel"] = mod["PATJetsPrunedLabel"]+'Subjets' addJetCollection( proc, labelName = mod["PATSubjetsPrunedLabel"], jetSource = cms.InputTag( mod["PFJetsPruned"], 'SubJets'), algo = jetalgo, # needed for subjet b tagging rParam = jetSize, # needed for subjet b tagging jetCorrections = subJEC if subJEC is not None else None, pfCandidates = cms.InputTag( pfCand ), pvSource = cms.InputTag( pvLabel), svSource = cms.InputTag( svLabel ), muSource = cms.InputTag( muLabel ), elSource = cms.InputTag( elLabel ), getJetMCFlavour = GetSubjetMCFlavour, genParticles = cms.InputTag(genParticlesLabel), btagDiscriminators = subjetBTagDiscriminators, btagInfos = bTagInfos, genJetCollection = cms.InputTag( mod["GenJetsNoNuPruned"],'SubJets'), explicitJTA = True, # needed for subjet b tagging svClustering = True, # needed for subjet b tagging fatJets=cms.InputTag(mod["PFJets"]), # needed for subjet flavor clustering groomedFatJets=cms.InputTag(mod["PFJetsPruned"]), # needed for subjet flavor clustering outputModules = ['outputFile'] ) mod["PATSubjetsPruned"] = patJets+mod["PATSubjetsPrunedLabel"] mod["selPATSubjetsPruned"] = selPatJets+mod["PATSubjetsPrunedLabel"] _addProcessAndTask(proc, mod["selPATSubjetsPruned"], selectedPatJets.clone(src=mod["PATSubjetsPruned"], cut=CutSubjet)) ## Establish references between PATified fat jets and subjets using the BoostedJetMerger mod["selPATJetsPrunedPacked"] = mod["selPATJetsPruned"]+'Packed' _addProcessAndTask(proc, mod["selPATJetsPrunedPacked"], cms.EDProducer("BoostedJetMerger", jetSrc=cms.InputTag(mod["selPATJetsPruned"]), subjetSrc=cms.InputTag(mod["selPATSubjetsPruned"]), )) jetSeq += getattr(proc, mod["selPATJetsPrunedPacked"]) elemToKeep += [ 'keep *_'+mod["selPATJetsPrunedPacked"]+'_SubJets_*' ] toolsUsed.append( mod["selPATJetsPrunedPacked"]+':SubJets' ) ## Pack fat jets with subjets mod["packedPATJetsPruned"] = 'packedPatJets'+mod["PATSubjetsPrunedLabel"] _addProcessAndTask(proc, mod["packedPATJetsPruned"], cms.EDProducer("JetSubstructurePacker", jetSrc=cms.InputTag(mod["selPATJets"]), distMax = cms.double( jetSize ), fixDaughters = cms.bool(False), algoTags = cms.VInputTag( cms.InputTag(mod["selPATJetsPrunedPacked"]) ), algoLabels =cms.vstring('Pruned') ) ) jetSeq += getattr(proc, mod["packedPATJetsPruned"]) elemToKeep += [ 'keep *_'+mod["packedPATJetsPruned"]+'_*_*' ] if verbosity>=2: print('|---- jetToolBox: Creating '+mod["packedPATJetsPruned"]+' collection with Pruned subjets.') if addTrimming: mod["PFJetsTrimmed"] = mod["PFJets"]+'Trimmed' mod["TrimmedMass"] = mod["PFJets"]+'TrimmedMass' _addProcessAndTask(proc, mod["PFJetsTrimmed"], ak8PFJetsCHSTrimmed.clone( rParam = jetSize, src = cms.InputTag( mod["PFJetsConstituentsColonOrUpdate"] ), jetAlgorithm = algorithm, rFilt= rFiltTrim, trimPtFracMin= ptFrac) ) _addProcessAndTask(proc, mod["TrimmedMass"], ak8PFJetsCHSTrimmedMass.clone( src = cms.InputTag( mod["PFJetsOrUpdate"] ), matched = cms.InputTag( mod["PFJetsTrimmed"]), distMax = cms.double( jetSize ) ) ) elemToKeep += [ 'keep *_'+mod["TrimmedMass"]+'_*_*'] jetSeq += getattr(proc, mod["PFJetsTrimmed"]) jetSeq += getattr(proc, mod["TrimmedMass"]) getattr( proc, mod["PATJets"]).userData.userFloats.src += [mod["TrimmedMass"]] toolsUsed.append( mod["TrimmedMass"] ) if addFiltering: mod["PFJetsFiltered"] = mod["PFJets"]+'Filtered' mod["FilteredMass"] = mod["PFJets"]+'FilteredMass' _addProcessAndTask(proc, mod["PFJetsFiltered"], ak8PFJetsCHSFiltered.clone( src = cms.InputTag( mod["PFJetsConstituentsColonOrUpdate"] ), rParam = jetSize, jetAlgorithm = algorithm, rFilt= rfilt, nFilt= nfilt ) ) _addProcessAndTask(proc, mod["FilteredMass"], ak8PFJetsCHSFilteredMass.clone( src = cms.InputTag( mod["PFJetsOrUpdate"] ), matched = cms.InputTag( mod["PFJetsFiltered"]), distMax = cms.double( jetSize ) ) ) elemToKeep += [ 'keep *_'+mod["FilteredMass"]+'_*_*'] jetSeq += getattr(proc, mod["PFJetsFiltered"]) jetSeq += getattr(proc, mod["FilteredMass"]) getattr( proc, patJets+jetALGO+'PF'+PUMethod+postFix).userData.userFloats.src += [mod["FilteredMass"]] toolsUsed.append( mod["FilteredMass"] ) if addCMSTopTagger : if 'CA' in jetALGO : mod["PFJetsCMSTopTag"] = mod["PFJets"].replace(jetalgo,"cmsTopTag") _addProcessAndTask(proc, mod["PFJetsCMSTopTag"], cms.EDProducer("CATopJetProducer", PFJetParameters.clone( src = cms.InputTag( mod["PFJetsConstituentsColonOrUpdate"] ), doAreaFastjet = cms.bool(True), doRhoFastjet = cms.bool(False), jetPtMin = cms.double(100.0) ), AnomalousCellParameters, CATopJetParameters.clone( jetCollInstanceName = cms.string("SubJets"), verbose = cms.bool(False), algorithm = cms.int32(1), # 0 = KT, 1 = CA, 2 = anti-KT tagAlgo = cms.int32(0), #0=legacy top useAdjacency = cms.int32(2), # modified adjacency centralEtaCut = cms.double(2.5), # eta for defining "central" jets sumEtBins = cms.vdouble(0,1600,2600), # sumEt bins over which cuts vary. vector={bin 0 lower bound, bin 1 lower bound, ...} rBins = cms.vdouble(0.8,0.8,0.8), # Jet distance paramter R. R values depend on sumEt bins. ptFracBins = cms.vdouble(0.05,0.05,0.05), # minimum fraction of central jet pt for subjets (deltap) deltarBins = cms.vdouble(0.19,0.19,0.19), # Applicable only if useAdjacency=1. deltar adjacency values for each sumEtBin nCellBins = cms.vdouble(1.9,1.9,1.9), ), jetAlgorithm = cms.string("CambridgeAachen"), rParam = cms.double(jetSize), writeCompound = cms.bool(True) ) ) mod["CATopTagInfos"] = "CATopTagInfos"+postFix _addProcessAndTask(proc, mod["CATopTagInfos"], cms.EDProducer("CATopJetTagger", src = cms.InputTag(mod["PFJetsCMSTopTag"]), TopMass = cms.double(171), TopMassMin = cms.double(0.), TopMassMax = cms.double(250.), WMass = cms.double(80.4), WMassMin = cms.double(0.0), WMassMax = cms.double(200.0), MinMassMin = cms.double(0.0), MinMassMax = cms.double(200.0), verbose = cms.bool(False) ) ) mod["PATJetsCMSTopTagLabel"] = 'CMSTopTag'+PUMethod+postFix addJetCollection( proc, labelName = mod["PATJetsCMSTopTagLabel"], jetSource = cms.InputTag(mod["PFJetsCMSTopTag"]), jetCorrections = JEC if JEC is not None else None, pfCandidates = cms.InputTag( pfCand ), pvSource = cms.InputTag( pvLabel), svSource = cms.InputTag( svLabel ), muSource = cms.InputTag( muLabel ), elSource = cms.InputTag( elLabel ), btagDiscriminators = bTagDiscriminators, btagInfos = bTagInfos, genJetCollection = cms.InputTag(mod["GenJetsNoNu"]), getJetMCFlavour = False, # jet flavor should always be disabled for groomed jets genParticles = cms.InputTag(genParticlesLabel) ) mod["PATJetsCMSTopTag"] = patJets+mod["PATJetsCMSTopTagLabel"] mod["selPATJetsCMSTopTag"] = selPatJets+mod["PATJetsCMSTopTagLabel"] getattr(proc,mod["PATJetsCMSTopTag"]).addTagInfos = True getattr(proc,mod["PATJetsCMSTopTag"]).tagInfoSources = cms.VInputTag( cms.InputTag(mod["CATopTagInfos"])) _addProcessAndTask(proc, mod["selPATJetsCMSTopTag"], selectedPatJets.clone(src=mod["PATJetsCMSTopTag"], cut=Cut)) mod["PATSubjetsCMSTopTagLabel"] = mod["PATJetsCMSTopTagLabel"]+'Subjets' addJetCollection( proc, labelName = mod["PATSubjetsCMSTopTagLabel"], jetSource = cms.InputTag(mod["PFJetsCMSTopTag"], 'SubJets'), algo = jetalgo, # needed for subjet b tagging rParam = jetSize, # needed for subjet b tagging jetCorrections = subJEC if subJEC is not None else None, pfCandidates = cms.InputTag( pfCand ), pvSource = cms.InputTag( pvLabel), svSource = cms.InputTag( svLabel ), muSource = cms.InputTag( muLabel ), elSource = cms.InputTag( elLabel ), btagDiscriminators = bTagDiscriminators, btagInfos = bTagInfos, genJetCollection = cms.InputTag( mod["GenJetsNoNu"]), getJetMCFlavour = GetSubjetMCFlavour, explicitJTA = True, # needed for subjet b tagging svClustering = True, # needed for subjet b tagging fatJets=cms.InputTag(mod["PFJets"]), # needed for subjet flavor clustering groomedFatJets=cms.InputTag(mod["PATJetsCMSTopTag"]), # needed for subjet flavor clustering genParticles = cms.InputTag(genParticlesLabel) ) mod["PATSubjetsCMSTopTag"] = patJets+mod["PATSubjetsCMSTopTagLabel"] mod["selPATSubjetsCMSTopTag"] = selPatJets+mod["PATSubjetsCMSTopTagLabel"] _addProcessAndTask(proc, mod["selPATSubjetsCMSTopTag"], selectedPatJets.clone(src=mod["PATSubjetsCMSTopTag"], cut=Cut)) mod["PATJetsCMSTopTagPacked"] = mod["PATJetsCMSTopTag"]+'Packed' _addProcessAndTask(proc, mod["PATJetsCMSTopTagPacked"], cms.EDProducer("BoostedJetMerger", jetSrc=cms.InputTag(mod["PATJetsCMSTopTag"]), subjetSrc=cms.InputTag(mod["PATSubjetsCMSTopTag"]) )) jetSeq += getattr(proc, mod["PATJetsCMSTopTagPacked"]) elemToKeep += [ 'keep *_'+mod["PATJetsCMSTopTagPacked"]+'_*_*' ] toolsUsed.append( mod["PATJetsCMSTopTagPacked"] ) else: raise ValueError('|---- jetToolBox: CMS recommends CambridgeAachen for CMS Top Tagger, you are using '+algorithm+'. JetToolbox will not run CMS Top Tagger.') if addMassDrop : if 'CA' in jetALGO : mod["PFJetsMassDrop"] = mod["PFJets"]+'MassDropFiltered' mod["MassDropFilteredMass"] = mod["PFJetsMassDrop"]+'Mass' _addProcessAndTask(proc, mod["PFJetsMassDrop"], ca15PFJetsCHSMassDropFiltered.clone( rParam = jetSize, src = cms.InputTag( mod["PFJetsConstituentsColonOrUpdate"] ), ) ) _addProcessAndTask(proc, mod["MassDropFilteredMass"], ak8PFJetsCHSPrunedMass.clone(src=cms.InputTag(mod["PFJets"]), matched = cms.InputTag(mod["PFJetsMassDrop"]), distMax = cms.double( jetSize ) ) ) elemToKeep += [ 'keep *_'+mod["MassDropFilteredMass"]+'_*_*' ] getattr( proc, mod["PATJets"]).userData.userFloats.src += [ mod["MassDropFilteredMass"] ] jetSeq += getattr(proc, mod["PFJetsMassDrop"]) jetSeq += getattr(proc, mod["MassDropFilteredMass"]) toolsUsed.append( mod["MassDropFilteredMass"] ) else: raise ValueError('|---- jetToolBox: CMS recommends CambridgeAachen for Mass Drop, you are using '+algorithm+'. JetToolbox will not run Mass Drop.') if addHEPTopTagger: if ( jetSize >= 1. ) and ( 'CA' in jetALGO ): mod["PFJetsHEPTopTag"] = mod["PFJets"].replace(jetalgo,"hepTopTag") mod["PFJetsHEPTopTagMass"] = mod["PFJetsHEPTopTag"]+'Mass'+jetALGO _addProcessAndTask(proc, mod["PFJetsHEPTopTag"], hepTopTagPFJetsCHS.clone(src=cms.InputTag(mod["PFJetsConstituentsColonOrUpdate"]))) _addProcessAndTask(proc, mod["PFJetsHEPTopTagMass"], ak8PFJetsCHSPrunedMass.clone(src=cms.InputTag(mod["PFJets"]), matched = cms.InputTag(mod["PFJetsHEPTopTag"]), distMax = cms.double( jetSize ) ) ) elemToKeep += [ 'keep *_'+mod["PFJetsHEPTopTagMass"]+'_*_*' ] getattr( proc, mod["PATJets"]).userData.userFloats.src += [ mod["PFJetsHEPTopTagMass"] ] jetSeq += getattr(proc, mod["PFJetsHEPTopTag"]) jetSeq += getattr(proc, mod["PFJetsHEPTopTagMass"]) toolsUsed.append( mod["PFJetsHEPTopTagMass"] ) else: raise ValueError('|---- jetToolBox: CMS recommends CambridgeAachen w/ jet cone size > 1.0 for HEPTopTagger, you are using '+algorithm+'. JetToolbox will not run HEP TopTagger.') ####### Nsubjettiness if addNsub: from RecoJets.JetProducers.nJettinessAdder_cfi import Njettiness rangeTau = range(1,maxTau+1) mod["Njettiness"] = 'Njettiness'+mod["SubstructureLabel"] _addProcessAndTask(proc, mod["Njettiness"], Njettiness.clone( src = cms.InputTag( mod["PFJetsOrUpdate"] ), Njets=cms.vuint32(rangeTau), # compute 1-, 2-, 3-, 4- subjettiness # variables for measure definition : measureDefinition = cms.uint32( 0 ), # CMS default is normalized measure beta = cms.double(1.0), # CMS default is 1 R0 = cms.double( jetSize ), # CMS default is jet cone size Rcutoff = cms.double( 999.0), # not used by default # variables for axes definition : axesDefinition = cms.uint32( 6 ), # CMS default is 1-pass KT axes nPass = cms.int32(999), # not used by default akAxesR0 = cms.double(-999.0) ) ) # not used by default elemToKeep += [ 'keep *_'+mod["Njettiness"]+'_*_*' ] for tau in rangeTau: getattr( proc, mod["PATJets"]).userData.userFloats.src += [mod["Njettiness"]+':tau'+str(tau) ] jetSeq += getattr(proc, mod["Njettiness"]) toolsUsed.append( mod["Njettiness"] ) ####### Nsubjettiness if addNsubSubjets: from RecoJets.JetProducers.nJettinessAdder_cfi import Njettiness mod["NsubGroomer"] = '' mod["NsubSubjets"] = '' mod["NsubPATSubjets"] = '' if addSoftDropSubjets or updateCollectionSubjets: mod["NsubGroomer"] = mod["PFJetsSoftDrop"] mod["NsubSubjets"] = mod["PATSubjetsSoftDropLabel"] mod["NsubPATSubjets"] = mod["PATSubjetsSoftDrop"] if updateCollectionSubjets: if verbosity>=2: print('|---- jetToolBox: Using updateCollection option. ASSUMING MINIAOD collection '+ updateCollectionSubjets +' for Nsubjettiness of subjets.') elif addPrunedSubjets: mod["NsubGroomer"] = mod["PFJetsPruned"] mod["NsubSubjets"] = mod["PATSubjetsPrunedLabel"] mod["NsubPATSubjets"] = mod["PATSubjetsPruned"] else: raise ValueError('|---- jetToolBox: Nsubjettiness of subjets needs a Subjet collection. Or create one using addSoftDropSubjets option, or updateCollection.') mod["Nsubjettiness"] = 'Nsubjettiness'+mod["NsubSubjets"] rangeTau = range(1,subjetMaxTau+1) _addProcessAndTask(proc, mod["Nsubjettiness"], Njettiness.clone( src = cms.InputTag( ( mod["NsubGroomer"] if not updateCollectionSubjets else updateCollectionSubjets ), 'SubJets' ), Njets=cms.vuint32(rangeTau), # compute 1-, 2-, 3-, 4- subjettiness # variables for measure definition : measureDefinition = cms.uint32( 0 ), # CMS default is normalized measure beta = cms.double(1.0), # CMS default is 1 R0 = cms.double( jetSize ), # CMS default is jet cone size Rcutoff = cms.double( 999.0), # not used by default # variables for axes definition : axesDefinition = cms.uint32( 6 ), # CMS default is 1-pass KT axes nPass = cms.int32(999), # not used by default akAxesR0 = cms.double(-999.0) ) ) # not used by default elemToKeep += [ 'keep *_'+mod["Nsubjettiness"]+'_*_*' ] for tau in rangeTau: getattr( proc, ( mod["NsubPATSubjets"] if not updateCollectionSubjets else patSubJets ) ).userData.userFloats.src += [mod["Nsubjettiness"]+':tau'+str(tau) ] jetSeq += getattr(proc, mod["Nsubjettiness"]) toolsUsed.append( mod["Nsubjettiness"] ) ###### QGTagger if addQGTagger: if ( 'ak4' in jetalgo ) and ( PUMethod not in ['Puppi','CS','SK'] ) : from RecoJets.JetProducers.QGTagger_cfi import QGTagger proc.load('RecoJets.JetProducers.QGTagger_cfi') ## In 74X you need to run some stuff before. mod["QGTagger"] = 'QGTagger'+mod["PATJetsLabelPost"] _addProcessAndTask(proc, mod["QGTagger"], QGTagger.clone( srcJets = cms.InputTag( mod["PFJetsOrUpdate"] ), # Could be reco::PFJetCollection or pat::JetCollection (both AOD and miniAOD) jetsLabel = cms.string('QGL_AK4PF'+QGjetsLabel) # Other options (might need to add an ESSource for it): see https://twiki.cern.ch/twiki/bin/viewauth/CMS/QGDataBaseVersion ) ) elemToKeep += [ 'keep *_'+mod["QGTagger"]+'_*_*' ] getattr( proc, mod["PATJets"]).userData.userFloats.src += [mod["QGTagger"]+':qgLikelihood'] jetSeq += getattr(proc, mod["QGTagger"]) toolsUsed.append( mod["QGTagger"] ) else: raise ValueError('|---- jetToolBox: QGTagger is optimized for ak4 jets with CHS. NOT running QGTagger') ####### Pileup JetID if addPUJetID: if ( 'ak4' in jetalgo ) and ( PUMethod not in ['CS','SK'] ): if PUMethod=="Puppi" and verbosity>=1: print('|---- jetToolBox: PUJetID is not yet optimized for ak4 PFjets with PUPPI. USE ONLY FOR TESTING.') from RecoJets.JetProducers.pileupjetidproducer_cfi import pileupJetIdCalculator,pileupJetIdEvaluator mod["PUJetIDCalc"] = mod["PATJetsLabelPost"]+'pileupJetIdCalculator' _addProcessAndTask(proc, mod["PUJetIDCalc"], pileupJetIdCalculator.clone( jets = cms.InputTag( mod["PFJetsOrUpdate"] ), rho = cms.InputTag("fixedGridRhoFastjetAll"), vertexes = cms.InputTag(pvLabel), applyJec = cms.bool(True), inputIsCorrected = cms.bool(False) )) mod["PUJetIDEval"] = mod["PATJetsLabelPost"]+'pileupJetIdEvaluator' _addProcessAndTask(proc, mod["PUJetIDEval"], pileupJetIdEvaluator.clone( jetids = cms.InputTag(mod["PUJetIDCalc"]), jets = cms.InputTag( mod["PFJetsOrUpdate"] ), rho = cms.InputTag("fixedGridRhoFastjetAll"), vertexes = cms.InputTag(pvLabel) ) ) getattr( proc, mod["PATJets"]).userData.userFloats.src += [mod["PUJetIDEval"]+':fullDiscriminant'] getattr( proc, mod["PATJets"]).userData.userInts.src += [mod["PUJetIDEval"]+':cutbasedId',mod["PUJetIDEval"]+':fullId'] elemToKeep += ['keep *_'+mod["PUJetIDEval"]+'_*_*'] toolsUsed.append( mod["PUJetIDEval"] ) else: raise ValueError('|---- jetToolBox: PUJetID is optimized for ak4 PFjets with CHS. NOT running PUJetID.') ###### Energy Correlation Functions if addEnergyCorrFunc: if PUMethod!="Puppi" or (addSoftDrop==False and addSoftDropSubjets==False): raise ValueError("|---- jetToolBox: addEnergyCorrFunc only supported for Puppi w/ addSoftDrop or addSoftDropSubjets") from RecoJets.JetProducers.ECF_cff import ecfNbeta1, ecfNbeta2 mod["ECFnb1"] = 'nb1'+mod["SubstructureLabel"]+'SoftDrop' # mod["ECFnb2"] = 'nb2'+mod["SubstructureLabel"]+'SoftDrop' _addProcessAndTask(proc, mod["ECFnb1"], ecfNbeta1.clone(src=cms.InputTag(mod["PFJetsSoftDrop"]), cuts=cms.vstring('', '', 'pt > 250'))) # _addProcessAndTask(proc, mod["ECFnb2"], ecfNbeta2.clone(src=cms.InputTag(mod["PFJetsSoftDrop"]), cuts=cms.vstring('', '', 'pt > 250'))) elemToKeep += [ 'keep *_' + mod["ECFnb1"] + '_*_*', # 'keep *_'+mod["ECFnb2"]+'_*_*' ] jetSeq += getattr(proc, mod["ECFnb1"]) # jetSeq += getattr(proc, mod["ECFnb2"]) # toolsUsed.extend([mod["ECFnb1"], mod["ECFnb2"]]) toolsUsed.extend([mod["ECFnb1"]]) # set up user floats getattr(proc, mod["PATJetsSoftDrop"]).userData.userFloats.src += [ mod["ECFnb1"]+':ecfN2', mod["ECFnb1"]+':ecfN3', # mod["ECFnb2"]+':ecfN2', # mod["ECFnb2"]+':ecfN3', ] # rekey the groomed ECF value maps to the ungroomed reco jets, which will then be picked # up by PAT in the user floats. mod["PFJetsSoftDropValueMap"] = mod["PFJetsSoftDrop"]+'ValueMap' _addProcessAndTask(proc, mod["PFJetsSoftDropValueMap"], cms.EDProducer("RecoJetToPatJetDeltaRValueMapProducer", src = cms.InputTag(mod["PFJets"]), matched = cms.InputTag(mod["PATJetsSoftDrop"]), distMax = cms.double(jetSize), values = cms.vstring([ 'userFloat("'+mod["ECFnb1"]+':ecfN2'+'")', 'userFloat("'+mod["ECFnb1"]+':ecfN3'+'")', # 'userFloat("'+mod["ECFnb2"]+':ecfN2'+'")', # 'userFloat("'+mod["ECFnb2"]+':ecfN3'+'")', ]), valueLabels = cms.vstring( [ mod["ECFnb1"]+'N2', mod["ECFnb1"]+'N3', # mod["ECFnb2"]+'N2', # mod["ECFnb2"]+'N3', ]), ) ) getattr(proc, mod["PATJets"]).userData.userFloats.src += [ mod["PFJetsSoftDropValueMap"]+':'+mod["ECFnb1"]+'N2', mod["PFJetsSoftDropValueMap"]+':'+mod["ECFnb1"]+'N3', # mod["PFJetsSoftDropValueMap"]+':'+mod["ECFnb2"]+'N2', # mod["PFJetsSoftDropValueMap"]+':'+mod["ECFnb2"]+'N3', ] if addEnergyCorrFuncSubjets: if PUMethod!="Puppi" or addSoftDropSubjets==False: raise ValueError("|---- jetToolBox: addEnergyCorrFuncSubjets only supported for Puppi w/ addSoftDropSubjets") from RecoJets.JetProducers.ECF_cff import ecfNbeta1, ecfNbeta2 mod["ECFnb1Subjets"] = 'nb1'+mod["SubstructureLabel"]+'SoftDropSubjets' mod["ECFnb2Subjets"] = 'nb2'+mod["SubstructureLabel"]+'SoftDropSubjets' _addProcessAndTask(proc, mod["ECFnb1Subjets"], ecfNbeta1.clone(src=cms.InputTag(mod["PFJetsSoftDrop"], 'SubJets'))) _addProcessAndTask(proc, mod["ECFnb2Subjets"], ecfNbeta2.clone(src=cms.InputTag(mod["PFJetsSoftDrop"], 'SubJets'))) elemToKeep += [ 'keep *_'+mod["ECFnb1Subjets"]+'_*_*', 'keep *_'+mod["ECFnb2Subjets"]+'_*_*'] jetSeq += getattr(proc, mod["ECFnb1Subjets"]) jetSeq += getattr(proc, mod["ECFnb2Subjets"]) toolsUsed.extend([mod["ECFnb1Subjets"],mod["ECFnb2Subjets"]]) # set up user floats getattr(proc, mod["PATSubjetsSoftDrop"]).userData.userFloats.src += [ mod["ECFnb1Subjets"]+':ecfN2', mod["ECFnb1Subjets"]+':ecfN3', mod["ECFnb2Subjets"]+':ecfN2', mod["ECFnb2Subjets"]+':ecfN3', ] if hasattr(proc, 'patJetPartons'): proc.patJetPartons.particles = genParticlesLabel _addProcessAndTask(proc, mod["selPATJets"], selectedPatJets.clone(src=mod["PATJets"], cut=Cut)) elemToKeep += [ 'keep *_'+mod["selPATJets"]+'_*_*' ] elemToKeep += [ 'drop *_'+mod["selPATJets"]+'_calo*_*' ] elemToKeep += [ 'drop *_'+mod["selPATJets"]+'_tagInfos_*' ] if updateCollectionSubjets: mod["PATSubjets"] = patJets+mod["PATSubjetsLabel"] mod["selPATSubjets"] = selPatJets+mod["PATSubjetsLabel"] _addProcessAndTask(proc, mod["selPATSubjets"], selectedPatJets.clone(src=mod["PATSubjets"], cut=Cut)) elemToKeep += [ 'keep *_'+mod["selPATSubjets"]+'__*' ] if len(toolsUsed) > 0 and verbosity>=2: print('|---- jetToolBox: Running '+', '.join(toolsUsed)+'.') if verbosity>=2: print('|---- jetToolBox: Creating '+mod["selPATJets"]+' collection.') if updateCollectionSubjets and verbosity>=2: print('|---- jetToolBox: Creating '+mod["selPATSubjets"]+' collection.') ### "return" setattr(proc, jetSequence, jetSeq) if outputFile!='': if hasattr(proc, outputFile): getattr(proc, outputFile).outputCommands += elemToKeep else: setattr( proc, outputFile, cms.OutputModule('PoolOutputModule', fileName = cms.untracked.string('jettoolbox.root'), outputCommands = cms.untracked.vstring( elemToKeep ) ) ) if associateTask: from PhysicsTools.PatAlgos.tools.helpers import getPatAlgosToolsTask task = getPatAlgosToolsTask(proc) if hasattr(proc, 'endpath'): getattr(proc, 'endpath').associate(task) else: setattr(proc, 'endpath', cms.EndPath(task)) if outputFile != '': getattr(proc, 'endpath').insert(-1, getattr(proc, outputFile)) #### removing mc matching for data if runOnData: from PhysicsTools.PatAlgos.tools.coreTools import removeMCMatching removeMCMatching(proc, names=['Jets'], outputModules=[outputFile]) if verbosity>=3: print('|---- jetToolBox: List of modules created (and other internal names):') for m in mod: print(' '+m+' = '+mod[m])
#process.patJets.addTagInfos = cms.bool(False) import HLTrigger.HLTfilters.hltHighLevel_cfi process.dimuonsHLTFilter = HLTrigger.HLTfilters.hltHighLevel_cfi.hltHighLevel.clone( ) process.dimuonsHLTFilter.TriggerResultsTag = cms.InputTag( "TriggerResults", "", "HLT") process.dimuonsHLTFilter.HLTPaths = ["HLT_Mu13_Mu8*", "HLT_Mu17_TkMu8*"] process.TFileService = cms.Service("TFileService", fileName=cms.string('ntuple_skim.root')) from DimuonAnalysis.DYPackage.DiMuonIntoNtuples_cfi import * from PhysicsTools.PatAlgos.tools.coreTools import removeMCMatching removeMCMatching(process, ['All']) from DimuonAnalysis.DYPackage.DiMuonIntoNtuples_cfi import * from DimuonAnalysis.DYPackage.PUreweight2012_cff import * process.recoTree = DiMuonIntoNtuples.clone() process.recoTree.isMC = False process.recoTree.StoreGENFlag = False process.recoTree.Muon = "selectedPatMuons" process.recoTree.PileUpRD = PileUpRun2012 process.recoTree.PileUpMC = Summer12S10 process.p = cms.Path(process.dimuonsHLTFilter * process.patDefaultSequence * process.recoTree) #process.outpath = cms.EndPath(process.out)
def removeMCMatchingPF2PAT( process, postfix="", outputModules=['out'] ): from PhysicsTools.PatAlgos.tools.coreTools import removeMCMatching removeIfInSequence(process, "genForPF2PATSequence", "patDefaultSequence", postfix) removeMCMatching(process, names=['All'], postfix=postfix, outputModules=outputModules)
def removeMCMatchingPF2PAT( process, postfix="" ): from PhysicsTools.PatAlgos.tools.coreTools import removeMCMatching removeIfInSequence(process, "genForPF2PATSequence", "patDefaultSequence", postfix) removeMCMatching(process, ['All'],postfix)
def removeMCDependence( process ): #-- Remove MC dependence ------------------------------------------------------ from PhysicsTools.PatAlgos.tools.coreTools import removeMCMatching removeMCMatching(process, ['All'])
def addPat(process, isData, doRECO, doTTEffShrinkingConePFTau): sequence = cms.Sequence() # If running together with RECO # We get another kt6PFJets from PAT, and as-is they clash producing an exception runningWithReco = hasattr(process, "recoAllPFJets") if runningWithReco: process.recoAllPFJets.remove(process.kt6PFJets) process.recoPFJets.remove(process.kt6PFJets) process.load("PhysicsTools.PatAlgos.patSequences_cff") if runningWithReco: process.recoAllPFJets.replace(process.kt4PFJets, process.kt4PFJets * process.kt6PFJets) process.recoPFJets.replace(process.kt4PFJets, process.kt4PFJets * process.kt6PFJets) # process.load("PhysicsTools.PatAlgos.producersLayer1.patCandidates_cff") # Calculate PF isolation of the muon #process.muonPFIsolationSequence = MuonPFIsolation.addMuonPFIsolation(process, "muons", process.patMuons) #sequence += process.muonPFIsolationSequence if doRECO: process.pfPileUpIso.PFCandidates = "particleFlowTmp" # I don't know why I have to do this process.pfNoPileUpIso.bottomCollection = "particleFlowTmp" jetCorr = ["L1FastJet", "L2Relative", "L3Absolute"] if isData: jetCorr.append("L2L3Residual") # coreTools.removeMCMatching(process, ["All"], outputInProcess=False) coreTools.removeMCMatching(process, ["All"], outputModules=[]) #### coreTools.removeCleaning(process, False) coreTools.removeCleaning(process, outputModules=[]) #### coreTools.removeSpecificPATObjects(process, ["Electrons", "Photons", "METs"], False) coreTools.removeSpecificPATObjects(process, ["Electrons", "Photons", "METs"], outputModules=[]) tauTools.addTauCollection(process, cms.InputTag('hpsPFTauProducer'), algoLabel="hps", typeLabel="PFTau") jetTools.switchJetCollection(process, cms.InputTag('ak5PFJets'), doJTA=True, doBTagging=True, jetCorrLabel=('AK5PF', jetCorr), doType1MET=False, genJetCollection=cms.InputTag("ak5GenJets"), doJetID=False, jetIdLabel="ak5", outputModules=[]) # If the reference tau should be the old TTEff shrinking cone # if doTTEffShrinkingConePFTau: # process.patTaus.tauSource = "TTEffShrinkingConePFTauProducer" # for module in [process.tauIsoDepositPFCandidates, process.tauIsoDepositPFChargedHadrons, process.tauIsoDepositPFGammas, process.tauIsoDepositPFNeutralHadrons]: # module.src = "TTEffShrinkingConePFTauProducer" # module.ExtractorPSet.tauSource = "TTEffShrinkingConePFTauProducer" # process.tauMatch.src = "TTEffShrinkingConePFTauProducer" # process.patTaus.tauIDSources.leadingPionPtCut = "TTEffPFTauDiscriminationByLeadingPionPtCut" # process.patTaus.tauIDSources.byIsolationUsingLeadingPion = "TTEffPFTauDiscriminationByIsolationUsingLeadingPion" # process.patTaus.tauIDSources.leadingTrackFinding = "TTEffPFTauDiscriminationByLeadingTrackFinding" # process.patTaus.tauIDSources.againstMuon = "TTEffPFTauDiscriminationAgainstMuon" # process.patTaus.tauIDSources.againstElectron = "TTEffPFTauDiscriminationAgainstElectron" # process.selectedPatTaus.cut = "pt() > 15 && abs(eta()) < 2.5 && tauID('leadingPionPtCut')" sequence += process.patDefaultSequence return sequence
def addInvHiggsProcess( process, iRunOnData=True, iData="ParkedData", iHLTFilter="MET", iMCSignal=False, iFile='/store/data/Run2012C/VBF1Parked/AOD/22Jan2013-v1/20000/40F56410-D979-E211-9843-002618943849.root', iMaxEvent=100): ###-------------------------------------------------------------- ### Load PAT, because it insists on defining the process for you #from PhysicsTools.PatAlgos.patTemplate_cfg import * ###-------------------------------------------------------------- ###-------------------------------------------------------------- ### Input process.maxEvents.input = iMaxEvent process.source.fileNames = [iFile] ###-------------------------------------------------------------- ###-------------------------------------------------------------- ### GlobalTag if iRunOnData == True: process.GlobalTag.globaltag = "FT53_V21A_AN6::All" else: process.GlobalTag.globaltag = "START53_V27::All" ###-------------------------------------------------------------- ###-------------------------------------------------------------- ### Logger process.load("FWCore.MessageService.MessageLogger_cfi") process.load("FWCore.MessageLogger.MessageLogger_cfi") process.MessageLogger.cerr.FwkReport = cms.untracked.PSet( reportEvery=cms.untracked.int32(2000), limit=cms.untracked.int32(10000000)) ###-------------------------------------------------------------- ###-------------------------------------------------------------- ### L1 Trigger process.load('L1Trigger.Skimmer.l1Filter_cfi') process.l1Filter.algorithms = cms.vstring('L1_ETM40') ###-------------------------------------------------------------- ###-------------------------------------------------------------- ### HLT Trigger(s) # If it's MC signal, no trigger will be applied if iRunOnData == False and iMCSignal == True: iHLTFilter = "NoTrig" # Load hltHighLevel process.load('HLTrigger.HLTfilters.hltHighLevel_cfi') process.hltHighLevel.TriggerResultsTag = cms.InputTag( "TriggerResults", "", "HLT") process.hltHighLevel.throw = cms.bool( False) # Tolerate if triggers not available process.hltHighLevel.andOr = cms.bool(True) # True = OR, False = AND if (iRunOnData == True and iHLTFilter.find("MET") == 0): process.hltHighLevel.HLTPaths = cms.vstring( #"HLT_DiPFJet40_PFMETnoMu65_MJJ600VBF_LeadingJets_v*", #"HLT_DiPFJet40_PFMETnoMu65_MJJ800VBF_AllJets_v*" "HLT_DiJet35_MJJ700_AllJets_DEta3p5_VBF_v*", "HLT_DiJet30_MJJ700_AllJets_DEta3p5_VBF_v*") elif (iHLTFilter.find("SingleMu") == 0): process.hltHighLevel.HLTPaths = cms.vstring("HLT_IsoMu24_eta2p1_v*", "HLT_Mu40_eta2p1_v*") #elif (iHLTFilter.find("DoubleMu")==0): # process.hltHighLevel.HLTPaths = cms.vstring("HLT_Mu17_Mu8_v*") #elif (iHLTFilter.find("SingleElectron")==0): # process.hltHighLevel.HLTPaths = cms.vstring("HLT_Ele27_WP80_v*") #elif (iHLTFilter.find("DoubleElectron")==0): # process.hltHighLevel.HLTPaths = cms.vstring("HLT_Ele17_CaloIdT_CaloIsoVL_TrkIdVL_TrkIsoVL_Ele8_CaloIdT_CaloIsoVL_TrkIdVL_TrkIsoVL_v*") elif (iHLTFilter.find("NoTrig") == 0): process.hltHighLevel.HLTPaths = cms.vstring("*") else: process.hltHighLevel.HLTPaths = cms.vstring( #"HLT_DiPFJet40_PFMETnoMu65_MJJ600VBF_LeadingJets_v*", #"HLT_DiPFJet40_PFMETnoMu65_MJJ800VBF_AllJets_v*" "HLT_DiJet35_MJJ700_AllJets_DEta3p5_VBF_v*", "HLT_DiJet30_MJJ700_AllJets_DEta3p5_VBF_v*") ### VBF filter for MC Background process.vbfFilter = cms.EDFilter("HLTPFJetVBFFilter", saveTags=cms.bool(True), triggerType=cms.int32(85), inputTag=cms.InputTag("ak5PFJets"), leadingJetOnly=cms.bool(False), minPtHigh=cms.double(25.0), minPtLow=cms.double(25.0), maxEta=cms.double(5.0), etaOpposite=cms.bool(True), minDeltaEta=cms.double(3.0), minInvMass=cms.double(500.0)) ###-------------------------------------------------------------- ###-------------------------------------------------------------- print "-----------------------------------------------" print "INVISIBLE HIGGS: Ntuple V12 for Parked Data" print "-----------------------------------------------" print "RunOnData = ", iRunOnData if iRunOnData == True: print "Dataset = ", iData else: if iMCSignal == True: print "Dataset = MC Signal or DYNoTrig" else: print "Dataset = MC Background" print "GlobalTag = ", process.GlobalTag.globaltag print "Trigger = ", process.hltHighLevel.HLTPaths print "Sample input file = ", iFile print "Max events = ", iMaxEvent print "-----------------------------------------------" ###-------------------------------------------------------------- ###-------------------------------------------------------------- ### Basic filters # Track quality filter process.noscraping = cms.EDFilter("FilterOutScraping", applyfilter=cms.untracked.bool(True), debugOn=cms.untracked.bool(False), numtrack=cms.untracked.uint32(10), thresh=cms.untracked.double(0.25)) # Require a good vertex process.primaryVertexFilter = cms.EDFilter( "VertexSelector", src=cms.InputTag("offlinePrimaryVertices"), cut=cms.string( "!isFake && ndof > 4 && abs(z) <= 24 && position.Rho <= 2"), filter=cms.bool(True)) ###-------------------------------------------------------------- ###-------------------------------------------------------------- ### MET Filters # The iso-based HBHE noise filter process.load('CommonTools.RecoAlgos.HBHENoiseFilter_cfi') # The CSC beam halo tight filter process.load('RecoMET.METAnalyzers.CSCHaloFilter_cfi') # The HCAL laser filter process.load("RecoMET.METFilters.hcalLaserEventFilter_cfi") #process.load("EventFilter.HcalRawToDigi.hcallasereventfilter2012_cff") #process.hcallasereventfilter2012.eventFileName = cms.string('HCALLaser2012AllDatasets.txt.gz') process.load( "EventFilter.HcalRawToDigi.hcallaserFilterFromTriggerResult_cff") # The ECAL dead cell trigger primitive filter process.load('RecoMET.METFilters.EcalDeadCellTriggerPrimitiveFilter_cfi') # The EE bad SuperCrystal filter process.load('RecoMET.METFilters.eeBadScFilter_cfi') # The ECAL laser correction filter process.load('RecoMET.METFilters.ecalLaserCorrFilter_cfi') # The Good vertices collection needed by the tracking failure filter process.goodVertices = cms.EDFilter( "VertexSelector", filter=cms.bool(False), src=cms.InputTag("offlinePrimaryVertices"), cut=cms.string( "!isFake && ndof > 4 && abs(z) <= 24 && position.rho < 2")) # The tracking failure filter process.load('RecoMET.METFilters.trackingFailureFilter_cfi') # The tracking POG filters process.load('RecoMET.METFilters.trackingPOGFilters_cff') ###-------------------------------------------------------------- ###-------------------------------------------------------------- ### customise PAT process.load('JetMETCorrections.Configuration.DefaultJEC_cff') from PhysicsTools.PatAlgos.tools.coreTools import removeMCMatching, runOnData if iRunOnData == True: removeMCMatching(process, ['All']) runOnData(process) # Add the PF MET from PhysicsTools.PatAlgos.tools.metTools import addPfMET addPfMET(process, 'PF') # Switch to PF jets from PhysicsTools.PatAlgos.tools.jetTools import switchJetCollection if iRunOnData == True: switchJetCollection(process, cms.InputTag('ak5PFJets'), doJTA=True, doBTagging=False, jetCorrLabel=('AK5PF', [ 'L1FastJet', 'L2Relative', 'L3Absolute', 'L2L3Residual' ]), doType1MET=True, genJetCollection=cms.InputTag("ak5GenJets"), doJetID=False, jetIdLabel="ak5") else: switchJetCollection( process, cms.InputTag('ak5PFJets'), doJTA=True, doBTagging=False, jetCorrLabel=('AK5PF', ['L1FastJet', 'L2Relative', 'L3Absolute']), doType1MET=True, genJetCollection=cms.InputTag("ak5GenJets"), doJetID=False, jetIdLabel="ak5") from PhysicsTools.PatAlgos.tools.pfTools import usePFIso usePFIso(process) process.patMuons.isoDeposits = cms.PSet() process.patMuons.isolationValues = cms.PSet() process.patElectrons.isolationValues = cms.PSet( pfChargedHadrons=cms.InputTag("elPFIsoValueCharged03PFIdPFIso"), pfChargedAll=cms.InputTag("elPFIsoValueChargedAll03PFIdPFIso"), pfPUChargedHadrons=cms.InputTag("elPFIsoValuePU03PFIdPFIso"), pfNeutralHadrons=cms.InputTag("elPFIsoValueNeutral03PFIdPFIso"), pfPhotons=cms.InputTag("elPFIsoValueGamma03PFIdPFIso")) process.patElectrons.isolationValuesNoPFId = cms.PSet( pfChargedHadrons=cms.InputTag("elPFIsoValueCharged03NoPFIdPFIso"), pfChargedAll=cms.InputTag("elPFIsoValueChargedAll03NoPFIdPFIso"), pfPUChargedHadrons=cms.InputTag("elPFIsoValuePU03NoPFIdPFIso"), pfNeutralHadrons=cms.InputTag("elPFIsoValueNeutral03NoPFIdPFIso"), pfPhotons=cms.InputTag("elPFIsoValueGamma03NoPFIdPFIso")) process.patDefaultSequence.replace( process.patElectrons, process.eleIsoSequence + process.patElectrons) process.cleanPatTaus.preselection = cms.string( 'tauID("decayModeFinding") > 0.5 & tauID("byLooseCombinedIsolationDeltaBetaCorr") > 0.5' ) ###-------------------------------------------------------------- ###-------------------------------------------------------------- ### Object (pre) selection # Jet selection process.selectedPatJets.cut = cms.string("pt>10. && abs(eta)<5.") # Remove overlaps ??? # process.cleanPatJets.finalCut = "!hasOverlaps('electrons') && !hasOverlaps('muons')" # Apply loose PF jet ID from PhysicsTools.SelectorUtils.pfJetIDSelector_cfi import pfJetIDSelector process.goodPatJets = cms.EDFilter("PFJetIDSelectionFunctorFilter", filterParams=pfJetIDSelector.clone(), src=cms.InputTag("selectedPatJets"), filter=cms.bool(True)) process.selectedPatMuons.cut = cms.string( "isGlobalMuon && pt>10. && abs(eta)<2.5") process.selectedPatElectrons.cut = cms.string("pt>10. && abs(eta)<2.5") ###-------------------------------------------------------------- ###-------------------------------------------------------------- ### Load the PU JetID sequence if iRunOnData == True: process.load("CMGTools.External.pujetidsequence_cff") process.puJetMva.jets = cms.InputTag("goodPatJets") process.puJetId.jets = cms.InputTag("goodPatJets") else: process.load("CMGTools.External.pujetidsequence_cff") process.puJetMva.jets = cms.InputTag("goodPatJets") process.puJetId.jets = cms.InputTag("goodPatJets") process.puJetMvaSmeared = process.puJetMva.clone() process.puJetIdSmeared = process.puJetId.clone() process.puJetMvaResUp = process.puJetMva.clone() process.puJetIdResUp = process.puJetId.clone() process.puJetMvaResDown = process.puJetMva.clone() process.puJetIdResDown = process.puJetId.clone() process.puJetMvaEnUp = process.puJetMva.clone() process.puJetIdEnUp = process.puJetId.clone() process.puJetMvaEnDown = process.puJetMva.clone() process.puJetIdEnDown = process.puJetId.clone() process.puJetIdSmeared.jets = cms.InputTag("smearedGoodPatJets") process.puJetMvaSmeared.jetids = cms.InputTag("puJetIdSmeared") process.puJetMvaSmeared.jets = cms.InputTag("smearedGoodPatJets") process.puJetIdResUp.jets = cms.InputTag("smearedGoodPatJetsResUp") process.puJetMvaResUp.jetids = cms.InputTag("puJetIdResUp") process.puJetMvaResUp.jets = cms.InputTag("smearedGoodPatJetsResUp") process.puJetIdResDown.jets = cms.InputTag("smearedGoodPatJetsResDown") process.puJetMvaResDown.jetids = cms.InputTag("puJetIdResDown") process.puJetMvaResDown.jets = cms.InputTag( "smearedGoodPatJetsResDown") process.puJetIdEnUp.jets = cms.InputTag( "shiftedGoodPatJetsEnUpForCorrMEt") process.puJetMvaEnUp.jetids = cms.InputTag("puJetIdEnUp") process.puJetMvaEnUp.jets = cms.InputTag( "shiftedGoodPatJetsEnUpForCorrMEt") process.puJetIdEnDown.jets = cms.InputTag( "shiftedGoodPatJetsEnDownForCorrMEt") process.puJetMvaEnDown.jetids = cms.InputTag("puJetIdEnDown") process.puJetMvaEnDown.jets = cms.InputTag( "shiftedGoodPatJetsEnDownForCorrMEt") ###-------------------------------------------------------------- ###-------------------------------------------------------------- ### MET # Apply type 0 MET corrections based on PFCandidate process.load("JetMETCorrections.Type1MET.pfMETCorrectionType0_cfi") process.pfType1CorrectedMet.applyType0Corrections = cms.bool(False) process.pfType1CorrectedMet.srcType1Corrections = cms.VInputTag( cms.InputTag('pfMETcorrType0'), cms.InputTag('pfJetMETcorr', 'type1')) # Get loose ID/Iso muons and veto ID electrons process.load("InvisibleHiggs.Ntuple.PhysicsObjectCandidates_cff") # Get PFMET from runMEtUncertainties from PhysicsTools.PatUtils.tools.metUncertaintyTools import runMEtUncertainties process.load("JetMETCorrections.Type1MET.pfMETsysShiftCorrections_cfi") if iRunOnData == True: runMEtUncertainties( process, electronCollection=cms.InputTag('selectVetoElectrons'), photonCollection='', muonCollection='selectLooseMuons', tauCollection='', jetCollection=cms.InputTag('goodPatJets'), jetCorrLabel='L2L3Residual', doSmearJets=False, makeType1corrPFMEt=True, makeType1p2corrPFMEt=False, makePFMEtByMVA=False, makeNoPileUpPFMEt=False, doApplyType0corr=True, sysShiftCorrParameter=process. pfMEtSysShiftCorrParameters_2012runAvsNvtx_data, doApplySysShiftCorr=False, addToPatDefaultSequence=False, ) process.patPFJetMETtype1p2Corr.jetCorrLabel = cms.string( 'L2L3Residual') process.patPFJetMETtype2Corr.jetCorrLabel = cms.string('L2L3Residual') else: runMEtUncertainties( process, electronCollection=cms.InputTag('selectVetoElectrons'), photonCollection='', muonCollection='selectLooseMuons', tauCollection='', jetCollection=cms.InputTag('goodPatJets'), jetCorrLabel='L3Absolute', doSmearJets=True, makeType1corrPFMEt=True, makeType1p2corrPFMEt=False, makePFMEtByMVA=False, makeNoPileUpPFMEt=False, doApplyType0corr=True, sysShiftCorrParameter=process. pfMEtSysShiftCorrParameters_2012runAvsNvtx_mc, doApplySysShiftCorr=False, addToPatDefaultSequence=False, ) # Fix Type0 correction module #process.patPFMETtype0Corr.correction.par3 = cms.double(0.909209) #process.patPFMETtype0Corr.correction.par2 = cms.double(0.0303531) #process.patPFMETtype0Corr.correction.par1 = cms.double(-0.703151) #process.patPFMETtype0Corr.correction.par0 = cms.double(0.0) # Need this line for CMSSW_5_3_11 process.producePatPFMETCorrections.replace( process.patPFJetMETtype2Corr, process.patPFJetMETtype2Corr + process.type0PFMEtCorrectionPFCandToVertexAssociation + process.patPFMETtype0Corr) #process.producePatPFMETCorrections.replace(process.patPFJetMETtype2Corr,process.patPFJetMETtype2Corr + process.patPFMETtype0Corr) ###-------------------------------------------------------------- # PAT/ntuples one step # Z and W candidates process.load('InvisibleHiggs/Ntuple/WCandidates_cff') process.load('InvisibleHiggs/Ntuple/ZCandidates_cff') # Ntuple producer process.load('InvisibleHiggs/Ntuple/invHiggsInfo_cfi') if iRunOnData == False: # Jet/MET uncertainty process.invHiggsInfo.jetTag = cms.untracked.InputTag( "smearedGoodPatJets") process.invHiggsInfo.metTag = cms.untracked.InputTag( "patType1CorrectedPFMet") process.invHiggsInfo.puJetMvaTag = cms.untracked.InputTag( "puJetMvaSmeared", "full53xDiscriminant") process.invHiggsInfo.puJetIdTag = cms.untracked.InputTag( "puJetMvaSmeared", "full53xId") # PU re-weighting process.invHiggsInfo.puMCFile = cms.untracked.string("PUHistS10.root") process.invHiggsInfo.puDataFile = cms.untracked.string( "PUHistRun2012All_forParked.root") process.invHiggsInfo.puMCHist = cms.untracked.string("pileup") process.invHiggsInfo.puDataHist = cms.untracked.string("pileup") process.invHiggsInfo.mcPYTHIA = cms.untracked.bool(True) process.invHiggsInfo.trigCorrFile = cms.untracked.string( "DataMCWeight_53X_v1.root") # TTree output file process.load("CommonTools.UtilAlgos.TFileService_cfi") process.TFileService.fileName = cms.string('invHiggsInfo.root') ###-------------------------------------------------------------- ###-------------------------------------------------------------- ### Tau # removeSpecificPATObjects( process, ['Taus'] ) # process.patDefaultSequence.remove( process.patTaus ) process.load("RecoTauTag.Configuration.RecoPFTauTag_cff") ###-------------------------------------------------------------- ###-------------------------------------------------------------- ### Trigger matching # from PhysicsTools.PatAlgos.tools.trigTools import * # process.metTriggerMatch = cms.EDProducer( # "PATTriggerMatcherDRLessByR" # match by DeltaR only, best match by DeltaR # , src = cms.InputTag( 'patMETs' ) # , matched = cms.InputTag( 'patTrigger' ) # default producer label as defined in PhysicsTools/PatAlgos/python/triggerLayer1/triggerProducer_cfi.py # , matchedCuts = cms.string( 'path( "HLT_MET100_v*" )' ) # , maxDPtRel = cms.double( 0.5 ) # , maxDeltaR = cms.double( 0.5 ) # , resolveAmbiguities = cms.bool( True ) # only one match per trigger object # , resolveByMatchQuality = cms.bool( True ) # take best match found per reco object: by DeltaR here (s. above) # ) # process.jetTriggerMatch = cms.EDProducer( # "PATTriggerMatcherDRLessByR" # match by DeltaR only, best match by DeltaR # , src = cms.InputTag( 'patJets' ) # , matched = cms.InputTag( 'patTrigger' ) # default producer label as defined in PhysicsTools/PatAlgos/python/triggerLayer1/triggerProducer_cfi.py # , matchedCuts = cms.string( 'path( "HLT_Jet30_v*" )' ) # , maxDPtRel = cms.double( 0.5 ) # , maxDeltaR = cms.double( 0.5 ) # , resolveAmbiguities = cms.bool( True ) # only one match per trigger object # , resolveByMatchQuality = cms.bool( True ) # take best match found per reco object: by DeltaR here (s. above) # ) # switchOnTriggerMatchEmbedding( process, [ 'metTriggerMatch', 'jetTriggerMatch' ] ) ###-------------------------------------------------------------- ###-------------------------------------------------------------- ### Paths process.p0 = cms.Path(process.HBHENoiseFilter) process.p1 = cms.Path(process.CSCTightHaloFilter) process.p2 = cms.Path(process.hcalLaserEventFilter) process.p3 = cms.Path(process.EcalDeadCellTriggerPrimitiveFilter) process.p4 = cms.Path(process.eeBadScFilter) process.p5 = cms.Path(process.ecalLaserCorrFilter) process.p6 = cms.Path(process.goodVertices * process.trackingFailureFilter) process.p7 = cms.Path(process.trkPOGFilters) if iRunOnData == True: #process.p8 = cms.Path( process.hcallLaserEvent2012Filter ) process.p8 = cms.Path(process.hcalfilter) else: process.p8 = cms.Path(process.primaryVertexFilter) if iRunOnData == True: process.p = cms.Path( # Trigger filter process.l1Filter * process.hltHighLevel * # Basic filters process.noscraping * process.primaryVertexFilter * # MET filters (Move to be flagged) # MET Correction process.type0PFMEtCorrection * # Tau process.recoTauClassicHPSSequence * # Generate PAT process.pfParticleSelectionSequence * process.patDefaultSequence * process.goodPatJets * process.PhysicsObjectSequence * process.metUncertaintySequence * process.puJetIdSqeuence * process.WSequence * process.ZSequence * process.invHiggsInfo) elif (iMCSignal == True): process.p = cms.Path( # Trigger filter #process.hltHighLevel * # Basic filters process.noscraping * process.primaryVertexFilter * # MET filters (Move to be flags) # MET Correction process.type0PFMEtCorrection * # Tau process.recoTauClassicHPSSequence * # Generate PAT process.pfParticleSelectionSequence * process.patDefaultSequence * process.goodPatJets * process.PhysicsObjectSequence * process.metUncertaintySequence * process.puJetIdSqeuence * process.puJetIdSmeared * process.puJetMvaSmeared * process.puJetIdResUp * process.puJetMvaResUp * process.puJetIdResDown * process.puJetMvaResDown * process.puJetIdEnUp * process.puJetMvaEnUp * process.puJetIdEnDown * process.puJetMvaEnDown * process.WSequence * process.ZSequence * process.invHiggsInfo) else: process.p = cms.Path( # Trigger filter #process.hltHighLevel * process.vbfFilter * # Basic filters process.noscraping * process.primaryVertexFilter * # MET filters (Move to be flags) # MET Correction process.type0PFMEtCorrection * # Tau process.recoTauClassicHPSSequence * # Generate PAT process.pfParticleSelectionSequence * process.patDefaultSequence * process.goodPatJets * process.PhysicsObjectSequence * process.metUncertaintySequence * process.puJetIdSqeuence * process.puJetIdSmeared * process.puJetMvaSmeared * process.puJetIdResUp * process.puJetMvaResUp * process.puJetIdResDown * process.puJetMvaResDown * process.puJetIdEnUp * process.puJetMvaEnUp * process.puJetIdEnDown * process.puJetMvaEnDown * process.WSequence * process.ZSequence * process.invHiggsInfo) ###-------------------------------------------------------------- ###-------------------------------------------------------------- ### Output process.out.outputCommands += [ # trigger results 'keep edmTriggerResults_*_*_*', 'keep *_hltTriggerSummaryAOD_*_*' # L1 , 'keep *_l1extraParticles_MET_RECO', 'keep *_l1extraParticles_MHT_RECO' # good jets , 'keep *_goodPatJets_*_*' # PU jet ID , 'keep *_puJetId*_*_*', 'keep *_puJetMva*_*_*' # vertices , 'keep *_offlineBeamSpot_*_*', 'keep *_offlinePrimaryVertices*_*_*', 'keep *_goodOfflinePrimaryVertices*_*_*', 'keep double_*_rho_*' ] if iRunOnData == False: process.out.outputCommands += [ 'keep GenEventInfoProduct_*_*_*', 'keep recoGenParticles_*_*_*', 'keep GenMETs_*_*_*', 'keep *_addPileupInfo_*_*', 'keep LHEEventProduct_*_*_*' ] process.out.fileName = 'patTuple.root' del (process.out) del (process.outpath)
def createProcess(runOnMC, runCHS, correctMETWithT1, processCaloJets, globalTag): ## import skeleton process from PhysicsTools.PatAlgos.patTemplate_cfg import process # load the PAT config process.load("PhysicsTools.PatAlgos.patSequences_cff") process.load("JetMETCorrections.Configuration.JetCorrectionProducers_cff") # Do some CHS stuff process.ak5PFchsL1Fastjet = process.ak5PFL1Fastjet.clone(algorithm = 'AK5PFchs') process.ak5PFchsL2Relative = process.ak5PFL2Relative.clone(algorithm = 'AK5PFchs') process.ak5PFchsL3Absolute = process.ak5PFL3Absolute.clone(algorithm = 'AK5PFchs') process.ak5PFchsResidual = process.ak5PFResidual.clone(algorithm = 'AK5PFchs') process.ak5PFchsL1FastL2L3 = cms.ESProducer( 'JetCorrectionESChain', correctors = cms.vstring('ak5PFchsL1Fastjet', 'ak5PFchsL2Relative','ak5PFchsL3Absolute') ) from PhysicsTools.SelectorUtils.pvSelector_cfi import pvSelector ## The good primary vertex filter ____________________________________________|| ## This filter throw events with no primary vertex process.primaryVertexFilter = cms.EDFilter( "VertexSelector", src = cms.InputTag("offlinePrimaryVertices"), cut = cms.string("!isFake && ndof > 4 && abs(z) <= 24 && position.Rho <= 2"), filter = cms.bool(True) ) process.goodOfflinePrimaryVertices = cms.EDFilter("PrimaryVertexObjectFilter", filterParams = pvSelector.clone( minNdof = cms.double(4.0), maxZ = cms.double(24.0) ), src = cms.InputTag('offlinePrimaryVertices') ) # Configure PAT to use PF2PAT instead of AOD sources # this function will modify the PAT sequences. from PhysicsTools.PatAlgos.tools.coreTools import removeSpecificPATObjects, removeMCMatching from PhysicsTools.PatAlgos.tools.pfTools import usePF2PAT, adaptPFIsoElectrons, adaptPVs, usePFIso #from PhysicsTools.PatAlgos.tools.metTools import * def usePF2PATForAnalysis(jetAlgo, postfix, useTypeIMET, usePFNoPU): # Jet corrections # No L2L3 Residual on purpose if usePFNoPU: jetCorrections = ("%sPFchs" % algo, ['L1FastJet', 'L2Relative', 'L3Absolute']) postfix += "chs" else: jetCorrections = ("%sPF" % algo, ['L1FastJet', 'L2Relative', 'L3Absolute']) #if not runOnMC: # jetCorrections[1].append('L2L3Residual') p = postfix usePF2PAT(process, runPF2PAT=True, jetAlgo=jetAlgo, runOnMC=runOnMC, postfix=p, jetCorrections=jetCorrections, typeIMetCorrections = useTypeIMET) getattr(process, "pfPileUp" + p).Enable = True getattr(process, "pfPileUp" + p).Vertices = 'goodOfflinePrimaryVertices' getattr(process, "pfPileUp" + p).checkClosestZVertex = cms.bool(False) getattr(process, "pfJets" + p).doAreaFastjet = cms.bool(True) getattr(process, "pfJets" + p).doRhoFastjet = False getattr(process, 'patJetCorrFactors' + p).rho = cms.InputTag("kt6PFJets", "rho") # Do not use kt6PFJetsPFlowAK5, it's not ok for L1FastJet. # top projections in PF2PAT: getattr(process,"pfNoPileUp" + p).enable = cms.bool(usePFNoPU) getattr(process,"pfNoMuon" + p).enable = True getattr(process,"pfNoElectron" + p).enable = True getattr(process,"pfNoTau" + p).enable = True getattr(process,"pfNoJet" + p).enable = True getattr(process,"patElectrons" + p).embedTrack = True getattr(process,"patMuons" + p).embedTrack = True # enable delta beta correction for muon selection in PF2PAT? getattr(process,"pfIsolatedMuons" + p).doDeltaBetaCorrection = True getattr(process, "patJets" + p).embedPFCandidates = False # Keep only jets with pt > 2 Gev getattr(process, "selectedPatJets" + p).cut = "pt > 2"; # Use a cone of 0.3 for photon isolation #adaptPFIsoPhotons(process, applyPostfix(process, "patPhotons", postfix), postfix, "03") # 2012 Photon ID # Electron conversion setattr(process, "patConversions" + p, cms.EDProducer("PATConversionProducer", # input collection electronSource = cms.InputTag("selectedPatElectrons" + p) )) # Switch electron isolation to dR = 0.3, for PF2PAT getattr(process, "pfIsolatedElectrons" + p).isolationValueMapsCharged = cms.VInputTag(cms.InputTag("elPFIsoValueCharged03PFId" + p)) getattr(process, "pfIsolatedElectrons" + p).deltaBetaIsolationValueMap = cms.InputTag("elPFIsoValuePU03PFId" + p) getattr(process, "pfIsolatedElectrons" + p).isolationValueMapsNeutral = cms.VInputTag(cms.InputTag("elPFIsoValueNeutral03PFId" + p), cms.InputTag("elPFIsoValueGamma03PFId" + p)) getattr(process, "pfElectrons" + p).isolationValueMapsCharged = cms.VInputTag(cms.InputTag("elPFIsoValueCharged03PFId" + p)) getattr(process, "pfElectrons" + p).deltaBetaIsolationValueMap = cms.InputTag("elPFIsoValuePU03PFId" + p) getattr(process, "pfElectrons" + p).isolationValueMapsNeutral = cms.VInputTag(cms.InputTag( "elPFIsoValueNeutral03PFId" + p), cms.InputTag("elPFIsoValueGamma03PFId" + p)) # ... And for PAT adaptPFIsoElectrons(process, getattr(process, "pfElectrons" + p), p, "03") ##there used to be a modulo to keep track of muons gen info, doesnt work anymore and we don't use that info - so removed for now. setattr(process, "patMuonsLoose" + p, getattr(process, "patMuons" + p).clone( pfMuonSource = cms.InputTag("pfMuons" + p), embedGenMatch = False, addGenMatch = False ) ) setattr(process, "selectedPatMuonsLoose" + p, getattr(process, "selectedPatMuons" + p).clone( src = cms.InputTag("patMuonsLoose" + p) ) ) sequence = getattr(process, "patDefaultSequence" + p) sequence += getattr(process, "patMuonsLoose" + p) sequence += (getattr(process, "selectedPatMuonsLoose" + p)) setattr(process, "patElectronsLoose" + p, getattr(process, "patElectrons" + p).clone( pfElectronSource = cms.InputTag("pfElectrons" + p) ) ) setattr(process, "selectedPatElectronsLoose" + p, getattr(process, "selectedPatElectrons" + p).clone( src = cms.InputTag("patElectronsLoose" + p) ) ) adaptPFIsoElectrons(process, getattr(process, "patElectronsLoose" + p), postfix, "03") sequence = getattr(process, "patDefaultSequence" + p) sequence += (getattr(process, "patElectronsLoose" + p) * getattr(process, "selectedPatElectronsLoose" + p)) # Setup quark gluon tagger #process.load('QuarkGluonTagger.EightTeV.QGTagger_RecoJets_cff') #cloneProcessingSnippet(process, process.QuarkGluonTagger, p) #getattr(process, "QGTagger" + p).srcJets = cms.InputTag("selectedPatJets" + p) #getattr(process, "QGTagger" + p).isPatJet = cms.untracked.bool(True) #getattr(process, "QGTagger" + p).useCHS = cms.untracked.bool(usePFNoPU) ## Remove the processing of primary vertices, as it's already what we do here #getattr(process, 'QGTagger' + p).srcPV = cms.InputTag('goodOfflinePrimaryVertices') #getattr(process, 'QuarkGluonTagger' + p).remove(getattr(process, 'goodOfflinePrimaryVerticesQG' + p)) if not runOnMC: if 'L2L3Residual' in jetCorrections: getattr(process, 'patPFJetMETtype1p2Corr' + p).jetCorrLabel = 'L2L3Residual' getattr(process, 'patPFMet' + p).addGenMET = cms.bool(False) names = ["Taus"] #if jetAlgo != "AK5": #names += ["Electrons", "Muons"] if len(names) > 0: removeSpecificPATObjects(process, names = names, outputModules = ['out'], postfix = p) adaptPVs(process, pvCollection = cms.InputTag("goodOfflinePrimaryVertices"), postfix = p) getattr(process, "patDefaultSequence" + p).replace(getattr(process, "selectedPatElectrons" + p), getattr(process, "selectedPatElectrons" + p) + getattr(process, "patConversions" + p)) #getattr(process, "patDefaultSequence" + p).replace(getattr(process, "selectedPatJets" + p), getattr(process, "selectedPatJets" + p) + getattr(process, "QuarkGluonTagger" + p)) return getattr(process, "patPF2PATSequence" + p) if correctMETWithT1: process.load("PhysicsTools.PatUtils.patPFMETCorrections_cff") from PhysicsTools.PatAlgos.tools.helpers import cloneProcessingSnippet print "##########################" print "PF jets with PF2PAT" print "Using Type I met" if correctMETWithT1 else "NOT using Type I met" print "##########################" #runCHS = False #postfixes = {'PFlowAK5': 'AK5', 'PFlowAK7': 'AK7'} postfixes = {'PFlowAK5': 'AK5'} # Setup quark gluon tagger process.load('QuarkGluonTagger.EightTeV.QGTagger_RecoJets_cff') process.sequence_chs = cms.Sequence() process.sequence_nochs = cms.Sequence() for p, algo in postfixes.items(): process.sequence_nochs += usePF2PATForAnalysis(jetAlgo=algo, postfix=p, usePFNoPU=False, useTypeIMET=correctMETWithT1) if runCHS: process.sequence_chs += usePF2PATForAnalysis(jetAlgo=algo, postfix=p, usePFNoPU=True, useTypeIMET=correctMETWithT1) setattr(process, 'QGTagger' + p, process.QGTagger.clone()) getattr(process, "QGTagger" + p).srcJets = cms.InputTag("selectedPatJets" + p) getattr(process, "QGTagger" + p).isPatJet = cms.untracked.bool(True) getattr(process, "QGTagger" + p).useCHS = cms.untracked.bool(False) process.QuarkGluonTagger.replace(process.QGTagger, getattr(process, 'QGTagger' + p)) if runCHS: chsP = p + "chs" setattr(process, 'QGTagger' + chsP, process.QGTagger.clone()) getattr(process, "QGTagger" + chsP).srcJets = cms.InputTag("selectedPatJets" + chsP) getattr(process, "QGTagger" + chsP).isPatJet = cms.untracked.bool(True) getattr(process, "QGTagger" + chsP).useCHS = cms.untracked.bool(True) process.QuarkGluonTagger.replace(getattr(process, 'QGTagger' + p), getattr(process, 'QGTagger' + p) + getattr(process, 'QGTagger' + chsP)) print "##########################" print "Calo jets" if processCaloJets else "No processing of calo jets" print "##########################" usePFIso(process, "") #adaptPFIsoPhotons(process, process.patPhotons, "", "03") if processCaloJets: # No L2L3 Residual on purpose jetCorrections = ('AK5Calo', ['L1Offset', 'L2Relative', 'L3Absolute']) addJetCollection(process, cms.InputTag('ak7CaloJets'), 'AK7', 'Calo', doJTA = True, doBTagging = True, jetCorrLabel = jetCorrections, doType1MET = correctMETWithT1, doL1Cleaning = False, doL1Counters = False, genJetCollection = cms.InputTag("ak7GenJets"), doJetID = True, jetIdLabel = "ak7" ) switchJetCollection(process, cms.InputTag('ak5CaloJets'), doJTA = True, doBTagging = True, jetCorrLabel = jetCorrections, doType1MET = correctMETWithT1, genJetCollection = cms.InputTag("ak5GenJets"), doJetID = True, jetIdLabel = "ak5" ) process.selectedPatJets.cut = "pt > 2" process.selectedPatJetsAK7Calo.cut = "pt > 2" else: removeSpecificPATObjects(process, names = ['Jets', 'METs']) if not runOnMC: # Remove MC Matching removeMCMatching(process, names = ["All"]) removeSpecificPATObjects(process, names = ['Electrons', 'Muons', 'Taus']) if runCHS: print "##########################" print "Running CHS sequence" print "##########################" process.analysisSequence = cms.Sequence() process.analysisSequence *= process.sequence_nochs if runCHS: process.analysisSequence *= process.sequence_chs # Quark Gluon tagging process.analysisSequence *= process.QuarkGluonTagger # Add default pat sequence to our path # This brings to life TcMET, Calo jets and Photons process.analysisSequence *= process.patDefaultSequence # Add our PhotonIsolationProducer to the analysisSequence. This producer compute pf isolations # for our photons process.photonPFIsolation = cms.EDProducer("PhotonIsolationProducer", src = cms.InputTag("selectedPatPhotons") ) process.analysisSequence *= process.photonPFIsolation # Filtering # require physics declared process.load('HLTrigger.special.hltPhysicsDeclared_cfi') process.hltPhysicsDeclared.L1GtReadoutRecordTag = 'gtDigis' # require scraping filter process.scrapingVeto = cms.EDFilter("FilterOutScraping", applyfilter = cms.untracked.bool(True), debugOn = cms.untracked.bool(False), numtrack = cms.untracked.uint32(10), thresh = cms.untracked.double(0.25) ) # Count events process.nEventsTotal = cms.EDProducer("EventCountProducer") process.nEventsFiltered = cms.EDProducer("EventCountProducer") # MET Filters process.load("RecoMET.METFilters.metFilters_cff") # HCAL Laser filter : work only on Winter13 rereco process.load("EventFilter.HcalRawToDigi.hcallaserFilterFromTriggerResult_cff") #needed fot photon energy regression calculation process.load('Calibration.EleNewEnergiesProducer.elenewenergiesproducer_cfi') #getattr(process,"patPhotons" + p) process.patPhotons.userData.userFloats.src = [ cms.InputTag("eleNewEnergiesProducer","energySCEleJoshPhoSemiParamV5ecorr") ] ## uncomment to run interactive ## process.eleNewEnergiesProducer.regrPhoJoshV5_SemiParamFile = cms.string('../../../../src/HiggsAnalysis/GBRLikelihoodEGTools/data/regweights_v5_forest_ph.root') ## process.eleNewEnergiesProducer.regrEleJoshV5_SemiParamFile = cms.string('../../../../src/HiggsAnalysis/GBRLikelihoodEGTools/data/regweights_v5_forest_ele.root') process.eleNewEnergiesProducer.electronCollection = getattr(process,"patPhotons" + p).photonSource # Let it run process.p = cms.Path( process.nEventsTotal + # Filters process.hcalfilter + process.primaryVertexFilter + process.scrapingVeto + process.metFilters + process.goodOfflinePrimaryVertices + # photon energy regression process.eleNewEnergiesProducer + # Physics process.analysisSequence + process.nEventsFiltered ) if runOnMC: process.p.remove(process.hcalfilter) process.p.remove(process.scrapingVeto) # Add PF2PAT output to the created file from PhysicsTools.PatAlgos.patEventContent_cff import patEventContentNoCleaning #process.load("CommonTools.ParticleFlow.PF2PAT_EventContent_cff") process.out.outputCommands = cms.untracked.vstring('drop *', 'keep *_photonCore_*_*', 'keep double_kt6*Jets*_rho_*', 'keep *_goodOfflinePrimaryVertices_*_*', 'keep recoPFCandidates_particleFlow_*_*', # Content of *patEventContentNoCleaning 'keep *_selectedPatPhotons*_*_*', 'keep *_selectedPatElectrons*_*_*', 'keep *_selectedPatMuons*_*_*', 'keep *_selectedPatTaus*_*_*', 'keep *_selectedPatJets*_*_*', 'drop *_selectedPatJets_pfCandidates_*', 'drop *_*PF_caloTowers_*', 'drop *_*JPT_pfCandidates_*', 'drop *_*Calo_pfCandidates_*', 'keep *_patMETs*_*_*', 'keep *_selectedPatPFParticles*_*_*', 'keep *_selectedPatTrackCands*_*_*', 'keep *_cleanPatPhotons*_*_*', 'keep *_cleanPatElectrons*_*_*', 'keep *_cleanPatMuons*_*_*', 'keep *_cleanPatTaus*_*_*', 'keep *_cleanPatJets*_*_*', 'keep *_cleanPatHemispheres*_*_*', 'keep *_cleanPatPFParticles*_*_*', 'keep *_cleanPatTrackCands*_*_*', 'drop *_*PFlow_caloTowers_*', # Type I residual 'drop *_selectedPatJetsForMET*_*_PAT', 'keep *_patPFMet*_*_PAT', # Keep raw met # Trigger 'keep *_TriggerResults_*_HLT', # Debug #'keep *_pf*_*_PAT' # Photon ID 'keep *_patConversions*_*_*', 'keep *_photonPFIsolation*_*_*', # Quark Gluon tagging 'keep *_QGTagger*_*_*', 'drop *_kt6PFJetsIsoQG_*_PAT', 'drop *_kt6PFJetsQG_*_PAT', # MC truth 'keep *_genParticles_*_*', # RecHits 'keep *EcalRecHit*_*_*_*', # Beam spot 'keep *_offlineBeamSpot_*_*', #photon energy regression 'keep *_eleNewEnergiesProducer_*_*' ) if runOnMC: process.out.outputCommands.extend(['keep *_addPileupInfo_*_*', 'keep *_generator_*_*']) # switch on PAT trigger # from PhysicsTools.PatAlgos.tools.trigTools import switchOnTrigger # switchOnTrigger( process ) ## ------------------------------------------------------ # In addition you usually want to change the following # parameters: ## ------------------------------------------------------ # process.GlobalTag.globaltag = "%s::All" % (globalTag) ## (according to https://twiki.cern.ch/twiki/bin/view/CMS/SWGuideFrontierConditions) # ## #process.source.fileNames = cms.untracked.vstring('file:input_data.root') ## (e.g. 'file:AOD.root') # ## process.maxEvents.input = 2500 # ## # process.out.outputCommands = [ ... ] ## (e.g. taken from PhysicsTools/PatAlgos/python/patEventContent_cff.py) # ## process.options.wantSummary = False ## (to suppress the long output at the end of the job) process.MessageLogger.cerr.FwkReport.reportEvery = 1000 # Remove annoying ecalLaser messages process.MessageLogger.suppressError = cms.untracked.vstring ('ecalLaserCorrFilter') return process
def removeMCDependence(process): #-- Remove MC dependence ------------------------------------------------------ from PhysicsTools.PatAlgos.tools.coreTools import removeMCMatching removeMCMatching(process, ['All'])
#GT if runOnMC : process.GlobalTag.globaltag = 'START53_V27::All' else : process.GlobalTag.globaltag = 'FT_53_V21_AN6::All' ## Source process.source = cms.Source( "PoolSource", fileNames = files ) ## Maximal Number of Events process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(nevents) ) #objects from PhysicsTools.PatAlgos.tools.coreTools import removeMCMatching if not runOnMC : removeMCMatching(process, ['All']) from PhysicsTools.PatAlgos.tools.trigTools import * switchOnTrigger(process,sequence='patDefaultSequence',hltProcess = '*') from UserCode.zbb_louvain.PATconfig.vertex_cff import * setupGoodVertex(process) from UserCode.zbb_louvain.PATconfig.muon_cff import * setupPatMuons(process, runOnMC, muPt) from UserCode.zbb_louvain.PATconfig.electron_cff import * setupPatElectrons(process, runOnMC, elePt) from UserCode.zbb_louvain.PATconfig.tau_cff import * setupPatTaus(process) from UserCode.zbb_louvain.PATconfig.jet_cff import * setupPatJets(process, runOnMC) from UserCode.zbb_louvain.PATconfig.subjet_cff import * setupPatSubJets(process, runOnMC) from UserCode.zbb_louvain.PATconfig.met_cff import *
def configurePatTupleProduction(process, patSequenceBuilder=buildGenericTauSequence, patPFTauCleanerPrototype=None, patCaloTauCleanerPrototype=None, addSVfitInfo=False, hltProcess="HLT", isMC=False, applyTauVertexMatch=True): # check that patSequenceBuilder and patTauCleanerPrototype are defined and non-null if patSequenceBuilder is None: raise ValueError("Undefined 'patSequenceBuilder' Parameter !!") if patPFTauCleanerPrototype is None or patCaloTauCleanerPrototype is None: raise ValueError("Undefined 'patTauCleanerPrototype' Parameter !!") #-------------------------------------------------------------------------------- # produce PAT objects #-------------------------------------------------------------------------------- process.load("PhysicsTools.PatAlgos.patSequences_cff") process.load("PhysicsTools.PatAlgos.producersLayer1.tauProducer_cff") process.load("PhysicsTools.PatAlgos.producersLayer1.muonProducer_cff") process.load("PhysicsTools.PatAlgos.producersLayer1.metProducer_cff") process.load("TauAnalysis.CandidateTools.muTauPairProduction_cff") # per default, do **not** run SVfit algorithm if not addSVfitInfo: process.allMuTauPairs.doSVreco = cms.bool(False) process.allMuTauPairs.doPFMEtSign = cms.bool(False) process.allMuTauPairsLooseMuonIsolation.doSVreco = cms.bool(False) process.allMuTauPairsLooseMuonIsolation.doPFMEtSign = cms.bool(False) if not isMC: removeMCMatching(process, ["All"], outputModules=[]) else: # match pat::Taus to all genJets # (including to genJets build from electrons/muons produced in tau --> e/mu decays) process.tauGenJetMatch.matched = cms.InputTag("tauGenJets") #-------------------------------------------------------------------------------- # configure PAT trigger matching switchOnTrigger(process, hltProcess=hltProcess, outputModule='') # CV: disable L1Algos in MC for now, to prevent error messages # # %MSG-e L1GlobalTriggerObjectMapRecord: PATTriggerProducer:patTrigger # # ERROR: The requested algorithm name = L1_DoubleEG1 # does not exists in the trigger menu. # Returning zero pointer for getObjectMap # # to be printed for every event (06/05/2011) # # for Data the L1Algos flag needs to be enabled, # in order for the prescale computation/correction for Data # implemented in TauAnalysis/TauIdEfficiency/bin/FWLiteTauIdEffAnalyzer.cc to work if isMC: process.patTrigger.addL1Algos = cms.bool(False) else: process.patTrigger.addL1Algos = cms.bool(True) process.patTauTriggerMatchHLTprotoType = cms.EDProducer( "PATTriggerMatcherDRLessByR", src=cms.InputTag("cleanLayer1Taus"), matched=cms.InputTag("patTrigger"), matchedCuts=cms.string('path("HLT_Jet30_v*")'), maxDPtRel=cms.double(1.e+3), maxDeltaR=cms.double(0.5), resolveAmbiguities=cms.bool(True), resolveByMatchQuality=cms.bool(True)) #-------------------------------------------------------------------------------- #-------------------------------------------------------------------------------- # compute Pt sum of charged + neutral hadrons and photons within isolation cones of size dR = 0.4/0.6 process.load("RecoMuon/MuonIsolation/muonPFIsolation_cff") patutils.massSearchReplaceAnyInputTag( process.muonPFIsolationDepositsSequence, cms.InputTag('muons1stStep'), cms.InputTag('muons')) process.patMuons.isoDeposits = cms.PSet( # CV: strings for IsoDeposits defined in PhysicsTools/PatAlgos/plugins/PATMuonProducer.cc pfChargedHadrons=cms.InputTag("muPFIsoDepositCharged"), pfNeutralHadrons=cms.InputTag("muPFIsoDepositNeutral"), pfPhotons=cms.InputTag("muPFIsoDepositGamma"), user=cms.VInputTag(cms.InputTag("muPFIsoDepositChargedAll"), cms.InputTag("muPFIsoDepositPU"))) process.patMuons.userIsolation = cms.PSet( # CV: strings for Isolation values defined in PhysicsTools/PatAlgos/src/MultiIsolator.cc pfChargedHadron=cms.PSet( deltaR=cms.double(0.4), src=process.patMuons.isoDeposits.pfChargedHadrons, vetos=process.muPFIsoValueCharged04.deposits[0].vetos, skipDefaultVeto=process.muPFIsoValueCharged04.deposits[0]. skipDefaultVeto), pfNeutralHadron=cms.PSet( deltaR=cms.double(0.4), src=process.patMuons.isoDeposits.pfNeutralHadrons, vetos=process.muPFIsoValueNeutral04.deposits[0].vetos, skipDefaultVeto=process.muPFIsoValueNeutral04.deposits[0]. skipDefaultVeto), pfGamma=cms.PSet(deltaR=cms.double(0.4), src=process.patMuons.isoDeposits.pfPhotons, vetos=process.muPFIsoValueGamma04.deposits[0].vetos, skipDefaultVeto=process.muPFIsoValueGamma04. deposits[0].skipDefaultVeto), user=cms.VPSet( cms.PSet(deltaR=cms.double(0.4), src=process.patMuons.isoDeposits.user[0], vetos=process.muPFIsoValueChargedAll04.deposits[0].vetos, skipDefaultVeto=process.muPFIsoValueChargedAll04. deposits[0].skipDefaultVeto), cms.PSet(deltaR=cms.double(0.4), src=process.patMuons.isoDeposits.user[1], vetos=process.muPFIsoValuePU04.deposits[0].vetos, skipDefaultVeto=process.muPFIsoValuePU04.deposits[0]. skipDefaultVeto))) process.patMuonsWithinAcc = cms.EDFilter( "PATMuonSelector", src=cms.InputTag('patMuons'), cut=cms.string("pt > 15. & abs(eta) < 2.1"), filter=cms.bool(False)) process.selectedPatMuonsVBTFid = cms.EDFilter( "PATMuonIdSelector", src=cms.InputTag('patMuonsWithinAcc'), vertexSource=cms.InputTag('selectedPrimaryVertexPosition'), beamSpotSource=cms.InputTag('offlineBeamSpot'), filter=cms.bool(False)) #-------------------------------------------------------------------------------- #-------------------------------------------------------------------------------- # # produce collections of pat::Jets for CaloJets and PFJets # # NOTE: needed for evaluating jetId for Calo/TCTaus and PFTaus # jec = ['L1FastJet', 'L2Relative', 'L3Absolute'] if not isMC: jec.extend(['L2L3Residual']) addJetCollection(process, cms.InputTag('ak5PFJets'), 'AK5', 'PF', doJTA=False, doBTagging=False, jetCorrLabel=('AK5PF', cms.vstring(jec)), doType1MET=False, genJetCollection=cms.InputTag("ak5GenJets"), doJetID=True, jetIdLabel="ak5", outputModules=[]) addJetCollection(process, cms.InputTag('ak5CaloJets'), 'AK5', 'Calo', doJTA=False, doBTagging=False, jetCorrLabel=('AK5Calo', cms.vstring(jec)), doType1MET=False, genJetCollection=cms.InputTag("ak5GenJets"), doJetID=True, jetIdLabel="ak5", outputModules=[]) #-------------------------------------------------------------------------------- #-------------------------------------------------------------------------------- # # configure Jet Energy Corrections # process.load("TauAnalysis.Configuration.jetCorrectionParameters_cfi") #-------------------------------------------------------------------------------- #-------------------------------------------------------------------------------- # add pfMET process.load("PhysicsTools.PatUtils.patPFMETCorrections_cff") if isMC: import PhysicsTools.PatAlgos.tools.helpers as configtools configtools.cloneProcessingSnippet(process, process.producePatPFMETCorrections, "NoSmearing") process.selectedPatJetsForMETtype1p2CorrNoSmearing.src = cms.InputTag( 'patJetsNotOverlappingWithLeptonsForMEtUncertainty') process.selectedPatJetsForMETtype2CorrNoSmearing.src = process.selectedPatJetsForMETtype1p2CorrNoSmearing.src process.patMEtProductionSequence = cms.Sequence() process.patMEtProductionSequence += process.patDefaultSequence from PhysicsTools.PatUtils.tools.metUncertaintyTools import runMEtUncertainties doSmearJets = None if isMC: doSmearJets = True else: doSmearJets = False runMEtUncertainties( process, electronCollection='', photonCollection='', muonCollection=cms.InputTag('selectedPatMuonsVBTFid'), tauCollection='', jetCollection=cms.InputTag('patJetsAK5PF'), doSmearJets=doSmearJets, doApplyType0corr=True, sysShiftCorrParameter=None, doApplySysShiftCorr=False, # CV: shift Jet energy by 3 standard-deviations, # so that template morphing remains an interpolation and no extrapolation is needed varyByNsigmas=3.0, addToPatDefaultSequence=False) if isMC: process.patPFMet.addGenMET = cms.bool(True) process.patPFJetMETtype1p2Corr.jetCorrLabel = cms.string("L3Absolute") process.patMEtProductionSequence += process.metUncertaintySequence else: process.patPFMet.addGenMET = cms.bool(False) process.patPFJetMETtype1p2Corr.jetCorrLabel = cms.string( "L2L3Residual") process.patMEtProductionSequence += process.patJetsAK5PFnotOverlappingWithLeptonsForMEtUncertainty process.patMEtProductionSequence += process.producePatPFMETCorrections #-------------------------------------------------------------------------------- pfJetCollection = 'patJetsAK5PFnotOverlappingWithLeptonsForMEtUncertainty' pfMEtCollection = 'patType1CorrectedPFMet' if isMC: pfJetCollection = 'smearedPatJetsAK5PF' #-------------------------------------------------------------------------------- # # produce combinations of muon + tau-jet pairs # for collection of pat::Tau objects representing CaloTaus # switchToCaloTau(process) process.patCaloTauProducer = copy.deepcopy(process.patTaus) retVal_caloTau = patSequenceBuilder( process, collectionName=["patCaloTaus", ""], jetCollectionName="patJetsAK5Calo", patTauProducerPrototype=process.patCaloTauProducer, patTauCleanerPrototype=patCaloTauCleanerPrototype, triggerMatcherProtoType=process.patTauTriggerMatchHLTprotoType, addGenInfo=isMC, applyTauJEC=False, applyTauVertexMatch=applyTauVertexMatch) process.caloTauSequence = retVal_caloTau["sequence"] process.patMuonCaloTauPairs = process.allMuTauPairs.clone( srcLeg1=cms.InputTag('selectedPatMuonsVBTFid'), srcLeg2=cms.InputTag(retVal_caloTau["collection"]), srcMET=cms.InputTag('patMETs'), srcGenParticles=cms.InputTag(''), doSVreco=cms.bool(False), doPFMEtSign=cms.bool(False)) if hasattr(process.patMuonCaloTauPairs, "nSVfit"): delattr(process.patMuonCaloTauPairs, "nSVfit") if hasattr(process.patMuonCaloTauPairs, "pfMEtSign"): delattr(process.patMuonCaloTauPairs, "pfMEtSign") #-------------------------------------------------------------------------------- #-------------------------------------------------------------------------------- # # produce collection of pat::Tau objects representing PFTaus # reconstructed by fixed signal cone algorithm # (plus combinations of muon + tau-jet pairs) # #switchToPFTauFixedCone(process) #process.patPFTauProducerFixedCone = copy.deepcopy(process.patTaus) # #retVal_pfTauFixedCone = patSequenceBuilder( # process, # collectionName = [ "patPFTaus", "FixedCone" ], # jetCollectionName = pfJetCollection, # patTauProducerPrototype = process.patPFTauProducerFixedCone, # patTauCleanerPrototype = patPFTauCleanerPrototype, # triggerMatcherProtoType = process.patTauTriggerMatchHLTprotoType, # addGenInfo = isMC, # applyTauJEC = False, # applyTauVertexMatch = applyTauVertexMatch #) #process.pfTauSequenceFixedCone = retVal_pfTauFixedCone["sequence"] # #process.patMuonPFTauPairsFixedCone = process.allMuTauPairs.clone( # srcLeg1 = cms.InputTag('selectedPatMuonsVBTFid'), # srcLeg2 = cms.InputTag(retVal_pfTauFixedCone["collection"]), # srcMET = cms.InputTag(pfMEtCollection), # srcGenParticles = cms.InputTag(''), # doSVreco = cms.bool(False) #) #if hasattr(process.patMuonPFTauPairsFixedCone, "nSVfit"): # delattr(process.patMuonPFTauPairsFixedCone, "nSVfit") #if hasattr(process.patMuonPFTauPairsFixedCone, "pfMEtSign"): # delattr(process.patMuonPFTauPairsFixedCone, "pfMEtSign") #-------------------------------------------------------------------------------- #-------------------------------------------------------------------------------- # # produce collection of pat::Tau objects representing PFTaus # reconstructed by shrinking signal cone algorithm # (plus combinations of muon + tau-jet pairs) # #switchToPFTauShrinkingCone(process) #process.patPFTauProducerShrinkingCone = copy.deepcopy(process.patTaus) # #retVal_pfTauShrinkingCone = patSequenceBuilder( # process, # collectionName = [ "patPFTaus", "ShrinkingCone" ], # jetCollectionName = pfJetCollection, # patTauProducerPrototype = process.patPFTauProducerShrinkingCone, # patTauCleanerPrototype = patPFTauCleanerPrototype, # triggerMatcherProtoType = process.patTauTriggerMatchHLTprotoType, # addGenInfo = isMC, # applyTauJEC = False, # applyTauVertexMatch = applyTauVertexMatch #) #process.pfTauSequenceShrinkingCone = retVal_pfTauShrinkingCone["sequence"] # #process.patMuonPFTauPairsShrinkingCone = process.allMuTauPairs.clone( # srcLeg1 = cms.InputTag('selectedPatMuonsVBTFid'), # srcLeg2 = cms.InputTag(retVal_pfTauShrinkingCone["collection"]), # srcMET = cms.InputTag(pfMEtCollection), # srcGenParticles = cms.InputTag(''), # doSVreco = cms.bool(False) #) #if hasattr(process.patMuonPFTauPairsShrinkingCone, "nSVfit"): # delattr(process.patMuonPFTauPairsShrinkingCone, "nSVfit") #if hasattr(process.patMuonPFTauPairsShrinkingCone, "pfMEtSign"): # delattr(process.patMuonPFTauPairsShrinkingCone, "pfMEtSign") #-------------------------------------------------------------------------------- #-------------------------------------------------------------------------------- # # produce collection of pat::Tau objects representing PFTaus # reconstructed by hadron + strips (HPS) algorithm # (plus combinations of muon + tau-jet pairs) # # NOTE: switchToPFTauHPS function overwrites process.cleanPatTaus.preselection using HPS specific discriminators; # undo overwriting, in order to prevent run-time errors in case of subsequence _switchToPFTau call, # arising from the fact that HPS specific discriminators are not available for all tau types # switchToPFTauHPS(process) process.cleanPatTaus.preselection = cms.string('') process.patPFTauProducerHPS = copy.deepcopy(process.patTaus) retVal_pfTauHPS = patSequenceBuilder( process, collectionName=["patPFTaus", "HPS"], jetCollectionName=pfJetCollection, patTauProducerPrototype=process.patPFTauProducerHPS, patTauCleanerPrototype=patPFTauCleanerPrototype, triggerMatcherProtoType=process.patTauTriggerMatchHLTprotoType, addGenInfo=isMC, applyTauJEC=True, applyTauVertexMatch=applyTauVertexMatch) process.pfTauSequenceHPS = retVal_pfTauHPS["sequence"] process.patMuonPFTauPairsHPS = process.allMuTauPairs.clone( srcLeg1=cms.InputTag('selectedPatMuonsVBTFid'), srcLeg2=cms.InputTag(retVal_pfTauHPS["collection"]), srcMET=cms.InputTag(pfMEtCollection), srcGenParticles=cms.InputTag(''), doSVreco=cms.bool(False)) if hasattr(process.patMuonPFTauPairsHPS, "nSVfit"): delattr(process.patMuonPFTauPairsHPS, "nSVfit") if hasattr(process.patMuonPFTauPairsHPS, "pfMEtSign"): delattr(process.patMuonPFTauPairsHPS, "pfMEtSign") #-------------------------------------------------------------------------------- #-------------------------------------------------------------------------------- # # produce collection of pat::Tau objects representing PFTaus # reconstructed by HPS + TaNC combined tau id. algorithm # (plus combinations of muon + tau-jet pairs) # switchToPFTauHPSpTaNC(process) process.cleanPatTaus.preselection = cms.string('') process.patPFTauProducerHPSpTaNC = copy.deepcopy(process.patTaus) retVal_pfTauHPSpTaNC = patSequenceBuilder( process, collectionName=["patPFTaus", "HPSpTaNC"], jetCollectionName=pfJetCollection, patTauProducerPrototype=process.patPFTauProducerHPSpTaNC, patTauCleanerPrototype=patPFTauCleanerPrototype, triggerMatcherProtoType=process.patTauTriggerMatchHLTprotoType, addGenInfo=isMC, applyTauJEC=True, applyTauVertexMatch=applyTauVertexMatch) process.pfTauSequenceHPSpTaNC = retVal_pfTauHPSpTaNC["sequence"] process.patMuonPFTauPairsHPSpTaNC = process.allMuTauPairs.clone( srcLeg1=cms.InputTag('selectedPatMuonsVBTFid'), srcLeg2=cms.InputTag(retVal_pfTauHPSpTaNC["collection"]), srcMET=cms.InputTag(pfMEtCollection), srcGenParticles=cms.InputTag(''), doSVreco=cms.bool(False)) if hasattr(process.patMuonPFTauPairsHPSpTaNC, "nSVfit"): delattr(process.patMuonPFTauPairsHPSpTaNC, "nSVfit") if hasattr(process.patMuonPFTauPairsHPSpTaNC, "pfMEtSign"): delattr(process.patMuonPFTauPairsHPSpTaNC, "pfMEtSign") #-------------------------------------------------------------------------------- process.patTupleProductionSequence = cms.Sequence( process.muonPFIsolationSequence + process.patDefaultSequence ##+ process.patTrigger + process.patTriggerEvent + process.patMuonsWithinAcc + process.selectedPatMuonsVBTFid + process.patMEtProductionSequence + process.caloTauSequence # store TaNC inputs as discriminators #+ process.produceTancMVAInputDiscriminators #+ process.pfTauSequenceFixedCone #+ process.pfTauSequenceShrinkingCone + process.pfTauSequenceHPS + process.pfTauSequenceHPSpTaNC + process.patMuonCaloTauPairs #+ process.patMuonPFTauPairsFixedCone #+ process.patMuonPFTauPairsShrinkingCone + process.patMuonPFTauPairsHPS + process.patMuonPFTauPairsHPSpTaNC) # return names of "final" collections of CaloTaus/different types of PFTaus # to be used as InputTag for further processing retVal = {} retVal["caloTauCollection"] = retVal_caloTau["collection"] retVal["muonCaloTauCollection"] = process.patMuonCaloTauPairs.label() #retVal["pfTauCollectionFixedCone"] = retVal_pfTauFixedCone["collection"] #retVal["muonPFTauCollectionFixedCone"] = process.patMuonPFTauPairsFixedCone.label() #retVal["pfTauCollectionShrinkingCone"] = retVal_pfTauShrinkingCone["collection"] #retVal["muonPFTauCollectionShrinkingCone"] = process.patMuonPFTauPairsShrinkingCone.label() retVal["pfTauCollectionHPS"] = retVal_pfTauHPS["collection"] retVal["muonPFTauCollectionHPS"] = process.patMuonPFTauPairsHPS.label() retVal["pfTauCollectionHPSpTaNC"] = retVal_pfTauHPSpTaNC["collection"] retVal[ "muonPFTauCollectionHPSpTaNC"] = process.patMuonPFTauPairsHPSpTaNC.label( ) return retVal
outputCommands = cms.untracked.vstring('drop *') ) # load the PAT config process.load("PhysicsTools.PatAlgos.patSequences_cff") #process.patJets.addTagInfos = cms.bool(False) process.TFileService = cms.Service("TFileService", fileName = cms.string('ntuple_skim.root') ) #FIXME #process.Tracer = cms.Service("Tracer") from DimuonAnalysis.DYPackage.DiLeptonIntoNtuples_cfi import * from PhysicsTools.PatAlgos.tools.coreTools import removeMCMatching removeMCMatching(process, ['All']) from DimuonAnalysis.DYPackage.PUreweight2012_cff import * process.recoTree = DiLeptonIntoNtuples.clone() process.recoTree.isMC = False process.recoTree.isSignal = False process.recoTree.runOnEleInput = True process.recoTree.Muon = "selectedPatMuons" process.recoTree.Photon = "selectedPatPhotons" process.recoTree.Electron = "calibratedElectrons" #FIXME selectedPatElectrons" process.recoTree.Jet = "selectedPatJets" process.recoTree.metLabel = "patMETs" process.recoTree.PileUpRD = PileUpRun2012 process.recoTree.PileUpMC = Summer12S10
'keep *_selectedPatJets_*_*', # 'keep *_selectedPatJetsPFlow_*_*', # 'keep *_selectedPatJetsCHSPFlow_*_*', 'keep *_selectedPatJetsPFlowNoChs_*_*', 'keep *_selectedPatJetsPFlowChs_*_*', 'keep *_cleanPatJets_*_*', # 'keep *_cleanPatJetsPFlow_*_*', # 'keep *_cleanPatJetsCHSPFlow_*_*', 'keep *_cleanPatJetsPFlowNoChs_*_*', 'keep *_cleanPatJetsPFlowChs_*_*', 'keep *_ak4PFJets_*_*', 'keep *_ak4PFJetsCHS_*_*', # 'keep *_offlinePrimaryVertices_*_*', # 'keep CorrMETData_*_*_*', # Keep anything produced by metFilter 'keep *_metFilter_*_*', # *patEventContent) ) # load the coreTools of PAT from PhysicsTools.PatAlgos.tools.coreTools import removeMCMatching removeMCMatching(process, ['All'], 'PFlowNoChs', ['out']) removeMCMatching(process, ['All'], 'PFlowChs', ['out']) # storage process.outpath = cms.EndPath(process.out) #dummy
def addInvHiggsProcess(process, iRunOnData=True, iData="PromptC2", iHLTFilter="MET", iMCSignal=False, iFile='/store/data/Run2012C/MET/AOD/PromptReco-v2/000/203/002/04BCEC26-AA02-E211-A81D-003048CF99BA.root', iMaxEvent=100): ###-------------------------------------------------------------- ### Load PAT, because it insists on defining the process for you #from PhysicsTools.PatAlgos.patTemplate_cfg import * ###-------------------------------------------------------------- ###-------------------------------------------------------------- ### Input process.maxEvents.input = iMaxEvent process.source.fileNames = [iFile] ###-------------------------------------------------------------- ###-------------------------------------------------------------- ### GlobalTag if iRunOnData == True: if (iData.find("Jul13")==0): process.GlobalTag.globaltag = "FT_53_V6C_AN3::All" elif (iData.find("Aug06")==0): process.GlobalTag.globaltag = "FT_53_V6C_AN3::All" elif (iData.find("Aug24")==0): process.GlobalTag.globaltag = "FT53_V10A_AN3::All" elif (iData.find("PromptC2")==0): process.GlobalTag.globaltag = "GR_P_V42_AN3::All" elif (iData.find("PromptD")==0): process.GlobalTag.globaltag = "GR_P_V42_AN3::All" elif (iData.find("Dec11")==0): #Run201191 process.GlobalTag.globaltag = "FT_P_V42C_AN3::All" else: process.GlobalTag.globaltag = "GR_P_V42_AN3::All" else: process.GlobalTag.globaltag = "START53_V7G::All" ###-------------------------------------------------------------- ###-------------------------------------------------------------- ### Logger process.load("FWCore.MessageService.MessageLogger_cfi") process.load("FWCore.MessageLogger.MessageLogger_cfi") process.MessageLogger.cerr.FwkReport = cms.untracked.PSet( reportEvery = cms.untracked.int32(2000), limit = cms.untracked.int32(10000000) ) ###-------------------------------------------------------------- ###-------------------------------------------------------------- ### HLT Trigger(s) # If it's MC signal, no trigger will be applied if iRunOnData == False and iMCSignal == True: iHLTFilter = "NoTrig" # Load hltHighLevel process.load('HLTrigger.HLTfilters.hltHighLevel_cfi') process.hltHighLevel.TriggerResultsTag = cms.InputTag("TriggerResults","","HLT") process.hltHighLevel.throw = cms.bool(False) # Tolerate if triggers not available process.hltHighLevel.andOr = cms.bool(True) # True = OR, False = AND if (iHLTFilter.find("MET")==0): process.hltHighLevel.HLTPaths = cms.vstring( "HLT_DiPFJet40_PFMETnoMu65_MJJ600VBF_LeadingJets_v*", "HLT_DiPFJet40_PFMETnoMu65_MJJ800VBF_AllJets_v*" ) elif (iHLTFilter.find("SingleMu")==0): process.hltHighLevel.HLTPaths = cms.vstring("HLT_IsoMu24_eta2p1_v*","HLT_Mu40_eta2p1_v*") elif (iHLTFilter.find("DoubleMu")==0): process.hltHighLevel.HLTPaths = cms.vstring("HLT_Mu17_Mu8_v*") elif (iHLTFilter.find("SingleElectron")==0): process.hltHighLevel.HLTPaths = cms.vstring("HLT_Ele27_WP80_v*") elif (iHLTFilter.find("DoubleElectron")==0): process.hltHighLevel.HLTPaths = cms.vstring("HLT_Ele17_CaloIdT_CaloIsoVL_TrkIdVL_TrkIsoVL_Ele8_CaloIdT_CaloIsoVL_TrkIdVL_TrkIsoVL_v*") elif (iHLTFilter.find("NoTrig")==0): process.hltHighLevel.HLTPaths = cms.vstring("*") else: process.hltHighLevel.HLTPaths = cms.vstring( "HLT_DiPFJet40_PFMETnoMu65_MJJ600VBF_LeadingJets_v*", "HLT_DiPFJet40_PFMETnoMu65_MJJ800VBF_AllJets_v*" ) ###-------------------------------------------------------------- ###-------------------------------------------------------------- print "-----------------------------------------------" print "INVISIBLE HIGGS: Ntuple V10" print "-----------------------------------------------" print "RunOnData = ", iRunOnData if iRunOnData == True: print "Dataset = ", iData else: if iMCSignal == True: print "Dataset = MC Signal" else: print "Dataset = MC Background" print "GlobalTag = ", process.GlobalTag.globaltag print "Trigger = ", process.hltHighLevel.HLTPaths print "Sample input file = ", iFile print "Max events = ", iMaxEvent print "-----------------------------------------------" ###-------------------------------------------------------------- ###-------------------------------------------------------------- ### Basic filters # Track quality filter process.noscraping = cms.EDFilter( "FilterOutScraping", applyfilter = cms.untracked.bool(True), debugOn = cms.untracked.bool(False), numtrack = cms.untracked.uint32(10), thresh = cms.untracked.double(0.25) ) # Require a good vertex process.primaryVertexFilter = cms.EDFilter( "VertexSelector", src = cms.InputTag("offlinePrimaryVertices"), cut = cms.string("!isFake && ndof > 4 && abs(z) <= 24 && position.Rho <= 2"), filter = cms.bool(True) ) ###-------------------------------------------------------------- ###-------------------------------------------------------------- ### MET Filters # The iso-based HBHE noise filter process.load('CommonTools.RecoAlgos.HBHENoiseFilter_cfi') # The CSC beam halo tight filter process.load('RecoMET.METAnalyzers.CSCHaloFilter_cfi') # The HCAL laser filter process.load("RecoMET.METFilters.hcalLaserEventFilter_cfi") process.load("EventFilter.HcalRawToDigi.hcallasereventfilter2012_cff") process.hcallasereventfilter2012.eventFileName = cms.string('HCALLaser2012AllDatasets.txt.gz') # The ECAL dead cell trigger primitive filter process.load('RecoMET.METFilters.EcalDeadCellTriggerPrimitiveFilter_cfi') # The EE bad SuperCrystal filter process.load('RecoMET.METFilters.eeBadScFilter_cfi') # The ECAL laser correction filter process.load('RecoMET.METFilters.ecalLaserCorrFilter_cfi') # The Good vertices collection needed by the tracking failure filter process.goodVertices = cms.EDFilter( "VertexSelector", filter = cms.bool(False), src = cms.InputTag("offlinePrimaryVertices"), cut = cms.string("!isFake && ndof > 4 && abs(z) <= 24 && position.rho < 2") ) # The tracking failure filter process.load('RecoMET.METFilters.trackingFailureFilter_cfi') # The tracking POG filters process.load('RecoMET.METFilters.trackingPOGFilters_cff') ###-------------------------------------------------------------- ###-------------------------------------------------------------- ### customise PAT process.load('JetMETCorrections.Configuration.DefaultJEC_cff') from PhysicsTools.PatAlgos.tools.coreTools import removeMCMatching,runOnData if iRunOnData == True: removeMCMatching(process, ['All']) runOnData(process) # Add the PF MET from PhysicsTools.PatAlgos.tools.metTools import addPfMET addPfMET(process, 'PF') # Switch to PF jets from PhysicsTools.PatAlgos.tools.jetTools import switchJetCollection if iRunOnData == True: switchJetCollection(process, cms.InputTag('ak5PFJets'), doJTA = True, doBTagging = True, jetCorrLabel = ('AK5PF', ['L1FastJet', 'L2Relative', 'L3Absolute', 'L2L3Residual']), doType1MET = True, doJetID = False, jetIdLabel = "ak5" ) else: switchJetCollection(process, cms.InputTag('ak5PFJets'), doJTA = True, doBTagging = True, jetCorrLabel = ('AK5PF', ['L1FastJet', 'L2Relative', 'L3Absolute']), doType1MET = True, genJetCollection = cms.InputTag("ak5GenJetsNoNu"), doJetID = False, jetIdLabel = "ak5" ) from PhysicsTools.PatAlgos.tools.pfTools import usePFIso usePFIso(process) process.patMuons.isoDeposits = cms.PSet() process.patMuons.isolationValues = cms.PSet() process.patElectrons.isolationValues = cms.PSet( pfChargedHadrons = cms.InputTag("elPFIsoValueCharged03PFIdPFIso"), pfChargedAll = cms.InputTag("elPFIsoValueChargedAll03PFIdPFIso"), pfPUChargedHadrons = cms.InputTag("elPFIsoValuePU03PFIdPFIso"), pfNeutralHadrons = cms.InputTag("elPFIsoValueNeutral03PFIdPFIso"), pfPhotons = cms.InputTag("elPFIsoValueGamma03PFIdPFIso") ) process.patElectrons.isolationValuesNoPFId = cms.PSet( pfChargedHadrons = cms.InputTag("elPFIsoValueCharged03NoPFIdPFIso"), pfChargedAll = cms.InputTag("elPFIsoValueChargedAll03NoPFIdPFIso"), pfPUChargedHadrons = cms.InputTag("elPFIsoValuePU03NoPFIdPFIso"), pfNeutralHadrons = cms.InputTag("elPFIsoValueNeutral03NoPFIdPFIso"), pfPhotons = cms.InputTag("elPFIsoValueGamma03NoPFIdPFIso") ) process.patDefaultSequence.replace(process.patElectrons,process.eleIsoSequence+process.patElectrons) process.cleanPatTaus.preselection = cms.string('tauID("decayModeFinding") > 0.5 & tauID("byLooseCombinedIsolationDeltaBetaCorr") > 0.5') ###-------------------------------------------------------------- ###-------------------------------------------------------------- ### Object (pre) selection # Jet selection process.selectedPatJets.cut = cms.string("pt>10. && abs(eta)<5.") # Remove overlaps ??? # process.cleanPatJets.finalCut = "!hasOverlaps('electrons') && !hasOverlaps('muons')" # Apply loose PF jet ID from PhysicsTools.SelectorUtils.pfJetIDSelector_cfi import pfJetIDSelector process.goodPatJets = cms.EDFilter("PFJetIDSelectionFunctorFilter", filterParams = pfJetIDSelector.clone(), src = cms.InputTag("selectedPatJets"), filter = cms.bool(True) ) process.selectedPatMuons.cut = cms.string("isGlobalMuon && pt>10. && abs(eta)<2.5") process.selectedPatElectrons.cut = cms.string("pt>10. && abs(eta)<2.5") ###-------------------------------------------------------------- ###-------------------------------------------------------------- ### Load the PU JetID sequence if iRunOnData == True: process.load("CMGTools.External.pujetidsequence_cff") process.puJetMva.jets = cms.InputTag("goodPatJets") process.puJetId.jets = cms.InputTag("goodPatJets") else: process.load("CMGTools.External.pujetidsequence_cff") process.puJetMva.jets = cms.InputTag("goodPatJets") process.puJetId.jets = cms.InputTag("goodPatJets") process.puJetMvaSmeared = process.puJetMva.clone() process.puJetIdSmeared = process.puJetId.clone() process.puJetMvaResUp = process.puJetMva.clone() process.puJetIdResUp = process.puJetId.clone() process.puJetMvaResDown = process.puJetMva.clone() process.puJetIdResDown = process.puJetId.clone() process.puJetMvaEnUp = process.puJetMva.clone() process.puJetIdEnUp = process.puJetId.clone() process.puJetMvaEnDown = process.puJetMva.clone() process.puJetIdEnDown = process.puJetId.clone() process.puJetIdSmeared.jets = cms.InputTag("smearedGoodPatJetsWithGaussian") process.puJetMvaSmeared.jetids = cms.InputTag("puJetIdSmeared") process.puJetMvaSmeared.jets = cms.InputTag("smearedGoodPatJetsWithGaussian") process.puJetIdResUp.jets = cms.InputTag("smearedGoodPatJetsResUpWithGaussian") process.puJetMvaResUp.jetids = cms.InputTag("puJetIdResUp") process.puJetMvaResUp.jets = cms.InputTag("smearedGoodPatJetsResUpWithGaussian") process.puJetIdResDown.jets = cms.InputTag("smearedGoodPatJetsResDownWithGaussian") process.puJetMvaResDown.jetids = cms.InputTag("puJetIdResDown") process.puJetMvaResDown.jets = cms.InputTag("smearedGoodPatJetsResDownWithGaussian") process.puJetIdEnUp.jets = cms.InputTag("shiftedGoodPatJetsEnUpForCorrMEtWithGaussian") process.puJetMvaEnUp.jetids = cms.InputTag("puJetIdEnUp") process.puJetMvaEnUp.jets = cms.InputTag("shiftedGoodPatJetsEnUpForCorrMEtWithGaussian") process.puJetIdEnDown.jets = cms.InputTag("shiftedGoodPatJetsEnDownForCorrMEtWithGaussian") process.puJetMvaEnDown.jetids = cms.InputTag("puJetIdEnDown") process.puJetMvaEnDown.jets = cms.InputTag("shiftedGoodPatJetsEnDownForCorrMEtWithGaussian") # For jet without Gaussian smearing collection process.puJetMvaSmearedNoGaussian = process.puJetMva.clone() process.puJetIdSmearedNoGaussian = process.puJetId.clone() process.puJetMvaResUpNoGaussian = process.puJetMva.clone() process.puJetIdResUpNoGaussian = process.puJetId.clone() process.puJetMvaResDownNoGaussian = process.puJetMva.clone() process.puJetIdResDownNoGaussian = process.puJetId.clone() process.puJetMvaEnUpNoGaussian = process.puJetMva.clone() process.puJetIdEnUpNoGaussian = process.puJetId.clone() process.puJetMvaEnDownNoGaussian = process.puJetMva.clone() process.puJetIdEnDownNoGaussian = process.puJetId.clone() process.puJetIdSmearedNoGaussian.jets = cms.InputTag("smearedGoodPatJetsNoGaussian") process.puJetMvaSmearedNoGaussian.jetids = cms.InputTag("puJetIdSmearedNoGaussian") process.puJetMvaSmearedNoGaussian.jets = cms.InputTag("smearedGoodPatJetsNoGaussian") process.puJetIdResUpNoGaussian.jets = cms.InputTag("smearedGoodPatJetsResUpNoGaussian") process.puJetMvaResUpNoGaussian.jetids = cms.InputTag("puJetIdResUpNoGaussian") process.puJetMvaResUpNoGaussian.jets = cms.InputTag("smearedGoodPatJetsResUpNoGaussian") process.puJetIdResDownNoGaussian.jets = cms.InputTag("smearedGoodPatJetsResDownNoGaussian") process.puJetMvaResDownNoGaussian.jetids = cms.InputTag("puJetIdResDownNoGaussian") process.puJetMvaResDownNoGaussian.jets = cms.InputTag("smearedGoodPatJetsResDownNoGaussian") process.puJetIdEnUpNoGaussian.jets = cms.InputTag("shiftedGoodPatJetsEnUpForCorrMEtNoGaussian") process.puJetMvaEnUpNoGaussian.jetids = cms.InputTag("puJetIdEnUpNoGaussian") process.puJetMvaEnUpNoGaussian.jets = cms.InputTag("shiftedGoodPatJetsEnUpForCorrMEtNoGaussian") process.puJetIdEnDownNoGaussian.jets = cms.InputTag("shiftedGoodPatJetsEnDownForCorrMEtNoGaussian") process.puJetMvaEnDownNoGaussian.jetids = cms.InputTag("puJetIdEnDownNoGaussian") process.puJetMvaEnDownNoGaussian.jets = cms.InputTag("shiftedGoodPatJetsEnDownForCorrMEtNoGaussian") ###-------------------------------------------------------------- ###-------------------------------------------------------------- ### MET # Apply type 0 MET corrections based on PFCandidate process.load("JetMETCorrections.Type1MET.pfMETCorrectionType0_cfi") process.pfType1CorrectedMet.applyType0Corrections = cms.bool(False) process.pfType1CorrectedMet.srcType1Corrections = cms.VInputTag( cms.InputTag('pfMETcorrType0'), cms.InputTag('pfJetMETcorr', 'type1') ) # Get loose ID/Iso muons and veto ID electrons process.load("InvisibleHiggs.Ntuple.PhysicsObjectCandidates_cff") # Get PFMET from runMEtUncertainties from PhysicsTools.PatUtils.tools.metUncertaintyTools import runMEtUncertainties process.load("JetMETCorrections.Type1MET.pfMETsysShiftCorrections_cfi") if iRunOnData == True: runMEtUncertainties(process, electronCollection = cms.InputTag('selectVetoElectrons'), photonCollection = '', muonCollection = 'selectLooseMuons', tauCollection = '', jetCollection = cms.InputTag('goodPatJets'), jetCorrLabel = 'L2L3Residual', doSmearJets = False, makeType1corrPFMEt = True, makeType1p2corrPFMEt = False, makePFMEtByMVA = False, makeNoPileUpPFMEt = False, doApplyType0corr = True, sysShiftCorrParameter = process.pfMEtSysShiftCorrParameters_2012runAvsNvtx_data, doApplySysShiftCorr = False, addToPatDefaultSequence = False, postfix = '' ) process.patPFJetMETtype1p2Corr.jetCorrLabel = cms.string('L2L3Residual') process.patPFJetMETtype2Corr.jetCorrLabel = cms.string('L2L3Residual') else: runMEtUncertainties(process, electronCollection = cms.InputTag('selectVetoElectrons'), photonCollection = '', muonCollection = 'selectLooseMuons', tauCollection = '', jetCollection = cms.InputTag('goodPatJets'), jetCorrLabel = 'L3Absolute', doSmearJets = True, makeType1corrPFMEt = True, makeType1p2corrPFMEt = False, makePFMEtByMVA = False, makeNoPileUpPFMEt = False, doApplyType0corr = True, sysShiftCorrParameter = process.pfMEtSysShiftCorrParameters_2012runAvsNvtx_mc, doApplySysShiftCorr = False, addToPatDefaultSequence = False, postfix = 'WithGaussian' ) runMEtUncertainties(process, electronCollection = cms.InputTag('selectVetoElectrons'), photonCollection = '', muonCollection = 'selectLooseMuons', tauCollection = '', jetCollection = cms.InputTag('goodPatJets'), jetCorrLabel = 'L3Absolute', doSmearJets = True, makeType1corrPFMEt = True, makeType1p2corrPFMEt = False, makePFMEtByMVA = False, makeNoPileUpPFMEt = False, doApplyType0corr = True, sysShiftCorrParameter = process.pfMEtSysShiftCorrParameters_2012runAvsNvtx_mc, doApplySysShiftCorr = False, addToPatDefaultSequence = False, postfix = 'NoGaussian' ) # Turn off gaussian smearing process.smearedGoodPatJetsNoGaussian.doGaussian = cms.int32(0) process.smearedGoodPatJetsResUpNoGaussian.doGaussian = cms.int32(0) process.smearedGoodPatJetsResDownNoGaussian.doGaussian = cms.int32(0) # Fix Type0 correction module process.patPFMETtype0Corr.correction.par3 = cms.double(0.909209) process.patPFMETtype0Corr.correction.par2 = cms.double(0.0303531) process.patPFMETtype0Corr.correction.par1 = cms.double(-0.703151) process.patPFMETtype0Corr.correction.par0 = cms.double(0.0) ###-------------------------------------------------------------- # PAT/ntuples one step # Z and W candidates process.load('InvisibleHiggs/Ntuple/WCandidates_cff') process.load('InvisibleHiggs/Ntuple/ZCandidates_cff') # Ntuple producer process.load('InvisibleHiggs/Ntuple/invHiggsInfo_cfi') if iRunOnData == False: # Jet/MET uncertainty process.invHiggsInfo.jetTag = cms.untracked.InputTag("smearedGoodPatJetsWithGaussian") process.invHiggsInfo.metTag = cms.untracked.InputTag("patType1CorrectedPFMetWithGaussian") process.invHiggsInfo.puJetMvaTag = cms.untracked.InputTag("puJetMvaSmeared", "fullDiscriminant") process.invHiggsInfo.puJetIdTag = cms.untracked.InputTag("puJetMvaSmeared", "fullId") # PU re-weighting process.invHiggsInfo.puMCFile = cms.untracked.string("PUHistS10.root") process.invHiggsInfo.puDataFile = cms.untracked.string("PUHistRun2012All_forV9.root") process.invHiggsInfo.puMCHist = cms.untracked.string("pileup") process.invHiggsInfo.puDataHist = cms.untracked.string("pileup") process.invHiggsInfo.mcPYTHIA = cms.untracked.bool(True) process.invHiggsInfo.trigCorrFile = cms.untracked.string("DataMCWeight_53X_v1.root") process.invHiggsInfo.leptCorrFile = cms.untracked.string("leptonWeights.root") # TTree output file process.load("CommonTools.UtilAlgos.TFileService_cfi") process.TFileService.fileName = cms.string('invHiggsInfo_MC.root') ###-------------------------------------------------------------- ###-------------------------------------------------------------- ### Tau # removeSpecificPATObjects( process, ['Taus'] ) # process.patDefaultSequence.remove( process.patTaus ) process.load("RecoTauTag.Configuration.RecoPFTauTag_cff") ###-------------------------------------------------------------- ###-------------------------------------------------------------- ### Trigger matching # from PhysicsTools.PatAlgos.tools.trigTools import * # process.metTriggerMatch = cms.EDProducer( # "PATTriggerMatcherDRLessByR" # match by DeltaR only, best match by DeltaR # , src = cms.InputTag( 'patMETs' ) # , matched = cms.InputTag( 'patTrigger' ) # default producer label as defined in PhysicsTools/PatAlgos/python/triggerLayer1/triggerProducer_cfi.py # , matchedCuts = cms.string( 'path( "HLT_MET100_v*" )' ) # , maxDPtRel = cms.double( 0.5 ) # , maxDeltaR = cms.double( 0.5 ) # , resolveAmbiguities = cms.bool( True ) # only one match per trigger object # , resolveByMatchQuality = cms.bool( True ) # take best match found per reco object: by DeltaR here (s. above) # ) # process.jetTriggerMatch = cms.EDProducer( # "PATTriggerMatcherDRLessByR" # match by DeltaR only, best match by DeltaR # , src = cms.InputTag( 'patJets' ) # , matched = cms.InputTag( 'patTrigger' ) # default producer label as defined in PhysicsTools/PatAlgos/python/triggerLayer1/triggerProducer_cfi.py # , matchedCuts = cms.string( 'path( "HLT_Jet30_v*" )' ) # , maxDPtRel = cms.double( 0.5 ) # , maxDeltaR = cms.double( 0.5 ) # , resolveAmbiguities = cms.bool( True ) # only one match per trigger object # , resolveByMatchQuality = cms.bool( True ) # take best match found per reco object: by DeltaR here (s. above) # ) # switchOnTriggerMatchEmbedding( process, [ 'metTriggerMatch', 'jetTriggerMatch' ] ) ###-------------------------------------------------------------- ###-------------------------------------------------------------- ### Paths process.p0 = cms.Path( process.HBHENoiseFilter ) process.p1 = cms.Path( process.CSCTightHaloFilter ) process.p2 = cms.Path( process.hcalLaserEventFilter ) process.p3 = cms.Path( process.EcalDeadCellTriggerPrimitiveFilter ) process.p4 = cms.Path( process.eeBadScFilter ) process.p5 = cms.Path( process.ecalLaserCorrFilter ) process.p6 = cms.Path( process.goodVertices * process.trackingFailureFilter ) process.p7 = cms.Path( process.trkPOGFilters ) process.p8 = cms.Path( process.hcallLaserEvent2012Filter ) if iRunOnData == True: process.p = cms.Path( # Trigger filter process.hltHighLevel * # Basic filters process.noscraping * process.primaryVertexFilter * # MET filters (Move to be flags) # MET Correction process.type0PFMEtCorrection * # Tau process.recoTauClassicHPSSequence * # Generate PAT process.pfParticleSelectionSequence * process.patDefaultSequence * process.goodPatJets * process.PhysicsObjectSequence * process.metUncertaintySequence * process.puJetIdSqeuence * process.WSequence * process.ZSequence * process.invHiggsInfo ) else: process.p = cms.Path( # Trigger filter process.hltHighLevel * # Basic filters process.noscraping * process.primaryVertexFilter * # MET filters (Move to be flags) # MET Correction process.type0PFMEtCorrection * # Tau process.recoTauClassicHPSSequence * # Generate PAT process.pfParticleSelectionSequence * process.genParticlesForJetsNoNu * process.ak5GenJetsNoNu * process.patDefaultSequence * process.goodPatJets * process.PhysicsObjectSequence * process.metUncertaintySequenceWithGaussian * process.metUncertaintySequenceNoGaussian * process.puJetIdSqeuence * process.puJetIdSmeared * process.puJetMvaSmeared * process.puJetIdResUp * process.puJetMvaResUp * process.puJetIdResDown * process.puJetMvaResDown * process.puJetIdEnUp * process.puJetMvaEnUp * process.puJetIdEnDown * process.puJetMvaEnDown * process.puJetIdSmearedNoGaussian * process.puJetMvaSmearedNoGaussian * process.puJetIdResUpNoGaussian * process.puJetMvaResUpNoGaussian * process.puJetIdResDownNoGaussian * process.puJetMvaResDownNoGaussian * process.puJetIdEnUpNoGaussian * process.puJetMvaEnUpNoGaussian * process.puJetIdEnDownNoGaussian * process.puJetMvaEnDownNoGaussian * process.WSequence * process.ZSequence * process.invHiggsInfo ) ###-------------------------------------------------------------- ###-------------------------------------------------------------- ### Output process.out.outputCommands += [ # trigger results 'keep edmTriggerResults_*_*_*' ,'keep *_hltTriggerSummaryAOD_*_*' # L1 ,'keep *_l1extraParticles_MET_RECO' ,'keep *_l1extraParticles_MHT_RECO' # good jets ,'keep *_goodPatJets_*_*' # PU jet ID ,'keep *_puJetId*_*_*' ,'keep *_puJetMva*_*_*' # vertices ,'keep *_offlineBeamSpot_*_*' ,'keep *_offlinePrimaryVertices*_*_*' ,'keep *_goodOfflinePrimaryVertices*_*_*' ,'keep double_*_rho_*' ] if iRunOnData == False: process.out.outputCommands += ['keep GenEventInfoProduct_*_*_*' ,'keep recoGenParticles_*_*_*' ,'keep GenMETs_*_*_*' ,'keep *_addPileupInfo_*_*' ,'keep LHEEventProduct_*_*_*' ,'keep ak5GenJets_*_*_*' ,'keep ak5GenJetsNoNu_*_*_*' ] process.out.fileName = 'patTuple.root' del(process.out) del(process.outpath)