Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:23:56

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