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