CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
applySubstructure_cff.py
Go to the documentation of this file.
1 import FWCore.ParameterSet.Config as cms
2 
3 def applySubstructure( process, postfix="" ) :
4 
5  from PhysicsTools.PatAlgos.tools.jetTools import addJetCollection
6 
7 
8  from PhysicsTools.PatAlgos.producersLayer1.jetProducer_cfi import _patJets as patJetsDefault
9 
10  #add AK8
11  addJetCollection(process, postfix=postfix, labelName = 'AK8',
12  jetSource = cms.InputTag('ak8PFJetsCHS'+postfix),
13  algo= 'AK', rParam = 0.8,
14  jetCorrections = ('AK8PFchs', cms.vstring(['L1FastJet', 'L2Relative', 'L3Absolute']), 'None'),
15  btagDiscriminators = ([x.getModuleLabel() for x in patJetsDefault.discriminatorSources] + ['pfBoostedDoubleSecondaryVertexAK8BJetTags']),
16  genJetCollection = cms.InputTag('slimmedGenJetsAK8')
17  )
18  getattr(process, "patJetsAK8"+postfix).userData.userFloats.src = [] # start with empty list of user floats
19  getattr(process,"selectedPatJetsAK8"+postfix).cut = cms.string("pt > 170")
20 
21  from RecoJets.JetProducers.ak8PFJetsPuppi_cfi import ak8PFJetsPuppi
22  #process.load('RecoJets.JetProducers.ak8PFJetsPuppi_cfi')
23  setattr(process, "ak8PFJetsPuppi"+postfix, ak8PFJetsPuppi.clone(
24  doAreaFastjet=True) # even for standard ak8PFJets this is overwritten in RecoJets/Configuration/python/RecoPFJets_cff
25  )
26 
28  setattr(process,"ak8PFJetsPuppiTracksAssociatorAtVertex"+postfix,
29  cms.EDProducer("JetTracksAssociatorAtVertex",
30  j2tParametersVX,
31  jets = cms.InputTag("ak8PFJetsPuppi"+postfix)
32  )
33  )
34  setattr(process, "patJetPuppiCharge"+postfix,
35  cms.EDProducer("JetChargeProducer",
36  src = cms.InputTag("ak8PFJetsPuppiTracksAssociatorAtVertex"+postfix),
37  var = cms.string('Pt'),
38  exp = cms.double(1.0)
39  )
40  )
41 
42  ## AK8 groomed masses
43  from RecoJets.Configuration.RecoPFJets_cff import ak8PFJetsCHSPruned, ak8PFJetsCHSSoftDrop, ak8PFJetsPuppiSoftDrop
44  setattr(process, "ak8PFJetsCHSPruned"+postfix, ak8PFJetsCHSPruned.clone(
45  src = cms.InputTag("pfNoPileUpJME"+postfix),
46  ) )
47  setattr(process, "ak8PFJetsCHSSoftDrop"+postfix, ak8PFJetsCHSSoftDrop.clone(
48  src = cms.InputTag("pfNoPileUpJME"+postfix),
49  ) )
50  from RecoJets.JetProducers.ak8PFJetsCHS_groomingValueMaps_cfi import ak8PFJetsCHSPrunedMass, ak8PFJetsCHSSoftDropMass
51  setattr(process, "ak8PFJetsCHSPrunedMass"+postfix, ak8PFJetsCHSPrunedMass.clone(
52  src = cms.InputTag("ak8PFJetsCHS"+postfix),
53  matched = cms.InputTag("ak8PFJetsCHSPruned"+postfix),
54  ) )
55  setattr(process, "ak8PFJetsCHSSoftDropMass"+postfix, ak8PFJetsCHSSoftDropMass.clone(
56  src = cms.InputTag("ak8PFJetsCHS"+postfix),
57  matched = cms.InputTag("ak8PFJetsCHSSoftDrop"+postfix),
58  ) )
59 
60  getattr(process, "patJetsAK8"+postfix).userData.userFloats.src += ['ak8PFJetsCHSPrunedMass'+postfix,'ak8PFJetsCHSSoftDropMass'+postfix]
61  getattr(process, "patJetsAK8"+postfix).addTagInfos = cms.bool(False)
62 
63 
64  # add Njetiness
65  from RecoJets.JetProducers.nJettinessAdder_cfi import Njettiness
66  #process.load('RecoJets.JetProducers.nJettinessAdder_cfi')
67  setattr(process,"NjettinessAK8"+postfix, Njettiness.clone(
68  src = cms.InputTag("ak8PFJetsCHS"+postfix),
69  cone = cms.double(0.8) )
70  )
71  getattr(process, "patJetsAK8"+postfix).userData.userFloats.src += ['NjettinessAK8'+postfix+':tau1','NjettinessAK8'+postfix+':tau2','NjettinessAK8'+postfix+':tau3']
72 
73 
74 
75 
76  #add AK8 from PUPPI
77  #MM no need for that, already done on L23
78  #process.load('RecoJets.JetProducers.ak8PFJetsPuppi_cfi')
79  #from RecoJets.JetProducers.ak8PFJetsPuppi_cfi import ak8PFJetsPuppi
80  #getattr(process, "ak8PFJetsPuppi".doAreaFastjet = True # even for standard ak8PFJets this is overwritten in RecoJets/Configuration/python/RecoPFJets_cff
81 
82 
83  addJetCollection(process, postfix=postfix,labelName = 'AK8Puppi',
84  jetSource = cms.InputTag('ak8PFJetsPuppi'+postfix),
85  algo= 'AK', rParam = 0.8,
86  jetCorrections = ('AK8PFPuppi', cms.vstring(['L1FastJet', 'L2Relative', 'L3Absolute']), 'None'),
87  genJetCollection = cms.InputTag('slimmedGenJetsAK8')
88  )
89  getattr(process,"patJetsAK8Puppi"+postfix).userData.userFloats.src = [] # start with empty list of user floats
90  getattr(process,"selectedPatJetsAK8Puppi"+postfix).cut = cms.string("pt > 170")
91 
92 
94  setattr(process,"ak8PFJetsPuppiTracksAssociatorAtVertex"+postfix,
95  cms.EDProducer("JetTracksAssociatorAtVertex",
96  j2tParametersVX,
97  jets = cms.InputTag("ak8PFJetsPuppi"+postfix) )
98  )
99  setattr(process,"patJetAK8PuppiCharge"+postfix,
100  cms.EDProducer("JetChargeProducer",
101  src = cms.InputTag("ak8PFJetsPuppiTracksAssociatorAtVertex"+postfix),
102  var = cms.string('Pt'),
103  exp = cms.double(1.0) )
104  )
105 
106  ## AK8 groomed masses
107  from RecoJets.Configuration.RecoPFJets_cff import ak8PFJetsPuppiSoftDrop
108  setattr(process,"ak8PFJetsPuppiSoftDrop"+postfix, ak8PFJetsPuppiSoftDrop.clone(
109  src = cms.InputTag("puppi"+postfix),
110  ) )
111  from RecoJets.JetProducers.ak8PFJetsPuppi_groomingValueMaps_cfi import ak8PFJetsPuppiSoftDropMass
112  setattr(process, "ak8PFJetsPuppiSoftDropMass"+postfix, ak8PFJetsPuppiSoftDropMass.clone(
113  src = cms.InputTag("ak8PFJetsPuppi"+postfix),
114  matched = cms.InputTag("ak8PFJetsPuppiSoftDrop"+postfix),
115  ) )
116  getattr(process,"patJetsAK8Puppi"+postfix).userData.userFloats.src += ['ak8PFJetsPuppiSoftDropMass'+postfix]
117  getattr(process,"patJetsAK8Puppi"+postfix).addTagInfos = cms.bool(False)
118 
119 
120 
121  # add Njetiness
122  setattr(process,"NjettinessAK8Puppi"+postfix, Njettiness.clone(
123  src = cms.InputTag("ak8PFJetsPuppi"+postfix),
124  cone = cms.double(0.8) )
125  )
126  getattr(process,"patJetsAK8Puppi"+postfix).userData.userFloats.src += ['NjettinessAK8Puppi'+postfix+':tau1',
127  'NjettinessAK8Puppi'+postfix+':tau2',
128  'NjettinessAK8Puppi'+postfix+':tau3']
129 
130  setattr(process,"ak8PFJetsPuppiValueMap"+postfix,
131  cms.EDProducer("RecoJetToPatJetDeltaRValueMapProducer",
132  src = cms.InputTag("ak8PFJetsCHS"+postfix),
133  matched = cms.InputTag("patJetsAK8Puppi"+postfix),
134  distMax = cms.double(0.8),
135  values = cms.vstring([
136  'userFloat("NjettinessAK8Puppi'+postfix+':tau1")',
137  'userFloat("NjettinessAK8Puppi'+postfix+':tau2")',
138  'userFloat("NjettinessAK8Puppi'+postfix+':tau3")',
139  'pt','eta','phi','mass'
140  ]),
141  valueLabels = cms.vstring( [
142  'NjettinessAK8PuppiTau1',
143  'NjettinessAK8PuppiTau2',
144  'NjettinessAK8PuppiTau3',
145  'pt','eta','phi','mass'
146  ])
147  )
148  )
149  #process.patJetsAK8.userData.userFloats.src += ['NjettinessAK8:tau1','NjettinessAK8:tau2','NjettinessAK8:tau3']
150 
151  getattr(process,"patJetsAK8"+postfix).userData.userFloats.src += [cms.InputTag('ak8PFJetsPuppiValueMap'+postfix,'NjettinessAK8PuppiTau1'),
152  cms.InputTag('ak8PFJetsPuppiValueMap'+postfix,'NjettinessAK8PuppiTau2'),
153  cms.InputTag('ak8PFJetsPuppiValueMap'+postfix,'NjettinessAK8PuppiTau3'),
154  cms.InputTag('ak8PFJetsPuppiValueMap'+postfix,'pt'),
155  cms.InputTag('ak8PFJetsPuppiValueMap'+postfix,'eta'),
156  cms.InputTag('ak8PFJetsPuppiValueMap'+postfix,'phi'),
157  cms.InputTag('ak8PFJetsPuppiValueMap'+postfix,'mass'),
158  ]
159 
160 
161  ## PATify pruned fat jets
162  addJetCollection(
163  process, postfix=postfix,
164  labelName = 'AK8PFCHSSoftDrop',
165  jetSource = cms.InputTag('ak8PFJetsCHSSoftDrop'+postfix),
166  btagDiscriminators = ['None'],
167  jetCorrections = ('AK8PFchs', ['L1FastJet', 'L2Relative', 'L3Absolute'], 'None'),
168  getJetMCFlavour = False # jet flavor disabled
169  )
170 
171  ## PATify soft drop subjets
172  addJetCollection(
173  process, postfix=postfix,
174  labelName = 'AK8PFCHSSoftDropSubjets',
175  jetSource = cms.InputTag('ak8PFJetsCHSSoftDrop'+postfix,'SubJets'),
176  algo = 'ak', # needed for subjet flavor clustering
177  rParam = 0.8, # needed for subjet flavor clustering
178  btagDiscriminators = ['pfCombinedSecondaryVertexV2BJetTags', 'pfCombinedInclusiveSecondaryVertexV2BJetTags'],
179  jetCorrections = ('AK4PFchs', ['L1FastJet', 'L2Relative', 'L3Absolute'], 'None'),
180  explicitJTA = True, # needed for subjet b tagging
181  svClustering = True, # needed for subjet b tagging
182  genJetCollection = cms.InputTag('slimmedGenJets'),
183  fatJets=cms.InputTag('ak8PFJetsCHS'+postfix), # needed for subjet flavor clustering
184  groomedFatJets=cms.InputTag('ak8PFJetsCHSSoftDrop'+postfix) # needed for subjet flavor clustering
185  )
186  getattr(process,"selectedPatJetsAK8PFCHSSoftDrop"+postfix).cut = cms.string("pt > 170")
187 
188  setattr(process,"slimmedJetsAK8PFCHSSoftDropSubjets"+postfix,
189  cms.EDProducer("PATJetSlimmer",
190  src = cms.InputTag("selectedPatJetsAK8PFCHSSoftDropSubjets"+postfix),
191  packedPFCandidates = cms.InputTag("packedPFCandidates"+postfix),
192  dropJetVars = cms.string("1"),
193  dropDaughters = cms.string("0"),
194  rekeyDaughters = cms.string("1"),
195  dropTrackRefs = cms.string("1"),
196  dropSpecific = cms.string("1"),
197  dropTagInfos = cms.string("1"),
198  modifyJets = cms.bool(True),
199  mixedDaughters = cms.bool(False),
200  modifierConfig = cms.PSet( modifications = cms.VPSet() )
201  )
202  )
203 
204 
205  ## Establish references between PATified fat jets and subjets using the BoostedJetMerger
206  setattr(process,"slimmedJetsAK8PFCHSSoftDropPacked"+postfix,
207  cms.EDProducer("BoostedJetMerger",
208  jetSrc=cms.InputTag("selectedPatJetsAK8PFCHSSoftDrop"+postfix),
209  subjetSrc=cms.InputTag("slimmedJetsAK8PFCHSSoftDropSubjets"+postfix)
210  )
211  )
212 
213 
214 
215  ## PATify pruned fat jets
216  addJetCollection(
217  process, postfix=postfix,
218  labelName = 'AK8PFPuppiSoftDrop',
219  jetSource = cms.InputTag('ak8PFJetsPuppiSoftDrop'+postfix),
220  btagDiscriminators = ['None'],
221  jetCorrections = ('AK8PFPuppi', ['L1FastJet', 'L2Relative', 'L3Absolute'], 'None'),
222  getJetMCFlavour = False # jet flavor disabled
223  )
224 
225  ## PATify soft drop subjets
226  addJetCollection(
227  process, postfix=postfix,
228  labelName = 'AK8PFPuppiSoftDropSubjets',
229  jetSource = cms.InputTag('ak8PFJetsPuppiSoftDrop'+postfix,'SubJets'),
230  algo = 'ak', # needed for subjet flavor clustering
231  rParam = 0.8, # needed for subjet flavor clustering
232  btagDiscriminators = ['pfCombinedSecondaryVertexV2BJetTags', 'pfCombinedInclusiveSecondaryVertexV2BJetTags'],
233  jetCorrections = ('AK4PFPuppi', ['L1FastJet', 'L2Relative', 'L3Absolute'], 'None'),
234  explicitJTA = True, # needed for subjet b tagging
235  svClustering = True, # needed for subjet b tagging
236  genJetCollection = cms.InputTag('slimmedGenJets'),
237  fatJets=cms.InputTag('ak8PFJetsPuppi'+postfix), # needed for subjet flavor clustering
238  groomedFatJets=cms.InputTag('ak8PFJetsPuppiSoftDrop'+postfix) # needed for subjet flavor clustering
239  )
240  getattr(process,"selectedPatJetsAK8PFPuppiSoftDrop"+postfix).cut = cms.string("pt > 170")
241 
242  setattr(process,"slimmedJetsAK8PFPuppiSoftDropSubjets"+postfix,
243  cms.EDProducer("PATJetSlimmer",
244  src = cms.InputTag("selectedPatJetsAK8PFPuppiSoftDropSubjets"+postfix),
245  packedPFCandidates = cms.InputTag("packedPFCandidates"+postfix),
246  dropJetVars = cms.string("1"),
247  dropDaughters = cms.string("0"),
248  rekeyDaughters = cms.string("1"),
249  dropTrackRefs = cms.string("1"),
250  dropSpecific = cms.string("1"),
251  dropTagInfos = cms.string("1"),
252  modifyJets = cms.bool(True),
253  mixedDaughters = cms.bool(False),
254  modifierConfig = cms.PSet( modifications = cms.VPSet() )
255  ) )
256 
257 
258  ## Establish references between PATified fat jets and subjets using the BoostedJetMerger
259  setattr(process,"slimmedJetsAK8PFPuppiSoftDropPacked"+postfix,
260  cms.EDProducer("BoostedJetMerger",
261  jetSrc=cms.InputTag("selectedPatJetsAK8PFPuppiSoftDrop"+postfix),
262  subjetSrc=cms.InputTag("slimmedJetsAK8PFPuppiSoftDropSubjets"+postfix)
263  ) )
264 
265 
266  setattr(process,"packedPatJetsAK8"+postfix,
267  cms.EDProducer("JetSubstructurePacker",
268  jetSrc = cms.InputTag("selectedPatJetsAK8"+postfix),
269  distMax = cms.double(0.8),
270  algoTags = cms.VInputTag(
271  # NOTE: For an optimal storage of the AK8 jet daughters, the first subjet collection listed here should be
272  # derived from AK8 jets, i.e., subjets should contain either all or a subset of AK8 constituents.
273  # The PUPPI collection has its own pointers to its own PUPPI constituents.
274  cms.InputTag("slimmedJetsAK8PFCHSSoftDropPacked"+postfix),
275  cms.InputTag("slimmedJetsAK8PFPuppiSoftDropPacked"+postfix)
276  ),
277  algoLabels = cms.vstring(
278  'SoftDrop',
279  'SoftDropPuppi'
280  ),
281  fixDaughters = cms.bool(True),
282  packedPFCandidates = cms.InputTag("packedPFCandidates"+postfix), #oldPFCandToPackedOrDiscarded #"packedPFCandidates"+postfix
283  ) )
284 
285 
286  #if the slimmedJet collection is not here, produce it
287  if not hasattr(process, "slimmedJetsAK8"+postfix):
288  from PhysicsTools.PatAlgos.slimming.slimmedJets_cfi import slimmedJetsAK8
289  setattr(process, "slimmedJetsAK8"+postfix, slimmedJetsAK8.clone(
290  src = cms.InputTag("packedPatJetsAK8"+postfix),
291  packedPFCandidates = cms.InputTag("packedPFCandidates"), #MM FIXME
292  ) )
293 
294  # switch off daughter re-keying since it's done in the JetSubstructurePacker (and can't be done afterwards)
295  getattr(process,"slimmedJetsAK8"+postfix).rekeyDaughters = "0"
296