Back to home page

Project CMSSW displayed by LXR

 
 

    


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

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 import FWCore.ParameterSet.VarParsing as VarParsing
0009 options = VarParsing.VarParsing ('analysis')
0010 
0011 # load the full reconstraction configuration, to make sure we're getting all needed dependencies
0012 process.load("Configuration.StandardSequences.MagneticField_cff")
0013 process.load("Configuration.StandardSequences.GeometryRecoDB_cff")
0014 process.load("Configuration.StandardSequences.FrontierConditions_GlobalTag_cff")
0015 process.load("Configuration.StandardSequences.Reconstruction_cff")
0016 
0017 options.register ('jets',
0018                   "ak4PFJetsCHS", # default value, examples : "ak4PFJets", "ak4PFJetsCHS"
0019                   VarParsing.VarParsing.multiplicity.singleton,
0020                   VarParsing.VarParsing.varType.string,  
0021                   "jet collection to use")
0022 
0023 options.parseArguments()
0024 
0025 whichJets  = options.jets 
0026 applyJEC = True
0027 corrLabel = "ak4PFCHS"
0028 from Configuration.AlCa.GlobalTag import GlobalTag
0029 tag = GlobalTag(process.GlobalTag, 'auto:run2_mc', '')
0030 useTrigger = False
0031 triggerPath = "HLT_PFJet80_v*"
0032 runOnMC    = True
0033 #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                                     
0034 #b, c, light (dusg), non-identified (NI), PU jets plots are always produced
0035 flavPlots = "allbcldusg"
0036 
0037 ###prints###
0038 print("jet collcetion asked : ", whichJets)
0039 print("JEC applied?", applyJEC, ", correction:", corrLabel) 
0040 print("trigger will be used ? : ", useTrigger, ", Trigger paths:", triggerPath)
0041 print("is it MC ? : ", runOnMC, ", Flavours:", flavPlots)
0042 print("Global Tag : ", tag.globaltag)
0043 ############
0044 
0045 process.load("DQMServices.Components.DQMEnvironment_cfi")
0046 process.load("DQMServices.Core.DQM_cfg")
0047 
0048 process.load("JetMETCorrections.Configuration.JetCorrectors_cff")
0049 process.load("CommonTools.ParticleFlow.goodOfflinePrimaryVertices_cfi")
0050 process.load("RecoJets.JetAssociationProducers.ak4JTA_cff")
0051 process.load("RecoBTag.Configuration.RecoBTag_cff")
0052 process.load("PhysicsTools.JetMCAlgos.HadronAndPartonSelector_cfi")
0053 process.load("PhysicsTools.JetMCAlgos.AK4PFJetsMCFlavourInfos_cfi")
0054 process.load("PhysicsTools.JetMCAlgos.CaloJetsMCFlavour_cfi")
0055 process.load("PhysicsTools.PatAlgos.mcMatchLayer0.jetMatch_cfi")
0056 process.JECseq = cms.Sequence(getattr(process,corrLabel+"L1FastL2L3CorrectorChain"))
0057 
0058 newjetID=cms.InputTag(whichJets)
0059 process.ak4JetFlavourInfos.jets               = newjetID
0060 process.ak4JetFlavourInfos.hadronFlavourHasPriority = cms.bool(True)
0061 process.AK4byRef.jets                         = newjetID
0062 if not "ak4PFJetsCHS" in whichJets:
0063     process.ak4JetTracksAssociatorAtVertexPF.jets = newjetID
0064     process.pfImpactParameterTagInfos.jets        = newjetID
0065     process.softPFMuonsTagInfos.jets              = newjetID
0066     process.softPFElectronsTagInfos.jets          = newjetID
0067     process.patJetGenJetMatch.src                 = newjetID
0068 
0069 process.btagSequence = cms.Sequence(
0070     process.ak4JetTracksAssociatorAtVertexPF *
0071     process.btagging
0072     )
0073 process.jetSequences = cms.Sequence(process.goodOfflinePrimaryVertices * process.btagSequence)
0074 
0075 ###
0076 print("inputTag : ", process.ak4JetTracksAssociatorAtVertexPF.jets)
0077 ###
0078 
0079 if runOnMC:
0080     process.flavourSeq = cms.Sequence(
0081         process.selectedHadronsAndPartons *
0082         process.ak4JetFlavourInfos
0083         )
0084     process.load("Validation.RecoB.bTagAnalysis_cfi")
0085     process.bTagValidation.jetMCSrc = 'ak4JetFlavourInfos'
0086     if "Calo" in whichJets:
0087         process.bTagValidation.caloJetMCSrc = 'AK4byValAlgo'
0088         process.bTagValidation.useOldFlavourTool = True
0089         process.flavourSeq = cms.Sequence(
0090             process.myPartons *
0091             process.AK4Flavour
0092             )
0093     process.bTagValidation.applyPtHatWeight = False
0094     process.bTagValidation.doJetID = True
0095     process.bTagValidation.doJEC = applyJEC
0096     process.bTagValidation.JECsourceMC = cms.InputTag(corrLabel+"L1FastL2L3Corrector")
0097     process.bTagValidation.flavPlots = flavPlots
0098     process.bTagHarvestMC.flavPlots = flavPlots
0099     #process.bTagValidation.ptRecJetMin = cms.double(20.)
0100     process.bTagValidation.genJetsMatched = cms.InputTag("patJetGenJetMatch")
0101     process.bTagValidation.doPUid = cms.bool(True)
0102     process.ak4GenJetsForPUid = cms.EDFilter("GenJetSelector",
0103                                              src = cms.InputTag("ak4GenJets"),
0104                                              cut = cms.string('pt > 8.'),
0105                                              filter = cms.bool(False)
0106                                              )
0107     process.patJetGenJetMatch.matched = cms.InputTag("ak4GenJetsForPUid")
0108     process.patJetGenJetMatch.maxDeltaR = cms.double(0.25)
0109     process.patJetGenJetMatch.resolveAmbiguities = cms.bool(True)
0110 else:
0111     process.load("DQMOffline.RecoB.bTagAnalysisData_cfi")
0112     process.bTagAnalysis.doJEC = applyJEC
0113     process.bTagAnalysis.JECsourceData = cms.InputTag(corrLabel+"L1FastL2L3ResidualCorrector")
0114     process.JECseq *= (getattr(process,corrLabel+"ResidualCorrector") * getattr(process,corrLabel+"L1FastL2L3ResidualCorrector"))
0115 
0116 process.maxEvents = cms.untracked.PSet(
0117     input = cms.untracked.int32(-1)
0118 )
0119 process.source = cms.Source("PoolSource",
0120     fileNames = cms.untracked.vstring()
0121 )
0122 
0123 from HLTrigger.HLTfilters.hltHighLevel_cfi import *
0124 if useTrigger: 
0125     process.bTagHLT  = hltHighLevel.clone(TriggerResultsTag = "TriggerResults::HLT", HLTPaths = ["HLT_PFJet40_v*"])
0126     process.bTagHLT.HLTPaths = [triggerPath]
0127 
0128 if runOnMC:
0129     process.dqmSeq = cms.Sequence(process.ak4GenJetsForPUid * process.patJetGenJetMatch * process.flavourSeq * process.bTagValidation * process.bTagHarvestMC * process.dqmSaver)
0130 else:
0131     process.dqmSeq = cms.Sequence(process.bTagAnalysis * process.bTagHarvest * process.dqmSaver)
0132 
0133 if useTrigger:
0134     process.plots = cms.Path(process.bTagHLT * process.JECseq * process.jetSequences * process.dqmSeq)
0135 else:
0136     process.plots = cms.Path(process.JECseq * process.jetSequences * process.dqmSeq)
0137     
0138 process.dqmEnv.subSystemFolder = 'BTAG'
0139 process.dqmSaver.producer = 'DQM'
0140 process.dqmSaver.workflow = '/POG/BTAG/BJET'
0141 process.dqmSaver.convention = 'Offline'
0142 process.dqmSaver.saveByRun = cms.untracked.int32(-1)
0143 process.dqmSaver.saveAtJobEnd =cms.untracked.bool(True) 
0144 process.dqmSaver.forceRunNumber = cms.untracked.int32(1)
0145 process.PoolSource.fileNames = [
0146 
0147 ]
0148 
0149 #keep the logging output to a nice level
0150 process.load("FWCore.MessageLogger.MessageLogger_cfi")
0151 process.MessageLogger.cerr.FwkReport.reportEvery = 100
0152 
0153 process.GlobalTag = tag
0154