Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-25 02:14:03

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, subJetTable
0006 from PhysicsTools.NanoAOD.jetsAK4_Puppi_cff import jetPuppiTable
0007 from PhysicsTools.NanoAOD.genparticles_cff import *
0008 # when storing the flat table, always do "T"able in the naming convention
0009 
0010 
0011 finalGenParticles.select +=[
0012         "keep (4 <= abs(pdgId) <= 5) && statusFlags().isLastCopy()", # BTV: keep b/c quarks in their last copy
0013         "keep (abs(pdgId) == 310 || abs(pdgId) == 3122) && statusFlags().isLastCopy()", # BTV: keep K0s and Lambdas in their last copy
0014     ]
0015 
0016 btvGenTable =  cms.EDProducer(
0017         "SimpleGenParticleFlatTableProducer",
0018         src=finalGenParticles.src,
0019         name= cms.string("GenPart"),
0020         doc = cms.string("interesting gen particles "),
0021         singleton=cms.bool(False),
0022         variables=
0023         cms.PSet(
0024             genParticleTable.variables,
0025         vx = Var("vx", "float", doc="x coordinate of vertex position"),
0026         vy = Var("vy", "float", doc="y coordinate of vertex position"),
0027         vz = Var("vz", "float", doc="z coordinate of vertex position"),
0028         genPartIdxMother2 = Var("?numberOfMothers>1?motherRef(1).key():-1", "int", doc="index of the second mother particle, if valid")
0029         ))
0030 genParticleTablesTask.replace(genParticleTable,btvGenTable)
0031 btvMCTable = cms.EDProducer("BTVMCFlavourTableProducer",name=jetPuppiTable.name,src=cms.InputTag("linkedObjects","jets"),genparticles=cms.InputTag("prunedGenParticles"))
0032 
0033 btvAK4JetExtTable = cms.EDProducer(
0034         "SimplePATJetFlatTableProducer",
0035         src=jetPuppiTable.src,
0036         cut=jetPuppiTable.cut,
0037         name=jetPuppiTable.name,
0038         doc=jetPuppiTable.doc,
0039         singleton=cms.bool(False),  # the number of entries is variable
0040         extension=cms.bool(True),  # this is the extension table for Jets
0041         variables=cms.PSet(
0042         nBHadrons=Var("jetFlavourInfo().getbHadrons().size()",
0043                       int,
0044                       doc="number of b-hadrons"),
0045         nCHadrons=Var("jetFlavourInfo().getcHadrons().size()",
0046                       int,
0047                       doc="number of c-hadrons"),
0048         ))
0049 
0050 btvSubJetMCExtTable = cms.EDProducer(
0051     "SimplePATJetFlatTableProducer",
0052     src = subJetTable.src,
0053     cut = subJetTable.cut,
0054         name = subJetTable.name,
0055         doc=subJetTable.doc,
0056         singleton = cms.bool(False),
0057         extension = cms.bool(True),
0058         variables = cms.PSet(
0059         subGenJetAK8Idx = Var("?genJetFwdRef().backRef().isNonnull()?genJetFwdRef().backRef().key():-1",
0060         int,
0061         doc="index of matched gen Sub jet"),
0062        )
0063     )
0064 genJetsAK8Constituents = cms.EDProducer("GenJetPackedConstituentPtrSelector",
0065                                                 src = cms.InputTag("slimmedGenJetsAK8"),
0066                                                 cut = cms.string("pt > 100.")
0067                                                 )
0068 
0069 
0070 genJetsAK4Constituents = cms.EDProducer("GenJetPackedConstituentPtrSelector",
0071                                                 src = cms.InputTag("slimmedGenJets"),
0072                                                 cut = cms.string("pt > 20")
0073                                                 )
0074 
0075 
0076 
0077 
0078 
0079 ak4onlygenJetsConstituents = cms.EDProducer("PackedGenParticlePtrMerger", src = cms.VInputTag(cms.InputTag("genJetsAK4Constituents", "constituents")), skipNulls = cms.bool(True), warnOnSkip = cms.bool(True))
0080 
0081 ak8onlygenJetsConstituents = cms.EDProducer("PackedGenParticlePtrMerger", src = cms.VInputTag(cms.InputTag("genJetsAK8Constituents", "constituents")), skipNulls = cms.bool(True), warnOnSkip = cms.bool(True))
0082 ak4ak8genJetsConstituents = cms.EDProducer("PackedGenParticlePtrMerger", src = cms.VInputTag(cms.InputTag("genJetsAK4Constituents", "constituents"), cms.InputTag("genJetsAK8Constituents", "constituents")), skipNulls = cms.bool(True), warnOnSkip = cms.bool(True))
0083     
0084 allPFParticleTable = cms.EDProducer("SimpleCandidateFlatTableProducer",
0085                                                      src = cms.InputTag("packedGenParticles"),
0086                                                      cut = cms.string(""), #we should not filter after pruning
0087                                                      name= cms.string("GenCands"),
0088                                                      doc = cms.string("interesting gen particles from PF candidates"),
0089                                                      singleton = cms.bool(False), # the number of entries is variable
0090                                                      extension = cms.bool(False), # this is the main table for the AK8 constituents
0091                                                      variables = cms.PSet(CandVars
0092                                                                       )
0093                                                  )
0094 ak4onlygenJetsParticleTable = cms.EDProducer("SimpleCandidateFlatTableProducer",
0095                                                      src = cms.InputTag("ak4onlygenJetsConstituents"),
0096                                                      cut = cms.string(""), #we should not filter after pruning
0097                                                      name= cms.string("GenCands"),
0098                                                      doc = cms.string("interesting gen particles from AK4 jets"),
0099                                                      singleton = cms.bool(False), # the number of entries is variable
0100                                                      extension = cms.bool(False), # this is the main table for the AK8 constituents
0101                                                      variables = cms.PSet(CandVars
0102                                                                       )
0103                                                  )
0104 ak8onlygenJetsParticleTable = cms.EDProducer("SimpleCandidateFlatTableProducer",
0105                                                      src = cms.InputTag("ak8onlygenJetsConstituents"),
0106                                                      cut = cms.string(""), #we should not filter after pruning
0107                                                      name= cms.string("GenCands"),
0108                                                      doc = cms.string("interesting gen particles from AK8 jets"),
0109                                                      singleton = cms.bool(False), # the number of entries is variable
0110                                                      extension = cms.bool(False), # this is the main table for the AK8 constituents
0111                                                      variables = cms.PSet(CandVars
0112                                                                       )
0113                                                  )
0114 ak4ak8genJetsParticleTable = cms.EDProducer("SimpleCandidateFlatTableProducer",
0115                                                      src = cms.InputTag("ak4ak8genJetsConstituents"),
0116                                                      cut = cms.string(""), #we should not filter after pruning
0117                                                      name= cms.string("GenCands"),
0118                                                      doc = cms.string("interesting gen particles from AK4, AK8 jets"),
0119                                                      singleton = cms.bool(False), # the number of entries is variable
0120                                                      extension = cms.bool(False), # this is the main table for the AK8 constituents
0121                                                      variables = cms.PSet(CandVars
0122                                                                       )
0123                                                  )
0124 ak8onlygenAK8ConstituentsTable = cms.EDProducer("GenJetConstituentTableProducer",
0125                                                      candidates = cms.InputTag("ak8onlygenJetsConstituents"),
0126                                                      jets = cms.InputTag("genJetsAK8Constituents"), # Note: The name has "Constituents" in it, but these are the jets
0127                                                      name = cms.string("GenFatJetCands"),
0128                                                      nameSV = cms.string("GenFatJetSVs"),
0129                                                      idx_name = cms.string("pFCandsIdx"),
0130                                                      idx_nameSV = cms.string("sVIdx"),
0131                                                      readBtag = cms.bool(False))
0132 ak4onlygenAK4ConstituentsTable = cms.EDProducer("GenJetConstituentTableProducer",
0133                                                      candidates = cms.InputTag("ak4onlygenJetsConstituents"),
0134                                                      jets = cms.InputTag("genJetsAK4Constituents"), # Note: The name has "Constituents" in it, but these are the jets
0135                                                      name = cms.string("GenJetCands"),
0136                                                      nameSV = cms.string("GenJetSVs"),
0137                                                      idx_name = cms.string("pFCandsIdx"),
0138                                                      idx_nameSV = cms.string("sVIdx"),
0139                                                      readBtag = cms.bool(False))
0140 ak4ak8genAK4ConstituentsTable = cms.EDProducer("GenJetConstituentTableProducer",
0141                                                      candidates = cms.InputTag("ak4ak8genJetsConstituents"),
0142                                                      jets = cms.InputTag("genJetsAK4Constituents"), # Note: The name has "Constituents" in it, but these are the jets
0143                                                      name = cms.string("GenJetCands"),
0144                                                      nameSV = cms.string("GenJetSVs"),
0145                                                      idx_name = cms.string("pFCandsIdx"),
0146                                                      idx_nameSV = cms.string("sVIdx"),
0147                                                      readBtag = cms.bool(False))
0148 
0149 ak4ak8genAK8ConstituentsTable = cms.EDProducer("GenJetConstituentTableProducer",
0150                                                      candidates = cms.InputTag("ak4ak8genJetsConstituents"),
0151                                                      jets = cms.InputTag("genJetsAK8Constituents"), # Note: The name has "Constituents" in it, but these are the jets
0152                                                      name = cms.string("GenFatJetCands"),
0153                                                      nameSV = cms.string("GenFatJetSVs"),
0154                                                      idx_name = cms.string("pFCandsIdx"),
0155                                                      idx_nameSV = cms.string("sVIdx"),
0156                                                      readBtag = cms.bool(False))
0157 btvAK4MCSequence = cms.Sequence(btvGenTable+btvAK4JetExtTable+btvMCTable)
0158 btvAK8MCSequence = cms.Sequence(btvGenTable+btvSubJetMCExtTable)
0159 #PF Cands of AK4 only , with cross linking to AK4 jets
0160 ak4onlyPFCandsMCSequence=cms.Sequence(genJetsAK4Constituents+ak4onlygenJetsConstituents+ak4onlygenJetsParticleTable+ak4onlygenAK4ConstituentsTable)+btvAK4MCSequence
0161 #PF Cands of AK8 only , with cross linking to AK8 jets
0162 ak8onlyPFCandsMCSequence=cms.Sequence(genJetsAK8Constituents+ak8onlygenJetsConstituents+ak8onlygenJetsParticleTable+ak8onlygenAK8ConstituentsTable)+btvAK8MCSequence
0163 #PF Cands of AK4+AK8, with cross linking to AK4,AK8 jets
0164 ak4ak8PFCandsMCSequence=cms.Sequence(genJetsAK4Constituents+genJetsAK8Constituents+ak4ak8genJetsConstituents+ak4ak8genJetsParticleTable+ak4ak8genAK4ConstituentsTable+ak4ak8genAK8ConstituentsTable)+btvAK4MCSequence+btvAK8MCSequence
0165 #All PFCands, with cross linking to AK4,AK8 jets
0166 allPFPFCandsMCSequence=cms.Sequence(genJetsAK4Constituents+genJetsAK8Constituents+ak4ak8genJetsConstituents+allPFParticleTable+ak4ak8genAK4ConstituentsTable+ak4ak8genAK8ConstituentsTable)+btvAK4MCSequence+btvAK8MCSequence
0167 
0168 
0169 
0170