Back to home page

Project CMSSW displayed by LXR

 
 

    


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

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         # cut should follow genJetTable.cut
0016         genJetIdx = Var("?genJetFwdRef().backRef().isNonnull() && genJetFwdRef().backRef().pt() > 10.?genJetFwdRef().backRef().key():-1", "int16", doc="index of matched gen jet"),
0017     )
0018 )
0019 genJetTable = simpleCandidateFlatTableProducer.clone(
0020     src = cms.InputTag("slimmedGenJets"),
0021     cut = cms.string("pt > 10"),
0022     name = cms.string("GenJet"),
0023     doc  = cms.string("slimmedGenJets, i.e. ak4 Jets made with visible genparticles"),
0024     variables = cms.PSet(P4Vars,
0025     #anything else?
0026     )
0027 )
0028 
0029 patJetPartonsNano = cms.EDProducer('HadronAndPartonSelector',
0030     src = cms.InputTag("generator"),
0031     particles = cms.InputTag("prunedGenParticles"),
0032     partonMode = cms.string("Auto"),
0033     fullChainPhysPartons = cms.bool(True)
0034 )
0035 
0036 genJetFlavourAssociation = cms.EDProducer("JetFlavourClustering",
0037     jets = genJetTable.src,
0038     bHadrons = cms.InputTag("patJetPartonsNano","bHadrons"),
0039     cHadrons = cms.InputTag("patJetPartonsNano","cHadrons"),
0040     partons = cms.InputTag("patJetPartonsNano","physicsPartons"),
0041     leptons = cms.InputTag("patJetPartonsNano","leptons"),
0042     jetAlgorithm = cms.string("AntiKt"),
0043     rParam = cms.double(0.4),
0044     ghostRescaling = cms.double(1e-18),
0045     hadronFlavourHasPriority = cms.bool(False)
0046 )
0047 
0048 genJetFlavourTable = cms.EDProducer("GenJetFlavourTableProducer",
0049     name = genJetTable.name,
0050     src = genJetTable.src,
0051     cut = genJetTable.cut,
0052     deltaR = cms.double(0.1),
0053     jetFlavourInfos = cms.InputTag("slimmedGenJetsFlavourInfos"),
0054 )
0055 
0056 genJetAK8Table = simpleCandidateFlatTableProducer.clone(
0057     src = cms.InputTag("slimmedGenJetsAK8"),
0058     cut = cms.string("pt > 100."),
0059     name = cms.string("GenJetAK8"),
0060     doc  = cms.string("slimmedGenJetsAK8, i.e. ak8 Jets made with visible genparticles"),
0061     variables = cms.PSet(P4Vars,
0062     #anything else?
0063     )
0064 )
0065 
0066 genJetAK8FlavourAssociation = cms.EDProducer("JetFlavourClustering",
0067     jets = genJetAK8Table.src,
0068     bHadrons = cms.InputTag("patJetPartonsNano","bHadrons"),
0069     cHadrons = cms.InputTag("patJetPartonsNano","cHadrons"),
0070     partons = cms.InputTag("patJetPartonsNano","physicsPartons"),
0071     leptons = cms.InputTag("patJetPartonsNano","leptons"),
0072     jetAlgorithm = cms.string("AntiKt"),
0073     rParam = cms.double(0.8),
0074     ghostRescaling = cms.double(1e-18),
0075     hadronFlavourHasPriority = cms.bool(False)
0076 )
0077 
0078 genJetAK8FlavourTable = cms.EDProducer("GenJetFlavourTableProducer",
0079     name = genJetAK8Table.name,
0080     src = genJetAK8Table.src,
0081     cut = genJetAK8Table.cut,
0082     deltaR = cms.double(0.1),
0083     jetFlavourInfos = cms.InputTag("genJetAK8FlavourAssociation"),
0084 )
0085 fatJetMCTable = simpleCandidateFlatTableProducer.clone(
0086     src = _fatJetTable.src,
0087     cut = _fatJetTable.cut,
0088     name = _fatJetTable.name,
0089     extension = cms.bool(True),
0090     variables = cms.PSet(
0091         hadronFlavour = Var("hadronFlavour()", "uint8", doc="flavour from hadron ghost clustering"),
0092         # cut should follow genJetAK8Table.cut
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)