CMS 3D CMS Logo

Functions
applySubstructure_cff Namespace Reference

Functions

def applySubstructure (process, postfix="")
 

Function Documentation

◆ applySubstructure()

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

Definition at line 5 of file applySubstructure_cff.py.

References helpers.addToProcessAndTask(), and helpers.getPatAlgosToolsTask().

Referenced by miniAOD_tools.miniAOD_customizeCommon().

5 def applySubstructure( process, postfix="" ) :
6 
7  task = getPatAlgosToolsTask(process)
8 
9  from PhysicsTools.PatAlgos.tools.jetTools import addJetCollection
10 
11 
12  from PhysicsTools.PatAlgos.producersLayer1.jetProducer_cfi import _patJets as patJetsDefault
13 
14 
15  # Configure the RECO jets
16  from RecoJets.JetProducers.ak8PFJets_cfi import ak8PFJetsPuppi, ak8PFJetsPuppiSoftDrop, ak8PFJetsPuppiConstituents
17  setattr(process,'ak8PFJetsPuppi'+postfix,ak8PFJetsPuppi.clone())
18  setattr(process,'ak8PFJetsPuppiConstituents'+postfix, ak8PFJetsPuppiConstituents.clone(cut = cms.string('pt > 170.0 && abs(rapidity()) < 2.4') ))
19  setattr(process,'ak8PFJetsPuppiSoftDrop'+postfix, ak8PFJetsPuppiSoftDrop.clone( src = 'ak8PFJetsPuppiConstituents'+postfix+':constituents' ))
20  from RecoJets.JetProducers.ak8PFJetsPuppi_groomingValueMaps_cfi import ak8PFJetsPuppiSoftDropMass
21  setattr(process,'ak8PFJetsPuppiSoftDropMass'+postfix, ak8PFJetsPuppiSoftDropMass.clone())
22  from Configuration.Eras.Modifier_run2_miniAOD_80XLegacy_cff import run2_miniAOD_80XLegacy
23  from Configuration.Eras.Modifier_run2_miniAOD_94XFall17_cff import run2_miniAOD_94XFall17
24  from Configuration.ProcessModifiers.run2_miniAOD_UL_cff import run2_miniAOD_UL
25  _run2_miniAOD_ANY = (run2_miniAOD_80XLegacy | run2_miniAOD_94XFall17 | run2_miniAOD_UL)
26  from Configuration.Eras.Modifier_pA_2016_cff import pA_2016
27  from Configuration.Eras.Modifier_run3_miniAOD_12X_cff import run3_miniAOD_12X
28  if postfix=='':
29  # Avoid recomputing the PUPPI collections that are present in AOD
30  _rerun_puppijets_task = task.copy()
31  _rerun_puppijets_task.add(getattr(process,'ak8PFJetsPuppi'),
32  getattr(process,'ak8PFJetsPuppiConstituents'),
33  getattr(process,'ak8PFJetsPuppiSoftDrop'),
34  getattr(process,'ak8PFJetsPuppiSoftDropMass'))
35  (_run2_miniAOD_ANY | pA_2016 | run3_miniAOD_12X ).toReplaceWith(task, _rerun_puppijets_task)
36  (_run2_miniAOD_ANY | pA_2016 | run3_miniAOD_12X ).toModify(getattr(process,'ak8PFJetsPuppiConstituents'+postfix),
37  cut = cms.string('pt > 170.0 && abs(rapidity()) < 2.4'))
38  else:
39  task.add(getattr(process,'ak8PFJetsPuppi'+postfix),
40  getattr(process,'ak8PFJetsPuppiConstituents'+postfix),
41  getattr(process,'ak8PFJetsPuppiSoftDrop'+postfix),
42  getattr(process,'ak8PFJetsPuppiSoftDropMass'+postfix))
43 
44  from RecoJets.JetProducers.ak8GenJets_cfi import ak8GenJets, ak8GenJetsSoftDrop, ak8GenJetsConstituents
45  addToProcessAndTask('ak8GenJetsNoNuConstituents'+postfix, ak8GenJetsConstituents.clone(src='ak8GenJetsNoNu'), process, task )
46  addToProcessAndTask('ak8GenJetsNoNuSoftDrop'+postfix,ak8GenJetsSoftDrop.clone(src=cms.InputTag('ak8GenJetsNoNuConstituents'+postfix, 'constituents')),process,task)
47  addToProcessAndTask('slimmedGenJetsAK8SoftDropSubJets'+postfix,
48  cms.EDProducer("PATGenJetSlimmer",
49  src = cms.InputTag("ak8GenJetsNoNuSoftDrop"+postfix, "SubJets"),
50  packedGenParticles = cms.InputTag("packedGenParticles"),
51  cut = cms.string(""),
52  cutLoose = cms.string(""),
53  nLoose = cms.uint32(0),
54  clearDaughters = cms.bool(False), #False means rekeying
55  dropSpecific = cms.bool(True), # Save space
56  ), process, task )
57 
58 
59  addJetCollection(
60  process,
61  postfix=postfix,
62  labelName = 'AK8PFPuppiSoftDrop' + postfix,
63  jetSource = cms.InputTag('ak8PFJetsPuppiSoftDrop'+postfix),
64  btagDiscriminators = ['None'],
65  genJetCollection = cms.InputTag('slimmedGenJetsAK8'),
66  jetCorrections = ('AK8PFPuppi', ['L2Relative', 'L3Absolute'], 'None'),
67  getJetMCFlavour = False # jet flavor disabled
68  )
69 
70  addJetCollection(
71  process,
72  postfix=postfix,
73  labelName = 'AK8PFPuppiSoftDropSubjets',
74  jetSource = cms.InputTag('ak8PFJetsPuppiSoftDrop'+postfix,'SubJets'),
75  algo = 'ak', # needed for subjet flavor clustering
76  rParam = 0.8, # needed for subjet flavor clustering
77  btagDiscriminators = ['pfDeepCSVJetTags:probb', 'pfDeepCSVJetTags:probbb', 'pfCombinedInclusiveSecondaryVertexV2BJetTags','pfCombinedMVAV2BJetTags'],
78  jetCorrections = ('AK4PFPuppi', ['L2Relative', 'L3Absolute'], 'None'),
79  explicitJTA = True, # needed for subjet b tagging
80  svClustering = True, # needed for subjet b tagging
81  genJetCollection = cms.InputTag('slimmedGenJetsAK8SoftDropSubJets'),
82  fatJets=cms.InputTag('ak8PFJetsPuppi'), # needed for subjet flavor clustering
83  groomedFatJets=cms.InputTag('ak8PFJetsPuppiSoftDrop') # needed for subjet flavor clustering
84  )
85 
86  from Configuration.Eras.Modifier_run3_common_cff import run3_common
87  run3_common.toModify(process.patJetsAK8PFPuppiSoftDropSubjets,
88  discriminatorSources = cms.VInputTag(
89  cms.InputTag("pfDeepCSVJetTagsAK8PFPuppiSoftDropSubjets","probb"),
90  cms.InputTag("pfDeepCSVJetTagsAK8PFPuppiSoftDropSubjets","probbb")
91  )
92  )
93 
94  # add groomed ECFs and N-subjettiness to soft dropped pat::Jets for fat jets and subjets
95  process.load('RecoJets.JetProducers.ECF_cff')
96  addToProcessAndTask('nb1AK8PuppiSoftDrop'+postfix, process.ecfNbeta1.clone(src = cms.InputTag("ak8PFJetsPuppiSoftDrop"+postfix), cuts = cms.vstring('', '', 'pt > 250')), process, task)
97  addToProcessAndTask('nb2AK8PuppiSoftDrop'+postfix, process.ecfNbeta2.clone(src = cms.InputTag("ak8PFJetsPuppiSoftDrop"+postfix), cuts = cms.vstring('', '', 'pt > 250')), process, task)
98 
99  #too slow now ==> disable
100  from Configuration.Eras.Modifier_pp_on_XeXe_2017_cff import pp_on_XeXe_2017
101  from Configuration.Eras.Modifier_phase2_common_cff import phase2_common
102 
103  for e in [pp_on_XeXe_2017, phase2_common]:
104  e.toModify(getattr(process,'nb1AK8PuppiSoftDrop'+postfix), cuts = ['pt > 999999', 'pt > 999999', 'pt > 999999'] )
105  e.toModify(getattr(process,'nb2AK8PuppiSoftDrop'+postfix), cuts = ['pt > 999999', 'pt > 999999', 'pt > 999999'] )
106 
107  from RecoJets.JetProducers.nJettinessAdder_cfi import Njettiness
108  addToProcessAndTask('NjettinessAK8Subjets'+postfix, Njettiness.clone(), process, task)
109  getattr(process,"NjettinessAK8Subjets"+postfix).src = cms.InputTag("ak8PFJetsPuppiSoftDrop"+postfix, "SubJets")
110  getattr(process,"patJetsAK8PFPuppiSoftDrop").userData.userFloats.src += ['nb1AK8PuppiSoftDrop'+postfix+':ecfN2','nb1AK8PuppiSoftDrop'+postfix+':ecfN3']
111  getattr(process,"patJetsAK8PFPuppiSoftDrop").userData.userFloats.src += ['nb2AK8PuppiSoftDrop'+postfix+':ecfN2','nb2AK8PuppiSoftDrop'+postfix+':ecfN3']
112  addToProcessAndTask('nb1AK8PuppiSoftDropSubjets'+postfix, process.ecfNbeta1.clone(src = cms.InputTag("ak8PFJetsPuppiSoftDrop"+postfix, "SubJets")), process, task)
113  addToProcessAndTask('nb2AK8PuppiSoftDropSubjets'+postfix, process.ecfNbeta2.clone(src = cms.InputTag("ak8PFJetsPuppiSoftDrop"+postfix, "SubJets")), process, task)
114  getattr(process,"patJetsAK8PFPuppiSoftDropSubjets"+postfix).userData.userFloats.src += ['nb1AK8PuppiSoftDropSubjets'+postfix+':ecfN2','nb1AK8PuppiSoftDropSubjets'+postfix+':ecfN3']
115  getattr(process,"patJetsAK8PFPuppiSoftDropSubjets"+postfix).userData.userFloats.src += ['nb2AK8PuppiSoftDropSubjets'+postfix+':ecfN2','nb2AK8PuppiSoftDropSubjets'+postfix+':ecfN3']
116  getattr(process,"patJetsAK8PFPuppiSoftDropSubjets"+postfix).userData.userFloats.src += ['NjettinessAK8Subjets'+postfix+':tau1','NjettinessAK8Subjets'+postfix+':tau2','NjettinessAK8Subjets'+postfix+':tau3','NjettinessAK8Subjets'+postfix+':tau4']
117 
118  for e in [pp_on_XeXe_2017, phase2_common]:
119  e.toModify(getattr(process,'nb1AK8PuppiSoftDropSubjets'+postfix), cuts = ['pt > 999999', 'pt > 999999', 'pt > 999999'] )
120  e.toModify(getattr(process,'nb2AK8PuppiSoftDropSubjets'+postfix), cuts = ['pt > 999999', 'pt > 999999', 'pt > 999999'] )
121 
122 
123  # Patify AK8 PF PUPPI
124  addJetCollection(process, postfix=postfix, labelName = 'AK8Puppi',
125  jetSource = cms.InputTag('ak8PFJetsPuppi'+postfix),
126  algo= 'AK', rParam = 0.8,
127  jetCorrections = ('AK8PFPuppi', cms.vstring(['L2Relative', 'L3Absolute']), 'None'),
128  btagDiscriminators = ([
129  'pfCombinedSecondaryVertexV2BJetTags',
130  'pfCombinedInclusiveSecondaryVertexV2BJetTags',
131  'pfCombinedMVAV2BJetTags',
132  'pfDeepCSVJetTags:probb',
133  'pfDeepCSVJetTags:probc',
134  'pfDeepCSVJetTags:probudsg',
135  'pfDeepCSVJetTags:probbb',
136  'pfBoostedDoubleSecondaryVertexAK8BJetTags']),
137  genJetCollection = cms.InputTag('slimmedGenJetsAK8')
138  )
139  getattr(process,"patJetsAK8Puppi"+postfix).userData.userFloats.src = [] # start with empty list of user floats
140  getattr(process,"selectedPatJetsAK8Puppi"+postfix).cut = cms.string("pt > 100")
141  getattr(process,"selectedPatJetsAK8Puppi"+postfix).cutLoose = cms.string("pt > 30")
142  getattr(process,"selectedPatJetsAK8Puppi"+postfix).nLoose = cms.uint32(3)
143 
144  from Configuration.Eras.Modifier_run3_common_cff import run3_common
145  run3_common.toModify(process.patJetsAK8Puppi,
146  discriminatorSources = cms.VInputTag(
147  cms.InputTag("pfDeepCSVJetTagsAK8Puppi","probb"),
148  cms.InputTag("pfDeepCSVJetTagsAK8Puppi","probc"),
149  cms.InputTag("pfDeepCSVJetTagsAK8Puppi","probudsg"),
150  cms.InputTag("pfDeepCSVJetTagsAK8Puppi","probbb")
151  )
152  )
153 
154  from RecoJets.JetAssociationProducers.j2tParametersVX_cfi import j2tParametersVX
155  addToProcessAndTask('ak8PFJetsPuppiTracksAssociatorAtVertex'+postfix, cms.EDProducer("JetTracksAssociatorAtVertex",
156  j2tParametersVX.clone( coneSize = cms.double(0.8) ),
157  jets = cms.InputTag("ak8PFJetsPuppi") ),
158  process, task)
159  addToProcessAndTask('patJetAK8PuppiCharge'+postfix, cms.EDProducer("JetChargeProducer",
160  src = cms.InputTag("ak8PFJetsPuppiTracksAssociatorAtVertex"),
161  var = cms.string('Pt'),
162  exp = cms.double(1.0) ),
163  process, task)
164 
165 
166  getattr(process,"patJetsAK8Puppi"+postfix).userData.userFloats.src += ['ak8PFJetsPuppiSoftDropMass'+postfix]
167  getattr(process,"patJetsAK8Puppi"+postfix).addTagInfos = cms.bool(False)
168 
169 
170  # add PUPPI Njetiness
171  addToProcessAndTask('NjettinessAK8Puppi'+postfix, Njettiness.clone(), process, task)
172  getattr(process,"NjettinessAK8Puppi"+postfix).src = cms.InputTag("ak8PFJetsPuppi"+postfix)
173  getattr(process,"patJetsAK8Puppi").userData.userFloats.src += ['NjettinessAK8Puppi'+postfix+':tau1','NjettinessAK8Puppi'+postfix+':tau2','NjettinessAK8Puppi'+postfix+':tau3','NjettinessAK8Puppi'+postfix+':tau4']
174 
175 
176  addToProcessAndTask("slimmedJetsAK8PFPuppiSoftDropSubjets"+postfix,
177  cms.EDProducer("PATJetSlimmer",
178  src = cms.InputTag("selectedPatJetsAK8PFPuppiSoftDropSubjets"),
179  packedPFCandidates = cms.InputTag("packedPFCandidates"),
180  dropJetVars = cms.string("1"),
181  dropDaughters = cms.string("0"),
182  rekeyDaughters = cms.string("1"),
183  dropTrackRefs = cms.string("1"),
184  dropSpecific = cms.string("1"),
185  dropTagInfos = cms.string("1"),
186  modifyJets = cms.bool(True),
187  mixedDaughters = cms.bool(False),
188  modifierConfig = cms.PSet( modifications = cms.VPSet() )
189  ),
190  process, task)
191 
192 
193 
194  addToProcessAndTask("slimmedJetsAK8PFPuppiSoftDropPacked"+postfix,
195  cms.EDProducer("BoostedJetMerger",
196  jetSrc=cms.InputTag("selectedPatJetsAK8PFPuppiSoftDrop"),
197  subjetSrc=cms.InputTag("slimmedJetsAK8PFPuppiSoftDropSubjets")
198  ),
199  process, task )
200 
201 
202  addToProcessAndTask("packedPatJetsAK8"+postfix, cms.EDProducer("JetSubstructurePacker",
203  jetSrc = cms.InputTag("selectedPatJetsAK8Puppi"+postfix),
204  distMax = cms.double(0.8),
205  algoTags = cms.VInputTag(
206  cms.InputTag("slimmedJetsAK8PFPuppiSoftDropPacked"+postfix)
207  ),
208  algoLabels = cms.vstring(
209  'SoftDropPuppi'
210  ),
211  fixDaughters = cms.bool(True),
212  packedPFCandidates = cms.InputTag("packedPFCandidates"+postfix),
213  ),
214  process, task)
215 
216  # switch off daughter re-keying since it's done in the JetSubstructurePacker (and can't be done afterwards)
217  process.slimmedJetsAK8.rekeyDaughters = "0"
218  # Reconfigure the slimmedAK8 jet information to keep
219  process.slimmedJetsAK8.dropDaughters = cms.string("pt < 170")
220  process.slimmedJetsAK8.dropSpecific = cms.string("pt < 170")
221  process.slimmedJetsAK8.dropTagInfos = cms.string("pt < 170")
222 
def applySubstructure(process, postfix="")
def addToProcessAndTask(label, module, process, task)
Definition: helpers.py:28
def getPatAlgosToolsTask(process)
Definition: helpers.py:13