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