Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:33:26

0001 from __future__ import print_function
0002 # The following comments couldn't be translated into the new config version:
0003 #! /bin/env cmsRun
0004 
0005 import FWCore.ParameterSet.Config as cms
0006 process = cms.Process("validation")
0007 
0008 # load the full reconstraction configuration, to make sure we're getting all needed dependencies
0009 process.load("Configuration.StandardSequences.MagneticField_cff")
0010 process.load("Configuration.StandardSequences.GeometryRecoDB_cff")
0011 process.load("Configuration.StandardSequences.FrontierConditions_GlobalTag_cff")
0012 process.load("Configuration.StandardSequences.Reconstruction_cff")
0013 
0014 whichJets  = "ak4PFJetsCHS"
0015 applyJEC = True
0016 corrLabel = 'ak4PFCHS'
0017 from Configuration.AlCa.GlobalTag import GlobalTag
0018 tag = GlobalTag(process.GlobalTag, 'auto:run2_mc', '')
0019 useTrigger = False
0020 triggerPath = "HLT_PFJet80_v*"
0021 runOnMC    = True
0022 #Flavour plots for MC: "all" = plots for all jets ; "dusg" = plots for d, u, s, dus, g independently ; not mandatory and any combinations are possible                                     
0023 #b, c, light (dusg), non-identified (NI), PU jets plots are always produced
0024 flavPlots = "allbcldusg"
0025 
0026 ###prints###
0027 print("jet collcetion asked : ", whichJets)
0028 print("JEC applied?", applyJEC, ", correction:", corrLabel) 
0029 print("trigger will be used ? : ", useTrigger, ", Trigger paths:", triggerPath)
0030 print("is it MC ? : ", runOnMC, ", Flavours:", flavPlots)
0031 print("Global Tag : ", tag.globaltag)
0032 ############
0033 
0034 process.load("DQMServices.Components.DQMEnvironment_cfi")
0035 process.load("DQMServices.Core.DQM_cfg")
0036 
0037 process.load("JetMETCorrections.Configuration.JetCorrectors_cff")
0038 process.load("CommonTools.ParticleFlow.goodOfflinePrimaryVertices_cfi")
0039 process.load("RecoJets.JetAssociationProducers.ak4JTA_cff")
0040 process.load("RecoBTag.Configuration.RecoBTag_cff")
0041 process.load("PhysicsTools.JetMCAlgos.HadronAndPartonSelector_cfi")
0042 process.load("PhysicsTools.JetMCAlgos.AK4PFJetsMCFlavourInfos_cfi")
0043 process.load("PhysicsTools.JetMCAlgos.CaloJetsMCFlavour_cfi")
0044 process.JECseq = cms.Sequence(getattr(process,corrLabel+"L1FastL2L3CorrectorChain"))
0045 
0046 newjetID=cms.InputTag(whichJets)
0047 process.ak4JetFlavourInfos.jets = newjetID
0048 process.ak4JetFlavourInfos.hadronFlavourHasPriority = cms.bool(True)
0049 if not "ak4PFJetsCHS" in whichJets:
0050     process.ak4JetTracksAssociatorAtVertexPF.jets = newjetID
0051     process.pfImpactParameterTagInfos.jets        = newjetID
0052     process.softPFMuonsTagInfos.jets              = newjetID
0053     process.softPFElectronsTagInfos.jets          = newjetID
0054     process.patJetGenJetMatch.src                 = newjetID
0055 
0056 process.btagging = cms.Sequence(process.legacyBTagging + process.pfBTagging)
0057 process.btagSequence = cms.Sequence(
0058     process.ak4JetTracksAssociatorAtVertexPF *
0059     process.btagging
0060     )
0061 process.jetSequences = cms.Sequence(process.goodOfflinePrimaryVertices * process.btagSequence)
0062 
0063 ###
0064 print("inputTag : ", process.ak4JetTracksAssociatorAtVertexPF.jets)
0065 ###
0066 
0067 process.load("Validation.RecoB.bTagAnalysis_firststep_cfi")
0068 if runOnMC:
0069     process.flavourSeq = cms.Sequence(
0070         process.selectedHadronsAndPartons *
0071         process.ak4JetFlavourInfos
0072         )
0073     process.bTagValidationFirstStep.jetMCSrc = 'ak4JetFlavourInfos'
0074     process.bTagValidationFirstStep.applyPtHatWeight = False
0075     process.bTagValidationFirstStep.doJetID = True
0076     process.bTagValidationFirstStep.doJEC = applyJEC
0077     process.bTagValidation.JECsourceMC = cms.InputTag(corrLabel+"L1FastL2L3Corrector")
0078     process.bTagValidationFirstStep.flavPlots = flavPlots
0079     #process.bTagValidationFirstStep.ptRecJetMin = cms.double(20.)
0080     process.bTagValidationFirstStep.genJetsMatched = cms.InputTag("patJetGenJetMatch")
0081     process.bTagValidationFirstStep.doPUid = cms.bool(True)
0082     process.ak4GenJetsForPUid = cms.EDFilter("GenJetSelector",
0083                                              src = cms.InputTag("ak4GenJets"),
0084                                              cut = cms.string('pt > 8.'),
0085                                              filter = cms.bool(False)
0086                                              )
0087     process.load("PhysicsTools.PatAlgos.mcMatchLayer0.jetMatch_cfi")
0088     process.patJetGenJetMatch.matched = cms.InputTag("ak4GenJetsForPUid")
0089     process.patJetGenJetMatch.maxDeltaR = cms.double(0.25)
0090     process.patJetGenJetMatch.resolveAmbiguities = cms.bool(True)
0091 else:
0092     process.bTagValidationFirstStepData.doJEC = applyJEC
0093     process.bTagAnalysis.JECsourceData = cms.InputTag(corrLabel+"L1FastL2L3ResidualCorrector")
0094     process.JECseq *= (getattr(process,corrLabel+"ResidualCorrector") * getattr(process,corrLabel+"L1FastL2L3ResidualCorrector"))
0095 
0096 process.maxEvents = cms.untracked.PSet(
0097     input = cms.untracked.int32(10)
0098 )
0099 process.source = cms.Source("PoolSource",
0100     fileNames = cms.untracked.vstring()
0101 )
0102 
0103 process.EDM = cms.OutputModule("DQMRootOutputModule",
0104                                outputCommands = cms.untracked.vstring('drop *',
0105                                                                       "keep *_MEtoEDMConverter_*_*"),
0106                                fileName = cms.untracked.string('MEtoEDMConverter.root')
0107                                )
0108 from HLTrigger.HLTfilters.hltHighLevel_cfi import *
0109 if useTrigger: 
0110     process.bTagHLT  = hltHighLevel.clone(TriggerResultsTag = "TriggerResults::HLT", HLTPaths = ["HLT_PFJet40_v*"])
0111     process.bTagHLT.HLTPaths = [triggerPath]
0112 
0113 if runOnMC:
0114     process.dqmSeq = cms.Sequence(process.ak4GenJetsForPUid * process.patJetGenJetMatch * process.flavourSeq * process.bTagValidationFirstStep)
0115 else:
0116     process.dqmSeq = cms.Sequence(process.bTagValidationFirstStepData)
0117 
0118 if useTrigger:
0119     process.plots = cms.Path(process.bTagHLT * process.JECseq * process.jetSequences * process.dqmSeq)
0120 else:
0121     process.plots = cms.Path(process.JECseq * process.jetSequences * process.dqmSeq)
0122     
0123 process.outpath = cms.EndPath(process.EDM)
0124 
0125 process.dqmEnv.subSystemFolder = 'BTAG'
0126 process.dqmSaver.producer = 'DQM'
0127 process.dqmSaver.workflow = '/POG/BTAG/BJET'
0128 process.dqmSaver.convention = 'Offline'
0129 process.dqmSaver.saveByRun = cms.untracked.int32(-1)
0130 process.dqmSaver.saveAtJobEnd =cms.untracked.bool(True) 
0131 process.dqmSaver.forceRunNumber = cms.untracked.int32(1)
0132 process.PoolSource.fileNames = [
0133 
0134 ]
0135 
0136 #keep the logging output to a nice level
0137 process.load("FWCore.MessageLogger.MessageLogger_cfi")
0138 process.MessageLogger.cerr.FwkReport.reportEvery = 100
0139 
0140 process.GlobalTag = tag
0141