1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
|
import FWCore.ParameterSet.Config as cms
from DQMServices.Core.DQMEDHarvester import DQMEDHarvester
process = cms.Process("HLTBTAG")
from PhysicsTools.PatAlgos.tools.coreTools import *
process.load('FWCore.MessageService.MessageLogger_cfi')
process.load("Configuration.StandardSequences.GeometryRecoDB_cff")
process.load('Configuration.StandardSequences.Services_cff')
process.load("DQMServices.Components.EDMtoMEConverter_cff")
process.load("L1TriggerConfig.L1GtConfigProducers.L1GtConfig_cff")
#load hltJetMCTools sequence for the jet/partons matching
process.load("HLTriggerOffline.Btag.hltBtagJetMCTools_cff")
#read config.ini
from HLTriggerOffline.Btag.readConfig import *
fileini = fileINI("config.ini")
fileini.read()
#print read variables
print()
print("Reading ", fileini.fileName)
print()
print("maxEvents = ",fileini.maxEvents)
print("CMSSWVER = ",fileini.CMSSWVER)
print("processname = ",fileini.processname)
print("jets (for matching) = ",fileini.jets)
print("files = ",fileini.files)
print("btag_modules ",fileini.btag_modules)
print("btag_pathes ",fileini.btag_pathes)
print("vertex_modules ",fileini.vertex_modules)
print("vertex_pathes ",fileini.vertex_pathes)
print()
triggerFilter = []
triggerFilter.extend(fileini.vertex_pathes)
triggerFilter.extend(fileini.btag_pathes)
triggerFilter = list(set(triggerFilter))
triggerString = ""
for i in range(len(triggerFilter)):
if i is not 0:
triggerString += " OR "
triggerString += triggerFilter[i] + "*"
print("triggerString : ",triggerString)
#denominator trigger
process.hltBtagTriggerSelection = cms.EDFilter( "TriggerResultsFilter",
triggerConditions = cms.vstring(
triggerString),
hltResults = cms.InputTag( "TriggerResults", "", fileini.processname ),
l1tResults = cms.InputTag( "" ),
l1tIgnoreMaskAndPrescale = cms.bool( False ),
throw = cms.bool( True )
)
#correct the jet used for the matching
process.hltBtagJetsbyRef.jets = cms.InputTag(fileini.jets)
#define VertexValidationVertices for the vertex DQM validation
from DQMServices.Core.DQMEDAnalyzer import DQMEDAnalyzer
process.VertexValidationVertices= DQMEDAnalyzer('HLTVertexPerformanceAnalyzer',
SimVertexCollection = cms.InputTag("g4SimHits"),
TriggerResults = cms.InputTag('TriggerResults','',fileini.processname),
HLTPathNames = cms.vstring(fileini.vertex_pathes),
Vertex = fileini.vertex_modules,
)
#define bTagValidation for the b-tag DQM validation (distribution plot)
process.bTagValidation = DQMEDAnalyzer('HLTBTagPerformanceAnalyzer',
TriggerResults = cms.InputTag('TriggerResults','',fileini.processname),
HLTPathNames = cms.vstring(fileini.btag_pathes),
JetTag = fileini.btag_modules,
MinJetPT = cms.double(20),
mcFlavours = cms.PSet(
light = cms.vuint32(1, 2, 3, 21), # udsg
c = cms.vuint32(4),
b = cms.vuint32(5),
g = cms.vuint32(21),
uds = cms.vuint32(1, 2, 3)
),
mcPartons = cms.InputTag("hltBtagJetsbyValAlgo")
)
#define bTagPostValidation for the b-tag DQM validation (efficiency and mistagrate plot)
process.bTagPostValidation = DQMEDHarvester("HLTBTagHarvestingAnalyzer",
HLTPathNames = fileini.btag_pathes,
histoName = fileini.btag_modules_string,
minTag = cms.double(0.2), #Medium WP for 2023, see https://btv-wiki.docs.cern.ch/ScaleFactors/Run3Summer23/
# MC stuff
mcFlavours = cms.PSet(
light = cms.vuint32(1, 2, 3, 21), # udsg
c = cms.vuint32(4),
b = cms.vuint32(5),
g = cms.vuint32(21),
uds = cms.vuint32(1, 2, 3)
)
)
#read input file
process.source = cms.Source("PoolSource",
fileNames = cms.untracked.vstring(fileini.files)
)
#put all in a path
process.DQM_BTag = cms.Path(
process.hltBtagTriggerSelection
+ process.hltBtagJetMCTools
+ process.VertexValidationVertices
+ process.bTagValidation
+ process.bTagPostValidation
#+ process.EDMtoMEConverter
+ process.dqmSaver
)
#Settings equivalent to 'RelVal' convention:
process.dqmSaver.convention = 'Offline'
process.dqmSaver.saveByRun = cms.untracked.int32(-1)
process.dqmSaver.saveAtJobEnd = cms.untracked.bool(True)
process.dqmSaver.forceRunNumber = cms.untracked.int32(1)
process.dqmSaver.workflow = "/" + fileini.CMSSWVER + "/RelVal/TrigVal"
process.DQMStore.verbose=0
process.options = cms.untracked.PSet(
wantSummary = cms.untracked.bool( True ),
fileMode = cms.untracked.string('FULLMERGE'),
SkipEvent = cms.untracked.vstring('ProductNotFound')
)
#maxEvents
process.maxEvents = cms.untracked.PSet(
input = cms.untracked.int32(int(fileini.maxEvents))
)
|