CMS 3D CMS Logo

jetMC_cff.py
Go to the documentation of this file.
1 import FWCore.ParameterSet.Config as cms
2 
4 from PhysicsTools.NanoAOD.simpleCandidateFlatTableProducer_cfi import simpleCandidateFlatTableProducer
5 from PhysicsTools.NanoAOD.simplePATJetFlatTableProducer_cfi import simplePATJetFlatTableProducer
6 from PhysicsTools.NanoAOD.jetsAK8_cff import fatJetTable as _fatJetTable
7 from PhysicsTools.NanoAOD.jetsAK8_cff import subJetTable as _subJetTable
8 
9 jetMCTable = simplePATJetFlatTableProducer.clone(
10  src = cms.InputTag("linkedObjects","jets"),
11  name = cms.string("Jet"),
12  extension = cms.bool(True), # this is an extension table for the jets
13  variables = cms.PSet(
14  partonFlavour = Var("partonFlavour()", "int16", doc="flavour from parton matching"),
15  hadronFlavour = Var("hadronFlavour()", "uint8", doc="flavour from hadron ghost clustering"),
16  # cut should follow genJetTable.cut
17  genJetIdx = Var("?genJetFwdRef().backRef().isNonnull() && genJetFwdRef().backRef().pt() > 10.?genJetFwdRef().backRef().key():-1", "int16", doc="index of matched gen jet"),
18  )
19 )
20 genJetTable = simpleCandidateFlatTableProducer.clone(
21  src = cms.InputTag("slimmedGenJets"),
22  cut = cms.string("pt > 10"),
23  name = cms.string("GenJet"),
24  doc = cms.string("slimmedGenJets, i.e. ak4 Jets made with visible genparticles"),
25  variables = cms.PSet(P4Vars,
26  #anything else?
27  )
28 )
29 
30 patJetPartonsNano = cms.EDProducer('HadronAndPartonSelector',
31  src = cms.InputTag("generator"),
32  particles = cms.InputTag("prunedGenParticles"),
33  partonMode = cms.string("Auto"),
34  fullChainPhysPartons = cms.bool(True)
35 )
36 
37 genJetFlavourAssociation = cms.EDProducer("JetFlavourClustering",
38  jets = genJetTable.src,
39  bHadrons = cms.InputTag("patJetPartonsNano","bHadrons"),
40  cHadrons = cms.InputTag("patJetPartonsNano","cHadrons"),
41  partons = cms.InputTag("patJetPartonsNano","physicsPartons"),
42  leptons = cms.InputTag("patJetPartonsNano","leptons"),
43  jetAlgorithm = cms.string("AntiKt"),
44  rParam = cms.double(0.4),
45  ghostRescaling = cms.double(1e-18),
46  hadronFlavourHasPriority = cms.bool(False)
47 )
48 
49 genJetFlavourTable = cms.EDProducer("GenJetFlavourTableProducer",
50  name = genJetTable.name,
51  src = genJetTable.src,
52  cut = genJetTable.cut,
53  deltaR = cms.double(0.1),
54  jetFlavourInfos = cms.InputTag("slimmedGenJetsFlavourInfos"),
55 )
56 
57 genJetAK8Table = simpleCandidateFlatTableProducer.clone(
58  src = cms.InputTag("slimmedGenJetsAK8"),
59  cut = cms.string("pt > 100."),
60  name = cms.string("GenJetAK8"),
61  doc = cms.string("slimmedGenJetsAK8, i.e. ak8 Jets made with visible genparticles"),
62  variables = cms.PSet(P4Vars,
63  #anything else?
64  )
65 )
66 
67 genJetAK8FlavourAssociation = cms.EDProducer("JetFlavourClustering",
68  jets = genJetAK8Table.src,
69  bHadrons = cms.InputTag("patJetPartonsNano","bHadrons"),
70  cHadrons = cms.InputTag("patJetPartonsNano","cHadrons"),
71  partons = cms.InputTag("patJetPartonsNano","physicsPartons"),
72  leptons = cms.InputTag("patJetPartonsNano","leptons"),
73  jetAlgorithm = cms.string("AntiKt"),
74  rParam = cms.double(0.8),
75  ghostRescaling = cms.double(1e-18),
76  hadronFlavourHasPriority = cms.bool(False)
77 )
78 
79 genJetAK8FlavourTable = cms.EDProducer("GenJetFlavourTableProducer",
80  name = genJetAK8Table.name,
81  src = genJetAK8Table.src,
82  cut = genJetAK8Table.cut,
83  deltaR = cms.double(0.1),
84  jetFlavourInfos = cms.InputTag("genJetAK8FlavourAssociation"),
85 )
86 fatJetMCTable = simplePATJetFlatTableProducer.clone(
87  src = _fatJetTable.src,
88  cut = _fatJetTable.cut,
89  name = _fatJetTable.name,
90  extension = cms.bool(True),
91  variables = cms.PSet(
92  hadronFlavour = Var("hadronFlavour()", "uint8", doc="flavour from hadron ghost clustering"),
93  # cut should follow genJetAK8Table.cut
94  genJetAK8Idx = Var("?genJetFwdRef().backRef().isNonnull() && genJetFwdRef().backRef().pt() > 100.?genJetFwdRef().backRef().key():-1", "int16", doc="index of matched gen AK8 jet"),
95  )
96 )
97 
98 genSubJetAK8Table = simpleCandidateFlatTableProducer.clone(
99  src = cms.InputTag("slimmedGenJetsAK8SoftDropSubJets"),
100  name = cms.string("SubGenJetAK8"),
101  doc = cms.string("slimmedGenJetsAK8SoftDropSubJets, i.e. subjets of ak8 Jets made with visible genparticles"),
102  variables = cms.PSet(P4Vars,
103  #anything else?
104  )
105 )
106 subjetMCTable = simplePATJetFlatTableProducer.clone(
107  src = _subJetTable.src,
108  cut = _subJetTable.cut,
109  name = _subJetTable.name,
110  extension = cms.bool(True),
111  variables = cms.PSet(
112  nBHadrons = Var("jetFlavourInfo().getbHadrons().size()", "uint8", doc="number of b-hadrons"),
113  nCHadrons = Var("jetFlavourInfo().getcHadrons().size()", "uint8", doc="number of c-hadrons"),
114  hadronFlavour = Var("hadronFlavour()", "uint8", doc="flavour from hadron ghost clustering"),
115  )
116 )
117 
118 
119 jetMCTaskak4 = cms.Task(jetMCTable,genJetTable,patJetPartonsNano,genJetFlavourTable)
120 jetMCTaskak8 = cms.Task(genJetAK8Table,genJetAK8FlavourAssociation,genJetAK8FlavourTable,fatJetMCTable,genSubJetAK8Table,subjetMCTable)
121 jetMCTask = jetMCTaskak4.copyAndAdd(jetMCTaskak8)
def Var(expr, valtype, doc=None, precision=-1, lazyEval=False)
Definition: common_cff.py:17