Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:33:01

0001 import FWCore.ParameterSet.Config as cms
0002 
0003 from PhysicsTools.PatAlgos.tools.helpers import getPatAlgosToolsTask, addToProcessAndTask
0004 
0005 def applySubstructure( process, postfix="" ) :
0006 
0007     task = getPatAlgosToolsTask(process)
0008 
0009     from PhysicsTools.PatAlgos.tools.jetTools import addJetCollection
0010 
0011 
0012     from PhysicsTools.PatAlgos.producersLayer1.jetProducer_cfi import _patJets as patJetsDefault
0013 
0014 
0015     # Configure the RECO jets
0016     from RecoJets.JetProducers.ak8PFJets_cfi import ak8PFJetsPuppi, ak8PFJetsPuppiSoftDrop, ak8PFJetsPuppiConstituents
0017     setattr(process,'ak8PFJetsPuppi'+postfix,ak8PFJetsPuppi.clone())
0018     setattr(process,'ak8PFJetsPuppiConstituents'+postfix, ak8PFJetsPuppiConstituents.clone(cut = cms.string('pt > 170.0 && abs(rapidity()) < 2.4') ))
0019     setattr(process,'ak8PFJetsPuppiSoftDrop'+postfix, ak8PFJetsPuppiSoftDrop.clone( src = 'ak8PFJetsPuppiConstituents'+postfix+':constituents' ))
0020     from RecoJets.JetProducers.ak8PFJetsPuppi_groomingValueMaps_cfi import ak8PFJetsPuppiSoftDropMass
0021     setattr(process,'ak8PFJetsPuppiSoftDropMass'+postfix, ak8PFJetsPuppiSoftDropMass.clone())
0022     from Configuration.Eras.Modifier_run2_miniAOD_80XLegacy_cff import run2_miniAOD_80XLegacy
0023     from Configuration.Eras.Modifier_run2_miniAOD_94XFall17_cff import run2_miniAOD_94XFall17
0024     from Configuration.ProcessModifiers.run2_miniAOD_UL_cff import run2_miniAOD_UL
0025     _run2_miniAOD_ANY = (run2_miniAOD_80XLegacy | run2_miniAOD_94XFall17 | run2_miniAOD_UL)
0026     from Configuration.Eras.Modifier_pA_2016_cff import pA_2016
0027     if postfix=='':
0028       # Avoid recomputing the PUPPI collections that are present in AOD
0029       _rerun_puppijets_task = task.copy()
0030       _rerun_puppijets_task.add(getattr(process,'ak8PFJetsPuppi'),
0031                                 getattr(process,'ak8PFJetsPuppiConstituents'),
0032                                 getattr(process,'ak8PFJetsPuppiSoftDrop'),
0033                                 getattr(process,'ak8PFJetsPuppiSoftDropMass'))
0034       (_run2_miniAOD_ANY | pA_2016 ).toReplaceWith(task, _rerun_puppijets_task)
0035     else:
0036       task.add(getattr(process,'ak8PFJetsPuppi'+postfix),
0037                getattr(process,'ak8PFJetsPuppiConstituents'+postfix),
0038                getattr(process,'ak8PFJetsPuppiSoftDrop'+postfix),
0039                getattr(process,'ak8PFJetsPuppiSoftDropMass'+postfix))
0040 
0041     from RecoJets.JetProducers.ak8GenJets_cfi import ak8GenJets, ak8GenJetsSoftDrop, ak8GenJetsConstituents
0042     addToProcessAndTask('ak8GenJetsNoNuConstituents'+postfix, ak8GenJetsConstituents.clone(src='ak8GenJetsNoNu'), process, task )
0043     addToProcessAndTask('ak8GenJetsNoNuSoftDrop'+postfix,ak8GenJetsSoftDrop.clone(src=cms.InputTag('ak8GenJetsNoNuConstituents'+postfix, 'constituents')),process,task)
0044     addToProcessAndTask('slimmedGenJetsAK8SoftDropSubJets'+postfix,
0045                             cms.EDProducer("PATGenJetSlimmer",
0046                                                src = cms.InputTag("ak8GenJetsNoNuSoftDrop"+postfix, "SubJets"),
0047                                                packedGenParticles = cms.InputTag("packedGenParticles"),
0048                                                cut = cms.string(""),
0049                                                cutLoose = cms.string(""),
0050                                                nLoose = cms.uint32(0),
0051                                                clearDaughters = cms.bool(False), #False means rekeying
0052                                                dropSpecific = cms.bool(True),  # Save space
0053                                                ), process, task )
0054 
0055     ## PATify puppi soft drop fat jets
0056     addJetCollection(
0057         process,
0058         postfix=postfix,
0059         labelName = 'AK8PFPuppiSoftDrop' + postfix,
0060         jetSource = cms.InputTag('ak8PFJetsPuppiSoftDrop'+postfix),
0061         btagDiscriminators = ['None'],
0062         genJetCollection = cms.InputTag('slimmedGenJetsAK8'), 
0063         jetCorrections = ('AK8PFPuppi', ['L2Relative', 'L3Absolute'], 'None'),
0064         getJetMCFlavour = False # jet flavor disabled
0065     )
0066     ## PATify soft drop subjets
0067     addJetCollection(
0068         process,
0069         postfix=postfix,
0070         labelName = 'AK8PFPuppiSoftDropSubjets',
0071         jetSource = cms.InputTag('ak8PFJetsPuppiSoftDrop'+postfix,'SubJets'),
0072         algo = 'ak',  # needed for subjet flavor clustering
0073         rParam = 0.8, # needed for subjet flavor clustering
0074         btagDiscriminators = ['pfDeepCSVJetTags:probb', 'pfDeepCSVJetTags:probbb', 'pfCombinedInclusiveSecondaryVertexV2BJetTags','pfCombinedMVAV2BJetTags'],
0075         jetCorrections = ('AK4PFPuppi', ['L2Relative', 'L3Absolute'], 'None'),
0076         explicitJTA = True,  # needed for subjet b tagging
0077         svClustering = True, # needed for subjet b tagging
0078         genJetCollection = cms.InputTag('slimmedGenJetsAK8SoftDropSubJets'), 
0079         fatJets=cms.InputTag('ak8PFJetsPuppi'),             # needed for subjet flavor clustering
0080         groomedFatJets=cms.InputTag('ak8PFJetsPuppiSoftDrop') # needed for subjet flavor clustering
0081     )
0082 
0083 
0084     # add groomed ECFs and N-subjettiness to soft dropped pat::Jets for fat jets and subjets
0085     process.load('RecoJets.JetProducers.ECF_cff')
0086     addToProcessAndTask('nb1AK8PuppiSoftDrop'+postfix, process.ecfNbeta1.clone(src = cms.InputTag("ak8PFJetsPuppiSoftDrop"+postfix), cuts = cms.vstring('', '', 'pt > 250')), process, task)
0087     addToProcessAndTask('nb2AK8PuppiSoftDrop'+postfix, process.ecfNbeta2.clone(src = cms.InputTag("ak8PFJetsPuppiSoftDrop"+postfix), cuts = cms.vstring('', '', 'pt > 250')), process, task)
0088 
0089     #too slow now ==> disable
0090     from Configuration.Eras.Modifier_pp_on_XeXe_2017_cff import pp_on_XeXe_2017
0091     from Configuration.Eras.Modifier_phase2_common_cff import phase2_common
0092 
0093     for e in [pp_on_XeXe_2017, phase2_common]:
0094         e.toModify(getattr(process,'nb1AK8PuppiSoftDrop'+postfix), cuts = ['pt > 999999', 'pt > 999999', 'pt > 999999'] )
0095         e.toModify(getattr(process,'nb2AK8PuppiSoftDrop'+postfix), cuts = ['pt > 999999', 'pt > 999999', 'pt > 999999'] )
0096 
0097     from RecoJets.JetProducers.nJettinessAdder_cfi import Njettiness
0098     addToProcessAndTask('NjettinessAK8Subjets'+postfix, Njettiness.clone(), process, task)
0099     getattr(process,"NjettinessAK8Subjets"+postfix).src = cms.InputTag("ak8PFJetsPuppiSoftDrop"+postfix, "SubJets")
0100     getattr(process,"patJetsAK8PFPuppiSoftDrop").userData.userFloats.src += ['nb1AK8PuppiSoftDrop'+postfix+':ecfN2','nb1AK8PuppiSoftDrop'+postfix+':ecfN3']
0101     getattr(process,"patJetsAK8PFPuppiSoftDrop").userData.userFloats.src += ['nb2AK8PuppiSoftDrop'+postfix+':ecfN2','nb2AK8PuppiSoftDrop'+postfix+':ecfN3']
0102     addToProcessAndTask('nb1AK8PuppiSoftDropSubjets'+postfix, process.ecfNbeta1.clone(src = cms.InputTag("ak8PFJetsPuppiSoftDrop"+postfix, "SubJets")), process, task)
0103     addToProcessAndTask('nb2AK8PuppiSoftDropSubjets'+postfix, process.ecfNbeta2.clone(src = cms.InputTag("ak8PFJetsPuppiSoftDrop"+postfix, "SubJets")), process, task)
0104     getattr(process,"patJetsAK8PFPuppiSoftDropSubjets"+postfix).userData.userFloats.src += ['nb1AK8PuppiSoftDropSubjets'+postfix+':ecfN2','nb1AK8PuppiSoftDropSubjets'+postfix+':ecfN3']
0105     getattr(process,"patJetsAK8PFPuppiSoftDropSubjets"+postfix).userData.userFloats.src += ['nb2AK8PuppiSoftDropSubjets'+postfix+':ecfN2','nb2AK8PuppiSoftDropSubjets'+postfix+':ecfN3']
0106     getattr(process,"patJetsAK8PFPuppiSoftDropSubjets"+postfix).userData.userFloats.src += ['NjettinessAK8Subjets'+postfix+':tau1','NjettinessAK8Subjets'+postfix+':tau2','NjettinessAK8Subjets'+postfix+':tau3','NjettinessAK8Subjets'+postfix+':tau4']
0107 
0108     for e in [pp_on_XeXe_2017, phase2_common]:
0109         e.toModify(getattr(process,'nb1AK8PuppiSoftDropSubjets'+postfix), cuts = ['pt > 999999', 'pt > 999999', 'pt > 999999'] )
0110         e.toModify(getattr(process,'nb2AK8PuppiSoftDropSubjets'+postfix), cuts = ['pt > 999999', 'pt > 999999', 'pt > 999999'] )
0111 
0112         
0113     # Patify AK8 PF PUPPI
0114     addJetCollection(process, postfix=postfix, labelName = 'AK8Puppi',
0115                      jetSource = cms.InputTag('ak8PFJetsPuppi'+postfix),
0116                      algo= 'AK', rParam = 0.8,
0117                      jetCorrections = ('AK8PFPuppi', cms.vstring(['L2Relative', 'L3Absolute']), 'None'),
0118                      btagDiscriminators = ([
0119                          'pfCombinedSecondaryVertexV2BJetTags',
0120                          'pfCombinedInclusiveSecondaryVertexV2BJetTags',
0121                          'pfCombinedMVAV2BJetTags',
0122                          'pfDeepCSVJetTags:probb',
0123                          'pfDeepCSVJetTags:probc',
0124                          'pfDeepCSVJetTags:probudsg',
0125                          'pfDeepCSVJetTags:probbb',
0126                          'pfBoostedDoubleSecondaryVertexAK8BJetTags']),
0127                      genJetCollection = cms.InputTag('slimmedGenJetsAK8')
0128                      )
0129     getattr(process,"patJetsAK8Puppi"+postfix).userData.userFloats.src = [] # start with empty list of user floats
0130     getattr(process,"selectedPatJetsAK8Puppi"+postfix).cut = cms.string("pt > 100")
0131     getattr(process,"selectedPatJetsAK8Puppi"+postfix).cutLoose = cms.string("pt > 30")
0132     getattr(process,"selectedPatJetsAK8Puppi"+postfix).nLoose = cms.uint32(3)
0133 
0134     from RecoJets.JetAssociationProducers.j2tParametersVX_cfi import j2tParametersVX
0135     addToProcessAndTask('ak8PFJetsPuppiTracksAssociatorAtVertex'+postfix, cms.EDProducer("JetTracksAssociatorAtVertex",
0136                                       j2tParametersVX.clone( coneSize = cms.double(0.8) ),
0137                                       jets = cms.InputTag("ak8PFJetsPuppi") ),
0138                         process, task)
0139     addToProcessAndTask('patJetAK8PuppiCharge'+postfix, cms.EDProducer("JetChargeProducer",
0140                                      src = cms.InputTag("ak8PFJetsPuppiTracksAssociatorAtVertex"),
0141                                      var = cms.string('Pt'),
0142                                      exp = cms.double(1.0) ), 
0143                         process, task)
0144 
0145     ## now add AK8 groomed masses and ECF
0146     getattr(process,"patJetsAK8Puppi"+postfix).userData.userFloats.src += ['ak8PFJetsPuppiSoftDropMass'+postfix]
0147     getattr(process,"patJetsAK8Puppi"+postfix).addTagInfos = cms.bool(False)
0148 
0149 
0150     # add PUPPI Njetiness    
0151     addToProcessAndTask('NjettinessAK8Puppi'+postfix, Njettiness.clone(), process, task)
0152     getattr(process,"NjettinessAK8Puppi"+postfix).src = cms.InputTag("ak8PFJetsPuppi"+postfix)
0153     getattr(process,"patJetsAK8Puppi").userData.userFloats.src += ['NjettinessAK8Puppi'+postfix+':tau1','NjettinessAK8Puppi'+postfix+':tau2','NjettinessAK8Puppi'+postfix+':tau3','NjettinessAK8Puppi'+postfix+':tau4']
0154 
0155     
0156     addToProcessAndTask("slimmedJetsAK8PFPuppiSoftDropSubjets"+postfix,
0157                         cms.EDProducer("PATJetSlimmer",
0158                              src = cms.InputTag("selectedPatJetsAK8PFPuppiSoftDropSubjets"),
0159                              packedPFCandidates = cms.InputTag("packedPFCandidates"),
0160                              dropJetVars = cms.string("1"),
0161                              dropDaughters = cms.string("0"),
0162                              rekeyDaughters = cms.string("1"),
0163                              dropTrackRefs = cms.string("1"),
0164                              dropSpecific = cms.string("1"),
0165                              dropTagInfos = cms.string("1"),
0166                              modifyJets = cms.bool(True),
0167                              mixedDaughters = cms.bool(False),
0168                              modifierConfig = cms.PSet( modifications = cms.VPSet() )
0169                                        ),
0170                         process, task)
0171 
0172     
0173     ## Establish references between PATified fat jets and subjets using the BoostedJetMerger
0174     addToProcessAndTask("slimmedJetsAK8PFPuppiSoftDropPacked"+postfix,
0175                         cms.EDProducer("BoostedJetMerger",
0176                                jetSrc=cms.InputTag("selectedPatJetsAK8PFPuppiSoftDrop"),
0177                                subjetSrc=cms.InputTag("slimmedJetsAK8PFPuppiSoftDropSubjets")
0178                                        ),
0179                         process, task )
0180 
0181     
0182     addToProcessAndTask("packedPatJetsAK8"+postfix, cms.EDProducer("JetSubstructurePacker",
0183                                            jetSrc = cms.InputTag("selectedPatJetsAK8Puppi"+postfix),
0184                                            distMax = cms.double(0.8),
0185                                            algoTags = cms.VInputTag(
0186                                                cms.InputTag("slimmedJetsAK8PFPuppiSoftDropPacked"+postfix)
0187                                            ),
0188                                            algoLabels = cms.vstring(
0189                                                'SoftDropPuppi'
0190                                            ),
0191                                           fixDaughters = cms.bool(True),
0192                                           packedPFCandidates = cms.InputTag("packedPFCandidates"+postfix),
0193                                                                    ),
0194                         process, task)
0195 
0196     # switch off daughter re-keying since it's done in the JetSubstructurePacker (and can't be done afterwards)
0197     process.slimmedJetsAK8.rekeyDaughters = "0"
0198     # Reconfigure the slimmedAK8 jet information to keep 
0199     process.slimmedJetsAK8.dropDaughters = cms.string("pt < 170")
0200     process.slimmedJetsAK8.dropSpecific = cms.string("pt < 170")
0201     process.slimmedJetsAK8.dropTagInfos = cms.string("pt < 170")