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_miniAOD_80XLegacy_cff import run2_miniAOD_80XLegacy
3 from Configuration.Eras.Modifier_run2_nanoAOD_92X_cff import run2_nanoAOD_92X
4 
6 
7 
8 
9 ##################### User floats producers, selectors ##########################
10 from RecoJets.JetProducers.ak4PFJets_cfi import ak4PFJets
11 
12 chsForSATkJets = cms.EDFilter("CandPtrSelector", src = cms.InputTag("packedPFCandidates"), cut = cms.string('charge()!=0 && pvAssociationQuality()>=5 && vertexRef().key()==0'))
13 softActivityJets = ak4PFJets.clone(src = 'chsForSATkJets', doAreaFastjet = False, jetPtMin=1)
14 softActivityJets10 = cms.EDFilter("CandPtrSelector", src = cms.InputTag("softActivityJets"), cut = cms.string('pt>10'))
15 softActivityJets5 = cms.EDFilter("CandPtrSelector", src = cms.InputTag("softActivityJets"), cut = cms.string('pt>5'))
16 softActivityJets2 = cms.EDFilter("CandPtrSelector", src = cms.InputTag("softActivityJets"), cut = cms.string('pt>2'))
17 
18 looseJetId = cms.EDProducer("PatJetIDValueMapProducer",
19  filterParams=cms.PSet(
20  version = cms.string('WINTER16'),
21  quality = cms.string('LOOSE'),
22  ),
23  src = cms.InputTag("slimmedJets")
24 )
25 tightJetId = cms.EDProducer("PatJetIDValueMapProducer",
26  filterParams=cms.PSet(
27  version = cms.string('WINTER17'),
28  quality = cms.string('TIGHT'),
29  ),
30  src = cms.InputTag("slimmedJets")
31 )
32 run2_miniAOD_80XLegacy.toModify( tightJetId.filterParams, version = "WINTER16" )
33 
34 tightJetIdLepVeto = cms.EDProducer("PatJetIDValueMapProducer",
35  filterParams=cms.PSet(
36  version = cms.string('WINTER17'),
37  quality = cms.string('TIGHTLEPVETO'),
38  ),
39  src = cms.InputTag("slimmedJets")
40 )
41 
42 looseJetIdAK8 = cms.EDProducer("PatJetIDValueMapProducer",
43  filterParams=cms.PSet(
44  version = cms.string('WINTER16'),
45  quality = cms.string('LOOSE'),
46  ),
47  src = cms.InputTag("slimmedJetsAK8")
48 )
49 tightJetIdAK8 = cms.EDProducer("PatJetIDValueMapProducer",
50  filterParams=cms.PSet(
51  version = cms.string('WINTER17'),
52  quality = cms.string('TIGHT'),
53  ),
54  src = cms.InputTag("slimmedJetsAK8")
55 )
56 run2_miniAOD_80XLegacy.toModify( tightJetIdAK8.filterParams, version = "WINTER16" )
57 
58 tightJetIdLepVetoAK8 = cms.EDProducer("PatJetIDValueMapProducer",
59  filterParams=cms.PSet(
60  version = cms.string('WINTER17'),
61  quality = cms.string('TIGHTLEPVETO'),
62  ),
63  src = cms.InputTag("slimmedJetsAK8")
64 )
65 
66 bJetVars = cms.EDProducer("JetRegressionVarProducer",
67  pvsrc = cms.InputTag("offlineSlimmedPrimaryVertices"),
68  src = cms.InputTag("slimmedJets"),
69  svsrc = cms.InputTag("slimmedSecondaryVertices"),
70  gpsrc = cms.InputTag("prunedGenParticles"),
71  #musrc = cms.InputTag("slimmedMuons"),
72  #elesrc = cms.InputTag("slimmedElectrons")
73 )
74 
75 
76 slimmedJetsWithUserData = cms.EDProducer("PATJetUserDataEmbedder",
77  src = cms.InputTag("slimmedJets"),
78  userFloats = cms.PSet(
79  leadTrackPt = cms.InputTag("bJetVars:leadTrackPt"),
80  leptonPtRel = cms.InputTag("bJetVars:leptonPtRel"),
81  leptonPtRatio = cms.InputTag("bJetVars:leptonPtRatio"),
82  leptonPtRelInv = cms.InputTag("bJetVars:leptonPtRelInv"),
83  leptonPtRelv0 = cms.InputTag("bJetVars:leptonPtRelv0"),
84  leptonPtRatiov0 = cms.InputTag("bJetVars:leptonPtRatiov0"),
85  leptonPtRelInvv0 = cms.InputTag("bJetVars:leptonPtRelInvv0"),
86  leptonDeltaR = cms.InputTag("bJetVars:leptonDeltaR"),
87  leptonPt = cms.InputTag("bJetVars:leptonPt"),
88  vtxPt = cms.InputTag("bJetVars:vtxPt"),
89  vtxMass = cms.InputTag("bJetVars:vtxMass"),
90  vtx3dL = cms.InputTag("bJetVars:vtx3dL"),
91  vtx3deL = cms.InputTag("bJetVars:vtx3deL"),
92  ptD = cms.InputTag("bJetVars:ptD"),
93  genPtwNu = cms.InputTag("bJetVars:genPtwNu"),
94 
95  ),
96  userInts = cms.PSet(
97  tightId = cms.InputTag("tightJetId"),
98  tightIdLepVeto = cms.InputTag("tightJetIdLepVeto"),
99  vtxNtrk = cms.InputTag("bJetVars:vtxNtrk"),
100  leptonPdgId = cms.InputTag("bJetVars:leptonPdgId"),
101 
102  ),
103 )
104 run2_miniAOD_80XLegacy.toModify( slimmedJetsWithUserData.userInts,
105  looseId = cms.InputTag("looseJetId"),
106  tightIdLepVeto = None,
107 )
108 
109 slimmedJetsAK8WithUserData = cms.EDProducer("PATJetUserDataEmbedder",
110  src = cms.InputTag("slimmedJetsAK8"),
111  userFloats = cms.PSet(),
112  userInts = cms.PSet(
113  tightId = cms.InputTag("tightJetIdAK8"),
114  tightIdLepVeto = cms.InputTag("tightJetIdLepVetoAK8"),
115  ),
116 )
117 run2_miniAOD_80XLegacy.toModify( slimmedJetsAK8WithUserData.userInts,
118  looseId = cms.InputTag("looseJetIdAK8"),
119  tightIdLepVeto = None,
120 )
121 
123 # Note: Safe to always add 'L2L3Residual' as MC contains dummy L2L3Residual corrections (always set to 1)
124 # (cf. https://twiki.cern.ch/twiki/bin/view/CMSPublic/WorkBookJetEnergyCorrections#CMSSW_7_6_4_and_above )
125 jetCorrFactorsNano = patJetCorrFactors.clone(src='slimmedJetsWithUserData',
126  levels = cms.vstring('L1FastJet',
127  'L2Relative',
128  'L3Absolute',
129  'L2L3Residual'),
130  primaryVertices = cms.InputTag("offlineSlimmedPrimaryVertices"),
131 )
132 jetCorrFactorsAK8 = patJetCorrFactors.clone(src='slimmedJetsAK8WithUserData',
133  levels = cms.vstring('L1FastJet',
134  'L2Relative',
135  'L3Absolute',
136  'L2L3Residual'),
137  payload = cms.string('AK8PFPuppi'),
138  primaryVertices = cms.InputTag("offlineSlimmedPrimaryVertices"),
139 )
140 
142 updatedJets = updatedPatJets.clone(
143  addBTagInfo=False,
144  jetSource='slimmedJetsWithUserData',
145  jetCorrFactorsSource=cms.VInputTag(cms.InputTag("jetCorrFactorsNano") ),
146 )
147 
148 finalJets = cms.EDFilter("PATJetRefSelector",
149  src = cms.InputTag("updatedJets"),
150  cut = cms.string("pt > 15")
151 )
152 
153 updatedJetsAK8 = updatedPatJets.clone(
154  addBTagInfo=False,
155  jetSource='slimmedJetsAK8WithUserData',
156  jetCorrFactorsSource=cms.VInputTag(cms.InputTag("jetCorrFactorsAK8") ),
157 )
158 
159 finalJetsAK8 = cms.EDFilter("PATJetRefSelector",
160  src = cms.InputTag("updatedJetsAK8"),
161  cut = cms.string("pt > 170")
162 )
163 
164 
165 
166 
167 
168 ##################### Tables for final output and docs ##########################
169 
170 
171 
172 jetTable = cms.EDProducer("SimpleCandidateFlatTableProducer",
173  src = cms.InputTag("linkedObjects","jets"),
174  cut = cms.string(""), #we should not filter on cross linked collections
175  name = cms.string("Jet"),
176  doc = cms.string("slimmedJets, i.e. ak4 PFJets CHS with JECs applied, after basic selection (" + finalJets.cut.value()+")"),
177  singleton = cms.bool(False), # the number of entries is variable
178  extension = cms.bool(False), # this is the main table for the jets
179  externalVariables = cms.PSet(
180  #bRegOld = ExtVar(cms.InputTag("bjetMVA"),float, doc="pt corrected with b-jet regression",precision=14),
181  bRegCorr = ExtVar(cms.InputTag("bjetNN:corr"),float, doc="pt correction for b-jet energy regression",precision=12),
182  bRegRes = ExtVar(cms.InputTag("bjetNN:res"),float, doc="res on pt corrected with b-jet regression",precision=8),
183  ),
184  variables = cms.PSet(P4Vars,
185  area = Var("jetArea()", float, doc="jet catchment area, for JECs",precision=10),
186  nMuons = Var("?hasOverlaps('muons')?overlaps('muons').size():0", int, doc="number of muons in the jet"),
187  muonIdx1 = Var("?overlaps('muons').size()>0?overlaps('muons')[0].key():-1", int, doc="index of first matching muon"),
188  muonIdx2 = Var("?overlaps('muons').size()>1?overlaps('muons')[1].key():-1", int, doc="index of second matching muon"),
189  electronIdx1 = Var("?overlaps('electrons').size()>0?overlaps('electrons')[0].key():-1", int, doc="index of first matching electron"),
190  electronIdx2 = Var("?overlaps('electrons').size()>1?overlaps('electrons')[1].key():-1", int, doc="index of second matching electron"),
191  nElectrons = Var("?hasOverlaps('electrons')?overlaps('electrons').size():0", int, doc="number of electrons in the jet"),
192  btagCMVA = Var("bDiscriminator('pfCombinedMVAV2BJetTags')",float,doc="CMVA V2 btag discriminator",precision=10),
193  btagDeepB = Var("bDiscriminator('pfDeepCSVJetTags:probb')+bDiscriminator('pfDeepCSVJetTags:probbb')",float,doc="DeepCSV b+bb tag discriminator",precision=10),
194  btagDeepFlavB = Var("bDiscriminator('pfDeepFlavourJetTags:probb')+bDiscriminator('pfDeepFlavourJetTags:probbb')+bDiscriminator('pfDeepFlavourJetTags:problepb')",float,doc="DeepFlavour b+bb+lepb tag discriminator",precision=10),
195  btagCSVV2 = Var("bDiscriminator('pfCombinedInclusiveSecondaryVertexV2BJetTags')",float,doc=" pfCombinedInclusiveSecondaryVertexV2 b-tag discriminator (aka CSVV2)",precision=10),
196  btagDeepC = Var("bDiscriminator('pfDeepCSVJetTags:probc')",float,doc="DeepCSV charm btag discriminator",precision=10),
197  #puIdDisc = Var("userFloat('pileupJetId:fullDiscriminant')",float,doc="Pilup ID discriminant",precision=10),
198  puId = Var("userInt('pileupJetId:fullId')",int,doc="Pilup ID flags"),
199  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"),
200  qgl = Var("userFloat('QGTagger:qgLikelihood')",float,doc="Quark vs Gluon likelihood discriminator",precision=10),
201  nConstituents = Var("numberOfDaughters()",int,doc="Number of particles in the jet"),
202  rawFactor = Var("1.-jecFactor('Uncorrected')",float,doc="1 - Factor to get back to raw pT",precision=6),
203  chHEF = Var("chargedHadronEnergyFraction()", float, doc="charged Hadron Energy Fraction", precision= 6),
204  neHEF = Var("neutralHadronEnergyFraction()", float, doc="neutral Hadron Energy Fraction", precision= 6),
205  chEmEF = Var("chargedEmEnergyFraction()", float, doc="charged Electromagnetic Energy Fraction", precision= 6),
206  neEmEF = Var("neutralEmEnergyFraction()", float, doc="neutral Electromagnetic Energy Fraction", precision= 6),
207  muEF = Var("muonEnergyFraction()", float, doc="muon Energy Fraction", precision= 6),
208  )
209 )
210 
211 #jets are not as precise as muons
212 jetTable.variables.pt.precision=10
213 
214 ### Era dependent customization
215 run2_miniAOD_80XLegacy.toModify( slimmedJetsWithUserData.userFloats,qgl=cms.InputTag('qgtagger80x:qgLikelihood'))
216 run2_miniAOD_80XLegacy.toModify( jetTable.variables.qgl, expr="userFloat('qgl')" )
217 run2_miniAOD_80XLegacy.toModify( jetTable.variables, jetId = Var("userInt('tightId')*2+userInt('looseId')",int,doc="Jet ID flags bit1 is loose, bit2 is tight"))
218 
219 bjetMVA= cms.EDProducer("BJetEnergyRegressionMVA",
220  backend = cms.string("TMVA"),
221  src = cms.InputTag("linkedObjects","jets"),
222  pvsrc = cms.InputTag("offlineSlimmedPrimaryVertices"),
223  svsrc = cms.InputTag("slimmedSecondaryVertices"),
224  rhosrc = cms.InputTag("fixedGridRhoFastjetAll"),
225  weightFile = cms.FileInPath("PhysicsTools/NanoAOD/data/bjet-regression.xml"),
226  name = cms.string("JetReg"),
227  isClassifier = cms.bool(False),
228  variablesOrder = cms.vstring(["Jet_pt","nPVs","Jet_eta","Jet_mt","Jet_leadTrackPt","Jet_leptonPtRel","Jet_leptonPt","Jet_leptonDeltaR","Jet_neHEF","Jet_neEmEF","Jet_vtxPt","Jet_vtxMass","Jet_vtx3dL","Jet_vtxNtrk","Jet_vtx3deL"]),
229  variables = cms.PSet(
230  Jet_pt = cms.string("pt"),
231  Jet_eta = cms.string("eta"),
232  Jet_mt = cms.string("mt"),
233  Jet_leadTrackPt = cms.string("userFloat('leadTrackPt')"),
234  Jet_vtxNtrk = cms.string("userInt('vtxNtrk')"),
235  Jet_vtxMass = cms.string("userFloat('vtxMass')"),
236  Jet_vtx3dL = cms.string("userFloat('vtx3dL')"),
237  Jet_vtx3deL = cms.string("userFloat('vtx3deL')"),
238  Jet_vtxPt = cms.string("userFloat('vtxPt')"),
239  Jet_leptonPtRel = cms.string("userFloat('leptonPtRelv0')"),
240  Jet_leptonPt = cms.string("?overlaps('muons').size()>0?overlaps('muons')[0].pt():(?overlaps('electrons').size()>0?overlaps('electrons')[0].pt():0)"),
241  Jet_neHEF = cms.string("neutralHadronEnergy()/energy()"),
242  Jet_neEmEF = cms.string("neutralEmEnergy()/energy()"),
243  Jet_leptonDeltaR = cms.string('''?overlaps('muons').size()>0?deltaR(eta,phi,overlaps('muons')[0].eta,overlaps('muons')[0].phi):
244  (?overlaps('electrons').size()>0?deltaR(eta,phi,overlaps('electrons')[0].eta,overlaps('electrons')[0].phi):
245  0)'''),
246  )
247 
248 )
249 
250 bjetNN= cms.EDProducer("BJetEnergyRegressionMVA",
251  backend = cms.string("TF"),
252  src = cms.InputTag("linkedObjects","jets"),
253  pvsrc = cms.InputTag("offlineSlimmedPrimaryVertices"),
254  svsrc = cms.InputTag("slimmedSecondaryVertices"),
255  rhosrc = cms.InputTag("fixedGridRhoFastjetAll"),
256 
257  weightFile = cms.FileInPath("PhysicsTools/NanoAOD/data/breg_training_2017.pb"),
258  name = cms.string("JetRegNN"),
259  isClassifier = cms.bool(False),
260  variablesOrder = cms.vstring(["Jet_pt","Jet_eta","rho","Jet_mt","Jet_leadTrackPt","Jet_leptonPtRel","Jet_leptonDeltaR","Jet_neHEF","Jet_neEmEF","Jet_vtxPt","Jet_vtxMass","Jet_vtx3dL","Jet_vtxNtrk","Jet_vtx3deL","Jet_numDaughters_pt03","Jet_energyRing_dR0_em_Jet_rawEnergy","Jet_energyRing_dR1_em_Jet_rawEnergy","Jet_energyRing_dR2_em_Jet_rawEnergy","Jet_energyRing_dR3_em_Jet_rawEnergy","Jet_energyRing_dR4_em_Jet_rawEnergy","Jet_energyRing_dR0_neut_Jet_rawEnergy","Jet_energyRing_dR1_neut_Jet_rawEnergy","Jet_energyRing_dR2_neut_Jet_rawEnergy","Jet_energyRing_dR3_neut_Jet_rawEnergy","Jet_energyRing_dR4_neut_Jet_rawEnergy","Jet_energyRing_dR0_ch_Jet_rawEnergy","Jet_energyRing_dR1_ch_Jet_rawEnergy","Jet_energyRing_dR2_ch_Jet_rawEnergy","Jet_energyRing_dR3_ch_Jet_rawEnergy","Jet_energyRing_dR4_ch_Jet_rawEnergy","Jet_energyRing_dR0_mu_Jet_rawEnergy","Jet_energyRing_dR1_mu_Jet_rawEnergy","Jet_energyRing_dR2_mu_Jet_rawEnergy","Jet_energyRing_dR3_mu_Jet_rawEnergy","Jet_energyRing_dR4_mu_Jet_rawEnergy","Jet_chHEF","Jet_chEmEF","Jet_leptonPtRelInv","isEle","isMu","isOther","Jet_mass","Jet_ptd"]),
261  variables = cms.PSet(
262  Jet_pt = cms.string("pt*jecFactor('Uncorrected')"),
263  Jet_mt = cms.string("mt*jecFactor('Uncorrected')"),
264  Jet_eta = cms.string("eta"),
265  Jet_mass = cms.string("mass*jecFactor('Uncorrected')"),
266  Jet_ptd = cms.string("userFloat('ptD')"),
267  Jet_leadTrackPt = cms.string("userFloat('leadTrackPt')"),
268  Jet_vtxNtrk = cms.string("userInt('vtxNtrk')"),
269  Jet_vtxMass = cms.string("userFloat('vtxMass')"),
270  Jet_vtx3dL = cms.string("userFloat('vtx3dL')"),
271  Jet_vtx3deL = cms.string("userFloat('vtx3deL')"),
272  Jet_vtxPt = cms.string("userFloat('vtxPt')"),
273  #Jet_leptonPt = cms.string("userFloat('leptonPt')"),
274  Jet_leptonPtRel = cms.string("userFloat('leptonPtRelv0')"),
275  Jet_leptonPtRelInv = cms.string("userFloat('leptonPtRelInvv0')*jecFactor('Uncorrected')"),
276  Jet_leptonDeltaR = cms.string("userFloat('leptonDeltaR')"),
277  #Jet_leptonPdgId = cms.string("userInt('leptonPdgId')"),
278  Jet_neHEF = cms.string("neutralHadronEnergyFraction()"),
279  Jet_neEmEF = cms.string("neutralEmEnergyFraction()"),
280  Jet_chHEF = cms.string("chargedHadronEnergyFraction()"),
281  Jet_chEmEF = cms.string("chargedEmEnergyFraction()"),
282  isMu = cms.string("?abs(userInt('leptonPdgId'))==13?1:0"),
283  isEle = cms.string("?abs(userInt('leptonPdgId'))==11?1:0"),
284  isOther = cms.string("?userInt('leptonPdgId')==0?1:0"),
285  ),
286  inputTensorName = cms.string("ffwd_inp"),
287  outputTensorName = cms.string("ffwd_out/BiasAdd"),
288  outputNames = cms.vstring(["corr","res"]),
289  outputFormulas = cms.vstring(["at(0)*0.28492164611816406+1.0596693754196167","0.5*(at(2)-at(1))*0.28492164611816406"]),
290  nThreads = cms.uint32(1),
291  singleThreadPool = cms.string("no_threads"),
292 )
293 
294 
295 
296 ##### Soft Activity tables
297 saJetTable = cms.EDProducer("SimpleCandidateFlatTableProducer",
298  src = cms.InputTag("softActivityJets"),
299  cut = cms.string(""),
300  maxLen = cms.uint32(6),
301  name = cms.string("SoftActivityJet"),
302  doc = cms.string("jets clustered from charged candidates compatible with primary vertex (" + chsForSATkJets.cut.value()+")"),
303  singleton = cms.bool(False), # the number of entries is variable
304  extension = cms.bool(False), # this is the main table for the jets
305  variables = cms.PSet(P3Vars,
306  )
307 )
308 
309 saJetTable.variables.pt.precision=10
310 saJetTable.variables.eta.precision=8
311 saJetTable.variables.phi.precision=8
312 
313 saTable = cms.EDProducer("GlobalVariablesTableProducer",
314  variables = cms.PSet(
315  SoftActivityJetHT = ExtVar( cms.InputTag("softActivityJets"), "candidatescalarsum", doc = "scalar sum of soft activity jet pt, pt>1" ),
316  SoftActivityJetHT10 = ExtVar( cms.InputTag("softActivityJets10"), "candidatescalarsum", doc = "scalar sum of soft activity jet pt , pt >10" ),
317  SoftActivityJetHT5 = ExtVar( cms.InputTag("softActivityJets5"), "candidatescalarsum", doc = "scalar sum of soft activity jet pt, pt>5" ),
318  SoftActivityJetHT2 = ExtVar( cms.InputTag("softActivityJets2"), "candidatescalarsum", doc = "scalar sum of soft activity jet pt, pt >2" ),
319  SoftActivityJetNjets10 = ExtVar( cms.InputTag("softActivityJets10"), "candidatesize", doc = "number of soft activity jet pt, pt >2" ),
320  SoftActivityJetNjets5 = ExtVar( cms.InputTag("softActivityJets5"), "candidatesize", doc = "number of soft activity jet pt, pt >5" ),
321  SoftActivityJetNjets2 = ExtVar( cms.InputTag("softActivityJets2"), "candidatesize", doc = "number of soft activity jet pt, pt >10" ),
322 
323  )
324 )
325 
326 
327 
328 ## BOOSTED STUFF #################
329 fatJetTable = cms.EDProducer("SimpleCandidateFlatTableProducer",
330  src = cms.InputTag("finalJetsAK8"),
331  cut = cms.string(" pt > 170"), #probably already applied in miniaod
332  name = cms.string("FatJet"),
333  doc = cms.string("slimmedJetsAK8, i.e. ak8 fat jets for boosted analysis"),
334  singleton = cms.bool(False), # the number of entries is variable
335  extension = cms.bool(False), # this is the main table for the jets
336  variables = cms.PSet(P4Vars,
337  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"),
338  area = Var("jetArea()", float, doc="jet catchment area, for JECs",precision=10),
339  rawFactor = Var("1.-jecFactor('Uncorrected')",float,doc="1 - Factor to get back to raw pT",precision=6),
340  tau1 = Var("userFloat('NjettinessAK8Puppi:tau1')",float, doc="Nsubjettiness (1 axis)",precision=10),
341  tau2 = Var("userFloat('NjettinessAK8Puppi:tau2')",float, doc="Nsubjettiness (2 axis)",precision=10),
342  tau3 = Var("userFloat('NjettinessAK8Puppi:tau3')",float, doc="Nsubjettiness (3 axis)",precision=10),
343  tau4 = Var("userFloat('NjettinessAK8Puppi:tau4')",float, doc="Nsubjettiness (4 axis)",precision=10),
344  n2b1 = Var("userFloat('ak8PFJetsPuppiSoftDropValueMap:nb1AK8PuppiSoftDropN2')", float, doc="N2 with beta=1", precision=10),
345  n3b1 = Var("userFloat('ak8PFJetsPuppiSoftDropValueMap:nb1AK8PuppiSoftDropN3')", float, doc="N3 with beta=1", precision=10),
346  msoftdrop = Var("groomedMass('SoftDropPuppi')",float, doc="Corrected soft drop mass with PUPPI",precision=10),
347  btagCMVA = Var("bDiscriminator('pfCombinedMVAV2BJetTags')",float,doc="CMVA V2 btag discriminator",precision=10),
348  btagDeepB = Var("bDiscriminator('pfDeepCSVJetTags:probb')+bDiscriminator('pfDeepCSVJetTags:probbb')",float,doc="DeepCSV b+bb tag discriminator",precision=10),
349  btagCSVV2 = Var("bDiscriminator('pfCombinedInclusiveSecondaryVertexV2BJetTags')",float,doc=" pfCombinedInclusiveSecondaryVertexV2 b-tag discriminator (aka CSVV2)",precision=10),
350  btagHbb = Var("bDiscriminator('pfBoostedDoubleSecondaryVertexAK8BJetTags')",float,doc="Higgs to BB tagger discriminator",precision=10),
351  subJetIdx1 = Var("?nSubjetCollections()>0 && subjets().size()>0?subjets()[0].key():-1", int,
352  doc="index of first subjet"),
353  subJetIdx2 = Var("?nSubjetCollections()>0 && subjets().size()>1?subjets()[1].key():-1", int,
354  doc="index of second subjet"),
355 
356 # btagDeepC = Var("bDiscriminator('pfDeepCSVJetTags:probc')",float,doc="CMVA V2 btag discriminator",precision=10),
357 #puIdDisc = Var("userFloat('pileupJetId:fullDiscriminant')",float,doc="Pilup ID discriminant",precision=10),
358 # nConstituents = Var("numberOfDaughters()",int,doc="Number of particles in the jet"),
359 # rawFactor = Var("1.-jecFactor('Uncorrected')",float,doc="1 - Factor to get back to raw pT",precision=6),
360  )
361 )
362 ### Era dependent customization
363 run2_miniAOD_80XLegacy.toModify( bjetNN,outputFormulas = cms.vstring(["at(0)*0.31628304719924927+1.0454729795455933","0.5*(at(2)-at(1))*0.31628304719924927"]))
364 run2_miniAOD_80XLegacy.toModify( fatJetTable.variables, msoftdrop_chs = Var("userFloat('ak8PFJetsCHSSoftDropMass')",float, doc="Legacy uncorrected soft drop mass with CHS",precision=10))
365 run2_miniAOD_80XLegacy.toModify( fatJetTable.variables.tau1, expr = cms.string("userFloat(\'ak8PFJetsPuppiValueMap:NjettinessAK8PuppiTau1\')"),)
366 run2_miniAOD_80XLegacy.toModify( fatJetTable.variables.tau2, expr = cms.string("userFloat(\'ak8PFJetsPuppiValueMap:NjettinessAK8PuppiTau2\')"),)
367 run2_miniAOD_80XLegacy.toModify( fatJetTable.variables.tau3, expr = cms.string("userFloat(\'ak8PFJetsPuppiValueMap:NjettinessAK8PuppiTau3\')"),)
368 run2_miniAOD_80XLegacy.toModify( fatJetTable.variables.tau4, expr = cms.string("-1"),)
369 run2_miniAOD_80XLegacy.toModify( fatJetTable.variables.n2b1, expr = cms.string("-1"),)
370 run2_miniAOD_80XLegacy.toModify( fatJetTable.variables.n3b1, expr = cms.string("-1"),)
371 run2_miniAOD_80XLegacy.toModify( fatJetTable.variables, jetId = Var("userInt('tightId')*2+userInt('looseId')",int,doc="Jet ID flags bit1 is loose, bit2 is tight"))
372 
373 run2_nanoAOD_92X.toModify( fatJetTable.variables.tau4, expr = cms.string("-1"),)
374 run2_nanoAOD_92X.toModify( fatJetTable.variables.n2b1, expr = cms.string("-1"),)
375 run2_nanoAOD_92X.toModify( fatJetTable.variables.n3b1, expr = cms.string("-1"),)
376 
377 
378 
379 subJetTable = cms.EDProducer("SimpleCandidateFlatTableProducer",
380  src = cms.InputTag("slimmedJetsAK8PFPuppiSoftDropPacked","SubJets"),
381  cut = cms.string(""), #probably already applied in miniaod
382  name = cms.string("SubJet"),
383  doc = cms.string("slimmedJetsAK8, i.e. ak8 fat jets for boosted analysis"),
384  singleton = cms.bool(False), # the number of entries is variable
385  extension = cms.bool(False), # this is the main table for the jets
386  variables = cms.PSet(P4Vars,
387  btagCMVA = Var("bDiscriminator('pfCombinedMVAV2BJetTags')",float,doc="CMVA V2 btag discriminator",precision=10),
388  btagDeepB = Var("bDiscriminator('pfDeepCSVJetTags:probb')+bDiscriminator('pfDeepCSVJetTags:probbb')",float,doc="DeepCSV b+bb tag discriminator",precision=10),
389  btagCSVV2 = Var("bDiscriminator('pfCombinedInclusiveSecondaryVertexV2BJetTags')",float,doc=" pfCombinedInclusiveSecondaryVertexV2 b-tag discriminator (aka CSVV2)",precision=10),
390  tau1 = Var("userFloat('NjettinessAK8Subjets:tau1')",float, doc="Nsubjettiness (1 axis)",precision=10),
391  tau2 = Var("userFloat('NjettinessAK8Subjets:tau2')",float, doc="Nsubjettiness (2 axis)",precision=10),
392  tau3 = Var("userFloat('NjettinessAK8Subjets:tau3')",float, doc="Nsubjettiness (3 axis)",precision=10),
393  tau4 = Var("userFloat('NjettinessAK8Subjets:tau4')",float, doc="Nsubjettiness (4 axis)",precision=10),
394  n2b1 = Var("userFloat('nb1AK8PuppiSoftDropSubjets:ecfN2')", float, doc="N2 with beta=1", precision=10),
395  n3b1 = Var("userFloat('nb1AK8PuppiSoftDropSubjets:ecfN3')", float, doc="N3 with beta=1", precision=10),
396  )
397 )
398 
399 #jets are not as precise as muons
400 fatJetTable.variables.pt.precision=10
401 subJetTable.variables.pt.precision=10
402 
403 run2_miniAOD_80XLegacy.toModify( subJetTable.variables.tau1, expr = cms.string("-1"),)
404 run2_miniAOD_80XLegacy.toModify( subJetTable.variables.tau2, expr = cms.string("-1"),)
405 run2_miniAOD_80XLegacy.toModify( subJetTable.variables.tau3, expr = cms.string("-1"),)
406 run2_miniAOD_80XLegacy.toModify( subJetTable.variables.tau4, expr = cms.string("-1"),)
407 run2_miniAOD_80XLegacy.toModify( subJetTable.variables.n2b1, expr = cms.string("-1"),)
408 run2_miniAOD_80XLegacy.toModify( subJetTable.variables.n3b1, expr = cms.string("-1"),)
409 
410 run2_nanoAOD_92X.toModify( subJetTable.variables.tau4, expr = cms.string("-1"),)
411 run2_nanoAOD_92X.toModify( subJetTable.variables.n2b1, expr = cms.string("-1"),)
412 run2_nanoAOD_92X.toModify( subJetTable.variables.n3b1, expr = cms.string("-1"),)
413 
414 
415 
416 
417 
418 ## MC STUFF ######################
419 jetMCTable = cms.EDProducer("SimpleCandidateFlatTableProducer",
420  src = cms.InputTag("linkedObjects","jets"),
421  cut = cms.string(""), #we should not filter on cross linked collections
422  name = cms.string("Jet"),
423  singleton = cms.bool(False), # the number of entries is variable
424  extension = cms.bool(True), # this is an extension table for the jets
425  variables = cms.PSet(
426  partonFlavour = Var("partonFlavour()", int, doc="flavour from parton matching"),
427  hadronFlavour = Var("hadronFlavour()", int, doc="flavour from hadron ghost clustering"),
428  genJetIdx = Var("?genJetFwdRef().backRef().isNonnull()?genJetFwdRef().backRef().key():-1", int, doc="index of matched gen jet"),
429  )
430 )
431 genJetTable = cms.EDProducer("SimpleCandidateFlatTableProducer",
432  src = cms.InputTag("slimmedGenJets"),
433  cut = cms.string("pt > 10"),
434  name = cms.string("GenJet"),
435  doc = cms.string("slimmedGenJets, i.e. ak4 Jets made with visible genparticles"),
436  singleton = cms.bool(False), # the number of entries is variable
437  extension = cms.bool(False), # this is the main table for the genjets
438  variables = cms.PSet(P4Vars,
439  #anything else?
440  )
441 )
442 patJetPartons = cms.EDProducer('HadronAndPartonSelector',
443  src = cms.InputTag("generator"),
444  particles = cms.InputTag("prunedGenParticles"),
445  partonMode = cms.string("Auto"),
446  fullChainPhysPartons = cms.bool(True)
447 )
448 genJetFlavourAssociation = cms.EDProducer("JetFlavourClustering",
449  jets = genJetTable.src,
450  bHadrons = cms.InputTag("patJetPartons","bHadrons"),
451  cHadrons = cms.InputTag("patJetPartons","cHadrons"),
452  partons = cms.InputTag("patJetPartons","physicsPartons"),
453  leptons = cms.InputTag("patJetPartons","leptons"),
454  jetAlgorithm = cms.string("AntiKt"),
455  rParam = cms.double(0.4),
456  ghostRescaling = cms.double(1e-18),
457  hadronFlavourHasPriority = cms.bool(False)
458 )
459 genJetFlavourTable = cms.EDProducer("GenJetFlavourTableProducer",
460  name = genJetTable.name,
461  src = genJetTable.src,
462  cut = genJetTable.cut,
463  deltaR = cms.double(0.1),
464  jetFlavourInfos = cms.InputTag("slimmedGenJetsFlavourInfos"),
465 )
466 
467 genJetAK8Table = cms.EDProducer("SimpleCandidateFlatTableProducer",
468  src = cms.InputTag("slimmedGenJetsAK8"),
469  cut = cms.string("pt > 100."),
470  name = cms.string("GenJetAK8"),
471  doc = cms.string("slimmedGenJetsAK8SoftDropSubJets, i.e. subjets of ak8 Jets made with visible genparticles"),
472  singleton = cms.bool(False), # the number of entries is variable
473  extension = cms.bool(False), # this is the main table for the genjets
474  variables = cms.PSet(P4Vars,
475  #anything else?
476  )
477 )
478 genJetAK8FlavourAssociation = cms.EDProducer("JetFlavourClustering",
479  jets = genJetAK8Table.src,
480  bHadrons = cms.InputTag("patJetPartons","bHadrons"),
481  cHadrons = cms.InputTag("patJetPartons","cHadrons"),
482  partons = cms.InputTag("patJetPartons","physicsPartons"),
483  leptons = cms.InputTag("patJetPartons","leptons"),
484  jetAlgorithm = cms.string("AntiKt"),
485  rParam = cms.double(0.8),
486  ghostRescaling = cms.double(1e-18),
487  hadronFlavourHasPriority = cms.bool(False)
488 )
489 genJetAK8FlavourTable = cms.EDProducer("GenJetFlavourTableProducer",
490  name = genJetAK8Table.name,
491  src = genJetAK8Table.src,
492  cut = genJetAK8Table.cut,
493  deltaR = cms.double(0.1),
494  jetFlavourInfos = cms.InputTag("genJetAK8FlavourAssociation"),
495 )
496 genSubJetAK8Table = cms.EDProducer("SimpleCandidateFlatTableProducer",
497  src = cms.InputTag("slimmedGenJetsAK8SoftDropSubJets"),
498  cut = cms.string(""), ## These don't get a pt cut, but in miniAOD only subjets from fat jets with pt > 100 are kept
499  name = cms.string("SubGenJetAK8"),
500  doc = cms.string("slimmedGenJetsAK8SoftDropSubJets, i.e. subjets of ak8 Jets made with visible genparticles"),
501  singleton = cms.bool(False), # the number of entries is variable
502  extension = cms.bool(False), # this is the main table for the genjets
503  variables = cms.PSet(P4Vars,
504  #anything else?
505  )
506 )
507 ### Era dependent customization
508 run2_miniAOD_80XLegacy.toModify( genJetFlavourTable, jetFlavourInfos = cms.InputTag("genJetFlavourAssociation"),)
509 run2_nanoAOD_92X.toModify( genJetFlavourTable, jetFlavourInfos = cms.InputTag("genJetFlavourAssociation"),)
510 
511 #before cross linking
512 jetSequence = cms.Sequence(tightJetId+tightJetIdLepVeto+bJetVars+slimmedJetsWithUserData+jetCorrFactorsNano+updatedJets+tightJetIdAK8+tightJetIdLepVetoAK8+slimmedJetsAK8WithUserData+jetCorrFactorsAK8+updatedJetsAK8+chsForSATkJets+softActivityJets+softActivityJets2+softActivityJets5+softActivityJets10+finalJets+finalJetsAK8)
513 
514 from RecoJets.JetProducers.QGTagger_cfi import QGTagger
515 qgtagger80x=QGTagger.clone(srcJets="slimmedJets",srcVertexCollection="offlineSlimmedPrimaryVertices")
516 
517 _jetSequence_80X = jetSequence.copy()
518 _jetSequence_80X.replace(tightJetIdLepVeto, looseJetId)
519 _jetSequence_80X.replace(tightJetIdLepVetoAK8, looseJetIdAK8)
520 _jetSequence_80X.insert(1,qgtagger80x)
521 run2_miniAOD_80XLegacy.toReplaceWith(jetSequence, _jetSequence_80X)
522 
523 #after cross linkining
524 jetTables = cms.Sequence(bjetMVA+bjetNN+jetTable+fatJetTable+subJetTable+saJetTable+saTable)
525 
526 #MC only producers and tables
527 jetMC = cms.Sequence(jetMCTable+genJetTable+patJetPartons+genJetFlavourTable+genJetAK8Table+genJetAK8FlavourAssociation+genJetAK8FlavourTable+genSubJetAK8Table)
528 _jetMC_pre94X = jetMC.copy()
529 _jetMC_pre94X.insert(_jetMC_pre94X.index(genJetFlavourTable),genJetFlavourAssociation)
530 _jetMC_pre94X.remove(genSubJetAK8Table)
531 run2_miniAOD_80XLegacy.toReplaceWith(jetMC, _jetMC_pre94X)
532 run2_nanoAOD_92X.toReplaceWith(jetMC, _jetMC_pre94X)
533 
534 
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