Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:20:49

0001 from __future__ import print_function
0002 import FWCore.ParameterSet.Config as cms
0003 from DQMServices.Core.DQMEDHarvester import DQMEDHarvester
0004 process = cms.Process("HLTBTAG")
0005 
0006 from PhysicsTools.PatAlgos.tools.coreTools import * 
0007 process.load('FWCore.MessageService.MessageLogger_cfi')
0008 process.load("Configuration.StandardSequences.GeometryRecoDB_cff")
0009 process.load('Configuration.StandardSequences.Services_cff')
0010 process.load("DQMServices.Components.EDMtoMEConverter_cff")
0011 process.load("L1TriggerConfig.L1GtConfigProducers.L1GtConfig_cff")
0012 
0013 #load hltJetMCTools sequence for the jet/partons matching
0014 process.load("HLTriggerOffline.Btag.hltBtagJetMCTools_cff")
0015 
0016 #read config.ini
0017 from HLTriggerOffline.Btag.readConfig import *
0018 fileini = fileINI("config.ini")
0019 fileini.read()
0020 
0021 #print read variables
0022 print()
0023 print("Reading ", fileini.fileName)
0024 print()
0025 print("maxEvents = ",fileini.maxEvents)
0026 print("CMSSWVER = ",fileini.CMSSWVER)
0027 print("processname = ",fileini.processname)
0028 print("jets (for matching) = ",fileini.jets)
0029 print("files = ",fileini.files)
0030 print("btag_modules ",fileini.btag_modules)
0031 print("btag_pathes ",fileini.btag_pathes)
0032 print("vertex_modules ",fileini.vertex_modules)
0033 print("vertex_pathes ",fileini.vertex_pathes)
0034 print()
0035 
0036 triggerFilter = []
0037 triggerFilter.extend(fileini.vertex_pathes)
0038 triggerFilter.extend(fileini.btag_pathes)
0039 triggerFilter = list(set(triggerFilter))
0040 triggerString = ""
0041 
0042 for i in range(len(triggerFilter)):
0043     if i is not 0:
0044         triggerString += " OR "
0045     
0046     triggerString +=  triggerFilter[i] + "*"
0047 
0048 print("triggerString : ",triggerString)
0049 
0050 #denominator trigger
0051 process.hltBtagTriggerSelection = cms.EDFilter( "TriggerResultsFilter",
0052     triggerConditions = cms.vstring(
0053       triggerString),
0054     hltResults = cms.InputTag( "TriggerResults", "", fileini.processname ),
0055     l1tResults = cms.InputTag( "" ),
0056     l1tIgnoreMaskAndPrescale = cms.bool( False ),
0057     throw = cms.bool( True )
0058 )
0059 
0060 #correct the jet used for the matching
0061 process.hltBtagJetsbyRef.jets = cms.InputTag(fileini.jets)
0062 
0063 #define VertexValidationVertices for the vertex DQM validation
0064 from DQMServices.Core.DQMEDAnalyzer import DQMEDAnalyzer
0065 process.VertexValidationVertices= DQMEDAnalyzer('HLTVertexPerformanceAnalyzer',
0066     SimVertexCollection = cms.InputTag("g4SimHits"),
0067     TriggerResults = cms.InputTag('TriggerResults','',fileini.processname),
0068     HLTPathNames = cms.vstring(fileini.vertex_pathes),
0069     Vertex = fileini.vertex_modules,
0070 )
0071 
0072 #define bTagValidation for the b-tag DQM validation (distribution plot)
0073 process.bTagValidation = DQMEDAnalyzer('HLTBTagPerformanceAnalyzer',
0074     TriggerResults = cms.InputTag('TriggerResults','',fileini.processname),
0075     HLTPathNames = cms.vstring(fileini.btag_pathes),
0076     JetTag = fileini.btag_modules,
0077     MinJetPT = cms.double(20),
0078     mcFlavours = cms.PSet(
0079     light = cms.vuint32(1, 2, 3, 21), # udsg
0080     c = cms.vuint32(4),
0081     b = cms.vuint32(5),
0082     g = cms.vuint32(21),
0083     uds = cms.vuint32(1, 2, 3)
0084     ),
0085     mcPartons = cms.InputTag("hltBtagJetsbyValAlgo")
0086 )
0087 
0088 #define bTagPostValidation for the b-tag DQM validation (efficiency and mistagrate plot)
0089 process.bTagPostValidation = DQMEDHarvester("HLTBTagHarvestingAnalyzer",
0090     HLTPathNames = fileini.btag_pathes,
0091     histoName   = fileini.btag_modules_string,
0092     minTag  = cms.double(0.6),
0093     # MC stuff
0094     mcFlavours = cms.PSet(
0095         light = cms.vuint32(1, 2, 3, 21), # udsg
0096         c = cms.vuint32(4),
0097         b = cms.vuint32(5),
0098         g = cms.vuint32(21),
0099         uds = cms.vuint32(1, 2, 3)
0100     )
0101 )
0102 #read input file
0103 process.source = cms.Source("PoolSource",
0104     fileNames = cms.untracked.vstring(fileini.files)
0105 )
0106 
0107 #put all in a path
0108 process.DQM_BTag = cms.Path(
0109 process.hltBtagTriggerSelection
0110 +   process.hltBtagJetMCTools
0111 +   process.VertexValidationVertices
0112 +   process.bTagValidation
0113 +   process.bTagPostValidation
0114 #+  process.EDMtoMEConverter
0115 +   process.dqmSaver
0116 )   
0117 
0118 #Settings equivalent to 'RelVal' convention:
0119 process.dqmSaver.convention = 'Offline'
0120 process.dqmSaver.saveByRun = cms.untracked.int32(-1)
0121 process.dqmSaver.saveAtJobEnd = cms.untracked.bool(True)
0122 process.dqmSaver.forceRunNumber = cms.untracked.int32(1)
0123 process.dqmSaver.workflow = "/" + fileini.CMSSWVER + "/RelVal/TrigVal"
0124 process.DQMStore.verbose=0
0125 process.options = cms.untracked.PSet(
0126     wantSummary = cms.untracked.bool( True ),
0127     fileMode    = cms.untracked.string('FULLMERGE'),
0128     SkipEvent   = cms.untracked.vstring('ProductNotFound')
0129 )
0130 
0131 #maxEvents
0132 process.maxEvents = cms.untracked.PSet(
0133     input = cms.untracked.int32(int(fileini.maxEvents))
0134 )