Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-06-04 01:26:10

0001 import FWCore.ParameterSet.Config as cms
0002 
0003 from PhysicsTools.NanoAOD.nano_eras_cff import *
0004 from PhysicsTools.NanoAOD.common_cff import *
0005 from PhysicsTools.NanoAOD.jetsAK8_cff import fatJetTable as _fatJetTable
0006 from PhysicsTools.NanoAOD.jetsAK8_cff import subJetTable as _subJetTable
0007 
0008 jetMCTable = cms.EDProducer("SimpleCandidateFlatTableProducer",
0009     src = cms.InputTag("linkedObjects","jets"),
0010     cut = cms.string(""), #we should not filter on cross linked collections
0011     name = cms.string("Jet"),
0012     singleton = cms.bool(False), # the number of entries is variable
0013     extension = cms.bool(True), # this is an extension  table for the jets
0014     variables = cms.PSet(
0015         partonFlavour = Var("partonFlavour()", int, doc="flavour from parton matching"),
0016         hadronFlavour = Var("hadronFlavour()", int, doc="flavour from hadron ghost clustering"),
0017         genJetIdx = Var("?genJetFwdRef().backRef().isNonnull()?genJetFwdRef().backRef().key():-1", int, doc="index of matched gen jet"),
0018     )
0019 )
0020 genJetTable = cms.EDProducer("SimpleCandidateFlatTableProducer",
0021     src = cms.InputTag("slimmedGenJets"),
0022     cut = cms.string("pt > 10"),
0023     name = cms.string("GenJet"),
0024     doc  = cms.string("slimmedGenJets, i.e. ak4 Jets made with visible genparticles"),
0025     singleton = cms.bool(False), # the number of entries is variable
0026     extension = cms.bool(False), # this is the main table for the genjets
0027     variables = cms.PSet(P4Vars,
0028     #anything else?
0029     )
0030 )
0031 
0032 patJetPartonsNano = cms.EDProducer('HadronAndPartonSelector',
0033     src = cms.InputTag("generator"),
0034     particles = cms.InputTag("prunedGenParticles"),
0035     partonMode = cms.string("Auto"),
0036     fullChainPhysPartons = cms.bool(True)
0037 )
0038 
0039 genJetFlavourAssociation = cms.EDProducer("JetFlavourClustering",
0040     jets = genJetTable.src,
0041     bHadrons = cms.InputTag("patJetPartonsNano","bHadrons"),
0042     cHadrons = cms.InputTag("patJetPartonsNano","cHadrons"),
0043     partons = cms.InputTag("patJetPartonsNano","physicsPartons"),
0044     leptons = cms.InputTag("patJetPartonsNano","leptons"),
0045     jetAlgorithm = cms.string("AntiKt"),
0046     rParam = cms.double(0.4),
0047     ghostRescaling = cms.double(1e-18),
0048     hadronFlavourHasPriority = cms.bool(False)
0049 )
0050 
0051 genJetFlavourTable = cms.EDProducer("GenJetFlavourTableProducer",
0052     name = genJetTable.name,
0053     src = genJetTable.src,
0054     cut = genJetTable.cut,
0055     deltaR = cms.double(0.1),
0056     jetFlavourInfos = cms.InputTag("slimmedGenJetsFlavourInfos"),
0057 )
0058 
0059 genJetAK8Table = cms.EDProducer("SimpleCandidateFlatTableProducer",
0060     src = cms.InputTag("slimmedGenJetsAK8"),
0061     cut = cms.string("pt > 100."),
0062     name = cms.string("GenJetAK8"),
0063     doc  = cms.string("slimmedGenJetsAK8, i.e. ak8 Jets made with visible genparticles"),
0064     singleton = cms.bool(False), # the number of entries is variable
0065     extension = cms.bool(False), # this is the main table for the genjets
0066     variables = cms.PSet(P4Vars,
0067     #anything else?
0068     )
0069 )
0070 
0071 genJetAK8FlavourAssociation = cms.EDProducer("JetFlavourClustering",
0072     jets = genJetAK8Table.src,
0073     bHadrons = cms.InputTag("patJetPartonsNano","bHadrons"),
0074     cHadrons = cms.InputTag("patJetPartonsNano","cHadrons"),
0075     partons = cms.InputTag("patJetPartonsNano","physicsPartons"),
0076     leptons = cms.InputTag("patJetPartonsNano","leptons"),
0077     jetAlgorithm = cms.string("AntiKt"),
0078     rParam = cms.double(0.8),
0079     ghostRescaling = cms.double(1e-18),
0080     hadronFlavourHasPriority = cms.bool(False)
0081 )
0082 
0083 genJetAK8FlavourTable = cms.EDProducer("GenJetFlavourTableProducer",
0084     name = genJetAK8Table.name,
0085     src = genJetAK8Table.src,
0086     cut = genJetAK8Table.cut,
0087     deltaR = cms.double(0.1),
0088     jetFlavourInfos = cms.InputTag("genJetAK8FlavourAssociation"),
0089 )
0090 fatJetMCTable = cms.EDProducer("SimpleCandidateFlatTableProducer",
0091     src = _fatJetTable.src,
0092     cut = _fatJetTable.cut,
0093     name = _fatJetTable.name,
0094     singleton = cms.bool(False),
0095     extension = cms.bool(True),
0096     variables = cms.PSet(
0097         nBHadrons = Var("jetFlavourInfo().getbHadrons().size()", "uint8", doc="number of b-hadrons"),
0098         nCHadrons = Var("jetFlavourInfo().getcHadrons().size()", "uint8", doc="number of c-hadrons"),
0099         hadronFlavour = Var("hadronFlavour()", int, doc="flavour from hadron ghost clustering"),
0100         genJetAK8Idx = Var("?genJetFwdRef().backRef().isNonnull() && genJetFwdRef().backRef().pt() > 100.?genJetFwdRef().backRef().key():-1", int, doc="index of matched gen AK8 jet"),
0101     )
0102 )
0103 
0104 genSubJetAK8Table = cms.EDProducer("SimpleCandidateFlatTableProducer",
0105     src = cms.InputTag("slimmedGenJetsAK8SoftDropSubJets"),
0106     cut = cms.string(""),  ## These don't get a pt cut, but in miniAOD only subjets from fat jets with pt > 100 are kept
0107     name = cms.string("SubGenJetAK8"),
0108     doc  = cms.string("slimmedGenJetsAK8SoftDropSubJets, i.e. subjets of ak8 Jets made with visible genparticles"),
0109     singleton = cms.bool(False), # the number of entries is variable
0110     extension = cms.bool(False), # this is the main table for the genjets
0111     variables = cms.PSet(P4Vars,
0112     #anything else?
0113     )
0114 )
0115 subjetMCTable = cms.EDProducer("SimpleCandidateFlatTableProducer",
0116     src = _subJetTable.src,
0117     cut = _subJetTable.cut,
0118     name = _subJetTable.name,
0119     singleton = cms.bool(False),
0120     extension = cms.bool(True),
0121     variables = cms.PSet(
0122         nBHadrons = Var("jetFlavourInfo().getbHadrons().size()", "uint8", doc="number of b-hadrons"),
0123         nCHadrons = Var("jetFlavourInfo().getcHadrons().size()", "uint8", doc="number of c-hadrons"),
0124         hadronFlavour = Var("hadronFlavour()", int, doc="flavour from hadron ghost clustering"),
0125     )
0126 )
0127 
0128 
0129 jetMCTaskak4 = cms.Task(jetMCTable,genJetTable,patJetPartonsNano,genJetFlavourTable)
0130 jetMCTaskak8 = cms.Task(genJetAK8Table,genJetAK8FlavourAssociation,genJetAK8FlavourTable,fatJetMCTable,genSubJetAK8Table,subjetMCTable)
0131 jetMCTask = jetMCTaskak4.copy()
0132 jetMCTask.add(jetMCTaskak8)
0133 
0134 
0135 ### Era dependent customization
0136 run2_miniAOD_80XLegacy.toModify( genJetFlavourTable, jetFlavourInfos = cms.InputTag("genJetFlavourAssociation"),)
0137 
0138 _jetMCTaskak8 = jetMCTaskak8.copyAndExclude([genSubJetAK8Table])
0139 
0140 _jetMC_pre94XTask = jetMCTaskak4.copy()
0141 _jetMC_pre94XTask.add(genJetFlavourAssociation)
0142 _jetMC_pre94XTask.add(_jetMCTaskak8)
0143 run2_miniAOD_80XLegacy.toReplaceWith(jetMCTask, _jetMC_pre94XTask)