1 import FWCore.ParameterSet.Config
as cms
5 from PhysicsTools.NanoAOD.simplePATJetFlatTableProducer_cfi
import simplePATJetFlatTableProducer
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 = simplePATJetFlatTableProducer.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 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),
139 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),
140 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),
141 btagPNetB =
Var(
"?bDiscriminator('pfParticleNetFromMiniAODAK4CHSCentralDiscriminatorsJetTags:BvsAll')>0?bDiscriminator('pfParticleNetFromMiniAODAK4CHSCentralDiscriminatorsJetTags:BvsAll'):-1",float,precision=10,doc=
"ParticleNet b vs. udscg"),
142 btagPNetCvL =
Var(
"?bDiscriminator('pfParticleNetFromMiniAODAK4CHSCentralDiscriminatorsJetTags:CvsL')>0?bDiscriminator('pfParticleNetFromMiniAODAK4CHSCentralDiscriminatorsJetTags:CvsL'):-1",float,precision=10,doc=
"ParticleNet c vs. udsg"),
143 btagPNetCvB =
Var(
"?bDiscriminator('pfParticleNetFromMiniAODAK4CHSCentralDiscriminatorsJetTags:CvsB')>0?bDiscriminator('pfParticleNetFromMiniAODAK4CHSCentralDiscriminatorsJetTags:CvsB'):-1",float,precision=10,doc=
"ParticleNet c vs. b"),
144 btagPNetCvNotB =
Var(
"?bDiscriminator('pfParticleNetFromMiniAODAK4CHSCentralJetTags:probb')>0?bDiscriminator('pfParticleNetFromMiniAODAK4CHSCentralJetTags:probc')/(1.-bDiscriminator('pfParticleNetFromMiniAODAK4CHSCentralJetTags:probb')):-1",float,precision=10,doc=
"ParticleNet C vs notB"),
145 btagPNetQvG =
Var(
"?abs(eta())<2.5?bDiscriminator('pfParticleNetFromMiniAODAK4CHSCentralDiscriminatorsJetTags:QvsG'):bDiscriminator('pfParticleNetFromMiniAODAK4CHSForwardDiscriminatorsJetTags:QvsG')",float,precision=10,doc=
"ParticleNet q (udsbc) vs. g"),
146 btagPNetTauVJet =
Var(
"?bDiscriminator('pfParticleNetFromMiniAODAK4CHSCentralDiscriminatorsJetTags:TauVsJet')>0?bDiscriminator('pfParticleNetFromMiniAODAK4CHSCentralDiscriminatorsJetTags:TauVsJet'):-1",float,precision=10,doc=
"ParticleNet tau vs. jet"),
147 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"),
148 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."),
149 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"),
150 btagUParTAK4B =
Var(
"?bDiscriminator('pfUnifiedParticleTransformerAK4DiscriminatorsJetTags:BvsAll')>0?bDiscriminator('pfUnifiedParticleTransformerAK4DiscriminatorsJetTags:BvsAll'):-1",float,precision=10,doc=
"UnifiedParT b vs. udscg"),
151 btagUParTAK4CvL =
Var(
"?bDiscriminator('pfUnifiedParticleTransformerAK4DiscriminatorsJetTags:CvsL')>0?bDiscriminator('pfUnifiedParticleTransformerAK4DiscriminatorsJetTags:CvsL'):-1",float,precision=10,doc=
"UnifiedParT c vs. udsg"),
152 btagUParTAK4CvB =
Var(
"?bDiscriminator('pfUnifiedParticleTransformerAK4DiscriminatorsJetTags:CvsB')>0?bDiscriminator('pfUnifiedParticleTransformerAK4DiscriminatorsJetTags:CvsB'):-1",float,precision=10,doc=
"UnifiedParT c vs. b"),
153 btagUParTAK4CvNotB =
Var(
"?((bDiscriminator('pfUnifiedParticleTransformerAK4JetTags:probb')+bDiscriminator('pfUnifiedParticleTransformerAK4JetTags:probbb')+bDiscriminator('pfUnifiedParticleTransformerAK4JetTags:problepb')))>0?((bDiscriminator('pfUnifiedParticleTransformerAK4JetTags:probc'))/(1.-bDiscriminator('pfUnifiedParticleTransformerAK4JetTags:probb')-bDiscriminator('pfUnifiedParticleTransformerAK4JetTags:probbb')-bDiscriminator('pfUnifiedParticleTransformerAK4JetTags:problepb'))):-1",float,precision=10,doc=
"UnifiedParT c vs. not b"),
154 btagUParTAK4QvG =
Var(
"?bDiscriminator('pfUnifiedParticleTransformerAK4DiscriminatorsJetTags:QvsG')>0?bDiscriminator('pfUnifiedParticleTransformerAK4DiscriminatorsJetTags:QvsG'):-1",float,precision=10,doc=
"UnifiedParT q (udsbc) vs. g"),
155 btagUParTAK4TauVJet =
Var(
"?bDiscriminator('pfUnifiedParticleTransformerAK4DiscriminatorsJetTags:TauVsJet')>0?bDiscriminator('pfUnifiedParticleTransformerAK4DiscriminatorsJetTags:TauVsJet'):-1",float,precision=10,doc=
"UnifiedParT tau vs. jet"),
156 UParTAK4RegPtRawCorr =
Var(
"?bDiscriminator('pfUnifiedParticleTransformerAK4JetTags:ptcorr')>0?bDiscriminator('pfUnifiedParticleTransformerAK4JetTags:ptcorr'):-1",float,precision=10,doc=
"UnifiedParT universal flavor-aware visible pT regression (no neutrinos), correction relative to raw jet pT"),
157 UParTAK4RegPtRawCorrNeutrino =
Var(
"?bDiscriminator('pfUnifiedParticleTransformerAK4JetTags:ptnu')>0?bDiscriminator('pfUnifiedParticleTransformerAK4JetTags:ptnu'):-1",float,precision=10,doc=
"UnifiedParT universal flavor-aware pT regression neutrino correction, relative to visible. To apply full regression, multiply raw jet pT by both UParTAK4RegPtRawCorr and UParTAK4RegPtRawCorrNeutrino."),
158 UParTAK4RegPtRawRes =
Var(
"?(bDiscriminator('pfUnifiedParticleTransformerAK4JetTags:ptreshigh')+bDiscriminator('pfUnifiedParticleTransformerAK4JetTags:ptreslow'))>0?0.5*(bDiscriminator('pfUnifiedParticleTransformerAK4JetTags:ptreshigh')-bDiscriminator('pfUnifiedParticleTransformerAK4JetTags:ptreslow')):-1",float,precision=10,doc=
"UnifiedParT universal flavor-aware jet pT resolution estimator, (q84 - q16)/2"),
159 puIdDisc =
Var(
"userFloat('puIdNanoDisc')", float,doc=
"Pileup ID discriminant with 106X (2018) training",precision=10),
160 puId =
Var(
"userInt('puIdNanoId')",
"uint8", doc=
"Pileup ID flags with 106X (2018) training"),
161 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"),
162 qgl =
Var(
"?userFloat('qgl')>0?userFloat('qgl'):-1",float,doc=
"Quark vs Gluon likelihood discriminator",precision=10),
163 hfsigmaEtaEta =
Var(
"userFloat('hfJetShowerShape:sigmaEtaEta')",float,doc=
"sigmaEtaEta for HF jets (noise discriminating variable)",precision=10),
164 hfsigmaPhiPhi =
Var(
"userFloat('hfJetShowerShape:sigmaPhiPhi')",float,doc=
"sigmaPhiPhi for HF jets (noise discriminating variable)",precision=10),
165 hfcentralEtaStripSize =
Var(
"userInt('hfJetShowerShape:centralEtaStripSize')", int, doc=
"eta size of the central tower strip in HF (noise discriminating variable) "),
166 hfadjacentEtaStripsSize =
Var(
"userInt('hfJetShowerShape:adjacentEtaStripsSize')", int, doc=
"eta size of the strips next to the central tower strip in HF (noise discriminating variable) "),
167 nConstituents =
Var(
"numberOfDaughters()",
"uint8",doc=
"Number of particles in the jet"),
168 chMultiplicity =
Var(
"chargedMultiplicity()",
"uint8",doc=
"Number of charged particles in the jet"),
169 neMultiplicity =
Var(
"neutralMultiplicity()",
"uint8",doc=
"Number of neutral particles in the jet"),
170 rawFactor =
Var(
"1.-jecFactor('Uncorrected')",float,doc=
"1 - Factor to get back to raw pT",precision=6),
171 chHEF =
Var(
"chargedHadronEnergyFraction()", float, doc=
"charged Hadron Energy Fraction", precision= 6),
172 neHEF =
Var(
"neutralHadronEnergyFraction()", float, doc=
"neutral Hadron Energy Fraction", precision= 6),
173 chEmEF =
Var(
"chargedEmEnergyFraction()", float, doc=
"charged Electromagnetic Energy Fraction", precision= 6),
174 neEmEF =
Var(
"neutralEmEnergyFraction()", float, doc=
"neutral Electromagnetic Energy Fraction", precision= 6),
175 hfHEF =
Var(
"HFHadronEnergyFraction()",float,doc=
"hadronic Energy Fraction in HF",precision= 6),
176 hfEmEF =
Var(
"HFEMEnergyFraction()",float,doc=
"electromagnetic Energy Fraction in HF",precision= 6),
177 muEF =
Var(
"muonEnergyFraction()", float, doc=
"muon Energy Fraction", precision= 6),
178 chFPV0EF =
Var(
"userFloat('chFPV0EF')", float, doc=
"charged fromPV==0 Energy Fraction (energy excluded from CHS jets). Previously called betastar.", precision= 6),
183 jetTable.variables.pt.precision=10
186 (run2_jme_2016 & ~tracker_apv_vfp30_2016 ).toModify(
187 jetTable.variables.puIdDisc, doc=
"Pileup ID discriminant with 106X (2016) training" 189 jetTable.variables.puId, doc=
"Pileup ID flags with 106X (2016) training" 191 (run2_jme_2016 & tracker_apv_vfp30_2016 ).toModify(
192 jetTable.variables.puIdDisc, doc=
"Pileup ID discriminant with 106X (2016APV) training" 194 jetTable.variables.puId, doc=
"Pileup ID flags with 106X (2016APV) training" 196 run2_jme_2017.toModify(
197 jetTable.variables.puIdDisc, doc=
"Pileup ID discriminant with 106X (2017) training" 199 jetTable.variables.puId, doc=
"Pileup ID flags with 106X (2017) training" 202 run2_nanoAOD_ANY.toModify(
204 btagCSVV2 =
Var(
"bDiscriminator('pfCombinedInclusiveSecondaryVertexV2BJetTags')",float,doc=
" pfCombinedInclusiveSecondaryVertexV2 b-tag discriminator (aka CSVV2)",precision=10),
205 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),
206 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),
207 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),
209 chMultiplicity =
None,
210 neMultiplicity =
None,
215 (run3_nanoAOD_122 | run3_nanoAOD_124).toModify(
222 btagPNetTauVJet =
None,
223 PNetRegPtRawCorr =
None,
224 PNetRegPtRawCorrNeutrino =
None,
225 PNetRegPtRawRes =
None,
227 chMultiplicity =
None,
228 neMultiplicity =
None,
233 bjetNN = cms.EDProducer(
"BJetEnergyRegressionMVA",
234 backend = cms.string(
"ONNX"),
235 batch_eval = cms.bool(
True),
236 src = cms.InputTag(
"linkedObjects",
"jets"),
237 pvsrc = cms.InputTag(
"offlineSlimmedPrimaryVertices"),
238 svsrc = cms.InputTag(
"slimmedSecondaryVertices"),
239 rhosrc = cms.InputTag(
"fixedGridRhoFastjetAll"),
241 weightFile = cms.FileInPath(
"PhysicsTools/NanoAOD/data/breg_training_2018.onnx"),
242 name = cms.string(
"JetRegNN"),
243 variables = cms.VPSet(
244 cms.PSet( name = cms.string(
"Jet_pt"), expr = cms.string(
"pt*jecFactor('Uncorrected')")),
245 cms.PSet( name = cms.string(
"Jet_eta"), expr = cms.string(
"eta")),
246 cms.PSet( name = cms.string(
"rho")),
247 cms.PSet( name = cms.string(
"Jet_mt"), expr = cms.string(
"mt*jecFactor('Uncorrected')")),
248 cms.PSet( name = cms.string(
"Jet_leadTrackPt"), expr = cms.string(
"userFloat('leadTrackPt')")),
249 cms.PSet( name = cms.string(
"Jet_leptonPtRel"), expr = cms.string(
"userFloat('leptonPtRelv0')")),
250 cms.PSet( name = cms.string(
"Jet_leptonDeltaR"), expr = cms.string(
"userFloat('leptonDeltaR')")),
251 cms.PSet( name = cms.string(
"Jet_neHEF"), expr = cms.string(
"neutralHadronEnergyFraction()")),
252 cms.PSet( name = cms.string(
"Jet_neEmEF"), expr = cms.string(
"neutralEmEnergyFraction()")),
253 cms.PSet( name = cms.string(
"Jet_vtxPt"), expr = cms.string(
"userFloat('vtxPt')")),
254 cms.PSet( name = cms.string(
"Jet_vtxMass"), expr = cms.string(
"userFloat('vtxMass')")),
255 cms.PSet( name = cms.string(
"Jet_vtx3dL"), expr = cms.string(
"userFloat('vtx3dL')")),
256 cms.PSet( name = cms.string(
"Jet_vtxNtrk"), expr = cms.string(
"userInt('vtxNtrk')")),
257 cms.PSet( name = cms.string(
"Jet_vtx3deL"), expr = cms.string(
"userFloat('vtx3deL')")),
258 cms.PSet( name = cms.string(
"Jet_numDaughters_pt03")),
259 cms.PSet( name = cms.string(
"Jet_energyRing_dR0_em_Jet_rawEnergy")),
260 cms.PSet( name = cms.string(
"Jet_energyRing_dR1_em_Jet_rawEnergy")),
261 cms.PSet( name = cms.string(
"Jet_energyRing_dR2_em_Jet_rawEnergy")),
262 cms.PSet( name = cms.string(
"Jet_energyRing_dR3_em_Jet_rawEnergy")),
263 cms.PSet( name = cms.string(
"Jet_energyRing_dR4_em_Jet_rawEnergy")),
264 cms.PSet( name = cms.string(
"Jet_energyRing_dR0_neut_Jet_rawEnergy")),
265 cms.PSet( name = cms.string(
"Jet_energyRing_dR1_neut_Jet_rawEnergy")),
266 cms.PSet( name = cms.string(
"Jet_energyRing_dR2_neut_Jet_rawEnergy")),
267 cms.PSet( name = cms.string(
"Jet_energyRing_dR3_neut_Jet_rawEnergy")),
268 cms.PSet( name = cms.string(
"Jet_energyRing_dR4_neut_Jet_rawEnergy")),
269 cms.PSet( name = cms.string(
"Jet_energyRing_dR0_ch_Jet_rawEnergy")),
270 cms.PSet( name = cms.string(
"Jet_energyRing_dR1_ch_Jet_rawEnergy")),
271 cms.PSet( name = cms.string(
"Jet_energyRing_dR2_ch_Jet_rawEnergy")),
272 cms.PSet( name = cms.string(
"Jet_energyRing_dR3_ch_Jet_rawEnergy")),
273 cms.PSet( name = cms.string(
"Jet_energyRing_dR4_ch_Jet_rawEnergy")),
274 cms.PSet( name = cms.string(
"Jet_energyRing_dR0_mu_Jet_rawEnergy")),
275 cms.PSet( name = cms.string(
"Jet_energyRing_dR1_mu_Jet_rawEnergy")),
276 cms.PSet( name = cms.string(
"Jet_energyRing_dR2_mu_Jet_rawEnergy")),
277 cms.PSet( name = cms.string(
"Jet_energyRing_dR3_mu_Jet_rawEnergy")),
278 cms.PSet( name = cms.string(
"Jet_energyRing_dR4_mu_Jet_rawEnergy")),
279 cms.PSet( name = cms.string(
"Jet_chHEF"), expr = cms.string(
"chargedHadronEnergyFraction()")),
280 cms.PSet( name = cms.string(
"Jet_chEmEF"), expr = cms.string(
"chargedEmEnergyFraction()")),
281 cms.PSet( name = cms.string(
"Jet_leptonPtRelInv"), expr = cms.string(
"userFloat('leptonPtRelInvv0')*jecFactor('Uncorrected')")),
282 cms.PSet( name = cms.string(
"isEle"), expr = cms.string(
"?abs(userInt('leptonPdgId'))==11?1:0")),
283 cms.PSet( name = cms.string(
"isMu"), expr = cms.string(
"?abs(userInt('leptonPdgId'))==13?1:0")),
284 cms.PSet( name = cms.string(
"isOther"), expr = cms.string(
"?userInt('leptonPdgId')==0?1:0")),
285 cms.PSet( name = cms.string(
"Jet_mass"), expr = cms.string(
"mass*jecFactor('Uncorrected')")),
286 cms.PSet( name = cms.string(
"Jet_ptd"), expr = cms.string(
"userFloat('ptD')"))
288 inputTensorName = cms.string(
"ffwd_inp:0"),
289 outputTensorName = cms.string(
"ffwd_out/BiasAdd:0"),
290 outputNames = cms.vstring([
"corr",
"res"]),
291 outputFormulas = cms.vstring([
"at(0)*0.27912887930870056+1.0545977354049683",
"0.5*(at(2)-at(1))*0.27912887930870056"]),
294 cjetNN = cms.EDProducer(
"BJetEnergyRegressionMVA",
295 backend = cms.string(
"ONNX"),
296 batch_eval = cms.bool(
True),
298 src = cms.InputTag(
"linkedObjects",
"jets"),
299 pvsrc = cms.InputTag(
"offlineSlimmedPrimaryVertices"),
300 svsrc = cms.InputTag(
"slimmedSecondaryVertices"),
301 rhosrc = cms.InputTag(
"fixedGridRhoFastjetAll"),
303 weightFile = cms.FileInPath(
"PhysicsTools/NanoAOD/data/creg_training_2018.onnx"),
304 name = cms.string(
"JetRegNN"),
305 variables = cms.VPSet(
306 cms.PSet( name = cms.string(
"Jet_pt"), expr = cms.string(
"pt*jecFactor('Uncorrected')")),
307 cms.PSet( name = cms.string(
"Jet_eta"), expr = cms.string(
"eta")),
308 cms.PSet( name = cms.string(
"rho")),
309 cms.PSet( name = cms.string(
"Jet_mt"), expr = cms.string(
"mt*jecFactor('Uncorrected')")),
310 cms.PSet( name = cms.string(
"Jet_leadTrackPt"), expr = cms.string(
"userFloat('leadTrackPt')")),
311 cms.PSet( name = cms.string(
"Jet_leptonPtRel"), expr = cms.string(
"userFloat('leptonPtRelv0')")),
312 cms.PSet( name = cms.string(
"Jet_leptonDeltaR"), expr = cms.string(
"userFloat('leptonDeltaR')")),
313 cms.PSet( name = cms.string(
"Jet_neHEF"), expr = cms.string(
"neutralHadronEnergyFraction()")),
314 cms.PSet( name = cms.string(
"Jet_neEmEF"), expr = cms.string(
"neutralEmEnergyFraction()")),
315 cms.PSet( name = cms.string(
"Jet_vtxPt"), expr = cms.string(
"userFloat('vtxPt')")),
316 cms.PSet( name = cms.string(
"Jet_vtxMass"), expr = cms.string(
"userFloat('vtxMass')")),
317 cms.PSet( name = cms.string(
"Jet_vtx3dL"), expr = cms.string(
"userFloat('vtx3dL')")),
318 cms.PSet( name = cms.string(
"Jet_vtxNtrk"), expr = cms.string(
"userInt('vtxNtrk')")),
319 cms.PSet( name = cms.string(
"Jet_vtx3deL"), expr = cms.string(
"userFloat('vtx3deL')")),
320 cms.PSet( name = cms.string(
"Jet_numDaughters_pt03")),
321 cms.PSet( name = cms.string(
"Jet_chEmEF"), expr = cms.string(
"chargedEmEnergyFraction()")),
322 cms.PSet( name = cms.string(
"Jet_chHEF"), expr = cms.string(
"chargedHadronEnergyFraction()")),
323 cms.PSet( name = cms.string(
"Jet_ptd"), expr = cms.string(
"userFloat('ptD')")),
324 cms.PSet( name = cms.string(
"Jet_mass"), expr = cms.string(
"mass*jecFactor('Uncorrected')")),
325 cms.PSet( name = cms.string(
"Jet_energyRing_dR0_em_Jet_rawEnergy")),
326 cms.PSet( name = cms.string(
"Jet_energyRing_dR1_em_Jet_rawEnergy")),
327 cms.PSet( name = cms.string(
"Jet_energyRing_dR2_em_Jet_rawEnergy")),
328 cms.PSet( name = cms.string(
"Jet_energyRing_dR3_em_Jet_rawEnergy")),
329 cms.PSet( name = cms.string(
"Jet_energyRing_dR4_em_Jet_rawEnergy")),
330 cms.PSet( name = cms.string(
"Jet_energyRing_dR0_neut_Jet_rawEnergy")),
331 cms.PSet( name = cms.string(
"Jet_energyRing_dR1_neut_Jet_rawEnergy")),
332 cms.PSet( name = cms.string(
"Jet_energyRing_dR2_neut_Jet_rawEnergy")),
333 cms.PSet( name = cms.string(
"Jet_energyRing_dR3_neut_Jet_rawEnergy")),
334 cms.PSet( name = cms.string(
"Jet_energyRing_dR4_neut_Jet_rawEnergy")),
335 cms.PSet( name = cms.string(
"Jet_energyRing_dR0_ch_Jet_rawEnergy")),
336 cms.PSet( name = cms.string(
"Jet_energyRing_dR1_ch_Jet_rawEnergy")),
337 cms.PSet( name = cms.string(
"Jet_energyRing_dR2_ch_Jet_rawEnergy")),
338 cms.PSet( name = cms.string(
"Jet_energyRing_dR3_ch_Jet_rawEnergy")),
339 cms.PSet( name = cms.string(
"Jet_energyRing_dR4_ch_Jet_rawEnergy")),
340 cms.PSet( name = cms.string(
"Jet_energyRing_dR0_mu_Jet_rawEnergy")),
341 cms.PSet( name = cms.string(
"Jet_energyRing_dR1_mu_Jet_rawEnergy")),
342 cms.PSet( name = cms.string(
"Jet_energyRing_dR2_mu_Jet_rawEnergy")),
343 cms.PSet( name = cms.string(
"Jet_energyRing_dR3_mu_Jet_rawEnergy")),
344 cms.PSet( name = cms.string(
"Jet_energyRing_dR4_mu_Jet_rawEnergy")),
346 inputTensorName = cms.string(
"ffwd_inp:0"),
347 outputTensorName = cms.string(
"ffwd_out/BiasAdd:0"),
348 outputNames = cms.vstring([
"corr",
"res"]),
349 outputFormulas = cms.vstring([
"at(0)*0.24325256049633026+0.993854820728302",
"0.5*(at(2)-at(1))*0.24325256049633026"]),
353 run2_jme_2016.toModify(
354 bjetNN, weightFile = cms.FileInPath(
"PhysicsTools/NanoAOD/data/breg_training_2016.onnx")
356 bjetNN,outputFormulas = cms.vstring([
"at(0)*0.31976690888404846+1.047176718711853",
"0.5*(at(2)-at(1))*0.31976690888404846"])
358 cjetNN, weightFile = cms.FileInPath(
"PhysicsTools/NanoAOD/data/creg_training_2016.onnx")
360 cjetNN, outputFormulas = cms.vstring([
"at(0)*0.28862622380256653+0.9908722639083862",
"0.5*(at(2)-at(1))*0.28862622380256653"])
363 run2_jme_2017.toModify(
364 bjetNN, weightFile = cms.FileInPath(
"PhysicsTools/NanoAOD/data/breg_training_2017.onnx")
366 bjetNN,outputFormulas = cms.vstring([
"at(0)*0.28225210309028625+1.055067777633667",
"0.5*(at(2)-at(1))*0.28225210309028625"])
368 cjetNN, weightFile = cms.FileInPath(
"PhysicsTools/NanoAOD/data/creg_training_2017.onnx")
370 cjetNN, outputFormulas = cms.vstring([
"at(0)*0.24718524515628815+0.9927206635475159",
"0.5*(at(2)-at(1))*0.24718524515628815"])
378 qgtagger=QGTagger.clone(srcJets=
"updatedJets",srcVertexCollection=
"offlineSlimmedPrimaryVertices")
384 pileupJetIdNano=pileupJetId.clone(jets=
"updatedJets",algos = cms.VPSet(_chsalgos_106X_UL18),inputIsCorrected=
True,applyJec=
False,vertexes=
"offlineSlimmedPrimaryVertices")
385 run2_jme_2017.toModify(
386 pileupJetIdNano, algos = _chsalgos_106X_UL17
388 (run2_jme_2016 & ~tracker_apv_vfp30_2016 ).toModify(
389 pileupJetIdNano, algos = _chsalgos_106X_UL16
391 (run2_jme_2016 & tracker_apv_vfp30_2016 ).toModify(
392 pileupJetIdNano, algos = _chsalgos_106X_UL16APV
401 _btagDiscriminators=[]
403 print(
"Updating process to run DeepCSV btag")
404 _btagDiscriminators += [
'pfDeepCSVJetTags:probb',
'pfDeepCSVJetTags:probbb',
'pfDeepCSVJetTags:probc']
406 print(
"Updating process to run DeepFlavour btag")
407 _btagDiscriminators += [
'pfDeepFlavourJetTags:probb',
'pfDeepFlavourJetTags:probbb',
'pfDeepFlavourJetTags:problepb',
'pfDeepFlavourJetTags:probc']
409 print(
"Updating process to run ParticleNetAK4")
410 from RecoBTag.ONNXRuntime.pfParticleNetFromMiniAODAK4_cff
import _pfParticleNetFromMiniAODAK4CHSCentralJetTagsAll
as pfParticleNetFromMiniAODAK4CHSCentralJetTagsAll
411 from RecoBTag.ONNXRuntime.pfParticleNetFromMiniAODAK4_cff
import _pfParticleNetFromMiniAODAK4CHSForwardJetTagsAll
as pfParticleNetFromMiniAODAK4CHSForwardJetTagsAll
412 _btagDiscriminators += pfParticleNetFromMiniAODAK4CHSCentralJetTagsAll
413 _btagDiscriminators += pfParticleNetFromMiniAODAK4CHSForwardJetTagsAll
415 print(
"Updating process to run RobustParTAK4")
417 _btagDiscriminators += pfParticleTransformerAK4JetTagsAll
418 if addUnifiedParTAK4:
419 print(
"Updating process to run UnifiedParTAK4")
421 _btagDiscriminators += pfUnifiedParticleTransformerAK4JetTagsAll
423 if len(_btagDiscriminators)==0:
return process
424 print(
"Will recalculate the following discriminators: "+
", ".
join(_btagDiscriminators))
427 jetSource = cms.InputTag(
'slimmedJets'),
428 jetCorrections = (
'AK4PFchs', cms.vstring([
'L1FastJet',
'L2Relative',
'L3Absolute',
'L2L3Residual']),
'None'),
429 btagDiscriminators = _btagDiscriminators,
430 postfix =
'WithDeepInfo',
432 process.load(
"Configuration.StandardSequences.MagneticField_cff")
433 process.jetCorrFactorsNano.src=
"selectedUpdatedPatJetsWithDeepInfo" 434 process.updatedJets.jetSource=
"selectedUpdatedPatJetsWithDeepInfo" 437 nanoAOD_addDeepInfoAK4CHS_switch = cms.PSet(
438 nanoAOD_addDeepBTag_switch = cms.untracked.bool(
False),
439 nanoAOD_addDeepFlavourTag_switch = cms.untracked.bool(
False),
440 nanoAOD_addParticleNet_switch = cms.untracked.bool(
False),
441 nanoAOD_addRobustParTAK4Tag_switch = cms.untracked.bool(
False),
442 nanoAOD_addUnifiedParTAK4Tag_switch = cms.untracked.bool(
False)
452 from Configuration.Eras.Modifier_fastSim_cff
import fastSim
455 fastSim.toModify( process.jetTable.variables,
456 btagDeepFlavBunrefined = process.jetTable.variables.btagDeepFlavB.clone(),
457 btagDeepFlavCvBunrefined = process.jetTable.variables.btagDeepFlavCvB.clone(),
458 btagDeepFlavCvLunrefined = process.jetTable.variables.btagDeepFlavCvL.clone(),
459 btagDeepFlavQGunrefined = process.jetTable.variables.btagDeepFlavQG.clone(),
462 fastSim.toModify( process.jetTable.variables,
463 btagDeepFlavB =
None,
464 btagDeepFlavCvB =
None,
465 btagDeepFlavCvL =
None,
466 btagDeepFlavQG =
None,
469 fastSim.toModify( process.jetTable.externalVariables,
470 btagDeepFlavB =
ExtVar(cms.InputTag(
"btagDeepFlavRefineNN:btagDeepFlavBrefined"), float, doc=
"DeepJet b+bb+lepb tag discriminator", precision=10),
471 btagDeepFlavCvB =
ExtVar(cms.InputTag(
"btagDeepFlavRefineNN:btagDeepFlavCvBrefined"), float, doc=
"DeepJet c vs b+bb+lepb discriminator", precision=10),
472 btagDeepFlavCvL =
ExtVar(cms.InputTag(
"btagDeepFlavRefineNN:btagDeepFlavCvLrefined"), float, doc=
"DeepJet c vs uds+g discriminator", precision=10),
473 btagDeepFlavQG =
ExtVar(cms.InputTag(
"btagDeepFlavRefineNN:btagDeepFlavQGrefined"), float, doc=
"DeepJet g vs uds discriminator", precision=10),
476 process.btagDeepFlavRefineNN= cms.EDProducer(
"JetBaseMVAValueMapProducer",
477 backend = cms.string(
"ONNX"),
478 batch_eval = cms.bool(
True),
479 disableONNXGraphOpt = cms.bool(
True),
481 src = cms.InputTag(
"linkedObjects",
"jets"),
483 weightFile=cms.FileInPath(
"PhysicsTools/NanoAOD/data/btagDeepFlavRefineNN_CHS.onnx"),
484 name = cms.string(
"btagDeepFlavRefineNN"),
486 variables = cms.VPSet(
487 cms.PSet( name = cms.string(
"GenJet_pt"), expr = cms.string(
"?genJetFwdRef().backRef().isNonnull()?genJetFwdRef().backRef().pt():pt")),
488 cms.PSet( name = cms.string(
"GenJet_eta"), expr = cms.string(
"?genJetFwdRef().backRef().isNonnull()?genJetFwdRef().backRef().eta():eta")),
489 cms.PSet( name = cms.string(
"Jet_hadronFlavour"), expr = cms.string(
"hadronFlavour()")),
490 cms.PSet( name = cms.string(
"Jet_btagDeepFlavB"), expr = cms.string(
"bDiscriminator('pfDeepFlavourJetTags:probb')+bDiscriminator('pfDeepFlavourJetTags:probbb')+bDiscriminator('pfDeepFlavourJetTags:problepb')")),
491 cms.PSet( name = cms.string(
"Jet_btagDeepFlavCvB"), expr = 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")),
492 cms.PSet( name = cms.string(
"Jet_btagDeepFlavCvL"), expr = 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")),
493 cms.PSet( name = cms.string(
"Jet_btagDeepFlavQG"), expr = cms.string(
"?(bDiscriminator('pfDeepFlavourJetTags:probg')+bDiscriminator('pfDeepFlavourJetTags:probuds'))>0?bDiscriminator('pfDeepFlavourJetTags:probg')/(bDiscriminator('pfDeepFlavourJetTags:probg')+bDiscriminator('pfDeepFlavourJetTags:probuds')):-1")),
495 inputTensorName = cms.string(
"input"),
496 outputTensorName = cms.string(
"output"),
497 outputNames = cms.vstring([
"btagDeepFlavBrefined",
"btagDeepFlavCvBrefined",
"btagDeepFlavCvLrefined",
"btagDeepFlavQGrefined"]),
498 outputFormulas = cms.vstring([
"at(0)",
"at(1)",
"at(2)",
"at(3)"]),
501 fastSim.toModify(process.jetTablesTask, process.jetTablesTask.add(process.btagDeepFlavRefineNN))
509 basicJetsForMetForT1METNano = cms.EDProducer(
"PATJetCleanerForType1MET",
510 src = updatedJetsWithUserData.src,
511 jetCorrEtaMax = cms.double(9.9),
512 jetCorrLabel = cms.InputTag(
"L3Absolute"),
513 jetCorrLabelRes = cms.InputTag(
"L2L3Residual"),
514 offsetCorrLabel = cms.InputTag(
"L1FastJet"),
515 skipEM = cms.bool(
False),
516 skipEMfractionThreshold = cms.double(0.9),
517 skipMuonSelection = cms.string(
'isGlobalMuon | isStandAloneMuon'),
518 skipMuons = cms.bool(
True),
519 type1JetPtThreshold = cms.double(0.0),
520 calcMuonSubtrRawPtAsValueMap = cms.bool(
True)
523 updatedJetsWithUserData.userFloats.muonSubtrRawPt = cms.InputTag(
"basicJetsForMetForT1METNano:MuonSubtrRawPt")
525 corrT1METJetTable = simplePATJetFlatTableProducer.clone(
527 cut = cms.string(
"pt<15 && abs(eta)<9.9"),
528 name = cms.string(
"CorrT1METJet"),
529 doc = cms.string(
"Additional low-pt ak4 CHS jets for Type-1 MET re-correction"),
530 variables = cms.PSet(
531 rawPt =
Var(
"pt()*jecFactor('Uncorrected')",float,precision=10),
532 eta =
Var(
"eta", float,precision=12),
533 phi =
Var(
"phi", float, precision=12),
534 area =
Var(
"jetArea()", float, doc=
"jet catchment area, for JECs",precision=10),
535 EmEF =
Var(
"chargedEmEnergyFraction()+neutralEmEnergyFraction()", float, doc=
"charged+neutral Electromagnetic Energy Fraction", precision=6),
539 corrT1METJetTable.variables.muonSubtrFactor =
Var(
"1-userFloat('muonSubtrRawPt')/(pt()*jecFactor('Uncorrected'))",float,doc=
"1-(muon-subtracted raw pt)/(raw pt)",precision=6)
540 jetTable.variables.muonSubtrFactor =
Var(
"1-userFloat('muonSubtrRawPt')/(pt()*jecFactor('Uncorrected'))",float,doc=
"1-(muon-subtracted raw pt)/(raw pt)",precision=6)
542 jetForMETTask = cms.Task(basicJetsForMetForT1METNano,corrT1METJetTable)
545 jetUserDataTask = cms.Task(bJetVars,qgtagger,jercVars,tightJetId,tightJetIdLepVeto,pileupJetIdNano)
548 jetTask = cms.Task(jetCorrFactorsNano,updatedJets,jetUserDataTask,updatedJetsWithUserData,finalJets)
551 jetTablesTask = cms.Task(bjetNN,cjetNN,jetTable)
def Var(expr, valtype, doc=None, precision=-1, lazyEval=False)
def ExtVar(tag, valtype, doc=None, precision=-1)
def nanoAOD_refineFastSim_bTagDeepFlav(process)
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
static std::string join(char **cmd)
def nanoAOD_addDeepInfoAK4CHS(process, addDeepBTag, addDeepFlavour, addParticleNet, addRobustParTAK4=False, addUnifiedParTAK4=False)