def addFlashggPuppiJets(process,
                        vertexIndex = 0,
                        doQGTagging = True,
                        label       ='',
                        useLocalJEC = True,
                        dbfile      = 'flashgg/MetaData/data/PuppiJEC/PY8_RunIISpring15DR74_bx50_MC.db',
                        debug       = False):
    
  from CommonTools.PileupAlgos.flashggPuppi_cff          import flashggPuppi 
  from RecoJets.JetProducers.ak4PFJets_cfi               import ak4PFJets

  # fill the puppi parameters
  setattr(process, 'flashggPuppi' + label,
          flashggPuppi.clone( candName              = cms.InputTag('packedPFCandidates'),
                              vertexName            = cms.InputTag('offlineSlimmedPrimaryVertices'),
                              diPhotonTag           = cms.InputTag('flashggDiPhotons'),
                              VertexCandidateMapTag = cms.InputTag('flashggVertexMapForPUPPI'),
                              vertexIndex           = cms.uint32(vertexIndex),
                              debug                 = cms.untracked.bool(debug)
                            )
  )
  setattr ( process, 'ak4PFJetsPuppi' + label,
            ak4PFJets.clone ( src = cms.InputTag('flashggPuppi' + label), doAreaFastjet = True)
          )
  
  if useLocalJEC :
    print ':: using a local JEC dbfile for PUPPI :',
    print '\t -- ',  dbfile
    
    from flashgg.MicroAOD.flashggJetTools_cfi import loadLocalJECDBfile
    loadLocalJECDBfile(process,
                       dbfile = os.environ['CMSSW_BASE'] + '/src/' + dbfile,
                       tag    = 'JetCorrectorParametersCollection_PY8_RunIISpring15DR74_bx50_MC_AK4PUPPI',
                       label  = 'AK4PFPuppi')
    
  # do jet clustering
  addJetCollection(
    process,
    postfix            = label,
    labelName          = 'AK4PUPPI',
    jetSource          = cms.InputTag('ak4PFJetsPuppi' + label),
    pvSource           = cms.InputTag('offlineSlimmedPrimaryVertices'),
    pfCandidates       = cms.InputTag('packedPFCandidates'),
    svSource           = cms.InputTag('slimmedSecondaryVertices'),
    btagDiscriminators = [ flashggBTag ],
    jetCorrections     = ('AK4PFPuppi',['L1FastJet',  'L2Relative', 'L3Absolute'], 'None'),
    genJetCollection   = cms.InputTag('slimmedGenJets'),
    genParticles       = cms.InputTag('prunedGenParticles'),
    # jet param
    algo = 'AK', rParam = 0.4
  )

  getattr(process, 'patJetCorrFactorsAK4PUPPI' + label).primaryVertices = "offlineSlimmedPrimaryVertices"
  setattr( process,'flashggPUPPIJets'+ label,
           cms.EDProducer('FlashggJetProducer',
                          DiPhotonTag           = cms.InputTag('flashggDiPhotons'),
                          VertexTag             = cms.InputTag('offlineSlimmedPrimaryVertices'),
                          JetTag                = cms.InputTag('patJetsAK4PUPPI' + label),
                          VertexCandidateMapTag = cms.InputTag("flashggVertexMapForPUPPI"),
                          UsePuppi              = cms.untracked.bool(True),
                          ComputeSimpleRMS = cms.bool(True)
#                          PileupJetIdParameters = cms.PSet(pu_jetid)
                        ))

  # randomize Jets
  from flashgg.MicroAOD.flashggRandomizedJetProducer_cfi import flashggRandomizedJets
  flashggRandomizedPUPPIJets = flashggRandomizedJets.clone()
  flashggRandomizedPUPPIJets.src = "flashggPUPPIJets" + label
  setattr(process.RandomNumberGeneratorService, 'flashggRandomizedPUPPIJets' + label, cms.PSet(initialSeed = cms.untracked.uint32(36421523 + int(label))))
  setattr( process, 'flashggRandomizedPUPPIJets' + label, flashggRandomizedPUPPIJets )

  setattr( process, 'selectedFlashggPUPPIJets'+ label,
           cms.EDFilter("FLASHggJetSelector",
                        src = cms.InputTag( 'flashggRandomizedPUPPIJets'+ label ),
                        cut = cms.string("pt > 15.")
                      ))
Beispiel #2
0
def addFlashggPuppiJets(
        process,
        vertexIndex=0,
        doQGTagging=True,
        label='',
        useLocalJEC=True,
        dbfile='flashgg/MetaData/data/PuppiJEC/PY8_RunIISpring15DR74_bx50_MC.db',
        debug=False):

    from CommonTools.PileupAlgos.flashggPuppi_cff import flashggPuppi
    from RecoJets.JetProducers.ak4PFJets_cfi import ak4PFJets

    # fill the puppi parameters
    setattr(
        process, 'flashggPuppi' + label,
        flashggPuppi.clone(
            candName=cms.InputTag('packedPFCandidates'),
            vertexName=cms.InputTag('offlineSlimmedPrimaryVertices'),
            diPhotonTag=cms.InputTag('flashggDiPhotons'),
            VertexCandidateMapTag=cms.InputTag('flashggVertexMapForPUPPI'),
            vertexIndex=cms.uint32(vertexIndex),
            debug=cms.untracked.bool(debug)))
    setattr(
        process, 'ak4PFJetsPuppi' + label,
        ak4PFJets.clone(src=cms.InputTag('flashggPuppi' + label),
                        doAreaFastjet=True))

    if useLocalJEC:
        print ':: using a local JEC dbfile for PUPPI :',
        print '\t -- ', dbfile

        from flashgg.MicroAOD.flashggJetTools_cfi import loadLocalJECDBfile
        loadLocalJECDBfile(
            process,
            dbfile=os.environ['CMSSW_BASE'] + '/src/' + dbfile,
            tag=
            'JetCorrectorParametersCollection_PY8_RunIISpring15DR74_bx50_MC_AK4PUPPI',
            label='AK4PFPuppi')

    # do jet clustering
    addJetCollection(
        process,
        postfix=label,
        labelName='AK4PUPPI',
        jetSource=cms.InputTag('ak4PFJetsPuppi' + label),
        pvSource=cms.InputTag('offlineSlimmedPrimaryVertices'),
        pfCandidates=cms.InputTag('packedPFCandidates'),
        svSource=cms.InputTag('slimmedSecondaryVertices'),
        btagDiscriminators=[flashggBTag],
        jetCorrections=('AK4PFPuppi',
                        ['L1FastJet', 'L2Relative', 'L3Absolute'], 'None'),
        genJetCollection=cms.InputTag('slimmedGenJets'),
        genParticles=cms.InputTag('prunedGenParticles'),
        # jet param
        algo='AK',
        rParam=0.4)

    getattr(process, 'patJetCorrFactorsAK4PUPPI' +
            label).primaryVertices = "offlineSlimmedPrimaryVertices"
    setattr(
        process,
        'flashggPUPPIJets' + label,
        cms.EDProducer(
            'FlashggJetProducer',
            DiPhotonTag=cms.InputTag('flashggDiPhotons'),
            VertexTag=cms.InputTag('offlineSlimmedPrimaryVertices'),
            JetTag=cms.InputTag('patJetsAK4PUPPI' + label),
            VertexCandidateMapTag=cms.InputTag("flashggVertexMapForPUPPI"),
            UsePuppi=cms.untracked.bool(True),
            ComputeSimpleRMS=cms.bool(True),
            ComputeRegVars=cms.bool(False)
            #                          PileupJetIdParameters = cms.PSet(pu_jetid)
        ))

    # randomize Jets
    from flashgg.MicroAOD.flashggRandomizedJetProducer_cfi import flashggRandomizedJets
    flashggRandomizedPUPPIJets = flashggRandomizedJets.clone()
    flashggRandomizedPUPPIJets.src = "flashggPUPPIJets" + label
    setattr(process.RandomNumberGeneratorService,
            'flashggRandomizedPUPPIJets' + label,
            cms.PSet(initialSeed=cms.untracked.uint32(36421523 + int(label))))
    setattr(process, 'flashggRandomizedPUPPIJets' + label,
            flashggRandomizedPUPPIJets)

    setattr(
        process, 'selectedFlashggPUPPIJets' + label,
        cms.EDFilter("FLASHggJetSelector",
                     src=cms.InputTag('flashggRandomizedPUPPIJets' + label),
                     cut=cms.string("pt > 15.")))
def addStandardPuppiJets(process,
                         label       ='',
                         useLocalJEC = True,
                         dbfile      = 'flashgg/MetaData/data/PuppiJEC/PY8_RunIISpring15DR74_bx50_MC.db',
                         debug       = False):

  print  ':: Running a standard PUPPI : --'
  
  from CommonTools.PileupAlgos.Puppi_cff           import puppi 
  from RecoJets.JetProducers.ak4PFJets_cfi         import ak4PFJets
  from PhysicsTools.PatAlgos.tools.jetTools        import addJetCollection
#  from RecoJets.JetProducers.PileupJetIDParams_cfi import cutbased_new as pu_jetid
  from flashgg.MicroAOD.flashggJets_cfi            import flashggBTag
  
  setattr(process, 'flashggStdPuppi' + label,
          puppi.clone( candName    = cms.InputTag('packedPFCandidates'),
                       vertexName  = cms.InputTag('offlineSlimmedPrimaryVertices'),
                     ))
  
  setattr(process, 'ak4PFJetsStdPuppi' + label,
          ak4PFJets.clone ( src = cms.InputTag('flashggStdPuppi'),
                            doAreaFastjet = True
                          ))

  if useLocalJEC :
    print ':: using a local JEC dbfile for PUPPI :',
    print ' -- ',  dbfile
    
    from flashgg.MicroAOD.flashggJetTools_cfi import loadLocalJECDBfile
    loadLocalJECDBfile(process,
                       dbfile = os.environ['CMSSW_BASE'] + '/src/' + dbfile,
                       tag    = 'JetCorrectorParametersCollection_PY8_RunIISpring15DR74_bx50_MC_AK4PUPPI',
                       label  = 'AK4PFPuppi')
    
    
  addJetCollection(
    process,
    postfix            = 'std' + label,
    labelName          = 'AK4PUPPI',
    jetSource          = cms.InputTag('ak4PFJetsStdPuppi'),
    pvSource           = cms.InputTag('offlineSlimmedPrimaryVertices'),
    pfCandidates       = cms.InputTag('packedPFCandidates'),
    svSource           = cms.InputTag('slimmedSecondaryVertices'),
    btagDiscriminators = [ flashggBTag ],
    jetCorrections     = ('AK4PFchs',['L1FastJet',  'L2Relative', 'L3Absolute'], 'None'),
    genJetCollection   = cms.InputTag('slimmedGenJets'),
    genParticles       = cms.InputTag('prunedGenParticles'),
    # jet param
    algo = 'AK', rParam = 0.4
  )
  
  getattr(process, 'patJetCorrFactorsAK4PUPPIstd' + label).primaryVertices = "offlineSlimmedPrimaryVertices"
  setattr(process, 'flashggStdPUPPIJets',
          cms.EDProducer('FlashggJetProducer',
                         DiPhotonTag           = cms.InputTag('flashggDiPhotons'),
                         VertexTag             = cms.InputTag('offlineSlimmedPrimaryVertices'),
                         JetTag                = cms.InputTag('patJetsAK4PUPPIstd' + label),
                         VertexCandidateMapTag = cms.InputTag("flashggVertexMapForPUPPI"),
                         UsePuppi              = cms.untracked.bool(True),
#                         PileupJetIdParameters = cms.PSet(pu_jetid))
                         )
          )
  setattr(process, 'selectedFlashggStdPUPPIJets' + label,
          cms.EDFilter("FLASHggJetSelector",
                       src = cms.InputTag( 'flashggStdPUPPIJets'),
                       cut = cms.string("pt > 15."))
          )
def addStandardPuppiJets(
        process,
        label='',
        useLocalJEC=True,
        dbfile='flashgg/MetaData/data/PuppiJEC/PY8_RunIISpring15DR74_bx50_MC.db',
        debug=False):

    print ':: Running a standard PUPPI : --'

    from CommonTools.PileupAlgos.Puppi_cff import puppi
    from RecoJets.JetProducers.ak4PFJets_cfi import ak4PFJets
    from PhysicsTools.PatAlgos.tools.jetTools import addJetCollection
    #  from RecoJets.JetProducers.PileupJetIDParams_cfi import cutbased_new as pu_jetid
    from flashgg.MicroAOD.flashggJets_cfi import flashggBTag

    setattr(
        process, 'flashggStdPuppi' + label,
        puppi.clone(
            candName=cms.InputTag('packedPFCandidates'),
            vertexName=cms.InputTag('offlineSlimmedPrimaryVertices'),
        ))

    setattr(
        process, 'ak4PFJetsStdPuppi' + label,
        ak4PFJets.clone(src=cms.InputTag('flashggStdPuppi'),
                        doAreaFastjet=True))

    if useLocalJEC:
        print ':: using a local JEC dbfile for PUPPI :',
        print ' -- ', dbfile

        from flashgg.MicroAOD.flashggJetTools_cfi import loadLocalJECDBfile
        loadLocalJECDBfile(
            process,
            dbfile=os.environ['CMSSW_BASE'] + '/src/' + dbfile,
            tag=
            'JetCorrectorParametersCollection_PY8_RunIISpring15DR74_bx50_MC_AK4PUPPI',
            label='AK4PFPuppi')

    addJetCollection(
        process,
        postfix='std' + label,
        labelName='AK4PUPPI',
        jetSource=cms.InputTag('ak4PFJetsStdPuppi'),
        pvSource=cms.InputTag('offlineSlimmedPrimaryVertices'),
        pfCandidates=cms.InputTag('packedPFCandidates'),
        svSource=cms.InputTag('slimmedSecondaryVertices'),
        elSource=cms.InputTag("slimmedElectrons"),
        muSource=cms.InputTag("slimmedMuons"),
        runIVF=True,
        btagDiscriminators=[
            flashggBTag,
            flashggCMVABTag,
            flashggDeepCSVb,
            flashggDeepCSVbb,
            flashggDeepCSVc,
            flashggDeepCSVudsg,
        ],
        jetCorrections=('AK4PFchs', ['L1FastJet', 'L2Relative',
                                     'L3Absolute'], 'None'),
        genJetCollection=cms.InputTag('slimmedGenJets'),
        genParticles=cms.InputTag('prunedGenParticles'),
        # jet param
        algo='AK',
        rParam=0.4)

    getattr(process, 'patJetCorrFactorsAK4PUPPIstd' +
            label).primaryVertices = "offlineSlimmedPrimaryVertices"
    setattr(
        process,
        'flashggStdPUPPIJets',
        cms.EDProducer(
            'FlashggJetProducer',
            DiPhotonTag=cms.InputTag('flashggDiPhotons'),
            VertexTag=cms.InputTag('offlineSlimmedPrimaryVertices'),
            JetTag=cms.InputTag('patJetsAK4PUPPIstd' + label),
            VertexCandidateMapTag=cms.InputTag("flashggVertexMapForPUPPI"),
            UsePuppi=cms.untracked.bool(True),
            #                         PileupJetIdParameters = cms.PSet(pu_jetid))
        ))
    setattr(
        process, 'selectedFlashggStdPUPPIJets' + label,
        cms.EDFilter("FLASHggJetSelector",
                     src=cms.InputTag('flashggStdPUPPIJets'),
                     cut=cms.string("pt > 15.")))