Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2025-02-20 03:45:38

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