1 import FWCore.ParameterSet.Config
as cms
8 jetCorrFactorsAK8 = cms.EDProducer(
"JetCorrFactorsProducer",
10 extraJPTOffset = cms.string(
'L1FastJet'),
11 flavorType = cms.string(
'J'),
18 mightGet = cms.optional.untracked.vstring,
19 payload = cms.string(
'AK8PFPuppi'),
20 primaryVertices = cms.InputTag(
"offlineSlimmedPrimaryVertices"),
21 rho = cms.InputTag(
"fixedGridRhoFastjetAll"),
22 src = cms.InputTag(
"slimmedJetsAK8"),
23 useNPV = cms.bool(
True),
24 useRho = cms.bool(
True)
28 updatedJetsAK8 = cms.EDProducer(
"PATJetUpdater",
29 addBTagInfo = cms.bool(
False),
30 addDiscriminators = cms.bool(
True),
31 addJetCorrFactors = cms.bool(
True),
32 addTagInfos = cms.bool(
False),
33 discriminatorSources = cms.VInputTag(),
34 jetCorrFactorsSource = cms.VInputTag(cms.InputTag(
"jetCorrFactorsAK8")),
35 jetSource = cms.InputTag(
"slimmedJetsAK8"),
36 mightGet = cms.optional.untracked.vstring,
37 printWarning = cms.bool(
True),
38 sort = cms.bool(
True),
39 tagInfoSources = cms.VInputTag(),
42 src = cms.VInputTag(
"")
44 userClasses = cms.PSet(
45 src = cms.VInputTag(
"")
47 userFloats = cms.PSet(
48 src = cms.VInputTag(
"")
50 userFunctionLabels = cms.vstring(),
51 userFunctions = cms.vstring(),
53 src = cms.VInputTag(
"")
61 looseJetIdAK8 = cms.EDProducer(
"PatJetIDValueMapProducer",
62 filterParams=cms.PSet(
63 version = cms.string(
'WINTER16'),
64 quality = cms.string(
'LOOSE'),
66 src = cms.InputTag(
"updatedJetsAK8")
68 tightJetIdAK8 = cms.EDProducer(
"PatJetIDValueMapProducer",
69 filterParams=cms.PSet(
70 version = cms.string(
'RUN2ULPUPPI'),
71 quality = cms.string(
'TIGHT'),
73 src = cms.InputTag(
"updatedJetsAK8")
75 tightJetIdLepVetoAK8 = cms.EDProducer(
"PatJetIDValueMapProducer",
76 filterParams=cms.PSet(
77 version = cms.string(
'RUN2ULPUPPI'),
78 quality = cms.string(
'TIGHTLEPVETO'),
80 src = cms.InputTag(
"updatedJetsAK8")
83 run2_jme_2016.toModify( tightJetIdAK8.filterParams, version =
"RUN2UL16PUPPI" )
84 run2_jme_2016.toModify( tightJetIdLepVetoAK8.filterParams, version =
"RUN2UL16PUPPI" )
87 updatedJetsAK8WithUserData = cms.EDProducer(
"PATJetUserDataEmbedder",
88 src = cms.InputTag(
"updatedJetsAK8"),
89 userFloats = cms.PSet(),
91 tightId = cms.InputTag(
"tightJetIdAK8"),
92 tightIdLepVeto = cms.InputTag(
"tightJetIdLepVetoAK8"),
97 finalJetsAK8 = cms.EDFilter(
"PATJetRefSelector",
98 src = cms.InputTag(
"updatedJetsAK8WithUserData"),
99 cut = cms.string(
"pt > 170")
103 lepInAK8JetVars = cms.EDProducer(
"LepInJetProducer",
104 src = cms.InputTag(
"updatedJetsAK8WithUserData"),
105 srcEle = cms.InputTag(
"finalElectrons"),
106 srcMu = cms.InputTag(
"finalMuons")
109 fatJetTable = cms.EDProducer(
"SimpleCandidateFlatTableProducer",
110 src = cms.InputTag(
"finalJetsAK8"),
111 cut = cms.string(
" pt > 170"),
112 name = cms.string(
"FatJet"),
113 doc = cms.string(
"slimmedJetsAK8, i.e. ak8 fat jets for boosted analysis"),
114 singleton = cms.bool(
False),
115 extension = cms.bool(
False),
116 variables = cms.PSet(P4Vars,
117 jetId =
Var(
"userInt('tightId')*2+4*userInt('tightIdLepVeto')",int,doc=
"Jet ID flags bit1 is loose (always false in 2017 since it does not exist), bit2 is tight, bit3 is tightLepVeto"),
118 area =
Var(
"jetArea()", float, doc=
"jet catchment area, for JECs",precision=10),
119 rawFactor =
Var(
"1.-jecFactor('Uncorrected')",float,doc=
"1 - Factor to get back to raw pT",precision=6),
120 tau1 =
Var(
"userFloat('NjettinessAK8Puppi:tau1')",float, doc=
"Nsubjettiness (1 axis)",precision=10),
121 tau2 =
Var(
"userFloat('NjettinessAK8Puppi:tau2')",float, doc=
"Nsubjettiness (2 axis)",precision=10),
122 tau3 =
Var(
"userFloat('NjettinessAK8Puppi:tau3')",float, doc=
"Nsubjettiness (3 axis)",precision=10),
123 tau4 =
Var(
"userFloat('NjettinessAK8Puppi:tau4')",float, doc=
"Nsubjettiness (4 axis)",precision=10),
124 n2b1 =
Var(
"?hasUserFloat('nb1AK8PuppiSoftDrop:ecfN2')?userFloat('nb1AK8PuppiSoftDrop:ecfN2'):-99999.", float, doc=
"N2 with beta=1 (for jets with raw pT>250 GeV)", precision=10),
125 n3b1 =
Var(
"?hasUserFloat('nb1AK8PuppiSoftDrop:ecfN3')?userFloat('nb1AK8PuppiSoftDrop:ecfN3'):-99999.", float, doc=
"N3 with beta=1 (for jets with raw pT>250 GeV)", precision=10),
126 msoftdrop =
Var(
"groomedMass('SoftDropPuppi')",float, doc=
"Corrected soft drop mass with PUPPI",precision=10),
127 btagDeepB =
Var(
"?(bDiscriminator('pfDeepCSVJetTags:probb')+bDiscriminator('pfDeepCSVJetTags:probbb'))>=0?bDiscriminator('pfDeepCSVJetTags:probb')+bDiscriminator('pfDeepCSVJetTags:probbb'):-1",float,doc=
"DeepCSV b+bb tag discriminator",precision=10),
128 btagCSVV2 =
Var(
"bDiscriminator('pfCombinedInclusiveSecondaryVertexV2BJetTags')",float,doc=
" pfCombinedInclusiveSecondaryVertexV2 b-tag discriminator (aka CSVV2)",precision=10),
129 btagHbb =
Var(
"bDiscriminator('pfBoostedDoubleSecondaryVertexAK8BJetTags')",float,doc=
"Higgs to BB tagger discriminator",precision=10),
130 btagDDBvLV2 =
Var(
"bDiscriminator('pfMassIndependentDeepDoubleBvLV2JetTags:probHbb')",float,doc=
"DeepDoubleX V2(mass-decorrelated) discriminator for H(Z)->bb vs QCD",precision=10),
131 btagDDCvLV2 =
Var(
"bDiscriminator('pfMassIndependentDeepDoubleCvLV2JetTags:probHcc')",float,doc=
"DeepDoubleX V2 (mass-decorrelated) discriminator for H(Z)->cc vs QCD",precision=10),
132 btagDDCvBV2 =
Var(
"bDiscriminator('pfMassIndependentDeepDoubleCvBV2JetTags:probHcc')",float,doc=
"DeepDoubleX V2 (mass-decorrelated) discriminator for H(Z)->cc vs H(Z)->bb",precision=10),
133 deepTag_TvsQCD =
Var(
"bDiscriminator('pfDeepBoostedDiscriminatorsJetTags:TvsQCD')",float,doc=
"DeepBoostedJet tagger top vs QCD discriminator",precision=10),
134 deepTag_WvsQCD =
Var(
"bDiscriminator('pfDeepBoostedDiscriminatorsJetTags:WvsQCD')",float,doc=
"DeepBoostedJet tagger W vs QCD discriminator",precision=10),
135 deepTag_ZvsQCD =
Var(
"bDiscriminator('pfDeepBoostedDiscriminatorsJetTags:ZvsQCD')",float,doc=
"DeepBoostedJet tagger Z vs QCD discriminator",precision=10),
136 deepTag_H =
Var(
"bDiscriminator('pfDeepBoostedJetTags:probHbb')+bDiscriminator('pfDeepBoostedJetTags:probHcc')+bDiscriminator('pfDeepBoostedJetTags:probHqqqq')",float,doc=
"DeepBoostedJet tagger H(bb,cc,4q) sum",precision=10),
137 deepTag_QCD =
Var(
"bDiscriminator('pfDeepBoostedJetTags:probQCDbb')+bDiscriminator('pfDeepBoostedJetTags:probQCDcc')+bDiscriminator('pfDeepBoostedJetTags:probQCDb')+bDiscriminator('pfDeepBoostedJetTags:probQCDc')+bDiscriminator('pfDeepBoostedJetTags:probQCDothers')",float,doc=
"DeepBoostedJet tagger QCD(bb,cc,b,c,others) sum",precision=10),
138 deepTag_QCDothers =
Var(
"bDiscriminator('pfDeepBoostedJetTags:probQCDothers')",float,doc=
"DeepBoostedJet tagger QCDothers value",precision=10),
139 deepTagMD_TvsQCD =
Var(
"bDiscriminator('pfMassDecorrelatedDeepBoostedDiscriminatorsJetTags:TvsQCD')",float,doc=
"Mass-decorrelated DeepBoostedJet tagger top vs QCD discriminator",precision=10),
140 deepTagMD_WvsQCD =
Var(
"bDiscriminator('pfMassDecorrelatedDeepBoostedDiscriminatorsJetTags:WvsQCD')",float,doc=
"Mass-decorrelated DeepBoostedJet tagger W vs QCD discriminator",precision=10),
141 deepTagMD_ZvsQCD =
Var(
"bDiscriminator('pfMassDecorrelatedDeepBoostedDiscriminatorsJetTags:ZvsQCD')",float,doc=
"Mass-decorrelated DeepBoostedJet tagger Z vs QCD discriminator",precision=10),
142 deepTagMD_ZHbbvsQCD =
Var(
"bDiscriminator('pfMassDecorrelatedDeepBoostedDiscriminatorsJetTags:ZHbbvsQCD')",float,doc=
"Mass-decorrelated DeepBoostedJet tagger Z/H->bb vs QCD discriminator",precision=10),
143 deepTagMD_ZbbvsQCD =
Var(
"bDiscriminator('pfMassDecorrelatedDeepBoostedDiscriminatorsJetTags:ZbbvsQCD')",float,doc=
"Mass-decorrelated DeepBoostedJet tagger Z->bb vs QCD discriminator",precision=10),
144 deepTagMD_HbbvsQCD =
Var(
"bDiscriminator('pfMassDecorrelatedDeepBoostedDiscriminatorsJetTags:HbbvsQCD')",float,doc=
"Mass-decorrelated DeepBoostedJet tagger H->bb vs QCD discriminator",precision=10),
145 deepTagMD_ZHccvsQCD =
Var(
"bDiscriminator('pfMassDecorrelatedDeepBoostedDiscriminatorsJetTags:ZHccvsQCD')",float,doc=
"Mass-decorrelated DeepBoostedJet tagger Z/H->cc vs QCD discriminator",precision=10),
146 deepTagMD_H4qvsQCD =
Var(
"bDiscriminator('pfMassDecorrelatedDeepBoostedDiscriminatorsJetTags:H4qvsQCD')",float,doc=
"Mass-decorrelated DeepBoostedJet tagger H->4q vs QCD discriminator",precision=10),
147 deepTagMD_bbvsLight =
Var(
"bDiscriminator('pfMassDecorrelatedDeepBoostedDiscriminatorsJetTags:bbvsLight')",float,doc=
"Mass-decorrelated DeepBoostedJet tagger Z/H/gluon->bb vs light flavour discriminator",precision=10),
148 deepTagMD_ccvsLight =
Var(
"bDiscriminator('pfMassDecorrelatedDeepBoostedDiscriminatorsJetTags:ccvsLight')",float,doc=
"Mass-decorrelated DeepBoostedJet tagger Z/H/gluon->cc vs light flavour discriminator",precision=10),
149 particleNet_TvsQCD =
Var(
"bDiscriminator('pfParticleNetDiscriminatorsJetTags:TvsQCD')",float,doc=
"ParticleNet tagger top vs QCD discriminator",precision=10),
150 particleNet_WvsQCD =
Var(
"bDiscriminator('pfParticleNetDiscriminatorsJetTags:WvsQCD')",float,doc=
"ParticleNet tagger W vs QCD discriminator",precision=10),
151 particleNet_ZvsQCD =
Var(
"bDiscriminator('pfParticleNetDiscriminatorsJetTags:ZvsQCD')",float,doc=
"ParticleNet tagger Z vs QCD discriminator",precision=10),
152 particleNet_HbbvsQCD =
Var(
"bDiscriminator('pfParticleNetDiscriminatorsJetTags:HbbvsQCD')",float,doc=
"ParticleNet tagger H(->bb) vs QCD discriminator",precision=10),
153 particleNet_HccvsQCD =
Var(
"bDiscriminator('pfParticleNetDiscriminatorsJetTags:HccvsQCD')",float,doc=
"ParticleNet tagger H(->cc) vs QCD discriminator",precision=10),
154 particleNet_H4qvsQCD =
Var(
"bDiscriminator('pfParticleNetDiscriminatorsJetTags:H4qvsQCD')",float,doc=
"ParticleNet tagger H(->VV->qqqq) vs QCD discriminator",precision=10),
155 particleNet_QCD =
Var(
"bDiscriminator('pfParticleNetJetTags:probQCDbb')+bDiscriminator('pfParticleNetJetTags:probQCDcc')+bDiscriminator('pfParticleNetJetTags:probQCDb')+bDiscriminator('pfParticleNetJetTags:probQCDc')+bDiscriminator('pfParticleNetJetTags:probQCDothers')",float,doc=
"ParticleNet tagger QCD(bb,cc,b,c,others) sum",precision=10),
156 particleNet_mass =
Var(
"bDiscriminator('pfParticleNetMassRegressionJetTags:mass')",float,doc=
"ParticleNet mass regression",precision=10),
157 particleNetMD_Xbb =
Var(
"bDiscriminator('pfMassDecorrelatedParticleNetJetTags:probXbb')",float,doc=
"Mass-decorrelated ParticleNet tagger raw X->bb score. For X->bb vs QCD tagging, use Xbb/(Xbb+QCD)",precision=10),
158 particleNetMD_Xcc =
Var(
"bDiscriminator('pfMassDecorrelatedParticleNetJetTags:probXcc')",float,doc=
"Mass-decorrelated ParticleNet tagger raw X->cc score. For X->cc vs QCD tagging, use Xcc/(Xcc+QCD)",precision=10),
159 particleNetMD_Xqq =
Var(
"bDiscriminator('pfMassDecorrelatedParticleNetJetTags:probXqq')",float,doc=
"Mass-decorrelated ParticleNet tagger raw X->qq (uds) score. For X->qq vs QCD tagging, use Xqq/(Xqq+QCD). For W vs QCD tagging, use (Xcc+Xqq)/(Xcc+Xqq+QCD)",precision=10),
160 particleNetMD_QCD =
Var(
"bDiscriminator('pfMassDecorrelatedParticleNetJetTags:probQCDbb')+bDiscriminator('pfMassDecorrelatedParticleNetJetTags:probQCDcc')+bDiscriminator('pfMassDecorrelatedParticleNetJetTags:probQCDb')+bDiscriminator('pfMassDecorrelatedParticleNetJetTags:probQCDc')+bDiscriminator('pfMassDecorrelatedParticleNetJetTags:probQCDothers')",float,doc=
"Mass-decorrelated ParticleNet tagger raw QCD score",precision=10),
161 subJetIdx1 =
Var(
"?nSubjetCollections()>0 && subjets('SoftDropPuppi').size()>0?subjets('SoftDropPuppi')[0].key():-1", int,
162 doc=
"index of first subjet"),
163 subJetIdx2 =
Var(
"?nSubjetCollections()>0 && subjets('SoftDropPuppi').size()>1?subjets('SoftDropPuppi')[1].key():-1", int,
164 doc=
"index of second subjet"),
165 nConstituents =
Var(
"numberOfDaughters()",
"uint8",doc=
"Number of particles in the jet"),
167 externalVariables = cms.PSet(
168 lsf3 =
ExtVar(cms.InputTag(
"lepInAK8JetVars:lsf3"),float, doc=
"Lepton Subjet Fraction (3 subjets)",precision=10),
169 muonIdx3SJ =
ExtVar(cms.InputTag(
"lepInAK8JetVars:muIdx3SJ"),int, doc=
"index of muon matched to jet"),
170 electronIdx3SJ =
ExtVar(cms.InputTag(
"lepInAK8JetVars:eleIdx3SJ"),int,doc=
"index of electron matched to jet"),
179 def nanoAOD_addDeepInfoAK8(process, addDeepBTag, addDeepBoostedJet, addDeepDoubleX, addDeepDoubleXV2, addParticleNet, addParticleNetMass, jecPayload):
180 _btagDiscriminators=[]
182 print(
"Updating process to run DeepCSV btag to AK8 jets")
183 _btagDiscriminators += [
'pfDeepCSVJetTags:probb',
'pfDeepCSVJetTags:probbb']
184 if addDeepBoostedJet:
185 print(
"Updating process to run DeepBoostedJet on datasets before 103X")
187 _btagDiscriminators += pfDeepBoostedJetTagsAll
189 print(
"Updating process to run ParticleNet before it's included in MiniAOD")
191 _btagDiscriminators += pfParticleNetJetTagsAll
192 if addParticleNetMass:
194 _btagDiscriminators += _pfParticleNetMassRegressionOutputs
196 print(
"Updating process to run DeepDoubleX on datasets before 104X")
197 _btagDiscriminators += [
'pfDeepDoubleBvLJetTags:probHbb', \
198 'pfDeepDoubleCvLJetTags:probHcc', \
199 'pfDeepDoubleCvBJetTags:probHcc', \
200 'pfMassIndependentDeepDoubleBvLJetTags:probHbb',
'pfMassIndependentDeepDoubleCvLJetTags:probHcc',
'pfMassIndependentDeepDoubleCvBJetTags:probHcc']
202 print(
"Updating process to run DeepDoubleXv2 on datasets before 11X")
203 _btagDiscriminators += [
204 'pfMassIndependentDeepDoubleBvLV2JetTags:probHbb',
205 'pfMassIndependentDeepDoubleCvLV2JetTags:probHcc',
206 'pfMassIndependentDeepDoubleCvBV2JetTags:probHcc' 208 if len(_btagDiscriminators)==0:
return process
209 print(
"Will recalculate the following discriminators on AK8 jets: "+
", ".
join(_btagDiscriminators))
212 jetSource = cms.InputTag(
'slimmedJetsAK8'),
213 pvSource = cms.InputTag(
'offlineSlimmedPrimaryVertices'),
214 svSource = cms.InputTag(
'slimmedSecondaryVertices'),
216 jetCorrections = (jecPayload.value(), cms.vstring([
'L1FastJet',
'L2Relative',
'L3Absolute',
'L2L3Residual']),
'None'),
217 btagDiscriminators = _btagDiscriminators,
218 postfix=
'AK8WithDeepInfo',
221 process.jetCorrFactorsAK8.src=
"selectedUpdatedPatJetsAK8WithDeepInfo" 222 process.updatedJetsAK8.jetSource=
"selectedUpdatedPatJetsAK8WithDeepInfo" 225 nanoAOD_addDeepInfoAK8_switch = cms.PSet(
226 nanoAOD_addDeepBTag_switch = cms.untracked.bool(
False),
227 nanoAOD_addDeepBoostedJet_switch = cms.untracked.bool(
False),
228 nanoAOD_addDeepDoubleX_switch = cms.untracked.bool(
False),
229 nanoAOD_addDeepDoubleXV2_switch = cms.untracked.bool(
False),
230 nanoAOD_addParticleNet_switch = cms.untracked.bool(
False),
231 nanoAOD_addParticleNetMass_switch = cms.untracked.bool(
False),
232 jecPayload = cms.untracked.string(
'AK8PFPuppi')
236 run2_nanoAOD_106Xv2.toModify(
237 nanoAOD_addDeepInfoAK8_switch,
238 nanoAOD_addParticleNetMass_switch =
True,
244 subJetTable = cms.EDProducer(
"SimpleCandidateFlatTableProducer",
245 src = cms.InputTag(
"slimmedJetsAK8PFPuppiSoftDropPacked",
"SubJets"),
246 cut = cms.string(
""),
247 name = cms.string(
"SubJet"),
248 doc = cms.string(
"slimmedJetsAK8, i.e. ak8 fat jets for boosted analysis"),
249 singleton = cms.bool(
False),
250 extension = cms.bool(
False),
251 variables = cms.PSet(P4Vars,
252 btagDeepB =
Var(
"bDiscriminator('pfDeepCSVJetTags:probb')+bDiscriminator('pfDeepCSVJetTags:probbb')",float,doc=
"DeepCSV b+bb tag discriminator",precision=10),
253 btagCSVV2 =
Var(
"bDiscriminator('pfCombinedInclusiveSecondaryVertexV2BJetTags')",float,doc=
" pfCombinedInclusiveSecondaryVertexV2 b-tag discriminator (aka CSVV2)",precision=10),
254 rawFactor =
Var(
"1.-jecFactor('Uncorrected')",float,doc=
"1 - Factor to get back to raw pT",precision=6),
255 tau1 =
Var(
"userFloat('NjettinessAK8Subjets:tau1')",float, doc=
"Nsubjettiness (1 axis)",precision=10),
256 tau2 =
Var(
"userFloat('NjettinessAK8Subjets:tau2')",float, doc=
"Nsubjettiness (2 axis)",precision=10),
257 tau3 =
Var(
"userFloat('NjettinessAK8Subjets:tau3')",float, doc=
"Nsubjettiness (3 axis)",precision=10),
258 tau4 =
Var(
"userFloat('NjettinessAK8Subjets:tau4')",float, doc=
"Nsubjettiness (4 axis)",precision=10),
259 n2b1 =
Var(
"userFloat('nb1AK8PuppiSoftDropSubjets:ecfN2')", float, doc=
"N2 with beta=1", precision=10),
260 n3b1 =
Var(
"userFloat('nb1AK8PuppiSoftDropSubjets:ecfN3')", float, doc=
"N3 with beta=1", precision=10),
266 fatJetTable.variables.pt.precision=10
267 subJetTable.variables.pt.precision=10
270 jetAK8UserDataTask = cms.Task(tightJetIdAK8,tightJetIdLepVetoAK8)
271 jetAK8Task = cms.Task(jetCorrFactorsAK8,updatedJetsAK8,jetAK8UserDataTask,updatedJetsAK8WithUserData,finalJetsAK8)
274 jetAK8LepTask = cms.Task(lepInAK8JetVars)
276 jetAK8TablesTask = cms.Task(fatJetTable,subJetTable)
def ExtVar(tag, valtype, doc=None, precision=-1)
def Var(expr, valtype, doc=None, precision=-1)
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
def nanoAOD_addDeepInfoAK8(process, addDeepBTag, addDeepBoostedJet, addDeepDoubleX, addDeepDoubleXV2, addParticleNet, addParticleNetMass, jecPayload)
static std::string join(char **cmd)