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(
'RUN3WINTER22CHS'),
40 quality = cms.string(
'TIGHT'),
42 src = cms.InputTag(
"updatedJets")
44 tightJetIdLepVeto = cms.EDProducer(
"PatJetIDValueMapProducer",
45 filterParams=cms.PSet(
46 version = cms.string(
'RUN3WINTER22CHS'),
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 =
"RUN3WINTER22CHSrunsBCDEprompt" 66 tightJetIdLepVeto.filterParams, version =
"RUN3WINTER22CHSrunsBCDEprompt" 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('pfDeepFlavourJetTags:probbb')+bDiscriminator('pfDeepFlavourJetTags: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 rawFactor =
Var(
"1.-jecFactor('Uncorrected')",float,doc=
"1 - Factor to get back to raw pT",precision=6),
175 chHEF =
Var(
"chargedHadronEnergyFraction()", float, doc=
"charged Hadron Energy Fraction", precision= 6),
176 neHEF =
Var(
"neutralHadronEnergyFraction()", float, doc=
"neutral Hadron Energy Fraction", precision= 6),
177 chEmEF =
Var(
"chargedEmEnergyFraction()", float, doc=
"charged Electromagnetic Energy Fraction", precision= 6),
178 neEmEF =
Var(
"neutralEmEnergyFraction()", float, doc=
"neutral Electromagnetic Energy Fraction", precision= 6),
179 muEF =
Var(
"muonEnergyFraction()", float, doc=
"muon Energy Fraction", precision= 6),
180 chFPV0EF =
Var(
"userFloat('chFPV0EF')", float, doc=
"charged fromPV==0 Energy Fraction (energy excluded from CHS jets). Previously called betastar.", precision= 6),
185 jetTable.variables.pt.precision=10
188 (run2_jme_2016 & ~tracker_apv_vfp30_2016 ).toModify(
189 jetTable.variables.puIdDisc, doc=
"Pileup ID discriminant with 106X (2016) training" 191 jetTable.variables.puId, doc=
"Pileup ID flags with 106X (2016) training" 193 (run2_jme_2016 & tracker_apv_vfp30_2016 ).toModify(
194 jetTable.variables.puIdDisc, doc=
"Pileup ID discriminant with 106X (2016APV) training" 196 jetTable.variables.puId, doc=
"Pileup ID flags with 106X (2016APV) training" 198 run2_jme_2017.toModify(
199 jetTable.variables.puIdDisc, doc=
"Pileup ID discriminant with 106X (2017) training" 201 jetTable.variables.puId, doc=
"Pileup ID flags with 106X (2017) training" 204 run2_nanoAOD_ANY.toModify(
206 btagCSVV2 =
Var(
"bDiscriminator('pfCombinedInclusiveSecondaryVertexV2BJetTags')",float,doc=
" pfCombinedInclusiveSecondaryVertexV2 b-tag discriminator (aka CSVV2)",precision=10),
207 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),
208 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),
209 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)
212 (run3_nanoAOD_122 | run3_nanoAOD_124).toModify(
219 btagPNetTauVJet =
None,
220 PNetRegPtRawCorr =
None,
221 PNetRegPtRawCorrNeutrino =
None,
222 PNetRegPtRawRes =
None 225 bjetNN = cms.EDProducer(
"BJetEnergyRegressionMVA",
226 backend = cms.string(
"ONNX"),
227 batch_eval = cms.bool(
True),
228 src = cms.InputTag(
"linkedObjects",
"jets"),
229 pvsrc = cms.InputTag(
"offlineSlimmedPrimaryVertices"),
230 svsrc = cms.InputTag(
"slimmedSecondaryVertices"),
231 rhosrc = cms.InputTag(
"fixedGridRhoFastjetAll"),
233 weightFile = cms.FileInPath(
"PhysicsTools/NanoAOD/data/breg_training_2018.onnx"),
234 name = cms.string(
"JetRegNN"),
235 isClassifier = cms.bool(
False),
236 variablesOrder = cms.vstring([
"Jet_pt",
"Jet_eta",
"rho",
"Jet_mt",
"Jet_leadTrackPt",
"Jet_leptonPtRel",
"Jet_leptonDeltaR",
"Jet_neHEF",
237 "Jet_neEmEF",
"Jet_vtxPt",
"Jet_vtxMass",
"Jet_vtx3dL",
"Jet_vtxNtrk",
"Jet_vtx3deL",
238 "Jet_numDaughters_pt03",
"Jet_energyRing_dR0_em_Jet_rawEnergy",
"Jet_energyRing_dR1_em_Jet_rawEnergy",
239 "Jet_energyRing_dR2_em_Jet_rawEnergy",
"Jet_energyRing_dR3_em_Jet_rawEnergy",
"Jet_energyRing_dR4_em_Jet_rawEnergy",
240 "Jet_energyRing_dR0_neut_Jet_rawEnergy",
"Jet_energyRing_dR1_neut_Jet_rawEnergy",
"Jet_energyRing_dR2_neut_Jet_rawEnergy",
241 "Jet_energyRing_dR3_neut_Jet_rawEnergy",
"Jet_energyRing_dR4_neut_Jet_rawEnergy",
"Jet_energyRing_dR0_ch_Jet_rawEnergy",
242 "Jet_energyRing_dR1_ch_Jet_rawEnergy",
"Jet_energyRing_dR2_ch_Jet_rawEnergy",
"Jet_energyRing_dR3_ch_Jet_rawEnergy",
243 "Jet_energyRing_dR4_ch_Jet_rawEnergy",
"Jet_energyRing_dR0_mu_Jet_rawEnergy",
"Jet_energyRing_dR1_mu_Jet_rawEnergy",
244 "Jet_energyRing_dR2_mu_Jet_rawEnergy",
"Jet_energyRing_dR3_mu_Jet_rawEnergy",
"Jet_energyRing_dR4_mu_Jet_rawEnergy",
245 "Jet_chHEF",
"Jet_chEmEF",
"Jet_leptonPtRelInv",
"isEle",
"isMu",
"isOther",
"Jet_mass",
"Jet_ptd"]),
246 variables = cms.PSet(
247 Jet_pt = cms.string(
"pt*jecFactor('Uncorrected')"),
248 Jet_mt = cms.string(
"mt*jecFactor('Uncorrected')"),
249 Jet_eta = cms.string(
"eta"),
250 Jet_mass = cms.string(
"mass*jecFactor('Uncorrected')"),
251 Jet_ptd = cms.string(
"userFloat('ptD')"),
252 Jet_leadTrackPt = cms.string(
"userFloat('leadTrackPt')"),
253 Jet_vtxNtrk = cms.string(
"userInt('vtxNtrk')"),
254 Jet_vtxMass = cms.string(
"userFloat('vtxMass')"),
255 Jet_vtx3dL = cms.string(
"userFloat('vtx3dL')"),
256 Jet_vtx3deL = cms.string(
"userFloat('vtx3deL')"),
257 Jet_vtxPt = cms.string(
"userFloat('vtxPt')"),
258 Jet_leptonPtRel = cms.string(
"userFloat('leptonPtRelv0')"),
259 Jet_leptonPtRelInv = cms.string(
"userFloat('leptonPtRelInvv0')*jecFactor('Uncorrected')"),
260 Jet_leptonDeltaR = cms.string(
"userFloat('leptonDeltaR')"),
261 Jet_neHEF = cms.string(
"neutralHadronEnergyFraction()"),
262 Jet_neEmEF = cms.string(
"neutralEmEnergyFraction()"),
263 Jet_chHEF = cms.string(
"chargedHadronEnergyFraction()"),
264 Jet_chEmEF = cms.string(
"chargedEmEnergyFraction()"),
265 isMu = cms.string(
"?abs(userInt('leptonPdgId'))==13?1:0"),
266 isEle = cms.string(
"?abs(userInt('leptonPdgId'))==11?1:0"),
267 isOther = cms.string(
"?userInt('leptonPdgId')==0?1:0"),
269 inputTensorName = cms.string(
"ffwd_inp:0"),
270 outputTensorName = cms.string(
"ffwd_out/BiasAdd:0"),
271 outputNames = cms.vstring([
"corr",
"res"]),
272 outputFormulas = cms.vstring([
"at(0)*0.27912887930870056+1.0545977354049683",
"0.5*(at(2)-at(1))*0.27912887930870056"]),
275 cjetNN = cms.EDProducer(
"BJetEnergyRegressionMVA",
276 backend = cms.string(
"ONNX"),
277 batch_eval = cms.bool(
True),
279 src = cms.InputTag(
"linkedObjects",
"jets"),
280 pvsrc = cms.InputTag(
"offlineSlimmedPrimaryVertices"),
281 svsrc = cms.InputTag(
"slimmedSecondaryVertices"),
282 rhosrc = cms.InputTag(
"fixedGridRhoFastjetAll"),
284 weightFile = cms.FileInPath(
"PhysicsTools/NanoAOD/data/creg_training_2018.onnx"),
285 name = cms.string(
"JetRegNN"),
286 isClassifier = cms.bool(
False),
287 variablesOrder = cms.vstring([
"Jet_pt",
"Jet_eta",
"rho",
"Jet_mt",
"Jet_leadTrackPt",
"Jet_leptonPtRel",
"Jet_leptonDeltaR",
288 "Jet_neHEF",
"Jet_neEmEF",
"Jet_vtxPt",
"Jet_vtxMass",
"Jet_vtx3dL",
"Jet_vtxNtrk",
"Jet_vtx3deL",
289 "Jet_numDaughters_pt03",
"Jet_chEmEF",
"Jet_chHEF",
"Jet_ptd",
"Jet_mass",
290 "Jet_energyRing_dR0_em_Jet_rawEnergy",
"Jet_energyRing_dR1_em_Jet_rawEnergy",
291 "Jet_energyRing_dR2_em_Jet_rawEnergy",
"Jet_energyRing_dR3_em_Jet_rawEnergy",
"Jet_energyRing_dR4_em_Jet_rawEnergy",
292 "Jet_energyRing_dR0_neut_Jet_rawEnergy",
"Jet_energyRing_dR1_neut_Jet_rawEnergy",
"Jet_energyRing_dR2_neut_Jet_rawEnergy",
293 "Jet_energyRing_dR3_neut_Jet_rawEnergy",
"Jet_energyRing_dR4_neut_Jet_rawEnergy",
"Jet_energyRing_dR0_ch_Jet_rawEnergy",
294 "Jet_energyRing_dR1_ch_Jet_rawEnergy",
"Jet_energyRing_dR2_ch_Jet_rawEnergy",
"Jet_energyRing_dR3_ch_Jet_rawEnergy",
295 "Jet_energyRing_dR4_ch_Jet_rawEnergy",
"Jet_energyRing_dR0_mu_Jet_rawEnergy",
"Jet_energyRing_dR1_mu_Jet_rawEnergy",
296 "Jet_energyRing_dR2_mu_Jet_rawEnergy",
"Jet_energyRing_dR3_mu_Jet_rawEnergy",
"Jet_energyRing_dR4_mu_Jet_rawEnergy"]),
297 variables = cms.PSet(
298 Jet_pt = cms.string(
"pt*jecFactor('Uncorrected')"),
299 Jet_mt = cms.string(
"mt*jecFactor('Uncorrected')"),
300 Jet_eta = cms.string(
"eta"),
301 Jet_mass = cms.string(
"mass*jecFactor('Uncorrected')"),
302 Jet_ptd = cms.string(
"userFloat('ptD')"),
303 Jet_leadTrackPt = cms.string(
"userFloat('leadTrackPt')"),
304 Jet_vtxNtrk = cms.string(
"userInt('vtxNtrk')"),
305 Jet_vtxMass = cms.string(
"userFloat('vtxMass')"),
306 Jet_vtx3dL = cms.string(
"userFloat('vtx3dL')"),
307 Jet_vtx3deL = cms.string(
"userFloat('vtx3deL')"),
308 Jet_vtxPt = cms.string(
"userFloat('vtxPt')"),
309 Jet_leptonPtRel = cms.string(
"userFloat('leptonPtRelv0')"),
310 Jet_leptonPtRelInv = cms.string(
"userFloat('leptonPtRelInvv0')*jecFactor('Uncorrected')"),
311 Jet_leptonDeltaR = cms.string(
"userFloat('leptonDeltaR')"),
312 Jet_neHEF = cms.string(
"neutralHadronEnergyFraction()"),
313 Jet_neEmEF = cms.string(
"neutralEmEnergyFraction()"),
314 Jet_chHEF = cms.string(
"chargedHadronEnergyFraction()"),
315 Jet_chEmEF = cms.string(
"chargedEmEnergyFraction()"),
316 isMu = cms.string(
"?abs(userInt('leptonPdgId'))==13?1:0"),
317 isEle = cms.string(
"?abs(userInt('leptonPdgId'))==11?1:0"),
318 isOther = cms.string(
"?userInt('leptonPdgId')==0?1:0"),
320 inputTensorName = cms.string(
"ffwd_inp:0"),
321 outputTensorName = cms.string(
"ffwd_out/BiasAdd:0"),
322 outputNames = cms.vstring([
"corr",
"res"]),
323 outputFormulas = cms.vstring([
"at(0)*0.24325256049633026+0.993854820728302",
"0.5*(at(2)-at(1))*0.24325256049633026"]),
327 run2_jme_2016.toModify(
328 bjetNN, weightFile = cms.FileInPath(
"PhysicsTools/NanoAOD/data/breg_training_2016.onnx")
330 bjetNN,outputFormulas = cms.vstring([
"at(0)*0.31976690888404846+1.047176718711853",
"0.5*(at(2)-at(1))*0.31976690888404846"])
332 cjetNN, weightFile = cms.FileInPath(
"PhysicsTools/NanoAOD/data/creg_training_2016.onnx")
334 cjetNN, outputFormulas = cms.vstring([
"at(0)*0.28862622380256653+0.9908722639083862",
"0.5*(at(2)-at(1))*0.28862622380256653"])
337 run2_jme_2017.toModify(
338 bjetNN, weightFile = cms.FileInPath(
"PhysicsTools/NanoAOD/data/breg_training_2017.onnx")
340 bjetNN,outputFormulas = cms.vstring([
"at(0)*0.28225210309028625+1.055067777633667",
"0.5*(at(2)-at(1))*0.28225210309028625"])
342 cjetNN, weightFile = cms.FileInPath(
"PhysicsTools/NanoAOD/data/creg_training_2017.onnx")
344 cjetNN, outputFormulas = cms.vstring([
"at(0)*0.24718524515628815+0.9927206635475159",
"0.5*(at(2)-at(1))*0.24718524515628815"])
352 qgtagger=QGTagger.clone(srcJets=
"updatedJets",srcVertexCollection=
"offlineSlimmedPrimaryVertices")
358 pileupJetIdNano=pileupJetId.clone(jets=
"updatedJets",algos = cms.VPSet(_chsalgos_106X_UL18),inputIsCorrected=
True,applyJec=
False,vertexes=
"offlineSlimmedPrimaryVertices")
359 run2_jme_2017.toModify(
360 pileupJetIdNano, algos = _chsalgos_106X_UL17
362 (run2_jme_2016 & ~tracker_apv_vfp30_2016 ).toModify(
363 pileupJetIdNano, algos = _chsalgos_106X_UL16
365 (run2_jme_2016 & tracker_apv_vfp30_2016 ).toModify(
366 pileupJetIdNano, algos = _chsalgos_106X_UL16APV
375 _btagDiscriminators=[]
377 print(
"Updating process to run DeepCSV btag")
378 _btagDiscriminators += [
'pfDeepCSVJetTags:probb',
'pfDeepCSVJetTags:probbb',
'pfDeepCSVJetTags:probc']
380 print(
"Updating process to run DeepFlavour btag")
381 _btagDiscriminators += [
'pfDeepFlavourJetTags:probb',
'pfDeepFlavourJetTags:probbb',
'pfDeepFlavourJetTags:problepb',
'pfDeepFlavourJetTags:probc']
383 print(
"Updating process to run ParticleNetAK4")
384 from RecoBTag.ONNXRuntime.pfParticleNetFromMiniAODAK4_cff
import _pfParticleNetFromMiniAODAK4CHSCentralJetTagsAll
as pfParticleNetFromMiniAODAK4CHSCentralJetTagsAll
385 from RecoBTag.ONNXRuntime.pfParticleNetFromMiniAODAK4_cff
import _pfParticleNetFromMiniAODAK4CHSForwardJetTagsAll
as pfParticleNetFromMiniAODAK4CHSForwardJetTagsAll
386 _btagDiscriminators += pfParticleNetFromMiniAODAK4CHSCentralJetTagsAll
387 _btagDiscriminators += pfParticleNetFromMiniAODAK4CHSForwardJetTagsAll
389 print(
"Updating process to run RobustParTAK4")
391 _btagDiscriminators += pfParticleTransformerAK4JetTagsAll
393 if len(_btagDiscriminators)==0:
return process
394 print(
"Will recalculate the following discriminators: "+
", ".
join(_btagDiscriminators))
397 jetSource = cms.InputTag(
'slimmedJets'),
398 jetCorrections = (
'AK4PFchs', cms.vstring([
'L1FastJet',
'L2Relative',
'L3Absolute',
'L2L3Residual']),
'None'),
399 btagDiscriminators = _btagDiscriminators,
400 postfix =
'WithDeepInfo',
402 process.load(
"Configuration.StandardSequences.MagneticField_cff")
403 process.jetCorrFactorsNano.src=
"selectedUpdatedPatJetsWithDeepInfo" 404 process.updatedJets.jetSource=
"selectedUpdatedPatJetsWithDeepInfo" 407 nanoAOD_addDeepInfoAK4CHS_switch = cms.PSet(
408 nanoAOD_addDeepBTag_switch = cms.untracked.bool(
False),
409 nanoAOD_addDeepFlavourTag_switch = cms.untracked.bool(
False),
410 nanoAOD_addParticleNet_switch = cms.untracked.bool(
False),
411 nanoAOD_addRobustParTAK4Tag_switch = cms.untracked.bool(
False)
421 from Configuration.Eras.Modifier_fastSim_cff
import fastSim
424 fastSim.toModify( process.jetTable.variables,
425 btagDeepFlavBunrefined = process.jetTable.variables.btagDeepFlavB.clone(),
426 btagDeepFlavCvBunrefined = process.jetTable.variables.btagDeepFlavCvB.clone(),
427 btagDeepFlavCvLunrefined = process.jetTable.variables.btagDeepFlavCvL.clone(),
428 btagDeepFlavQGunrefined = process.jetTable.variables.btagDeepFlavQG.clone(),
431 fastSim.toModify( process.jetTable.variables,
432 btagDeepFlavB =
None,
433 btagDeepFlavCvB =
None,
434 btagDeepFlavCvL =
None,
435 btagDeepFlavQG =
None,
438 fastSim.toModify( process.jetTable.externalVariables,
439 btagDeepFlavB =
ExtVar(cms.InputTag(
"btagDeepFlavRefineNN:btagDeepFlavBrefined"), float, doc=
"DeepJet b+bb+lepb tag discriminator", precision=10),
440 btagDeepFlavCvB =
ExtVar(cms.InputTag(
"btagDeepFlavRefineNN:btagDeepFlavCvBrefined"), float, doc=
"DeepJet c vs b+bb+lepb discriminator", precision=10),
441 btagDeepFlavCvL =
ExtVar(cms.InputTag(
"btagDeepFlavRefineNN:btagDeepFlavCvLrefined"), float, doc=
"DeepJet c vs uds+g discriminator", precision=10),
442 btagDeepFlavQG =
ExtVar(cms.InputTag(
"btagDeepFlavRefineNN:btagDeepFlavQGrefined"), float, doc=
"DeepJet g vs uds discriminator", precision=10),
445 process.btagDeepFlavRefineNN= cms.EDProducer(
"JetBaseMVAValueMapProducer",
446 backend = cms.string(
"ONNX"),
447 batch_eval = cms.bool(
True),
448 disableONNXGraphOpt = cms.bool(
True),
450 src = cms.InputTag(
"linkedObjects",
"jets"),
452 weightFile=cms.FileInPath(
"PhysicsTools/NanoAOD/data/btagDeepFlavRefineNN_CHS.onnx"),
453 name = cms.string(
"btagDeepFlavRefineNN"),
455 isClassifier = cms.bool(
False),
456 variablesOrder = cms.vstring([
"GenJet_pt",
"GenJet_eta",
"Jet_hadronFlavour",
457 "Jet_btagDeepFlavB",
"Jet_btagDeepFlavCvB",
"Jet_btagDeepFlavCvL",
"Jet_btagDeepFlavQG"]),
458 variables = cms.PSet(
459 GenJet_pt = cms.string(
"?genJetFwdRef().backRef().isNonnull()?genJetFwdRef().backRef().pt():pt"),
460 GenJet_eta = cms.string(
"?genJetFwdRef().backRef().isNonnull()?genJetFwdRef().backRef().eta():eta"),
461 Jet_hadronFlavour = cms.string(
"hadronFlavour()"),
462 Jet_btagDeepFlavB = cms.string(
"bDiscriminator('pfDeepFlavourJetTags:probb')+bDiscriminator('pfDeepFlavourJetTags:probbb')+bDiscriminator('pfDeepFlavourJetTags:problepb')"),
463 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"),
464 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"),
465 Jet_btagDeepFlavQG = cms.string(
"?(bDiscriminator('pfDeepFlavourJetTags:probg')+bDiscriminator('pfDeepFlavourJetTags:probuds'))>0?bDiscriminator('pfDeepFlavourJetTags:probg')/(bDiscriminator('pfDeepFlavourJetTags:probg')+bDiscriminator('pfDeepFlavourJetTags:probuds')):-1"),
467 inputTensorName = cms.string(
"input"),
468 outputTensorName = cms.string(
"output"),
469 outputNames = cms.vstring([
"btagDeepFlavBrefined",
"btagDeepFlavCvBrefined",
"btagDeepFlavCvLrefined",
"btagDeepFlavQGrefined"]),
470 outputFormulas = cms.vstring([
"at(0)",
"at(1)",
"at(2)",
"at(3)"]),
473 fastSim.toModify(process.jetTablesTask, process.jetTablesTask.add(process.btagDeepFlavRefineNN))
481 basicJetsForMetForT1METNano = cms.EDProducer(
"PATJetCleanerForType1MET",
482 src = updatedJetsWithUserData.src,
483 jetCorrEtaMax = cms.double(9.9),
484 jetCorrLabel = cms.InputTag(
"L3Absolute"),
485 jetCorrLabelRes = cms.InputTag(
"L2L3Residual"),
486 offsetCorrLabel = cms.InputTag(
"L1FastJet"),
487 skipEM = cms.bool(
False),
488 skipEMfractionThreshold = cms.double(0.9),
489 skipMuonSelection = cms.string(
'isGlobalMuon | isStandAloneMuon'),
490 skipMuons = cms.bool(
True),
491 type1JetPtThreshold = cms.double(0.0),
492 calcMuonSubtrRawPtAsValueMap = cms.bool(
True)
495 updatedJetsWithUserData.userFloats.muonSubtrRawPt = cms.InputTag(
"basicJetsForMetForT1METNano:MuonSubtrRawPt")
497 corrT1METJetTable = simpleCandidateFlatTableProducer.clone(
499 cut = cms.string(
"pt<15 && abs(eta)<9.9"),
500 name = cms.string(
"CorrT1METJet"),
501 doc = cms.string(
"Additional low-pt ak4 CHS jets for Type-1 MET re-correction"),
502 variables = cms.PSet(
503 rawPt =
Var(
"pt()*jecFactor('Uncorrected')",float,precision=10),
504 eta =
Var(
"eta", float,precision=12),
505 phi =
Var(
"phi", float, precision=12),
506 area =
Var(
"jetArea()", float, doc=
"jet catchment area, for JECs",precision=10),
510 corrT1METJetTable.variables.muonSubtrFactor =
Var(
"1-userFloat('muonSubtrRawPt')/(pt()*jecFactor('Uncorrected'))",float,doc=
"1-(muon-subtracted raw pt)/(raw pt)",precision=6)
511 jetTable.variables.muonSubtrFactor =
Var(
"1-userFloat('muonSubtrRawPt')/(pt()*jecFactor('Uncorrected'))",float,doc=
"1-(muon-subtracted raw pt)/(raw pt)",precision=6)
513 jetForMETTask = cms.Task(basicJetsForMetForT1METNano,corrT1METJetTable)
516 jetUserDataTask = cms.Task(bJetVars,qgtagger,jercVars,tightJetId,tightJetIdLepVeto,pileupJetIdNano)
519 jetTask = cms.Task(jetCorrFactorsNano,updatedJets,jetUserDataTask,updatedJetsWithUserData,finalJets)
522 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)