1 import FWCore.ParameterSet.Config
as cms
5 from PhysicsTools.NanoAOD.simpleCandidateFlatTableProducer_cfi
import simpleCandidateFlatTableProducer
12 jetCorrFactorsNano = patJetCorrFactors.clone(src=
'slimmedJets',
13 levels = cms.vstring(
'L1FastJet',
17 primaryVertices = cms.InputTag(
"offlineSlimmedPrimaryVertices"),
21 updatedJets = updatedPatJets.clone(
23 jetSource=
'slimmedJets',
24 jetCorrFactorsSource=cms.VInputTag(cms.InputTag(
"jetCorrFactorsNano") ),
30 looseJetId = cms.EDProducer(
"PatJetIDValueMapProducer",
31 filterParams=cms.PSet(
32 version = cms.string(
'WINTER16'),
33 quality = cms.string(
'LOOSE'),
35 src = cms.InputTag(
"updatedJets")
37 tightJetId = cms.EDProducer(
"PatJetIDValueMapProducer",
38 filterParams=cms.PSet(
39 version = cms.string(
'RUN3CHSruns2022FGruns2023CD'),
40 quality = cms.string(
'TIGHT'),
42 src = cms.InputTag(
"updatedJets")
44 tightJetIdLepVeto = cms.EDProducer(
"PatJetIDValueMapProducer",
45 filterParams=cms.PSet(
46 version = cms.string(
'RUN3CHSruns2022FGruns2023CD'),
47 quality = cms.string(
'TIGHTLEPVETO'),
49 src = cms.InputTag(
"updatedJets")
51 run2_jme_2016.toModify(
52 tightJetId.filterParams, version =
"RUN2UL16CHS" 54 tightJetIdLepVeto.filterParams, version =
"RUN2UL16CHS" 57 (run2_jme_2017 | run2_jme_2018).toModify(
58 tightJetId.filterParams, version =
"RUN2ULCHS" 60 tightJetIdLepVeto.filterParams, version =
"RUN2ULCHS" 63 run3_jme_Winter22runsBCDEprompt.toModify(
64 tightJetId.filterParams, version =
"RUN3CHSruns2022BCDEprompt" 66 tightJetIdLepVeto.filterParams, version =
"RUN3CHSruns2022BCDEprompt" 69 bJetVars = cms.EDProducer(
"JetRegressionVarProducer",
70 pvsrc = cms.InputTag(
"offlineSlimmedPrimaryVertices"),
71 src = cms.InputTag(
"updatedJets"),
72 svsrc = cms.InputTag(
"slimmedSecondaryVertices"),
75 jercVars = cms.EDProducer(
"BetaStarPackedCandidateVarProducer",
76 srcJet = cms.InputTag(
"updatedJets"),
77 srcPF = cms.InputTag(
"packedPFCandidates"),
78 maxDR = cms.double(0.4)
81 updatedJetsWithUserData = cms.EDProducer(
"PATJetUserDataEmbedder",
82 src = cms.InputTag(
"updatedJets"),
83 userFloats = cms.PSet(
84 leadTrackPt = cms.InputTag(
"bJetVars:leadTrackPt"),
85 leptonPtRelv0 = cms.InputTag(
"bJetVars:leptonPtRelv0"),
86 leptonPtRelInvv0 = cms.InputTag(
"bJetVars:leptonPtRelInvv0"),
87 leptonDeltaR = cms.InputTag(
"bJetVars:leptonDeltaR"),
88 vtxPt = cms.InputTag(
"bJetVars:vtxPt"),
89 vtxMass = cms.InputTag(
"bJetVars:vtxMass"),
90 vtx3dL = cms.InputTag(
"bJetVars:vtx3dL"),
91 vtx3deL = cms.InputTag(
"bJetVars:vtx3deL"),
92 ptD = cms.InputTag(
"bJetVars:ptD"),
93 qgl = cms.InputTag(
'qgtagger:qgLikelihood'),
94 puIdNanoDisc = cms.InputTag(
'pileupJetIdNano:fullDiscriminant'),
95 chFPV0EF = cms.InputTag(
"jercVars:chargedFromPV0EnergyFraction"),
98 tightId = cms.InputTag(
"tightJetId"),
99 tightIdLepVeto = cms.InputTag(
"tightJetIdLepVeto"),
100 vtxNtrk = cms.InputTag(
"bJetVars:vtxNtrk"),
101 leptonPdgId = cms.InputTag(
"bJetVars:leptonPdgId"),
102 puIdNanoId = cms.InputTag(
'pileupJetIdNano:fullId'),
107 finalJets = cms.EDFilter(
"PATJetRefSelector",
108 src = cms.InputTag(
"updatedJetsWithUserData"),
109 cut = cms.string(
"pt > 15")
116 jetTable = simpleCandidateFlatTableProducer.clone(
117 src = cms.InputTag(
"linkedObjects",
"jets"),
118 name = cms.string(
"Jet"),
119 doc = cms.string(
"slimmedJets, i.e. ak4 PFJets CHS with JECs applied, after basic selection (" + finalJets.cut.value()+
")"),
120 externalVariables = cms.PSet(
121 bRegCorr =
ExtVar(cms.InputTag(
"bjetNN:corr"),float, doc=
"pt correction for b-jet energy regression",precision=10),
122 bRegRes =
ExtVar(cms.InputTag(
"bjetNN:res"),float, doc=
"res on pt corrected with b-jet regression",precision=6),
123 cRegCorr =
ExtVar(cms.InputTag(
"cjetNN:corr"),float, doc=
"pt correction for c-jet energy regression",precision=10),
124 cRegRes =
ExtVar(cms.InputTag(
"cjetNN:res"),float, doc=
"res on pt corrected with c-jet regression",precision=6),
126 variables = cms.PSet(P4Vars,
127 area =
Var(
"jetArea()", float, doc=
"jet catchment area, for JECs",precision=10),
128 nMuons =
Var(
"?hasOverlaps('muons')?overlaps('muons').size():0",
"uint8", doc=
"number of muons in the jet"),
129 muonIdx1 =
Var(
"?overlaps('muons').size()>0?overlaps('muons')[0].key():-1",
"int16", doc=
"index of first matching muon"),
130 muonIdx2 =
Var(
"?overlaps('muons').size()>1?overlaps('muons')[1].key():-1",
"int16", doc=
"index of second matching muon"),
131 electronIdx1 =
Var(
"?overlaps('electrons').size()>0?overlaps('electrons')[0].key():-1",
"int16", doc=
"index of first matching electron"),
132 electronIdx2 =
Var(
"?overlaps('electrons').size()>1?overlaps('electrons')[1].key():-1",
"int16", doc=
"index of second matching electron"),
133 nElectrons =
Var(
"?hasOverlaps('electrons')?overlaps('electrons').size():0",
"uint8", doc=
"number of electrons in the jet"),
134 svIdx1 =
Var(
"?overlaps('vertices').size()>0?overlaps('vertices')[0].key():-1",
"int16", doc=
"index of first matching secondary vertex"),
135 svIdx2 =
Var(
"?overlaps('vertices').size()>1?overlaps('vertices')[1].key():-1",
"int16", doc=
"index of second matching secondary vertex"),
136 nSVs =
Var(
"?hasOverlaps('vertices')?overlaps('vertices').size():0",
"uint8", doc=
"number of secondary vertices in the jet"),
137 btagDeepFlavB =
Var(
"bDiscriminator('pfDeepFlavourJetTags:probb')+bDiscriminator('pfDeepFlavourJetTags:probbb')+bDiscriminator('pfDeepFlavourJetTags:problepb')",float,doc=
"DeepJet b+bb+lepb tag discriminator",precision=10),
138 btagRobustParTAK4B =
Var(
"bDiscriminator('pfParticleTransformerAK4JetTags:probb')+bDiscriminator('pfParticleTransformerAK4JetTags:probbb')+bDiscriminator('pfParticleTransformerAK4JetTags:problepb')",
140 doc=
"RobustParTAK4 b+bb+lepb tag discriminator",
142 btagDeepFlavCvL =
Var(
"?(bDiscriminator('pfDeepFlavourJetTags:probc')+bDiscriminator('pfDeepFlavourJetTags:probuds')+bDiscriminator('pfDeepFlavourJetTags:probg'))>0?bDiscriminator('pfDeepFlavourJetTags:probc')/(bDiscriminator('pfDeepFlavourJetTags:probc')+bDiscriminator('pfDeepFlavourJetTags:probuds')+bDiscriminator('pfDeepFlavourJetTags:probg')):-1",float,doc=
"DeepJet c vs uds+g discriminator",precision=10),
143 btagDeepFlavCvB =
Var(
"?(bDiscriminator('pfDeepFlavourJetTags:probc')+bDiscriminator('pfDeepFlavourJetTags:probb')+bDiscriminator('pfDeepFlavourJetTags:probbb')+bDiscriminator('pfDeepFlavourJetTags:problepb'))>0?bDiscriminator('pfDeepFlavourJetTags:probc')/(bDiscriminator('pfDeepFlavourJetTags:probc')+bDiscriminator('pfDeepFlavourJetTags:probb')+bDiscriminator('pfDeepFlavourJetTags:probbb')+bDiscriminator('pfDeepFlavourJetTags:problepb')):-1",float,doc=
"DeepJet c vs b+bb+lepb discriminator",precision=10),
144 btagDeepFlavQG =
Var(
"?(bDiscriminator('pfDeepFlavourJetTags:probg')+bDiscriminator('pfDeepFlavourJetTags:probuds'))>0?bDiscriminator('pfDeepFlavourJetTags:probg')/(bDiscriminator('pfDeepFlavourJetTags:probg')+bDiscriminator('pfDeepFlavourJetTags:probuds')):-1",float,doc=
"DeepJet g vs uds discriminator",precision=10),
145 btagRobustParTAK4CvL =
Var(
"?(bDiscriminator('pfParticleTransformerAK4JetTags:probc')+bDiscriminator('pfParticleTransformerAK4JetTags:probuds')+bDiscriminator('pfParticleTransformerAK4JetTags:probg'))>0?bDiscriminator('pfParticleTransformerAK4JetTags:probc')/(bDiscriminator('pfParticleTransformerAK4JetTags:probc')+bDiscriminator('pfParticleTransformerAK4JetTags:probuds')+bDiscriminator('pfParticleTransformerAK4JetTags:probg')):-1",
147 doc=
"RobustParTAK4 c vs uds+g discriminator",
149 btagRobustParTAK4CvB =
Var(
"?(bDiscriminator('pfParticleTransformerAK4JetTags:probc')+bDiscriminator('pfParticleTransformerAK4JetTags:probb')+bDiscriminator('pfParticleTransformerAK4JetTags:probbb')+bDiscriminator('pfParticleTransformerAK4JetTags:problepb'))>0?bDiscriminator('pfParticleTransformerAK4JetTags:probc')/(bDiscriminator('pfParticleTransformerAK4JetTags:probc')+bDiscriminator('pfParticleTransformerAK4JetTags:probb')+bDiscriminator('pfParticleTransformerAK4JetTags:probbb')+bDiscriminator('pfParticleTransformerAK4JetTags:problepb')):-1",
151 doc=
"RobustParTAK4 c vs b+bb+lepb discriminator",
153 btagRobustParTAK4QG =
Var(
"?(bDiscriminator('pfParticleTransformerAK4JetTags:probg')+bDiscriminator('pfParticleTransformerAK4JetTags:probuds'))>0?bDiscriminator('pfParticleTransformerAK4JetTags:probg')/(bDiscriminator('pfParticleTransformerAK4JetTags:probg')+bDiscriminator('pfParticleTransformerAK4JetTags:probuds')):-1",
155 doc=
"RobustParTAK4 g vs uds discriminator",
157 btagPNetB =
Var(
"?bDiscriminator('pfParticleNetFromMiniAODAK4CHSCentralDiscriminatorsJetTags:BvsAll')>0?bDiscriminator('pfParticleNetFromMiniAODAK4CHSCentralDiscriminatorsJetTags:BvsAll'):-1",float,precision=10,doc=
"ParticleNet b vs. udscg"),
158 btagPNetCvL =
Var(
"?bDiscriminator('pfParticleNetFromMiniAODAK4CHSCentralDiscriminatorsJetTags:CvsL')>0?bDiscriminator('pfParticleNetFromMiniAODAK4CHSCentralDiscriminatorsJetTags:CvsL'):-1",float,precision=10,doc=
"ParticleNet c vs. udsg"),
159 btagPNetCvB =
Var(
"?bDiscriminator('pfParticleNetFromMiniAODAK4CHSCentralDiscriminatorsJetTags:CvsB')>0?bDiscriminator('pfParticleNetFromMiniAODAK4CHSCentralDiscriminatorsJetTags:CvsB'):-1",float,precision=10,doc=
"ParticleNet c vs. b"),
160 btagPNetQvG =
Var(
"?abs(eta())<2.5?bDiscriminator('pfParticleNetFromMiniAODAK4CHSCentralDiscriminatorsJetTags:QvsG'):bDiscriminator('pfParticleNetFromMiniAODAK4CHSForwardDiscriminatorsJetTags:QvsG')",float,precision=10,doc=
"ParticleNet q (udsbc) vs. g"),
161 btagPNetTauVJet =
Var(
"?bDiscriminator('pfParticleNetFromMiniAODAK4CHSCentralDiscriminatorsJetTags:TauVsJet')>0?bDiscriminator('pfParticleNetFromMiniAODAK4CHSCentralDiscriminatorsJetTags:TauVsJet'):-1",float,precision=10,doc=
"ParticleNet tau vs. jet"),
162 PNetRegPtRawCorr =
Var(
"?abs(eta())<2.5?bDiscriminator('pfParticleNetFromMiniAODAK4CHSCentralJetTags:ptcorr'):bDiscriminator('pfParticleNetFromMiniAODAK4CHSForwardJetTags:ptcorr')",float,precision=10,doc=
"ParticleNet universal flavor-aware visible pT regression (no neutrinos), correction relative to raw jet pT"),
163 PNetRegPtRawCorrNeutrino =
Var(
"?abs(eta())<2.5?bDiscriminator('pfParticleNetFromMiniAODAK4CHSCentralJetTags:ptnu'):bDiscriminator('pfParticleNetFromMiniAODAK4CHSForwardJetTags:ptnu')",float,precision=10,doc=
"ParticleNet universal flavor-aware pT regression neutrino correction, relative to visible. To apply full regression, multiply raw jet pT by both PNetRegPtRawCorr and PNetRegPtRawCorrNeutrino."),
164 PNetRegPtRawRes =
Var(
"?abs(eta())<2.5?0.5*(bDiscriminator('pfParticleNetFromMiniAODAK4CHSCentralJetTags:ptreshigh')-bDiscriminator('pfParticleNetFromMiniAODAK4CHSCentralJetTags:ptreslow')):0.5*(bDiscriminator('pfParticleNetFromMiniAODAK4CHSForwardJetTags:ptreshigh')-bDiscriminator('pfParticleNetFromMiniAODAK4CHSForwardJetTags:ptreslow'))",float,precision=10,doc=
"ParticleNet universal flavor-aware jet pT resolution estimator, (q84 - q16)/2"),
165 puIdDisc =
Var(
"userFloat('puIdNanoDisc')", float,doc=
"Pileup ID discriminant with 106X (2018) training",precision=10),
166 puId =
Var(
"userInt('puIdNanoId')",
"uint8", doc=
"Pileup ID flags with 106X (2018) training"),
167 jetId =
Var(
"userInt('tightId')*2+4*userInt('tightIdLepVeto')",
"uint8", doc=
"Jet ID flags bit1 is loose (always false in 2017 since it does not exist), bit2 is tight, bit3 is tightLepVeto"),
168 qgl =
Var(
"?userFloat('qgl')>0?userFloat('qgl'):-1",float,doc=
"Quark vs Gluon likelihood discriminator",precision=10),
169 hfsigmaEtaEta =
Var(
"userFloat('hfJetShowerShape:sigmaEtaEta')",float,doc=
"sigmaEtaEta for HF jets (noise discriminating variable)",precision=10),
170 hfsigmaPhiPhi =
Var(
"userFloat('hfJetShowerShape:sigmaPhiPhi')",float,doc=
"sigmaPhiPhi for HF jets (noise discriminating variable)",precision=10),
171 hfcentralEtaStripSize =
Var(
"userInt('hfJetShowerShape:centralEtaStripSize')", int, doc=
"eta size of the central tower strip in HF (noise discriminating variable) "),
172 hfadjacentEtaStripsSize =
Var(
"userInt('hfJetShowerShape:adjacentEtaStripsSize')", int, doc=
"eta size of the strips next to the central tower strip in HF (noise discriminating variable) "),
173 nConstituents =
Var(
"numberOfDaughters()",
"uint8",doc=
"Number of particles in the jet"),
174 chMultiplicity =
Var(
"chargedMultiplicity()",
"uint8",doc=
"Number of charged particles in the jet"),
175 neMultiplicity =
Var(
"neutralMultiplicity()",
"uint8",doc=
"Number of neutral particles in the jet"),
176 rawFactor =
Var(
"1.-jecFactor('Uncorrected')",float,doc=
"1 - Factor to get back to raw pT",precision=6),
177 chHEF =
Var(
"chargedHadronEnergyFraction()", float, doc=
"charged Hadron Energy Fraction", precision= 6),
178 neHEF =
Var(
"neutralHadronEnergyFraction()", float, doc=
"neutral Hadron Energy Fraction", precision= 6),
179 chEmEF =
Var(
"chargedEmEnergyFraction()", float, doc=
"charged Electromagnetic Energy Fraction", precision= 6),
180 neEmEF =
Var(
"neutralEmEnergyFraction()", float, doc=
"neutral Electromagnetic Energy Fraction", precision= 6),
181 hfHEF =
Var(
"HFHadronEnergyFraction()",float,doc=
"hadronic Energy Fraction in HF",precision= 6),
182 hfEmEF =
Var(
"HFEMEnergyFraction()",float,doc=
"electromagnetic Energy Fraction in HF",precision= 6),
183 muEF =
Var(
"muonEnergyFraction()", float, doc=
"muon Energy Fraction", precision= 6),
184 chFPV0EF =
Var(
"userFloat('chFPV0EF')", float, doc=
"charged fromPV==0 Energy Fraction (energy excluded from CHS jets). Previously called betastar.", precision= 6),
189 jetTable.variables.pt.precision=10
192 (run2_jme_2016 & ~tracker_apv_vfp30_2016 ).toModify(
193 jetTable.variables.puIdDisc, doc=
"Pileup ID discriminant with 106X (2016) training" 195 jetTable.variables.puId, doc=
"Pileup ID flags with 106X (2016) training" 197 (run2_jme_2016 & tracker_apv_vfp30_2016 ).toModify(
198 jetTable.variables.puIdDisc, doc=
"Pileup ID discriminant with 106X (2016APV) training" 200 jetTable.variables.puId, doc=
"Pileup ID flags with 106X (2016APV) training" 202 run2_jme_2017.toModify(
203 jetTable.variables.puIdDisc, doc=
"Pileup ID discriminant with 106X (2017) training" 205 jetTable.variables.puId, doc=
"Pileup ID flags with 106X (2017) training" 208 run2_nanoAOD_ANY.toModify(
210 btagCSVV2 =
Var(
"bDiscriminator('pfCombinedInclusiveSecondaryVertexV2BJetTags')",float,doc=
" pfCombinedInclusiveSecondaryVertexV2 b-tag discriminator (aka CSVV2)",precision=10),
211 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),
212 btagDeepCvL =
Var(
"?bDiscriminator('pfDeepCSVJetTags:probc')>=0?bDiscriminator('pfDeepCSVJetTags:probc')/(bDiscriminator('pfDeepCSVJetTags:probc')+bDiscriminator('pfDeepCSVJetTags:probudsg')):-1", float,doc=
"DeepCSV c vs udsg discriminator",precision=10),
213 btagDeepCvB =
Var(
"?bDiscriminator('pfDeepCSVJetTags:probc')>=0?bDiscriminator('pfDeepCSVJetTags:probc')/(bDiscriminator('pfDeepCSVJetTags:probc')+bDiscriminator('pfDeepCSVJetTags:probb')+bDiscriminator('pfDeepCSVJetTags:probbb')):-1",float,doc=
"DeepCSV c vs b+bb discriminator",precision=10),
215 chMultiplicity =
None,
216 neMultiplicity =
None,
221 (run3_nanoAOD_122 | run3_nanoAOD_124).toModify(
228 btagPNetTauVJet =
None,
229 PNetRegPtRawCorr =
None,
230 PNetRegPtRawCorrNeutrino =
None,
231 PNetRegPtRawRes =
None,
233 chMultiplicity =
None,
234 neMultiplicity =
None,
239 bjetNN = cms.EDProducer(
"BJetEnergyRegressionMVA",
240 backend = cms.string(
"ONNX"),
241 batch_eval = cms.bool(
True),
242 src = cms.InputTag(
"linkedObjects",
"jets"),
243 pvsrc = cms.InputTag(
"offlineSlimmedPrimaryVertices"),
244 svsrc = cms.InputTag(
"slimmedSecondaryVertices"),
245 rhosrc = cms.InputTag(
"fixedGridRhoFastjetAll"),
247 weightFile = cms.FileInPath(
"PhysicsTools/NanoAOD/data/breg_training_2018.onnx"),
248 name = cms.string(
"JetRegNN"),
249 isClassifier = cms.bool(
False),
250 variablesOrder = cms.vstring([
"Jet_pt",
"Jet_eta",
"rho",
"Jet_mt",
"Jet_leadTrackPt",
"Jet_leptonPtRel",
"Jet_leptonDeltaR",
"Jet_neHEF",
251 "Jet_neEmEF",
"Jet_vtxPt",
"Jet_vtxMass",
"Jet_vtx3dL",
"Jet_vtxNtrk",
"Jet_vtx3deL",
252 "Jet_numDaughters_pt03",
"Jet_energyRing_dR0_em_Jet_rawEnergy",
"Jet_energyRing_dR1_em_Jet_rawEnergy",
253 "Jet_energyRing_dR2_em_Jet_rawEnergy",
"Jet_energyRing_dR3_em_Jet_rawEnergy",
"Jet_energyRing_dR4_em_Jet_rawEnergy",
254 "Jet_energyRing_dR0_neut_Jet_rawEnergy",
"Jet_energyRing_dR1_neut_Jet_rawEnergy",
"Jet_energyRing_dR2_neut_Jet_rawEnergy",
255 "Jet_energyRing_dR3_neut_Jet_rawEnergy",
"Jet_energyRing_dR4_neut_Jet_rawEnergy",
"Jet_energyRing_dR0_ch_Jet_rawEnergy",
256 "Jet_energyRing_dR1_ch_Jet_rawEnergy",
"Jet_energyRing_dR2_ch_Jet_rawEnergy",
"Jet_energyRing_dR3_ch_Jet_rawEnergy",
257 "Jet_energyRing_dR4_ch_Jet_rawEnergy",
"Jet_energyRing_dR0_mu_Jet_rawEnergy",
"Jet_energyRing_dR1_mu_Jet_rawEnergy",
258 "Jet_energyRing_dR2_mu_Jet_rawEnergy",
"Jet_energyRing_dR3_mu_Jet_rawEnergy",
"Jet_energyRing_dR4_mu_Jet_rawEnergy",
259 "Jet_chHEF",
"Jet_chEmEF",
"Jet_leptonPtRelInv",
"isEle",
"isMu",
"isOther",
"Jet_mass",
"Jet_ptd"]),
260 variables = cms.PSet(
261 Jet_pt = cms.string(
"pt*jecFactor('Uncorrected')"),
262 Jet_mt = cms.string(
"mt*jecFactor('Uncorrected')"),
263 Jet_eta = cms.string(
"eta"),
264 Jet_mass = cms.string(
"mass*jecFactor('Uncorrected')"),
265 Jet_ptd = cms.string(
"userFloat('ptD')"),
266 Jet_leadTrackPt = cms.string(
"userFloat('leadTrackPt')"),
267 Jet_vtxNtrk = cms.string(
"userInt('vtxNtrk')"),
268 Jet_vtxMass = cms.string(
"userFloat('vtxMass')"),
269 Jet_vtx3dL = cms.string(
"userFloat('vtx3dL')"),
270 Jet_vtx3deL = cms.string(
"userFloat('vtx3deL')"),
271 Jet_vtxPt = cms.string(
"userFloat('vtxPt')"),
272 Jet_leptonPtRel = cms.string(
"userFloat('leptonPtRelv0')"),
273 Jet_leptonPtRelInv = cms.string(
"userFloat('leptonPtRelInvv0')*jecFactor('Uncorrected')"),
274 Jet_leptonDeltaR = cms.string(
"userFloat('leptonDeltaR')"),
275 Jet_neHEF = cms.string(
"neutralHadronEnergyFraction()"),
276 Jet_neEmEF = cms.string(
"neutralEmEnergyFraction()"),
277 Jet_chHEF = cms.string(
"chargedHadronEnergyFraction()"),
278 Jet_chEmEF = cms.string(
"chargedEmEnergyFraction()"),
279 isMu = cms.string(
"?abs(userInt('leptonPdgId'))==13?1:0"),
280 isEle = cms.string(
"?abs(userInt('leptonPdgId'))==11?1:0"),
281 isOther = cms.string(
"?userInt('leptonPdgId')==0?1:0"),
283 inputTensorName = cms.string(
"ffwd_inp:0"),
284 outputTensorName = cms.string(
"ffwd_out/BiasAdd:0"),
285 outputNames = cms.vstring([
"corr",
"res"]),
286 outputFormulas = cms.vstring([
"at(0)*0.27912887930870056+1.0545977354049683",
"0.5*(at(2)-at(1))*0.27912887930870056"]),
289 cjetNN = cms.EDProducer(
"BJetEnergyRegressionMVA",
290 backend = cms.string(
"ONNX"),
291 batch_eval = cms.bool(
True),
293 src = cms.InputTag(
"linkedObjects",
"jets"),
294 pvsrc = cms.InputTag(
"offlineSlimmedPrimaryVertices"),
295 svsrc = cms.InputTag(
"slimmedSecondaryVertices"),
296 rhosrc = cms.InputTag(
"fixedGridRhoFastjetAll"),
298 weightFile = cms.FileInPath(
"PhysicsTools/NanoAOD/data/creg_training_2018.onnx"),
299 name = cms.string(
"JetRegNN"),
300 isClassifier = cms.bool(
False),
301 variablesOrder = cms.vstring([
"Jet_pt",
"Jet_eta",
"rho",
"Jet_mt",
"Jet_leadTrackPt",
"Jet_leptonPtRel",
"Jet_leptonDeltaR",
302 "Jet_neHEF",
"Jet_neEmEF",
"Jet_vtxPt",
"Jet_vtxMass",
"Jet_vtx3dL",
"Jet_vtxNtrk",
"Jet_vtx3deL",
303 "Jet_numDaughters_pt03",
"Jet_chEmEF",
"Jet_chHEF",
"Jet_ptd",
"Jet_mass",
304 "Jet_energyRing_dR0_em_Jet_rawEnergy",
"Jet_energyRing_dR1_em_Jet_rawEnergy",
305 "Jet_energyRing_dR2_em_Jet_rawEnergy",
"Jet_energyRing_dR3_em_Jet_rawEnergy",
"Jet_energyRing_dR4_em_Jet_rawEnergy",
306 "Jet_energyRing_dR0_neut_Jet_rawEnergy",
"Jet_energyRing_dR1_neut_Jet_rawEnergy",
"Jet_energyRing_dR2_neut_Jet_rawEnergy",
307 "Jet_energyRing_dR3_neut_Jet_rawEnergy",
"Jet_energyRing_dR4_neut_Jet_rawEnergy",
"Jet_energyRing_dR0_ch_Jet_rawEnergy",
308 "Jet_energyRing_dR1_ch_Jet_rawEnergy",
"Jet_energyRing_dR2_ch_Jet_rawEnergy",
"Jet_energyRing_dR3_ch_Jet_rawEnergy",
309 "Jet_energyRing_dR4_ch_Jet_rawEnergy",
"Jet_energyRing_dR0_mu_Jet_rawEnergy",
"Jet_energyRing_dR1_mu_Jet_rawEnergy",
310 "Jet_energyRing_dR2_mu_Jet_rawEnergy",
"Jet_energyRing_dR3_mu_Jet_rawEnergy",
"Jet_energyRing_dR4_mu_Jet_rawEnergy"]),
311 variables = cms.PSet(
312 Jet_pt = cms.string(
"pt*jecFactor('Uncorrected')"),
313 Jet_mt = cms.string(
"mt*jecFactor('Uncorrected')"),
314 Jet_eta = cms.string(
"eta"),
315 Jet_mass = cms.string(
"mass*jecFactor('Uncorrected')"),
316 Jet_ptd = cms.string(
"userFloat('ptD')"),
317 Jet_leadTrackPt = cms.string(
"userFloat('leadTrackPt')"),
318 Jet_vtxNtrk = cms.string(
"userInt('vtxNtrk')"),
319 Jet_vtxMass = cms.string(
"userFloat('vtxMass')"),
320 Jet_vtx3dL = cms.string(
"userFloat('vtx3dL')"),
321 Jet_vtx3deL = cms.string(
"userFloat('vtx3deL')"),
322 Jet_vtxPt = cms.string(
"userFloat('vtxPt')"),
323 Jet_leptonPtRel = cms.string(
"userFloat('leptonPtRelv0')"),
324 Jet_leptonPtRelInv = cms.string(
"userFloat('leptonPtRelInvv0')*jecFactor('Uncorrected')"),
325 Jet_leptonDeltaR = cms.string(
"userFloat('leptonDeltaR')"),
326 Jet_neHEF = cms.string(
"neutralHadronEnergyFraction()"),
327 Jet_neEmEF = cms.string(
"neutralEmEnergyFraction()"),
328 Jet_chHEF = cms.string(
"chargedHadronEnergyFraction()"),
329 Jet_chEmEF = cms.string(
"chargedEmEnergyFraction()"),
330 isMu = cms.string(
"?abs(userInt('leptonPdgId'))==13?1:0"),
331 isEle = cms.string(
"?abs(userInt('leptonPdgId'))==11?1:0"),
332 isOther = cms.string(
"?userInt('leptonPdgId')==0?1:0"),
334 inputTensorName = cms.string(
"ffwd_inp:0"),
335 outputTensorName = cms.string(
"ffwd_out/BiasAdd:0"),
336 outputNames = cms.vstring([
"corr",
"res"]),
337 outputFormulas = cms.vstring([
"at(0)*0.24325256049633026+0.993854820728302",
"0.5*(at(2)-at(1))*0.24325256049633026"]),
341 run2_jme_2016.toModify(
342 bjetNN, weightFile = cms.FileInPath(
"PhysicsTools/NanoAOD/data/breg_training_2016.onnx")
344 bjetNN,outputFormulas = cms.vstring([
"at(0)*0.31976690888404846+1.047176718711853",
"0.5*(at(2)-at(1))*0.31976690888404846"])
346 cjetNN, weightFile = cms.FileInPath(
"PhysicsTools/NanoAOD/data/creg_training_2016.onnx")
348 cjetNN, outputFormulas = cms.vstring([
"at(0)*0.28862622380256653+0.9908722639083862",
"0.5*(at(2)-at(1))*0.28862622380256653"])
351 run2_jme_2017.toModify(
352 bjetNN, weightFile = cms.FileInPath(
"PhysicsTools/NanoAOD/data/breg_training_2017.onnx")
354 bjetNN,outputFormulas = cms.vstring([
"at(0)*0.28225210309028625+1.055067777633667",
"0.5*(at(2)-at(1))*0.28225210309028625"])
356 cjetNN, weightFile = cms.FileInPath(
"PhysicsTools/NanoAOD/data/creg_training_2017.onnx")
358 cjetNN, outputFormulas = cms.vstring([
"at(0)*0.24718524515628815+0.9927206635475159",
"0.5*(at(2)-at(1))*0.24718524515628815"])
366 qgtagger=QGTagger.clone(srcJets=
"updatedJets",srcVertexCollection=
"offlineSlimmedPrimaryVertices")
372 pileupJetIdNano=pileupJetId.clone(jets=
"updatedJets",algos = cms.VPSet(_chsalgos_106X_UL18),inputIsCorrected=
True,applyJec=
False,vertexes=
"offlineSlimmedPrimaryVertices")
373 run2_jme_2017.toModify(
374 pileupJetIdNano, algos = _chsalgos_106X_UL17
376 (run2_jme_2016 & ~tracker_apv_vfp30_2016 ).toModify(
377 pileupJetIdNano, algos = _chsalgos_106X_UL16
379 (run2_jme_2016 & tracker_apv_vfp30_2016 ).toModify(
380 pileupJetIdNano, algos = _chsalgos_106X_UL16APV
389 _btagDiscriminators=[]
391 print(
"Updating process to run DeepCSV btag")
392 _btagDiscriminators += [
'pfDeepCSVJetTags:probb',
'pfDeepCSVJetTags:probbb',
'pfDeepCSVJetTags:probc']
394 print(
"Updating process to run DeepFlavour btag")
395 _btagDiscriminators += [
'pfDeepFlavourJetTags:probb',
'pfDeepFlavourJetTags:probbb',
'pfDeepFlavourJetTags:problepb',
'pfDeepFlavourJetTags:probc']
397 print(
"Updating process to run ParticleNetAK4")
398 from RecoBTag.ONNXRuntime.pfParticleNetFromMiniAODAK4_cff
import _pfParticleNetFromMiniAODAK4CHSCentralJetTagsAll
as pfParticleNetFromMiniAODAK4CHSCentralJetTagsAll
399 from RecoBTag.ONNXRuntime.pfParticleNetFromMiniAODAK4_cff
import _pfParticleNetFromMiniAODAK4CHSForwardJetTagsAll
as pfParticleNetFromMiniAODAK4CHSForwardJetTagsAll
400 _btagDiscriminators += pfParticleNetFromMiniAODAK4CHSCentralJetTagsAll
401 _btagDiscriminators += pfParticleNetFromMiniAODAK4CHSForwardJetTagsAll
403 print(
"Updating process to run RobustParTAK4")
405 _btagDiscriminators += pfParticleTransformerAK4JetTagsAll
407 if len(_btagDiscriminators)==0:
return process
408 print(
"Will recalculate the following discriminators: "+
", ".
join(_btagDiscriminators))
411 jetSource = cms.InputTag(
'slimmedJets'),
412 jetCorrections = (
'AK4PFchs', cms.vstring([
'L1FastJet',
'L2Relative',
'L3Absolute',
'L2L3Residual']),
'None'),
413 btagDiscriminators = _btagDiscriminators,
414 postfix =
'WithDeepInfo',
416 process.load(
"Configuration.StandardSequences.MagneticField_cff")
417 process.jetCorrFactorsNano.src=
"selectedUpdatedPatJetsWithDeepInfo" 418 process.updatedJets.jetSource=
"selectedUpdatedPatJetsWithDeepInfo" 421 nanoAOD_addDeepInfoAK4CHS_switch = cms.PSet(
422 nanoAOD_addDeepBTag_switch = cms.untracked.bool(
False),
423 nanoAOD_addDeepFlavourTag_switch = cms.untracked.bool(
False),
424 nanoAOD_addParticleNet_switch = cms.untracked.bool(
False),
425 nanoAOD_addRobustParTAK4Tag_switch = cms.untracked.bool(
False)
435 from Configuration.Eras.Modifier_fastSim_cff
import fastSim
438 fastSim.toModify( process.jetTable.variables,
439 btagDeepFlavBunrefined = process.jetTable.variables.btagDeepFlavB.clone(),
440 btagDeepFlavCvBunrefined = process.jetTable.variables.btagDeepFlavCvB.clone(),
441 btagDeepFlavCvLunrefined = process.jetTable.variables.btagDeepFlavCvL.clone(),
442 btagDeepFlavQGunrefined = process.jetTable.variables.btagDeepFlavQG.clone(),
445 fastSim.toModify( process.jetTable.variables,
446 btagDeepFlavB =
None,
447 btagDeepFlavCvB =
None,
448 btagDeepFlavCvL =
None,
449 btagDeepFlavQG =
None,
452 fastSim.toModify( process.jetTable.externalVariables,
453 btagDeepFlavB =
ExtVar(cms.InputTag(
"btagDeepFlavRefineNN:btagDeepFlavBrefined"), float, doc=
"DeepJet b+bb+lepb tag discriminator", precision=10),
454 btagDeepFlavCvB =
ExtVar(cms.InputTag(
"btagDeepFlavRefineNN:btagDeepFlavCvBrefined"), float, doc=
"DeepJet c vs b+bb+lepb discriminator", precision=10),
455 btagDeepFlavCvL =
ExtVar(cms.InputTag(
"btagDeepFlavRefineNN:btagDeepFlavCvLrefined"), float, doc=
"DeepJet c vs uds+g discriminator", precision=10),
456 btagDeepFlavQG =
ExtVar(cms.InputTag(
"btagDeepFlavRefineNN:btagDeepFlavQGrefined"), float, doc=
"DeepJet g vs uds discriminator", precision=10),
459 process.btagDeepFlavRefineNN= cms.EDProducer(
"JetBaseMVAValueMapProducer",
460 backend = cms.string(
"ONNX"),
461 batch_eval = cms.bool(
True),
462 disableONNXGraphOpt = cms.bool(
True),
464 src = cms.InputTag(
"linkedObjects",
"jets"),
466 weightFile=cms.FileInPath(
"PhysicsTools/NanoAOD/data/btagDeepFlavRefineNN_CHS.onnx"),
467 name = cms.string(
"btagDeepFlavRefineNN"),
469 isClassifier = cms.bool(
False),
470 variablesOrder = cms.vstring([
"GenJet_pt",
"GenJet_eta",
"Jet_hadronFlavour",
471 "Jet_btagDeepFlavB",
"Jet_btagDeepFlavCvB",
"Jet_btagDeepFlavCvL",
"Jet_btagDeepFlavQG"]),
472 variables = cms.PSet(
473 GenJet_pt = cms.string(
"?genJetFwdRef().backRef().isNonnull()?genJetFwdRef().backRef().pt():pt"),
474 GenJet_eta = cms.string(
"?genJetFwdRef().backRef().isNonnull()?genJetFwdRef().backRef().eta():eta"),
475 Jet_hadronFlavour = cms.string(
"hadronFlavour()"),
476 Jet_btagDeepFlavB = cms.string(
"bDiscriminator('pfDeepFlavourJetTags:probb')+bDiscriminator('pfDeepFlavourJetTags:probbb')+bDiscriminator('pfDeepFlavourJetTags:problepb')"),
477 Jet_btagDeepFlavCvB = cms.string(
"?(bDiscriminator('pfDeepFlavourJetTags:probc')+bDiscriminator('pfDeepFlavourJetTags:probb')+bDiscriminator('pfDeepFlavourJetTags:probbb')+bDiscriminator('pfDeepFlavourJetTags:problepb'))>0?bDiscriminator('pfDeepFlavourJetTags:probc')/(bDiscriminator('pfDeepFlavourJetTags:probc')+bDiscriminator('pfDeepFlavourJetTags:probb')+bDiscriminator('pfDeepFlavourJetTags:probbb')+bDiscriminator('pfDeepFlavourJetTags:problepb')):-1"),
478 Jet_btagDeepFlavCvL = cms.string(
"?(bDiscriminator('pfDeepFlavourJetTags:probc')+bDiscriminator('pfDeepFlavourJetTags:probuds')+bDiscriminator('pfDeepFlavourJetTags:probg'))>0?bDiscriminator('pfDeepFlavourJetTags:probc')/(bDiscriminator('pfDeepFlavourJetTags:probc')+bDiscriminator('pfDeepFlavourJetTags:probuds')+bDiscriminator('pfDeepFlavourJetTags:probg')):-1"),
479 Jet_btagDeepFlavQG = cms.string(
"?(bDiscriminator('pfDeepFlavourJetTags:probg')+bDiscriminator('pfDeepFlavourJetTags:probuds'))>0?bDiscriminator('pfDeepFlavourJetTags:probg')/(bDiscriminator('pfDeepFlavourJetTags:probg')+bDiscriminator('pfDeepFlavourJetTags:probuds')):-1"),
481 inputTensorName = cms.string(
"input"),
482 outputTensorName = cms.string(
"output"),
483 outputNames = cms.vstring([
"btagDeepFlavBrefined",
"btagDeepFlavCvBrefined",
"btagDeepFlavCvLrefined",
"btagDeepFlavQGrefined"]),
484 outputFormulas = cms.vstring([
"at(0)",
"at(1)",
"at(2)",
"at(3)"]),
487 fastSim.toModify(process.jetTablesTask, process.jetTablesTask.add(process.btagDeepFlavRefineNN))
495 basicJetsForMetForT1METNano = cms.EDProducer(
"PATJetCleanerForType1MET",
496 src = updatedJetsWithUserData.src,
497 jetCorrEtaMax = cms.double(9.9),
498 jetCorrLabel = cms.InputTag(
"L3Absolute"),
499 jetCorrLabelRes = cms.InputTag(
"L2L3Residual"),
500 offsetCorrLabel = cms.InputTag(
"L1FastJet"),
501 skipEM = cms.bool(
False),
502 skipEMfractionThreshold = cms.double(0.9),
503 skipMuonSelection = cms.string(
'isGlobalMuon | isStandAloneMuon'),
504 skipMuons = cms.bool(
True),
505 type1JetPtThreshold = cms.double(0.0),
506 calcMuonSubtrRawPtAsValueMap = cms.bool(
True)
509 updatedJetsWithUserData.userFloats.muonSubtrRawPt = cms.InputTag(
"basicJetsForMetForT1METNano:MuonSubtrRawPt")
511 corrT1METJetTable = simpleCandidateFlatTableProducer.clone(
513 cut = cms.string(
"pt<15 && abs(eta)<9.9"),
514 name = cms.string(
"CorrT1METJet"),
515 doc = cms.string(
"Additional low-pt ak4 CHS jets for Type-1 MET re-correction"),
516 variables = cms.PSet(
517 rawPt =
Var(
"pt()*jecFactor('Uncorrected')",float,precision=10),
518 eta =
Var(
"eta", float,precision=12),
519 phi =
Var(
"phi", float, precision=12),
520 area =
Var(
"jetArea()", float, doc=
"jet catchment area, for JECs",precision=10),
521 EmEF =
Var(
"chargedEmEnergyFraction()+neutralEmEnergyFraction()", float, doc=
"charged+neutral Electromagnetic Energy Fraction", precision=6),
525 corrT1METJetTable.variables.muonSubtrFactor =
Var(
"1-userFloat('muonSubtrRawPt')/(pt()*jecFactor('Uncorrected'))",float,doc=
"1-(muon-subtracted raw pt)/(raw pt)",precision=6)
526 jetTable.variables.muonSubtrFactor =
Var(
"1-userFloat('muonSubtrRawPt')/(pt()*jecFactor('Uncorrected'))",float,doc=
"1-(muon-subtracted raw pt)/(raw pt)",precision=6)
528 jetForMETTask = cms.Task(basicJetsForMetForT1METNano,corrT1METJetTable)
531 jetUserDataTask = cms.Task(bJetVars,qgtagger,jercVars,tightJetId,tightJetIdLepVeto,pileupJetIdNano)
534 jetTask = cms.Task(jetCorrFactorsNano,updatedJets,jetUserDataTask,updatedJetsWithUserData,finalJets)
537 jetTablesTask = cms.Task(bjetNN,cjetNN,jetTable)
def ExtVar(tag, valtype, doc=None, precision=-1)
def Var(expr, valtype, doc=None, precision=-1)
def nanoAOD_refineFastSim_bTagDeepFlav(process)
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
def nanoAOD_addDeepInfoAK4CHS(process, addDeepBTag, addDeepFlavour, addParticleNet, addRobustParTAK4=False)
static std::string join(char **cmd)