CMS 3D CMS Logo

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

Functions

def applySubstructure
 

Function Documentation

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