CMS 3D CMS Logo

jets_cff.py
Go to the documentation of this file.
1 import FWCore.ParameterSet.Config as cms
2 
6 
7 
8 
9 from RecoJets.JetProducers.ak4PFJets_cfi import ak4PFJets
10 
11 chsForSATkJets = cms.EDFilter("CandPtrSelector", src = cms.InputTag("packedPFCandidates"), cut = cms.string('charge()!=0 && pvAssociationQuality()>=5 && vertexRef().key()==0'))
12 softActivityJets = ak4PFJets.clone(src = 'chsForSATkJets', doAreaFastjet = False, jetPtMin=1)
13 softActivityJets10 = cms.EDFilter("CandPtrSelector", src = cms.InputTag("softActivityJets"), cut = cms.string('pt>10'))
14 softActivityJets5 = cms.EDFilter("CandPtrSelector", src = cms.InputTag("softActivityJets"), cut = cms.string('pt>5'))
15 softActivityJets2 = cms.EDFilter("CandPtrSelector", src = cms.InputTag("softActivityJets"), cut = cms.string('pt>2'))
16 
18 # Note: Safe to always add 'L2L3Residual' as MC contains dummy L2L3Residual corrections (always set to 1)
19 # (cf. https://twiki.cern.ch/twiki/bin/view/CMSPublic/WorkBookJetEnergyCorrections#CMSSW_7_6_4_and_above )
20 jetCorrFactorsNano = patJetCorrFactors.clone(src='slimmedJets',
21  levels = cms.vstring('L1FastJet',
22  'L2Relative',
23  'L3Absolute',
24  'L2L3Residual'),
25  primaryVertices = cms.InputTag("offlineSlimmedPrimaryVertices"),
26 )
27 jetCorrFactorsAK8 = patJetCorrFactors.clone(src='slimmedJetsAK8',
28  levels = cms.vstring('L1FastJet',
29  'L2Relative',
30  'L3Absolute',
31  'L2L3Residual'),
32  payload = cms.string('AK8PFPuppi'),
33  primaryVertices = cms.InputTag("offlineSlimmedPrimaryVertices"),
34 )
35 run2_miniAOD_80XLegacy.toModify(jetCorrFactorsAK8, payload = cms.string('AK8PFchs')) # ak8PFJetsCHS in 2016 80X miniAOD
36 
38 
39 updatedJets = updatedPatJets.clone(
40  addBTagInfo=False,
41  jetSource='slimmedJets',
42  jetCorrFactorsSource=cms.VInputTag(cms.InputTag("jetCorrFactorsNano") ),
43 )
44 
45 updatedJetsAK8 = updatedPatJets.clone(
46  addBTagInfo=False,
47  jetSource='slimmedJetsAK8',
48  jetCorrFactorsSource=cms.VInputTag(cms.InputTag("jetCorrFactorsAK8") ),
49 )
50 
51 
52 looseJetId = cms.EDProducer("PatJetIDValueMapProducer",
53  filterParams=cms.PSet(
54  version = cms.string('WINTER16'),
55  quality = cms.string('LOOSE'),
56  ),
57  src = cms.InputTag("updatedJets")
58 )
59 tightJetId = cms.EDProducer("PatJetIDValueMapProducer",
60  filterParams=cms.PSet(
61  version = cms.string('RUN2ULCHS'),
62  quality = cms.string('TIGHT'),
63  ),
64  src = cms.InputTag("updatedJets")
65 )
66 tightJetIdLepVeto = cms.EDProducer("PatJetIDValueMapProducer",
67  filterParams=cms.PSet(
68  version = cms.string('RUN2ULCHS'),
69  quality = cms.string('TIGHTLEPVETO'),
70  ),
71  src = cms.InputTag("updatedJets")
72 )
73 for modifier in run2_miniAOD_80XLegacy, run2_nanoAOD_94X2016:
74  modifier.toModify( tightJetId.filterParams, version = "WINTER16" )
75  modifier.toModify( tightJetIdLepVeto.filterParams, version = "WINTER16" )
76 for modifier in run2_nanoAOD_94XMiniAODv1, run2_nanoAOD_94XMiniAODv2:
77  modifier.toModify( tightJetId.filterParams, version = "WINTER17" )
78  modifier.toModify( tightJetIdLepVeto.filterParams, version = "WINTER17" )
79 run2_nanoAOD_102Xv1.toModify( tightJetId.filterParams, version = "SUMMER18" )
80 run2_nanoAOD_102Xv1.toModify( tightJetIdLepVeto.filterParams, version = "SUMMER18" )
81 
82 
83 looseJetIdAK8 = cms.EDProducer("PatJetIDValueMapProducer",
84  filterParams=cms.PSet(
85  version = cms.string('WINTER16'),
86  quality = cms.string('LOOSE'),
87  ),
88  src = cms.InputTag("updatedJetsAK8")
89 )
90 tightJetIdAK8 = cms.EDProducer("PatJetIDValueMapProducer",
91  filterParams=cms.PSet(
92  version = cms.string('RUN2ULPUPPI'),
93  quality = cms.string('TIGHT'),
94  ),
95  src = cms.InputTag("updatedJetsAK8")
96 )
97 tightJetIdLepVetoAK8 = cms.EDProducer("PatJetIDValueMapProducer",
98  filterParams=cms.PSet(
99  version = cms.string('RUN2ULPUPPI'),
100  quality = cms.string('TIGHTLEPVETO'),
101  ),
102  src = cms.InputTag("updatedJetsAK8")
103 )
104 for modifier in run2_miniAOD_80XLegacy, run2_nanoAOD_94X2016:
105  modifier.toModify( tightJetIdAK8.filterParams, version = "WINTER16" )
106  modifier.toModify( tightJetIdLepVetoAK8.filterParams, version = "WINTER16" )
107 for modifier in run2_nanoAOD_94XMiniAODv1, run2_nanoAOD_94XMiniAODv2:
108  modifier.toModify( tightJetIdAK8.filterParams, version = "WINTER17PUPPI" )
109  modifier.toModify( tightJetIdLepVetoAK8.filterParams, version = "WINTER17PUPPI" )
110 run2_nanoAOD_102Xv1.toModify( tightJetIdAK8.filterParams, version = "SUMMER18PUPPI" )
111 run2_nanoAOD_102Xv1.toModify( tightJetIdLepVetoAK8.filterParams, version = "SUMMER18PUPPI" )
112 
113 
114 bJetVars = cms.EDProducer("JetRegressionVarProducer",
115  pvsrc = cms.InputTag("offlineSlimmedPrimaryVertices"),
116  src = cms.InputTag("updatedJets"),
117  svsrc = cms.InputTag("slimmedSecondaryVertices"),
118  gpsrc = cms.InputTag("prunedGenParticles"),
119  #musrc = cms.InputTag("slimmedMuons"),
120  #elesrc = cms.InputTag("slimmedElectrons")
121 )
122 
123 jercVars = cms.EDProducer("BetaStarPackedCandidateVarProducer",
124  srcJet = cms.InputTag("updatedJets"),
125  srcPF = cms.InputTag("packedPFCandidates"),
126  maxDR = cms.double(0.4)
127 )
128 
129 updatedJetsWithUserData = cms.EDProducer("PATJetUserDataEmbedder",
130  src = cms.InputTag("updatedJets"),
131  userFloats = cms.PSet(
132  leadTrackPt = cms.InputTag("bJetVars:leadTrackPt"),
133  leptonPtRel = cms.InputTag("bJetVars:leptonPtRel"),
134  leptonPtRatio = cms.InputTag("bJetVars:leptonPtRatio"),
135  leptonPtRelInv = cms.InputTag("bJetVars:leptonPtRelInv"),
136  leptonPtRelv0 = cms.InputTag("bJetVars:leptonPtRelv0"),
137  leptonPtRatiov0 = cms.InputTag("bJetVars:leptonPtRatiov0"),
138  leptonPtRelInvv0 = cms.InputTag("bJetVars:leptonPtRelInvv0"),
139  leptonDeltaR = cms.InputTag("bJetVars:leptonDeltaR"),
140  leptonPt = cms.InputTag("bJetVars:leptonPt"),
141  vtxPt = cms.InputTag("bJetVars:vtxPt"),
142  vtxMass = cms.InputTag("bJetVars:vtxMass"),
143  vtx3dL = cms.InputTag("bJetVars:vtx3dL"),
144  vtx3deL = cms.InputTag("bJetVars:vtx3deL"),
145  ptD = cms.InputTag("bJetVars:ptD"),
146  genPtwNu = cms.InputTag("bJetVars:genPtwNu"),
147  qgl = cms.InputTag('qgtagger:qgLikelihood'),
148  puId94XDisc = cms.InputTag('pileupJetId94X:fullDiscriminant'),
149  puId102XDisc = cms.InputTag('pileupJetId102X:fullDiscriminant'),
150  puId106XUL17Disc = cms.InputTag('pileupJetId106XUL17:fullDiscriminant'),
151  chFPV0EF = cms.InputTag("jercVars:chargedFromPV0EnergyFraction"),
152  chFPV1EF = cms.InputTag("jercVars:chargedFromPV1EnergyFraction"),
153  chFPV2EF = cms.InputTag("jercVars:chargedFromPV2EnergyFraction"),
154  chFPV3EF = cms.InputTag("jercVars:chargedFromPV3EnergyFraction"),
155  ),
156  userInts = cms.PSet(
157  tightId = cms.InputTag("tightJetId"),
158  tightIdLepVeto = cms.InputTag("tightJetIdLepVeto"),
159  vtxNtrk = cms.InputTag("bJetVars:vtxNtrk"),
160  leptonPdgId = cms.InputTag("bJetVars:leptonPdgId"),
161  puId106XUL17Id = cms.InputTag('pileupJetId106XUL17:fullId'),
162  ),
163 )
164 for modifier in run2_miniAOD_80XLegacy, run2_nanoAOD_94X2016:
165  modifier.toModify(updatedJetsWithUserData.userInts,
166  looseId = cms.InputTag("looseJetId"),
167  )
168 
169 updatedJetsAK8WithUserData = cms.EDProducer("PATJetUserDataEmbedder",
170  src = cms.InputTag("updatedJetsAK8"),
171  userInts = cms.PSet(
172  tightId = cms.InputTag("tightJetIdAK8"),
173  tightIdLepVeto = cms.InputTag("tightJetIdLepVetoAK8"),
174  ),
175 )
176 for modifier in run2_miniAOD_80XLegacy, run2_nanoAOD_94X2016:
177  modifier.toModify(updatedJetsAK8WithUserData.userInts,
178  looseId = cms.InputTag("looseJetIdAK8"),
179  )
180 
181 
182 finalJets = cms.EDFilter("PATJetRefSelector",
183  src = cms.InputTag("updatedJetsWithUserData"),
184  cut = cms.string("pt > 15")
185 )
186 
187 finalJetsAK8 = cms.EDFilter("PATJetRefSelector",
188  src = cms.InputTag("updatedJetsAK8WithUserData"),
189  cut = cms.string("pt > 170")
190 )
191 
192 lepInJetVars = cms.EDProducer("LepInJetProducer",
193  src = cms.InputTag("updatedJetsAK8WithUserData"),
194  srcEle = cms.InputTag("finalElectrons"),
195  srcMu = cms.InputTag("finalMuons")
196 )
197 
198 
199 
200 
201 
202 
203 
204 jetTable = cms.EDProducer("SimpleCandidateFlatTableProducer",
205  src = cms.InputTag("linkedObjects","jets"),
206  cut = cms.string(""), #we should not filter on cross linked collections
207  name = cms.string("Jet"),
208  doc = cms.string("slimmedJets, i.e. ak4 PFJets CHS with JECs applied, after basic selection (" + finalJets.cut.value()+")"),
209  singleton = cms.bool(False), # the number of entries is variable
210  extension = cms.bool(False), # this is the main table for the jets
211  externalVariables = cms.PSet(
212  bRegCorr = ExtVar(cms.InputTag("bjetNN:corr"),float, doc="pt correction for b-jet energy regression",precision=10),
213  bRegRes = ExtVar(cms.InputTag("bjetNN:res"),float, doc="res on pt corrected with b-jet regression",precision=6),
214  cRegCorr = ExtVar(cms.InputTag("cjetNN:corr"),float, doc="pt correction for c-jet energy regression",precision=10),
215  cRegRes = ExtVar(cms.InputTag("cjetNN:res"),float, doc="res on pt corrected with c-jet regression",precision=6),
216  ),
217  variables = cms.PSet(P4Vars,
218  area = Var("jetArea()", float, doc="jet catchment area, for JECs",precision=10),
219  nMuons = Var("?hasOverlaps('muons')?overlaps('muons').size():0", int, doc="number of muons in the jet"),
220  muonIdx1 = Var("?overlaps('muons').size()>0?overlaps('muons')[0].key():-1", int, doc="index of first matching muon"),
221  muonIdx2 = Var("?overlaps('muons').size()>1?overlaps('muons')[1].key():-1", int, doc="index of second matching muon"),
222  electronIdx1 = Var("?overlaps('electrons').size()>0?overlaps('electrons')[0].key():-1", int, doc="index of first matching electron"),
223  electronIdx2 = Var("?overlaps('electrons').size()>1?overlaps('electrons')[1].key():-1", int, doc="index of second matching electron"),
224  nElectrons = Var("?hasOverlaps('electrons')?overlaps('electrons').size():0", int, doc="number of electrons in the jet"),
225  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),
226  btagDeepFlavB = Var("bDiscriminator('pfDeepFlavourJetTags:probb')+bDiscriminator('pfDeepFlavourJetTags:probbb')+bDiscriminator('pfDeepFlavourJetTags:problepb')",float,doc="DeepJet b+bb+lepb tag discriminator",precision=10),
227  btagCSVV2 = Var("bDiscriminator('pfCombinedInclusiveSecondaryVertexV2BJetTags')",float,doc=" pfCombinedInclusiveSecondaryVertexV2 b-tag discriminator (aka CSVV2)",precision=10),
228  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),
229  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),
230  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),
231  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),
232  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),
233  puIdDisc = Var("userFloat('puId102XDisc')",float,doc="Pileup ID discriminant with 102X (2018) training",precision=10),
234  puId = Var("userInt('pileupJetId:fullId')",int,doc="Pileup ID flags for pre-UL trainings"),
235  jetId = Var("userInt('tightId')*2+4*userInt('tightIdLepVeto')",int,doc="Jet ID flags bit1 is loose (always false in 2017 since it does not exist), bit2 is tight, bit3 is tightLepVeto"),
236  qgl = Var("userFloat('qgl')",float,doc="Quark vs Gluon likelihood discriminator",precision=10),
237  hfsigmaEtaEta = Var("userFloat('hfJetShowerShape:sigmaEtaEta')",float,doc="sigmaEtaEta for HF jets (noise discriminating variable)",precision=10),
238  hfsigmaPhiPhi = Var("userFloat('hfJetShowerShape:sigmaPhiPhi')",float,doc="sigmaPhiPhi for HF jets (noise discriminating variable)",precision=10),
239  hfcentralEtaStripSize = Var("userInt('hfJetShowerShape:centralEtaStripSize')", int, doc="eta size of the central tower strip in HF (noise discriminating variable) "),
240  hfadjacentEtaStripsSize = Var("userInt('hfJetShowerShape:adjacentEtaStripsSize')", int, doc="eta size of the strips next to the central tower strip in HF (noise discriminating variable) "),
241  nConstituents = Var("numberOfDaughters()",int,doc="Number of particles in the jet"),
242  rawFactor = Var("1.-jecFactor('Uncorrected')",float,doc="1 - Factor to get back to raw pT",precision=6),
243  chHEF = Var("chargedHadronEnergyFraction()", float, doc="charged Hadron Energy Fraction", precision= 6),
244  neHEF = Var("neutralHadronEnergyFraction()", float, doc="neutral Hadron Energy Fraction", precision= 6),
245  chEmEF = Var("chargedEmEnergyFraction()", float, doc="charged Electromagnetic Energy Fraction", precision= 6),
246  neEmEF = Var("neutralEmEnergyFraction()", float, doc="neutral Electromagnetic Energy Fraction", precision= 6),
247  muEF = Var("muonEnergyFraction()", float, doc="muon Energy Fraction", precision= 6),
248  chFPV0EF = Var("userFloat('chFPV0EF')", float, doc="charged fromPV==0 Energy Fraction (energy excluded from CHS jets). Previously called betastar.", precision= 6),
249  chFPV1EF = Var("userFloat('chFPV1EF')", float, doc="charged fromPV==1 Energy Fraction (component of the total charged Energy Fraction).", precision= 6),
250  chFPV2EF = Var("userFloat('chFPV2EF')", float, doc="charged fromPV==2 Energy Fraction (component of the total charged Energy Fraction).", precision= 6),
251  chFPV3EF = Var("userFloat('chFPV3EF')", float, doc="charged fromPV==3 Energy Fraction (component of the total charged Energy Fraction).", precision= 6),
252  )
253 )
254 
255 #jets are not as precise as muons
256 jetTable.variables.pt.precision=10
257 
258 
259 for modifier in run2_miniAOD_80XLegacy, run2_nanoAOD_94X2016, run2_nanoAOD_94XMiniAODv1, run2_nanoAOD_94XMiniAODv2, run2_nanoAOD_102Xv1, run2_nanoAOD_106Xv1:
260  # Deprecated after 106X
261  modifier.toModify(jetTable.variables,
262  btagCMVA = Var("bDiscriminator('pfCombinedMVAV2BJetTags')",float,doc="CMVA V2 btag discriminator",precision=10),
263  btagDeepC = Var("bDiscriminator('pfDeepCSVJetTags:probc')",float,doc="DeepCSV charm btag discriminator",precision=10),
264  btagDeepFlavC = Var("bDiscriminator('pfDeepFlavourJetTags:probc')",float,doc="DeepFlavour charm tag discriminator",precision=10),
265  )
266 for modifier in run2_miniAOD_80XLegacy, run2_nanoAOD_94X2016:
267  modifier.toModify( jetTable.variables, jetId = Var("userInt('tightIdLepVeto')*4+userInt('tightId')*2+userInt('looseId')",int,doc="Jet ID flags bit1 is loose, bit2 is tight, bit3 is tightLepVeto"))
268 run2_jme_2016.toModify( jetTable.variables, puIdDisc = Var("userFloat('pileupJetId:fullDiscriminant')",float,doc="Pileup ID discriminant with 80X (2016) training",precision=10))
269 run2_jme_2017.toModify( jetTable.variables, puId = Var("userInt('puId106XUL17Id')", int,doc="Pileup ID flags with 106X (2017) training"))
270 run2_jme_2017.toModify( jetTable.variables, puIdDisc = Var("userFloat('puId106XUL17Disc')", float,doc="Pileup ID discriminant with 106X (2017) training",precision=10))
271 for modifier in run2_nanoAOD_94XMiniAODv1, run2_nanoAOD_94XMiniAODv2:
272  modifier.toModify( jetTable.variables, puIdDisc = Var("userFloat('puId94XDisc')", float,doc="Pileup ID discriminant with 94X (2017) training",precision=10))
273  modifier.toModify( jetTable.variables, puId = Var("userInt('pileupJetId:fullId')",int,doc="Pileup ID flags for 2016/2017/2018 EOY trainings"))
274 
275 
276 bjetNN= cms.EDProducer("BJetEnergyRegressionMVA",
277  backend = cms.string("TF"),
278  src = cms.InputTag("linkedObjects","jets"),
279  pvsrc = cms.InputTag("offlineSlimmedPrimaryVertices"),
280  svsrc = cms.InputTag("slimmedSecondaryVertices"),
281  rhosrc = cms.InputTag("fixedGridRhoFastjetAll"),
282 
283  weightFile = cms.FileInPath("PhysicsTools/NanoAOD/data/breg_training_2018.pb"),
284  name = cms.string("JetRegNN"),
285  isClassifier = cms.bool(False),
286  variablesOrder = cms.vstring(["Jet_pt","Jet_eta","rho","Jet_mt","Jet_leadTrackPt","Jet_leptonPtRel","Jet_leptonDeltaR","Jet_neHEF",
287  "Jet_neEmEF","Jet_vtxPt","Jet_vtxMass","Jet_vtx3dL","Jet_vtxNtrk","Jet_vtx3deL",
288  "Jet_numDaughters_pt03","Jet_energyRing_dR0_em_Jet_rawEnergy","Jet_energyRing_dR1_em_Jet_rawEnergy",
289  "Jet_energyRing_dR2_em_Jet_rawEnergy","Jet_energyRing_dR3_em_Jet_rawEnergy","Jet_energyRing_dR4_em_Jet_rawEnergy",
290  "Jet_energyRing_dR0_neut_Jet_rawEnergy","Jet_energyRing_dR1_neut_Jet_rawEnergy","Jet_energyRing_dR2_neut_Jet_rawEnergy",
291  "Jet_energyRing_dR3_neut_Jet_rawEnergy","Jet_energyRing_dR4_neut_Jet_rawEnergy","Jet_energyRing_dR0_ch_Jet_rawEnergy",
292  "Jet_energyRing_dR1_ch_Jet_rawEnergy","Jet_energyRing_dR2_ch_Jet_rawEnergy","Jet_energyRing_dR3_ch_Jet_rawEnergy",
293  "Jet_energyRing_dR4_ch_Jet_rawEnergy","Jet_energyRing_dR0_mu_Jet_rawEnergy","Jet_energyRing_dR1_mu_Jet_rawEnergy",
294  "Jet_energyRing_dR2_mu_Jet_rawEnergy","Jet_energyRing_dR3_mu_Jet_rawEnergy","Jet_energyRing_dR4_mu_Jet_rawEnergy",
295  "Jet_chHEF","Jet_chEmEF","Jet_leptonPtRelInv","isEle","isMu","isOther","Jet_mass","Jet_ptd"]),
296  variables = cms.PSet(
297  Jet_pt = cms.string("pt*jecFactor('Uncorrected')"),
298  Jet_mt = cms.string("mt*jecFactor('Uncorrected')"),
299  Jet_eta = cms.string("eta"),
300  Jet_mass = cms.string("mass*jecFactor('Uncorrected')"),
301  Jet_ptd = cms.string("userFloat('ptD')"),
302  Jet_leadTrackPt = cms.string("userFloat('leadTrackPt')"),
303  Jet_vtxNtrk = cms.string("userInt('vtxNtrk')"),
304  Jet_vtxMass = cms.string("userFloat('vtxMass')"),
305  Jet_vtx3dL = cms.string("userFloat('vtx3dL')"),
306  Jet_vtx3deL = cms.string("userFloat('vtx3deL')"),
307  Jet_vtxPt = cms.string("userFloat('vtxPt')"),
308  #Jet_leptonPt = cms.string("userFloat('leptonPt')"),
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_leptonPdgId = cms.string("userInt('leptonPdgId')"),
313  Jet_neHEF = cms.string("neutralHadronEnergyFraction()"),
314  Jet_neEmEF = cms.string("neutralEmEnergyFraction()"),
315  Jet_chHEF = cms.string("chargedHadronEnergyFraction()"),
316  Jet_chEmEF = cms.string("chargedEmEnergyFraction()"),
317  isMu = cms.string("?abs(userInt('leptonPdgId'))==13?1:0"),
318  isEle = cms.string("?abs(userInt('leptonPdgId'))==11?1:0"),
319  isOther = cms.string("?userInt('leptonPdgId')==0?1:0"),
320  ),
321  inputTensorName = cms.string("ffwd_inp"),
322  outputTensorName = cms.string("ffwd_out/BiasAdd"),
323  outputNames = cms.vstring(["corr","res"]),
324  outputFormulas = cms.vstring(["at(0)*0.27912887930870056+1.0545977354049683","0.5*(at(2)-at(1))*0.27912887930870056"]),
325  nThreads = cms.uint32(1),
326  singleThreadPool = cms.string("no_threads"),
327 )
328 
329 cjetNN= cms.EDProducer("BJetEnergyRegressionMVA",
330  backend = cms.string("TF"),
331  src = cms.InputTag("linkedObjects","jets"),
332  pvsrc = cms.InputTag("offlineSlimmedPrimaryVertices"),
333  svsrc = cms.InputTag("slimmedSecondaryVertices"),
334  rhosrc = cms.InputTag("fixedGridRhoFastjetAll"),
335 
336  weightFile = cms.FileInPath("PhysicsTools/NanoAOD/data/creg_training_2018.pb"),
337  name = cms.string("JetRegNN"),
338  isClassifier = cms.bool(False),
339  variablesOrder = cms.vstring(["Jet_pt","Jet_eta","rho","Jet_mt","Jet_leadTrackPt","Jet_leptonPtRel","Jet_leptonDeltaR",
340  "Jet_neHEF","Jet_neEmEF","Jet_vtxPt","Jet_vtxMass","Jet_vtx3dL","Jet_vtxNtrk","Jet_vtx3deL",
341  "Jet_numDaughters_pt03","Jet_chEmEF","Jet_chHEF", "Jet_ptd","Jet_mass",
342  "Jet_energyRing_dR0_em_Jet_rawEnergy","Jet_energyRing_dR1_em_Jet_rawEnergy",
343  "Jet_energyRing_dR2_em_Jet_rawEnergy","Jet_energyRing_dR3_em_Jet_rawEnergy","Jet_energyRing_dR4_em_Jet_rawEnergy",
344  "Jet_energyRing_dR0_neut_Jet_rawEnergy","Jet_energyRing_dR1_neut_Jet_rawEnergy","Jet_energyRing_dR2_neut_Jet_rawEnergy",
345  "Jet_energyRing_dR3_neut_Jet_rawEnergy","Jet_energyRing_dR4_neut_Jet_rawEnergy","Jet_energyRing_dR0_ch_Jet_rawEnergy",
346  "Jet_energyRing_dR1_ch_Jet_rawEnergy","Jet_energyRing_dR2_ch_Jet_rawEnergy","Jet_energyRing_dR3_ch_Jet_rawEnergy",
347  "Jet_energyRing_dR4_ch_Jet_rawEnergy","Jet_energyRing_dR0_mu_Jet_rawEnergy","Jet_energyRing_dR1_mu_Jet_rawEnergy",
348  "Jet_energyRing_dR2_mu_Jet_rawEnergy","Jet_energyRing_dR3_mu_Jet_rawEnergy","Jet_energyRing_dR4_mu_Jet_rawEnergy"]),
349  variables = cms.PSet(
350  Jet_pt = cms.string("pt*jecFactor('Uncorrected')"),
351  Jet_mt = cms.string("mt*jecFactor('Uncorrected')"),
352  Jet_eta = cms.string("eta"),
353  Jet_mass = cms.string("mass*jecFactor('Uncorrected')"),
354  Jet_ptd = cms.string("userFloat('ptD')"),
355  Jet_leadTrackPt = cms.string("userFloat('leadTrackPt')"),
356  Jet_vtxNtrk = cms.string("userInt('vtxNtrk')"),
357  Jet_vtxMass = cms.string("userFloat('vtxMass')"),
358  Jet_vtx3dL = cms.string("userFloat('vtx3dL')"),
359  Jet_vtx3deL = cms.string("userFloat('vtx3deL')"),
360  Jet_vtxPt = cms.string("userFloat('vtxPt')"),
361  #Jet_leptonPt = cms.string("userFloat('leptonPt')"),
362  Jet_leptonPtRel = cms.string("userFloat('leptonPtRelv0')"),
363  Jet_leptonPtRelInv = cms.string("userFloat('leptonPtRelInvv0')*jecFactor('Uncorrected')"),
364  Jet_leptonDeltaR = cms.string("userFloat('leptonDeltaR')"),
365  #Jet_leptonPdgId = cms.string("userInt('leptonPdgId')"),
366  Jet_neHEF = cms.string("neutralHadronEnergyFraction()"),
367  Jet_neEmEF = cms.string("neutralEmEnergyFraction()"),
368  Jet_chHEF = cms.string("chargedHadronEnergyFraction()"),
369  Jet_chEmEF = cms.string("chargedEmEnergyFraction()"),
370  isMu = cms.string("?abs(userInt('leptonPdgId'))==13?1:0"),
371  isEle = cms.string("?abs(userInt('leptonPdgId'))==11?1:0"),
372  isOther = cms.string("?userInt('leptonPdgId')==0?1:0"),
373  ),
374  inputTensorName = cms.string("ffwd_inp"),
375  outputTensorName = cms.string("ffwd_out/BiasAdd"),
376  outputNames = cms.vstring(["corr","res"]),
377  outputFormulas = cms.vstring(["at(0)*0.24325256049633026+0.993854820728302","0.5*(at(2)-at(1))*0.24325256049633026"]),
378  nThreads = cms.uint32(1),
379  singleThreadPool = cms.string("no_threads"),
380 )
381 
382 
383 
384 saJetTable = cms.EDProducer("SimpleCandidateFlatTableProducer",
385  src = cms.InputTag("softActivityJets"),
386  cut = cms.string(""),
387  maxLen = cms.uint32(6),
388  name = cms.string("SoftActivityJet"),
389  doc = cms.string("jets clustered from charged candidates compatible with primary vertex (" + chsForSATkJets.cut.value()+")"),
390  singleton = cms.bool(False), # the number of entries is variable
391  extension = cms.bool(False), # this is the main table for the jets
392  variables = cms.PSet(P3Vars,
393  )
394 )
395 
396 saJetTable.variables.pt.precision=10
397 saJetTable.variables.eta.precision=8
398 saJetTable.variables.phi.precision=8
399 
400 saTable = cms.EDProducer("GlobalVariablesTableProducer",
401  variables = cms.PSet(
402  SoftActivityJetHT = ExtVar( cms.InputTag("softActivityJets"), "candidatescalarsum", doc = "scalar sum of soft activity jet pt, pt>1" ),
403  SoftActivityJetHT10 = ExtVar( cms.InputTag("softActivityJets10"), "candidatescalarsum", doc = "scalar sum of soft activity jet pt , pt >10" ),
404  SoftActivityJetHT5 = ExtVar( cms.InputTag("softActivityJets5"), "candidatescalarsum", doc = "scalar sum of soft activity jet pt, pt>5" ),
405  SoftActivityJetHT2 = ExtVar( cms.InputTag("softActivityJets2"), "candidatescalarsum", doc = "scalar sum of soft activity jet pt, pt >2" ),
406  SoftActivityJetNjets10 = ExtVar( cms.InputTag("softActivityJets10"), "candidatesize", doc = "number of soft activity jet pt, pt >2" ),
407  SoftActivityJetNjets5 = ExtVar( cms.InputTag("softActivityJets5"), "candidatesize", doc = "number of soft activity jet pt, pt >5" ),
408  SoftActivityJetNjets2 = ExtVar( cms.InputTag("softActivityJets2"), "candidatesize", doc = "number of soft activity jet pt, pt >10" ),
409 
410  )
411 )
412 
413 
414 
415 
416 fatJetTable = cms.EDProducer("SimpleCandidateFlatTableProducer",
417  src = cms.InputTag("finalJetsAK8"),
418  cut = cms.string(" pt > 170"), #probably already applied in miniaod
419  name = cms.string("FatJet"),
420  doc = cms.string("slimmedJetsAK8, i.e. ak8 fat jets for boosted analysis"),
421  singleton = cms.bool(False), # the number of entries is variable
422  extension = cms.bool(False), # this is the main table for the jets
423  variables = cms.PSet(P4Vars,
424  jetId = Var("userInt('tightId')*2+4*userInt('tightIdLepVeto')",int,doc="Jet ID flags bit1 is loose (always false in 2017 since it does not exist), bit2 is tight, bit3 is tightLepVeto"),
425  area = Var("jetArea()", float, doc="jet catchment area, for JECs",precision=10),
426  rawFactor = Var("1.-jecFactor('Uncorrected')",float,doc="1 - Factor to get back to raw pT",precision=6),
427  tau1 = Var("userFloat('NjettinessAK8Puppi:tau1')",float, doc="Nsubjettiness (1 axis)",precision=10),
428  tau2 = Var("userFloat('NjettinessAK8Puppi:tau2')",float, doc="Nsubjettiness (2 axis)",precision=10),
429  tau3 = Var("userFloat('NjettinessAK8Puppi:tau3')",float, doc="Nsubjettiness (3 axis)",precision=10),
430  tau4 = Var("userFloat('NjettinessAK8Puppi:tau4')",float, doc="Nsubjettiness (4 axis)",precision=10),
431  n2b1 = Var("?hasUserFloat('nb1AK8PuppiSoftDrop:ecfN2')?userFloat('nb1AK8PuppiSoftDrop:ecfN2'):-99999.", float, doc="N2 with beta=1 (for jets with raw pT>250 GeV)", precision=10),
432  n3b1 = Var("?hasUserFloat('nb1AK8PuppiSoftDrop:ecfN3')?userFloat('nb1AK8PuppiSoftDrop:ecfN3'):-99999.", float, doc="N3 with beta=1 (for jets with raw pT>250 GeV)", precision=10),
433  msoftdrop = Var("groomedMass('SoftDropPuppi')",float, doc="Corrected soft drop mass with PUPPI",precision=10),
434  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),
435  btagCSVV2 = Var("bDiscriminator('pfCombinedInclusiveSecondaryVertexV2BJetTags')",float,doc=" pfCombinedInclusiveSecondaryVertexV2 b-tag discriminator (aka CSVV2)",precision=10),
436  btagHbb = Var("bDiscriminator('pfBoostedDoubleSecondaryVertexAK8BJetTags')",float,doc="Higgs to BB tagger discriminator",precision=10),
437  btagDDBvLV2 = Var("bDiscriminator('pfMassIndependentDeepDoubleBvLV2JetTags:probHbb')",float,doc="DeepDoubleX V2(mass-decorrelated) discriminator for H(Z)->bb vs QCD",precision=10),
438  btagDDCvLV2 = Var("bDiscriminator('pfMassIndependentDeepDoubleCvLV2JetTags:probHcc')",float,doc="DeepDoubleX V2 (mass-decorrelated) discriminator for H(Z)->cc vs QCD",precision=10),
439  btagDDCvBV2 = Var("bDiscriminator('pfMassIndependentDeepDoubleCvBV2JetTags:probHcc')",float,doc="DeepDoubleX V2 (mass-decorrelated) discriminator for H(Z)->cc vs H(Z)->bb",precision=10),
440  deepTag_TvsQCD = Var("bDiscriminator('pfDeepBoostedDiscriminatorsJetTags:TvsQCD')",float,doc="DeepBoostedJet tagger top vs QCD discriminator",precision=10),
441  deepTag_WvsQCD = Var("bDiscriminator('pfDeepBoostedDiscriminatorsJetTags:WvsQCD')",float,doc="DeepBoostedJet tagger W vs QCD discriminator",precision=10),
442  deepTag_ZvsQCD = Var("bDiscriminator('pfDeepBoostedDiscriminatorsJetTags:ZvsQCD')",float,doc="DeepBoostedJet tagger Z vs QCD discriminator",precision=10),
443  deepTag_H = Var("bDiscriminator('pfDeepBoostedJetTags:probHbb')+bDiscriminator('pfDeepBoostedJetTags:probHcc')+bDiscriminator('pfDeepBoostedJetTags:probHqqqq')",float,doc="DeepBoostedJet tagger H(bb,cc,4q) sum",precision=10),
444  deepTag_QCD = Var("bDiscriminator('pfDeepBoostedJetTags:probQCDbb')+bDiscriminator('pfDeepBoostedJetTags:probQCDcc')+bDiscriminator('pfDeepBoostedJetTags:probQCDb')+bDiscriminator('pfDeepBoostedJetTags:probQCDc')+bDiscriminator('pfDeepBoostedJetTags:probQCDothers')",float,doc="DeepBoostedJet tagger QCD(bb,cc,b,c,others) sum",precision=10),
445  deepTag_QCDothers = Var("bDiscriminator('pfDeepBoostedJetTags:probQCDothers')",float,doc="DeepBoostedJet tagger QCDothers value",precision=10),
446  deepTagMD_TvsQCD = Var("bDiscriminator('pfMassDecorrelatedDeepBoostedDiscriminatorsJetTags:TvsQCD')",float,doc="Mass-decorrelated DeepBoostedJet tagger top vs QCD discriminator",precision=10),
447  deepTagMD_WvsQCD = Var("bDiscriminator('pfMassDecorrelatedDeepBoostedDiscriminatorsJetTags:WvsQCD')",float,doc="Mass-decorrelated DeepBoostedJet tagger W vs QCD discriminator",precision=10),
448  deepTagMD_ZvsQCD = Var("bDiscriminator('pfMassDecorrelatedDeepBoostedDiscriminatorsJetTags:ZvsQCD')",float,doc="Mass-decorrelated DeepBoostedJet tagger Z vs QCD discriminator",precision=10),
449  deepTagMD_ZHbbvsQCD = Var("bDiscriminator('pfMassDecorrelatedDeepBoostedDiscriminatorsJetTags:ZHbbvsQCD')",float,doc="Mass-decorrelated DeepBoostedJet tagger Z/H->bb vs QCD discriminator",precision=10),
450  deepTagMD_ZbbvsQCD = Var("bDiscriminator('pfMassDecorrelatedDeepBoostedDiscriminatorsJetTags:ZbbvsQCD')",float,doc="Mass-decorrelated DeepBoostedJet tagger Z->bb vs QCD discriminator",precision=10),
451  deepTagMD_HbbvsQCD = Var("bDiscriminator('pfMassDecorrelatedDeepBoostedDiscriminatorsJetTags:HbbvsQCD')",float,doc="Mass-decorrelated DeepBoostedJet tagger H->bb vs QCD discriminator",precision=10),
452  deepTagMD_ZHccvsQCD = Var("bDiscriminator('pfMassDecorrelatedDeepBoostedDiscriminatorsJetTags:ZHccvsQCD')",float,doc="Mass-decorrelated DeepBoostedJet tagger Z/H->cc vs QCD discriminator",precision=10),
453  deepTagMD_H4qvsQCD = Var("bDiscriminator('pfMassDecorrelatedDeepBoostedDiscriminatorsJetTags:H4qvsQCD')",float,doc="Mass-decorrelated DeepBoostedJet tagger H->4q vs QCD discriminator",precision=10),
454  deepTagMD_bbvsLight = Var("bDiscriminator('pfMassDecorrelatedDeepBoostedDiscriminatorsJetTags:bbvsLight')",float,doc="Mass-decorrelated DeepBoostedJet tagger Z/H/gluon->bb vs light flavour discriminator",precision=10),
455  deepTagMD_ccvsLight = Var("bDiscriminator('pfMassDecorrelatedDeepBoostedDiscriminatorsJetTags:ccvsLight')",float,doc="Mass-decorrelated DeepBoostedJet tagger Z/H/gluon->cc vs light flavour discriminator",precision=10),
456  particleNet_TvsQCD = Var("bDiscriminator('pfParticleNetDiscriminatorsJetTags:TvsQCD')",float,doc="ParticleNet tagger top vs QCD discriminator",precision=10),
457  particleNet_WvsQCD = Var("bDiscriminator('pfParticleNetDiscriminatorsJetTags:WvsQCD')",float,doc="ParticleNet tagger W vs QCD discriminator",precision=10),
458  particleNet_ZvsQCD = Var("bDiscriminator('pfParticleNetDiscriminatorsJetTags:ZvsQCD')",float,doc="ParticleNet tagger Z vs QCD discriminator",precision=10),
459  particleNet_HbbvsQCD = Var("bDiscriminator('pfParticleNetDiscriminatorsJetTags:HbbvsQCD')",float,doc="ParticleNet tagger H(->bb) vs QCD discriminator",precision=10),
460  particleNet_HccvsQCD = Var("bDiscriminator('pfParticleNetDiscriminatorsJetTags:HccvsQCD')",float,doc="ParticleNet tagger H(->cc) vs QCD discriminator",precision=10),
461  particleNet_H4qvsQCD = Var("bDiscriminator('pfParticleNetDiscriminatorsJetTags:H4qvsQCD')",float,doc="ParticleNet tagger H(->VV->qqqq) vs QCD discriminator",precision=10),
462  particleNet_QCD = Var("bDiscriminator('pfParticleNetJetTags:probQCDbb')+bDiscriminator('pfParticleNetJetTags:probQCDcc')+bDiscriminator('pfParticleNetJetTags:probQCDb')+bDiscriminator('pfParticleNetJetTags:probQCDc')+bDiscriminator('pfParticleNetJetTags:probQCDothers')",float,doc="ParticleNet tagger QCD(bb,cc,b,c,others) sum",precision=10),
463  particleNetMD_Xbb = Var("bDiscriminator('pfMassDecorrelatedParticleNetJetTags:probXbb')",float,doc="Mass-decorrelated ParticleNet tagger raw X->bb score. For X->bb vs QCD tagging, use Xbb/(Xbb+QCD)",precision=10),
464  particleNetMD_Xcc = Var("bDiscriminator('pfMassDecorrelatedParticleNetJetTags:probXcc')",float,doc="Mass-decorrelated ParticleNet tagger raw X->cc score. For X->cc vs QCD tagging, use Xcc/(Xcc+QCD)",precision=10),
465  particleNetMD_Xqq = Var("bDiscriminator('pfMassDecorrelatedParticleNetJetTags:probXqq')",float,doc="Mass-decorrelated ParticleNet tagger raw X->qq (uds) score. For X->qq vs QCD tagging, use Xqq/(Xqq+QCD). For W vs QCD tagging, use (Xcc+Xqq)/(Xcc+Xqq+QCD)",precision=10),
466  particleNetMD_QCD = Var("bDiscriminator('pfMassDecorrelatedParticleNetJetTags:probQCDbb')+bDiscriminator('pfMassDecorrelatedParticleNetJetTags:probQCDcc')+bDiscriminator('pfMassDecorrelatedParticleNetJetTags:probQCDb')+bDiscriminator('pfMassDecorrelatedParticleNetJetTags:probQCDc')+bDiscriminator('pfMassDecorrelatedParticleNetJetTags:probQCDothers')",float,doc="Mass-decorrelated ParticleNet tagger raw QCD score",precision=10),
467  subJetIdx1 = Var("?nSubjetCollections()>0 && subjets('SoftDropPuppi').size()>0?subjets('SoftDropPuppi')[0].key():-1", int,
468  doc="index of first subjet"),
469  subJetIdx2 = Var("?nSubjetCollections()>0 && subjets('SoftDropPuppi').size()>1?subjets('SoftDropPuppi')[1].key():-1", int,
470  doc="index of second subjet"),
471 
472 # btagDeepC = Var("bDiscriminator('pfDeepCSVJetTags:probc')",float,doc="CMVA V2 btag discriminator",precision=10),
473 #puIdDisc = Var("userFloat('pileupJetId:fullDiscriminant')",float,doc="Pileup ID discriminant",precision=10),
474 # nConstituents = Var("numberOfDaughters()",int,doc="Number of particles in the jet"),
475 # rawFactor = Var("1.-jecFactor('Uncorrected')",float,doc="1 - Factor to get back to raw pT",precision=6),
476  ),
477  externalVariables = cms.PSet(
478  lsf3 = ExtVar(cms.InputTag("lepInJetVars:lsf3"),float, doc="Lepton Subjet Fraction (3 subjets)",precision=10),
479  muonIdx3SJ = ExtVar(cms.InputTag("lepInJetVars:muIdx3SJ"),int, doc="index of muon matched to jet"),
480  electronIdx3SJ = ExtVar(cms.InputTag("lepInJetVars:eleIdx3SJ"),int,doc="index of electron matched to jet"),
481  )
482 )
483 
484 for modifier in run2_miniAOD_80XLegacy, run2_nanoAOD_94X2016, run2_nanoAOD_94XMiniAODv1, run2_nanoAOD_94XMiniAODv2, run2_nanoAOD_102Xv1, run2_nanoAOD_106Xv1:
485  modifier.toModify( fatJetTable.variables.n2b1, expr = cms.string("userFloat('ak8PFJetsPuppiSoftDropValueMap:nb1AK8PuppiSoftDropN2')"),)
486  modifier.toModify( fatJetTable.variables.n3b1, expr = cms.string("userFloat('ak8PFJetsPuppiSoftDropValueMap:nb1AK8PuppiSoftDropN3')"),)
487  # Deprecated after 106X
488  modifier.toModify( fatJetTable.variables,
489  btagCMVA = Var("bDiscriminator('pfCombinedMVAV2BJetTags')",float,doc="CMVA V2 btag discriminator",precision=10),
490  btagDDBvL_noMD = Var("bDiscriminator('pfDeepDoubleBvLJetTags:probHbb')",float,doc="DeepDoubleX discriminator (no mass-decorrelation) for H(Z)->bb vs QCD",precision=10),
491  btagDDCvL_noMD = Var("bDiscriminator('pfDeepDoubleCvLJetTags:probHcc')",float,doc="DeepDoubleX discriminator (no mass-decorrelation) for H(Z)->cc vs QCD",precision=10),
492  btagDDCvB_noMD = Var("bDiscriminator('pfDeepDoubleCvBJetTags:probHcc')",float,doc="DeepDoubleX discriminator (no mass-decorrelation) for H(Z)->cc vs H(Z)->bb",precision=10),
493  btagDDBvL = Var("bDiscriminator('pfMassIndependentDeepDoubleBvLJetTags:probHbb')",float,doc="DeepDoubleX (mass-decorrelated) discriminator for H(Z)->bb vs QCD",precision=10),
494  btagDDCvL = Var("bDiscriminator('pfMassIndependentDeepDoubleCvLJetTags:probHcc')",float,doc="DeepDoubleX (mass-decorrelated) discriminator for H(Z)->cc vs QCD",precision=10),
495  btagDDCvB = Var("bDiscriminator('pfMassIndependentDeepDoubleCvBJetTags:probHcc')",float,doc="DeepDoubleX (mass-decorrelated) discriminator for H(Z)->cc vs H(Z)->bb",precision=10),
496  )
497 run2_miniAOD_80XLegacy.toModify( fatJetTable.variables, msoftdrop_chs = Var("userFloat('ak8PFJetsCHSSoftDropMass')",float, doc="Legacy uncorrected soft drop mass with CHS",precision=10))
498 run2_miniAOD_80XLegacy.toModify( fatJetTable.variables.tau1, expr = cms.string("userFloat(\'ak8PFJetsPuppiValueMap:NjettinessAK8PuppiTau1\')"),)
499 run2_miniAOD_80XLegacy.toModify( fatJetTable.variables.tau2, expr = cms.string("userFloat(\'ak8PFJetsPuppiValueMap:NjettinessAK8PuppiTau2\')"),)
500 run2_miniAOD_80XLegacy.toModify( fatJetTable.variables.tau3, expr = cms.string("userFloat(\'ak8PFJetsPuppiValueMap:NjettinessAK8PuppiTau3\')"),)
501 run2_miniAOD_80XLegacy.toModify( fatJetTable.variables, tau4 = None)
502 run2_miniAOD_80XLegacy.toModify( fatJetTable.variables, n2b1 = None)
503 run2_miniAOD_80XLegacy.toModify( fatJetTable.variables, n3b1 = None)
504 for modifier in run2_miniAOD_80XLegacy, run2_nanoAOD_94X2016:
505  modifier.toModify( fatJetTable.variables, jetId = Var("userInt('tightId')*2+userInt('looseId')",int,doc="Jet ID flags bit1 is loose, bit2 is tight"))
506 
507 run2_jme_2016.toModify( bjetNN, weightFile = cms.FileInPath("PhysicsTools/NanoAOD/data/breg_training_2016.pb") )
508 run2_jme_2016.toModify( bjetNN,outputFormulas = cms.vstring(["at(0)*0.31976690888404846+1.047176718711853","0.5*(at(2)-at(1))*0.31976690888404846"]))
509 
510 run2_jme_2017.toModify( bjetNN, weightFile = cms.FileInPath("PhysicsTools/NanoAOD/data/breg_training_2017.pb") )
511 run2_jme_2017.toModify( bjetNN,outputFormulas = cms.vstring(["at(0)*0.28225210309028625+1.055067777633667","0.5*(at(2)-at(1))*0.28225210309028625"]))
512 
513 run2_jme_2016.toModify( cjetNN, weightFile = cms.FileInPath("PhysicsTools/NanoAOD/data/creg_training_2016.pb") )
514 run2_jme_2016.toModify( cjetNN,outputFormulas = cms.vstring(["at(0)*0.28862622380256653+0.9908722639083862","0.5*(at(2)-at(1))*0.28862622380256653"]))
515 
516 run2_jme_2017.toModify( cjetNN, weightFile = cms.FileInPath("PhysicsTools/NanoAOD/data/creg_training_2017.pb") )
517 run2_jme_2017.toModify( cjetNN,outputFormulas = cms.vstring(["at(0)*0.24718524515628815+0.9927206635475159","0.5*(at(2)-at(1))*0.24718524515628815"]))
518 
519 
520 
521 subJetTable = cms.EDProducer("SimpleCandidateFlatTableProducer",
522  src = cms.InputTag("slimmedJetsAK8PFPuppiSoftDropPacked","SubJets"),
523  cut = cms.string(""), #probably already applied in miniaod
524  name = cms.string("SubJet"),
525  doc = cms.string("slimmedJetsAK8, i.e. ak8 fat jets for boosted analysis"),
526  singleton = cms.bool(False), # the number of entries is variable
527  extension = cms.bool(False), # this is the main table for the jets
528  variables = cms.PSet(P4Vars,
529  btagDeepB = Var("bDiscriminator('pfDeepCSVJetTags:probb')+bDiscriminator('pfDeepCSVJetTags:probbb')",float,doc="DeepCSV b+bb tag discriminator",precision=10),
530  btagCSVV2 = Var("bDiscriminator('pfCombinedInclusiveSecondaryVertexV2BJetTags')",float,doc=" pfCombinedInclusiveSecondaryVertexV2 b-tag discriminator (aka CSVV2)",precision=10),
531  rawFactor = Var("1.-jecFactor('Uncorrected')",float,doc="1 - Factor to get back to raw pT",precision=6),
532  tau1 = Var("userFloat('NjettinessAK8Subjets:tau1')",float, doc="Nsubjettiness (1 axis)",precision=10),
533  tau2 = Var("userFloat('NjettinessAK8Subjets:tau2')",float, doc="Nsubjettiness (2 axis)",precision=10),
534  tau3 = Var("userFloat('NjettinessAK8Subjets:tau3')",float, doc="Nsubjettiness (3 axis)",precision=10),
535  tau4 = Var("userFloat('NjettinessAK8Subjets:tau4')",float, doc="Nsubjettiness (4 axis)",precision=10),
536  n2b1 = Var("userFloat('nb1AK8PuppiSoftDropSubjets:ecfN2')", float, doc="N2 with beta=1", precision=10),
537  n3b1 = Var("userFloat('nb1AK8PuppiSoftDropSubjets:ecfN3')", float, doc="N3 with beta=1", precision=10),
538  )
539 )
540 
541 # Deprecation/backcomp
542 for modifier in run2_miniAOD_80XLegacy, run2_nanoAOD_94X2016, run2_nanoAOD_94XMiniAODv1, run2_nanoAOD_94XMiniAODv2, run2_nanoAOD_102Xv1, run2_nanoAOD_106Xv1:
543  # post 106X
544  modifier.toModify(subJetTable.variables,
545  btagCMVA = Var("bDiscriminator('pfCombinedMVAV2BJetTags')",float,doc="CMVA V2 btag discriminator",precision=10),
546  )
547 
548 #jets are not as precise as muons
549 fatJetTable.variables.pt.precision=10
550 subJetTable.variables.pt.precision=10
551 
552 run2_miniAOD_80XLegacy.toModify( subJetTable.variables, tau1 = None)
553 run2_miniAOD_80XLegacy.toModify( subJetTable.variables, tau2 = None)
554 run2_miniAOD_80XLegacy.toModify( subJetTable.variables, tau3 = None)
555 run2_miniAOD_80XLegacy.toModify( subJetTable.variables, tau4 = None)
556 run2_miniAOD_80XLegacy.toModify( subJetTable.variables, n2b1 = None)
557 run2_miniAOD_80XLegacy.toModify( subJetTable.variables, n3b1 = None)
558 run2_miniAOD_80XLegacy.toModify( subJetTable.variables, btagCMVA = None, btagDeepB = None)
559 
560 
561 corrT1METJetTable = cms.EDProducer("SimpleCandidateFlatTableProducer",
562  src = cms.InputTag("corrT1METJets"),
563  cut = cms.string(""),
564  name = cms.string("CorrT1METJet"),
565  doc = cms.string("Additional low-pt jets for Type-1 MET re-correction"),
566  singleton = cms.bool(False), # the number of entries is variable
567  extension = cms.bool(False), # this is the main table for the jets
568  variables = cms.PSet(
569  rawPt = Var("pt()*jecFactor('Uncorrected')",float,precision=10),
570  eta = Var("eta", float,precision=12),
571  phi = Var("phi", float, precision=12),
572  area = Var("jetArea()", float, doc="jet catchment area, for JECs",precision=10),
573  )
574 )
575 
576 
577 
578 
579 jetMCTable = cms.EDProducer("SimpleCandidateFlatTableProducer",
580  src = cms.InputTag("linkedObjects","jets"),
581  cut = cms.string(""), #we should not filter on cross linked collections
582  name = cms.string("Jet"),
583  singleton = cms.bool(False), # the number of entries is variable
584  extension = cms.bool(True), # this is an extension table for the jets
585  variables = cms.PSet(
586  partonFlavour = Var("partonFlavour()", int, doc="flavour from parton matching"),
587  hadronFlavour = Var("hadronFlavour()", int, doc="flavour from hadron ghost clustering"),
588  genJetIdx = Var("?genJetFwdRef().backRef().isNonnull()?genJetFwdRef().backRef().key():-1", int, doc="index of matched gen jet"),
589  )
590 )
591 genJetTable = cms.EDProducer("SimpleCandidateFlatTableProducer",
592  src = cms.InputTag("slimmedGenJets"),
593  cut = cms.string("pt > 10"),
594  name = cms.string("GenJet"),
595  doc = cms.string("slimmedGenJets, i.e. ak4 Jets made with visible genparticles"),
596  singleton = cms.bool(False), # the number of entries is variable
597  extension = cms.bool(False), # this is the main table for the genjets
598  variables = cms.PSet(P4Vars,
599  #anything else?
600  )
601 )
602 patJetPartons = cms.EDProducer('HadronAndPartonSelector',
603  src = cms.InputTag("generator"),
604  particles = cms.InputTag("prunedGenParticles"),
605  partonMode = cms.string("Auto"),
606  fullChainPhysPartons = cms.bool(True)
607 )
608 genJetFlavourAssociation = cms.EDProducer("JetFlavourClustering",
609  jets = genJetTable.src,
610  bHadrons = cms.InputTag("patJetPartons","bHadrons"),
611  cHadrons = cms.InputTag("patJetPartons","cHadrons"),
612  partons = cms.InputTag("patJetPartons","physicsPartons"),
613  leptons = cms.InputTag("patJetPartons","leptons"),
614  jetAlgorithm = cms.string("AntiKt"),
615  rParam = cms.double(0.4),
616  ghostRescaling = cms.double(1e-18),
617  hadronFlavourHasPriority = cms.bool(False)
618 )
619 genJetFlavourTable = cms.EDProducer("GenJetFlavourTableProducer",
620  name = genJetTable.name,
621  src = genJetTable.src,
622  cut = genJetTable.cut,
623  deltaR = cms.double(0.1),
624  jetFlavourInfos = cms.InputTag("slimmedGenJetsFlavourInfos"),
625 )
626 
627 genJetAK8Table = cms.EDProducer("SimpleCandidateFlatTableProducer",
628  src = cms.InputTag("slimmedGenJetsAK8"),
629  cut = cms.string("pt > 100."),
630  name = cms.string("GenJetAK8"),
631  doc = cms.string("slimmedGenJetsAK8, i.e. ak8 Jets made with visible genparticles"),
632  singleton = cms.bool(False), # the number of entries is variable
633  extension = cms.bool(False), # this is the main table for the genjets
634  variables = cms.PSet(P4Vars,
635  #anything else?
636  )
637 )
638 genJetAK8FlavourAssociation = cms.EDProducer("JetFlavourClustering",
639  jets = genJetAK8Table.src,
640  bHadrons = cms.InputTag("patJetPartons","bHadrons"),
641  cHadrons = cms.InputTag("patJetPartons","cHadrons"),
642  partons = cms.InputTag("patJetPartons","physicsPartons"),
643  leptons = cms.InputTag("patJetPartons","leptons"),
644  jetAlgorithm = cms.string("AntiKt"),
645  rParam = cms.double(0.8),
646  ghostRescaling = cms.double(1e-18),
647  hadronFlavourHasPriority = cms.bool(False)
648 )
649 genJetAK8FlavourTable = cms.EDProducer("GenJetFlavourTableProducer",
650  name = genJetAK8Table.name,
651  src = genJetAK8Table.src,
652  cut = genJetAK8Table.cut,
653  deltaR = cms.double(0.1),
654  jetFlavourInfos = cms.InputTag("genJetAK8FlavourAssociation"),
655 )
656 fatJetMCTable = cms.EDProducer("SimpleCandidateFlatTableProducer",
657  src = fatJetTable.src,
658  cut = fatJetTable.cut,
659  name = fatJetTable.name,
660  singleton = cms.bool(False),
661  extension = cms.bool(True),
662  variables = cms.PSet(
663  nBHadrons = Var("jetFlavourInfo().getbHadrons().size()", "uint8", doc="number of b-hadrons"),
664  nCHadrons = Var("jetFlavourInfo().getcHadrons().size()", "uint8", doc="number of c-hadrons"),
665  hadronFlavour = Var("hadronFlavour()", int, doc="flavour from hadron ghost clustering"),
666  genJetAK8Idx = Var("?genJetFwdRef().backRef().isNonnull()?genJetFwdRef().backRef().key():-1", int, doc="index of matched gen AK8 jet"),
667  )
668 )
669 
670 genSubJetAK8Table = cms.EDProducer("SimpleCandidateFlatTableProducer",
671  src = cms.InputTag("slimmedGenJetsAK8SoftDropSubJets"),
672  cut = cms.string(""),
673  name = cms.string("SubGenJetAK8"),
674  doc = cms.string("slimmedGenJetsAK8SoftDropSubJets, i.e. subjets of ak8 Jets made with visible genparticles"),
675  singleton = cms.bool(False), # the number of entries is variable
676  extension = cms.bool(False), # this is the main table for the genjets
677  variables = cms.PSet(P4Vars,
678  #anything else?
679  )
680 )
681 subjetMCTable = cms.EDProducer("SimpleCandidateFlatTableProducer",
682  src = subJetTable.src,
683  cut = subJetTable.cut,
684  name = subJetTable.name,
685  singleton = cms.bool(False),
686  extension = cms.bool(True),
687  variables = cms.PSet(
688  nBHadrons = Var("jetFlavourInfo().getbHadrons().size()", "uint8", doc="number of b-hadrons"),
689  nCHadrons = Var("jetFlavourInfo().getcHadrons().size()", "uint8", doc="number of c-hadrons"),
690  hadronFlavour = Var("hadronFlavour()", int, doc="flavour from hadron ghost clustering"),
691  )
692 )
693 
694 
695 run2_miniAOD_80XLegacy.toModify( genJetFlavourTable, jetFlavourInfos = cms.InputTag("genJetFlavourAssociation"),)
696 
697 from RecoJets.JetProducers.QGTagger_cfi import QGTagger
698 qgtagger=QGTagger.clone(srcJets="updatedJets",srcVertexCollection="offlineSlimmedPrimaryVertices")
699 
700 
701 from RecoJets.JetProducers.PileupJetID_cfi import pileupJetId, _chsalgos_94x, _chsalgos_102x, _chsalgos_106X_UL17
702 pileupJetId94X=pileupJetId.clone(jets="updatedJets",algos = cms.VPSet(_chsalgos_94x),inputIsCorrected=True,applyJec=False,vertexes="offlineSlimmedPrimaryVertices")
703 pileupJetId102X=pileupJetId.clone(jets="updatedJets",algos = cms.VPSet(_chsalgos_102x),inputIsCorrected=True,applyJec=False,vertexes="offlineSlimmedPrimaryVertices")
704 pileupJetId106XUL17=pileupJetId.clone(jets="updatedJets",algos = cms.VPSet(_chsalgos_106X_UL17),inputIsCorrected=True,applyJec=False,vertexes="offlineSlimmedPrimaryVertices")
705 
706 #before cross linking
707 jetSequence = cms.Sequence(jetCorrFactorsNano+updatedJets+tightJetId+tightJetIdLepVeto+bJetVars+qgtagger+jercVars+pileupJetId94X+pileupJetId102X+pileupJetId106XUL17+updatedJetsWithUserData+jetCorrFactorsAK8+updatedJetsAK8+tightJetIdAK8+tightJetIdLepVetoAK8+updatedJetsAK8WithUserData+chsForSATkJets+softActivityJets+softActivityJets2+softActivityJets5+softActivityJets10+finalJets+finalJetsAK8)
708 
709 
710 _jetSequence_2016 = jetSequence.copy()
711 _jetSequence_2016.insert(_jetSequence_2016.index(tightJetId), looseJetId)
712 _jetSequence_2016.insert(_jetSequence_2016.index(tightJetIdAK8), looseJetIdAK8)
713 for modifier in run2_miniAOD_80XLegacy, run2_nanoAOD_94X2016:
714  modifier.toReplaceWith(jetSequence, _jetSequence_2016)
715 
716 #HF shower shape recomputation
717 #Only run if needed (i.e. if default MINIAOD info is missing or outdated because of new JECs...)
718 from RecoJets.JetProducers.hfJetShowerShape_cfi import hfJetShowerShape
719 hfJetShowerShapeforNanoAOD = hfJetShowerShape.clone(jets="updatedJets",vertices="offlineSlimmedPrimaryVertices")
720 for modifier in run2_miniAOD_80XLegacy, run2_nanoAOD_94X2016, run2_nanoAOD_94XMiniAODv1, run2_nanoAOD_94XMiniAODv2, run2_nanoAOD_102Xv1, run2_nanoAOD_106Xv1:
721  modifier.toModify(updatedJetsWithUserData.userFloats,
722  hfsigmaEtaEta = cms.InputTag('hfJetShowerShapeforNanoAOD:sigmaEtaEta'),
723  hfsigmaPhiPhi = cms.InputTag('hfJetShowerShapeforNanoAOD:sigmaPhiPhi'),
724  )
725  modifier.toModify(updatedJetsWithUserData.userInts,
726  hfcentralEtaStripSize = cms.InputTag('hfJetShowerShapeforNanoAOD:centralEtaStripSize'),
727  hfadjacentEtaStripsSize = cms.InputTag('hfJetShowerShapeforNanoAOD:adjacentEtaStripsSize'),
728  )
729  modifier.toModify( jetTable.variables, hfsigmaEtaEta = Var("userFloat('hfsigmaEtaEta')",float,doc="sigmaEtaEta for HF jets (noise discriminating variable)",precision=10))
730  modifier.toModify( jetTable.variables, hfsigmaPhiPhi = Var("userFloat('hfsigmaPhiPhi')",float,doc="sigmaPhiPhi for HF jets (noise discriminating variable)",precision=10))
731  modifier.toModify( jetTable.variables, hfcentralEtaStripSize = Var("userInt('hfcentralEtaStripSize')", int, doc="eta size of the central tower strip in HF (noise discriminating variable) "))
732  modifier.toModify( jetTable.variables, hfadjacentEtaStripsSize = Var("userInt('hfadjacentEtaStripsSize')", int, doc="eta size of the strips next to the central tower strip in HF (noise discriminating variable) "))
733  _jetSequence_rerunHFshowershape = jetSequence.copy()
734  _jetSequence_rerunHFshowershape.insert(_jetSequence_rerunHFshowershape.index(updatedJetsWithUserData), hfJetShowerShapeforNanoAOD)
735  modifier.toReplaceWith(jetSequence, _jetSequence_rerunHFshowershape)
736 
737 
738 #after lepton collections have been run
739 jetLepSequence = cms.Sequence(lepInJetVars)
740 
741 #after cross linkining
742 jetTables = cms.Sequence(bjetNN+cjetNN+jetTable+fatJetTable+subJetTable+saJetTable+saTable)
743 
744 #MC only producers and tables
745 jetMC = cms.Sequence(jetMCTable+genJetTable+patJetPartons+genJetFlavourTable+genJetAK8Table+genJetAK8FlavourAssociation+genJetAK8FlavourTable+fatJetMCTable+genSubJetAK8Table+subjetMCTable)
746 _jetMC_pre94X = jetMC.copy()
747 _jetMC_pre94X.insert(_jetMC_pre94X.index(genJetFlavourTable),genJetFlavourAssociation)
748 _jetMC_pre94X.remove(genSubJetAK8Table)
749 run2_miniAOD_80XLegacy.toReplaceWith(jetMC, _jetMC_pre94X)
750 
751 
ak4PFJetsBetaStar_cfi
common_cff
common_cff.Var
def Var(expr, valtype, compression=None, doc=None, mcOnly=False, precision=-1)
Definition: common_cff.py:20
jetCorrFactors_cfi
ak4PFJets_cfi
QGTagger_cfi
common_cff.ExtVar
def ExtVar(tag, valtype, compression=None, doc=None, mcOnly=False, precision=-1)
Definition: common_cff.py:31
nano_eras_cff
jetUpdater_cfi
PileupJetID_cfi