CMS 3D CMS Logo

genparticles_cff.py
Go to the documentation of this file.
1 import FWCore.ParameterSet.Config as cms
3 from PhysicsTools.NanoAOD.simpleCandidateFlatTableProducer_cfi import simpleCandidateFlatTableProducer
4 
5 
6 
7 
8 finalGenParticles = cms.EDProducer("GenParticlePruner",
9  src = cms.InputTag("prunedGenParticles"),
10  select = cms.vstring(
11  "drop *",
12  "keep++ abs(pdgId) == 15 & (pt > 15 || isPromptDecayed() )",# keep full tau decay chain for some taus
13  #"drop status==1 & pt < 1", #drop soft stable particle in tau decay
14  "keep+ abs(pdgId) == 15 ", # keep first gen decay product for all tau
15  "+keep pdgId == 22 && status == 1 && (pt > 10 || isPromptFinalState())", # keep gamma above 10 GeV (or all prompt) and its first parent
16  "+keep abs(pdgId) == 11 || abs(pdgId) == 13 || abs(pdgId) == 15", #keep leptons, with at most one mother back in the history
17  "drop abs(pdgId)= 2212 && abs(pz) > 1000", #drop LHC protons accidentally added by previous keeps
18  "keep (400 < abs(pdgId) < 600) || (4000 < abs(pdgId) < 6000)", #keep all B and C hadrons
19  "keep abs(pdgId) == 12 || abs(pdgId) == 14 || abs(pdgId) == 16", # keep neutrinos
20  "keep status == 3 || (status > 20 && status < 30)", #keep matrix element summary
21  "keep isHardProcess() || fromHardProcessDecayed() || fromHardProcessFinalState() || (statusFlags().fromHardProcess() && statusFlags().isLastCopy())", #keep event summary based on status flags
22  "keep (status > 70 && status < 80 && pt > 15) ", # keep high pt partons right before hadronization
23  "keep abs(pdgId) == 23 || abs(pdgId) == 24 || abs(pdgId) == 25 || abs(pdgId) == 37 ", # keep VIP(articles)s
24  #"keep abs(pdgId) == 310 && abs(eta) < 2.5 && pt > 1 ", # keep K0
25  "keep (1000001 <= abs(pdgId) <= 1000039 ) || ( 2000001 <= abs(pdgId) <= 2000015)", #keep SUSY fiction particles
26  )
27 )
28 
29 
30 
31 
32 genParticleTable = simpleCandidateFlatTableProducer.clone(
33  src = cms.InputTag("finalGenParticles"),
34  name= cms.string("GenPart"),
35  doc = cms.string("interesting gen particles "),
36  variables = cms.PSet(
37  pt = Var("pt", float, precision=8),
38  phi = Var("phi", float,precision=8),
39  eta = Var("eta", float,precision=8),
40  mass = Var("?!((abs(pdgId)>=1 && abs(pdgId)<=5) || (abs(pdgId)>=11 && abs(pdgId)<=16) || pdgId==21 || pdgId==111 || abs(pdgId)==211 || abs(pdgId)==421 || abs(pdgId)==411 || (pdgId==22 && mass<1))?mass:0", float,precision="?((abs(pdgId)==6 || abs(pdgId)>1000000) && statusFlags().isLastCopy())?20:8",doc="Mass stored for all particles with the exception of quarks (except top), leptons/neutrinos, photons with mass < 1 GeV, gluons, pi0(111), pi+(211), D0(421), and D+(411). For these particles, you can lookup the value from PDG."),
41  pdgId = Var("pdgId", int, doc="PDG id"),
42  status = Var("status", int, doc="Particle status. 1=stable"),
43  genPartIdxMother = Var("?numberOfMothers>0?motherRef(0).key():-1", int, doc="index of the mother particle"),
44  statusFlags = (Var(
45  "statusFlags().isLastCopyBeforeFSR() * 16384 +"
46  "statusFlags().isLastCopy() * 8192 +"
47  "statusFlags().isFirstCopy() * 4096 +"
48  "statusFlags().fromHardProcessBeforeFSR() * 2048 +"
49  "statusFlags().isDirectHardProcessTauDecayProduct() * 1024 +"
50  "statusFlags().isHardProcessTauDecayProduct() * 512 +"
51  "statusFlags().fromHardProcess() * 256 +"
52  "statusFlags().isHardProcess() * 128 +"
53  "statusFlags().isDirectHadronDecayProduct() * 64 +"
54  "statusFlags().isDirectPromptTauDecayProduct() * 32 +"
55  "statusFlags().isDirectTauDecayProduct() * 16 +"
56  "statusFlags().isPromptTauDecayProduct() * 8 +"
57  "statusFlags().isTauDecayProduct() * 4 +"
58  "statusFlags().isDecayedLeptonHadron() * 2 +"
59  "statusFlags().isPrompt() * 1 ",
60  int, doc=("gen status flags stored bitwise, bits are: "
61  "0 : isPrompt, "
62  "1 : isDecayedLeptonHadron, "
63  "2 : isTauDecayProduct, "
64  "3 : isPromptTauDecayProduct, "
65  "4 : isDirectTauDecayProduct, "
66  "5 : isDirectPromptTauDecayProduct, "
67  "6 : isDirectHadronDecayProduct, "
68  "7 : isHardProcess, "
69  "8 : fromHardProcess, "
70  "9 : isHardProcessTauDecayProduct, "
71  "10 : isDirectHardProcessTauDecayProduct, "
72  "11 : fromHardProcessBeforeFSR, "
73  "12 : isFirstCopy, "
74  "13 : isLastCopy, "
75  "14 : isLastCopyBeforeFSR, ")
76  )),
77  )
78 )
79 
80 genParticleTask = cms.Task(finalGenParticles)
81 genParticleTablesTask = cms.Task(genParticleTable)
82 
def Var(expr, valtype, doc=None, precision=-1)
Definition: common_cff.py:16