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