CMS 3D CMS Logo

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