Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-01-16 23:37:15

0001 import FWCore.ParameterSet.Config as cms
0002 
0003 from PhysicsTools.NanoAOD.common_cff import *
0004 from PhysicsTools.NanoAOD.simpleCandidateFlatTableProducer_cfi import simpleCandidateFlatTableProducer
0005 from PhysicsTools.NanoAOD.jetsAK8_cff import fatJetTable as _fatJetTable
0006 from PhysicsTools.NanoAOD.jetsAK8_cff import subJetTable as _subJetTable
0007 
0008 jetMCTable = simpleCandidateFlatTableProducer.clone(
0009     src = cms.InputTag("linkedObjects","jets"),
0010     name = cms.string("Jet"),
0011     extension = cms.bool(True), # this is an extension  table for the jets
0012     variables = cms.PSet(
0013         partonFlavour = Var("partonFlavour()", "int16", doc="flavour from parton matching"),
0014         hadronFlavour = Var("hadronFlavour()", "uint8", doc="flavour from hadron ghost clustering"),
0015         genJetIdx = Var("?genJetFwdRef().backRef().isNonnull()?genJetFwdRef().backRef().key():-1", "int16", doc="index of matched gen jet"),
0016     )
0017 )
0018 genJetTable = simpleCandidateFlatTableProducer.clone(
0019     src = cms.InputTag("slimmedGenJets"),
0020     cut = cms.string("pt > 10"),
0021     name = cms.string("GenJet"),
0022     doc  = cms.string("slimmedGenJets, i.e. ak4 Jets made with visible genparticles"),
0023     variables = cms.PSet(P4Vars,
0024     #anything else?
0025     )
0026 )
0027 
0028 patJetPartonsNano = cms.EDProducer('HadronAndPartonSelector',
0029     src = cms.InputTag("generator"),
0030     particles = cms.InputTag("prunedGenParticles"),
0031     partonMode = cms.string("Auto"),
0032     fullChainPhysPartons = cms.bool(True)
0033 )
0034 
0035 genJetFlavourAssociation = cms.EDProducer("JetFlavourClustering",
0036     jets = genJetTable.src,
0037     bHadrons = cms.InputTag("patJetPartonsNano","bHadrons"),
0038     cHadrons = cms.InputTag("patJetPartonsNano","cHadrons"),
0039     partons = cms.InputTag("patJetPartonsNano","physicsPartons"),
0040     leptons = cms.InputTag("patJetPartonsNano","leptons"),
0041     jetAlgorithm = cms.string("AntiKt"),
0042     rParam = cms.double(0.4),
0043     ghostRescaling = cms.double(1e-18),
0044     hadronFlavourHasPriority = cms.bool(False)
0045 )
0046 
0047 genJetFlavourTable = cms.EDProducer("GenJetFlavourTableProducer",
0048     name = genJetTable.name,
0049     src = genJetTable.src,
0050     cut = genJetTable.cut,
0051     deltaR = cms.double(0.1),
0052     jetFlavourInfos = cms.InputTag("slimmedGenJetsFlavourInfos"),
0053 )
0054 
0055 genJetAK8Table = simpleCandidateFlatTableProducer.clone(
0056     src = cms.InputTag("slimmedGenJetsAK8"),
0057     cut = cms.string("pt > 100."),
0058     name = cms.string("GenJetAK8"),
0059     doc  = cms.string("slimmedGenJetsAK8, i.e. ak8 Jets made with visible genparticles"),
0060     variables = cms.PSet(P4Vars,
0061     #anything else?
0062     )
0063 )
0064 
0065 genJetAK8FlavourAssociation = cms.EDProducer("JetFlavourClustering",
0066     jets = genJetAK8Table.src,
0067     bHadrons = cms.InputTag("patJetPartonsNano","bHadrons"),
0068     cHadrons = cms.InputTag("patJetPartonsNano","cHadrons"),
0069     partons = cms.InputTag("patJetPartonsNano","physicsPartons"),
0070     leptons = cms.InputTag("patJetPartonsNano","leptons"),
0071     jetAlgorithm = cms.string("AntiKt"),
0072     rParam = cms.double(0.8),
0073     ghostRescaling = cms.double(1e-18),
0074     hadronFlavourHasPriority = cms.bool(False)
0075 )
0076 
0077 genJetAK8FlavourTable = cms.EDProducer("GenJetFlavourTableProducer",
0078     name = genJetAK8Table.name,
0079     src = genJetAK8Table.src,
0080     cut = genJetAK8Table.cut,
0081     deltaR = cms.double(0.1),
0082     jetFlavourInfos = cms.InputTag("genJetAK8FlavourAssociation"),
0083 )
0084 fatJetMCTable = simpleCandidateFlatTableProducer.clone(
0085     src = _fatJetTable.src,
0086     cut = _fatJetTable.cut,
0087     name = _fatJetTable.name,
0088     extension = cms.bool(True),
0089     variables = cms.PSet(
0090         nBHadrons = Var("jetFlavourInfo().getbHadrons().size()", "uint8", doc="number of b-hadrons"),
0091         nCHadrons = Var("jetFlavourInfo().getcHadrons().size()", "uint8", doc="number of c-hadrons"),
0092         hadronFlavour = Var("hadronFlavour()", "uint8", doc="flavour from hadron ghost clustering"),
0093         genJetAK8Idx = Var("?genJetFwdRef().backRef().isNonnull() && genJetFwdRef().backRef().pt() > 100.?genJetFwdRef().backRef().key():-1", "int16", doc="index of matched gen AK8 jet"),
0094     )
0095 )
0096 
0097 genSubJetAK8Table = simpleCandidateFlatTableProducer.clone(
0098     src = cms.InputTag("slimmedGenJetsAK8SoftDropSubJets"),
0099     name = cms.string("SubGenJetAK8"),
0100     doc  = cms.string("slimmedGenJetsAK8SoftDropSubJets, i.e. subjets of ak8 Jets made with visible genparticles"),
0101     variables = cms.PSet(P4Vars,
0102     #anything else?
0103     )
0104 )
0105 subjetMCTable = simpleCandidateFlatTableProducer.clone(
0106     src = _subJetTable.src,
0107     cut = _subJetTable.cut,
0108     name = _subJetTable.name,
0109     extension = cms.bool(True),
0110     variables = cms.PSet(
0111         nBHadrons = Var("jetFlavourInfo().getbHadrons().size()", "uint8", doc="number of b-hadrons"),
0112         nCHadrons = Var("jetFlavourInfo().getcHadrons().size()", "uint8", doc="number of c-hadrons"),
0113         hadronFlavour = Var("hadronFlavour()", "uint8", doc="flavour from hadron ghost clustering"),
0114     )
0115 )
0116 
0117 
0118 jetMCTaskak4 = cms.Task(jetMCTable,genJetTable,patJetPartonsNano,genJetFlavourTable)
0119 jetMCTaskak8 = cms.Task(genJetAK8Table,genJetAK8FlavourAssociation,genJetAK8FlavourTable,fatJetMCTable,genSubJetAK8Table,subjetMCTable)
0120 jetMCTask = jetMCTaskak4.copyAndAdd(jetMCTaskak8)