CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Functions
applySubstructure_cff Namespace Reference

Functions

def applySubstructure
 

Function Documentation

def applySubstructure_cff.applySubstructure (   process,
  postfix = "" 
)

Definition at line 3 of file applySubstructure_cff.py.

Referenced by miniAOD_tools.miniAOD_customizeCommon().

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