CMS 3D CMS Logo

genparticles_cff.py
Go to the documentation of this file.
1 import FWCore.ParameterSet.Config as cms
3 
4 from Configuration.Eras.Modifier_run2_nanoAOD_106Xv1_cff import run2_nanoAOD_106Xv1
5 from Configuration.Eras.Modifier_run2_nanoAOD_devel_cff import run2_nanoAOD_devel
6 
7 ##################### User floats producers, selectors ##########################
8 
9 finalGenParticles = cms.EDProducer("GenParticlePruner",
10  src = cms.InputTag("prunedGenParticles"),
11  select = cms.vstring(
12  "drop *",
13  "keep++ abs(pdgId) == 15 & (pt > 15 || isPromptDecayed() )",# keep full tau decay chain for some taus
14  #"drop status==1 & pt < 1", #drop soft stable particle in tau decay
15  "keep+ abs(pdgId) == 15 ", # keep first gen decay product for all tau
16  "+keep pdgId == 22 && status == 1 && (pt > 10 || isPromptFinalState())", # keep gamma above 10 GeV (or all prompt) and its first parent
17  "+keep abs(pdgId) == 11 || abs(pdgId) == 13 || abs(pdgId) == 15", #keep leptons, with at most one mother back in the history
18  "drop abs(pdgId)= 2212 && abs(pz) > 1000", #drop LHC protons accidentally added by previous keeps
19  "keep (400 < abs(pdgId) < 600) || (4000 < abs(pdgId) < 6000)", #keep all B and C hadrons
20  "keep abs(pdgId) == 12 || abs(pdgId) == 14 || abs(pdgId) == 16", # keep neutrinos
21  "keep status == 3 || (status > 20 && status < 30)", #keep matrix element summary
22  "keep isHardProcess() || fromHardProcessDecayed() || fromHardProcessFinalState() || (statusFlags().fromHardProcess() && statusFlags().isLastCopy())", #keep event summary based on status flags
23  "keep (status > 70 && status < 80 && pt > 15) ", # keep high pt partons right before hadronization
24  "keep abs(pdgId) == 23 || abs(pdgId) == 24 || abs(pdgId) == 25 || abs(pdgId) == 37 ", # keep VIP(articles)s
25  #"keep abs(pdgId) == 310 && abs(eta) < 2.5 && pt > 1 ", # keep K0
26  "keep (1000001 <= abs(pdgId) <= 1000039 ) || ( 2000001 <= abs(pdgId) <= 2000015)", #keep SUSY fiction particles
27 
28  )
29 )
30 
31 
32 
33 ##################### Tables for final output and docs ##########################
34 genParticleTable = cms.EDProducer("SimpleCandidateFlatTableProducer",
35  src = cms.InputTag("finalGenParticles"),
36  cut = cms.string(""), #we should not filter after pruning
37  name= cms.string("GenPart"),
38  doc = cms.string("interesting gen particles "),
39  singleton = cms.bool(False), # the number of entries is variable
40  extension = cms.bool(False), # this is the main table for the taus
41  variables = cms.PSet(
42  pt = Var("pt", float, precision=8),
43  phi = Var("phi", float,precision=8),
44  eta = Var("eta", float,precision=8),
45  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."),
46  pdgId = Var("pdgId", int, doc="PDG id"),
47  status = Var("status", int, doc="Particle status. 1=stable"),
48  genPartIdxMother = Var("?numberOfMothers>0?motherRef(0).key():-1", int, doc="index of the mother particle"),
49  statusFlags = (Var(
50  "statusFlags().isLastCopyBeforeFSR() * 16384 +"
51  "statusFlags().isLastCopy() * 8192 +"
52  "statusFlags().isFirstCopy() * 4096 +"
53  "statusFlags().fromHardProcessBeforeFSR() * 2048 +"
54  "statusFlags().isDirectHardProcessTauDecayProduct() * 1024 +"
55  "statusFlags().isHardProcessTauDecayProduct() * 512 +"
56  "statusFlags().fromHardProcess() * 256 +"
57  "statusFlags().isHardProcess() * 128 +"
58  "statusFlags().isDirectHadronDecayProduct() * 64 +"
59  "statusFlags().isDirectPromptTauDecayProduct() * 32 +"
60  "statusFlags().isDirectTauDecayProduct() * 16 +"
61  "statusFlags().isPromptTauDecayProduct() * 8 +"
62  "statusFlags().isTauDecayProduct() * 4 +"
63  "statusFlags().isDecayedLeptonHadron() * 2 +"
64  "statusFlags().isPrompt() * 1 ",
65  int, doc=("gen status flags stored bitwise, bits are: "
66  "0 : isPrompt, "
67  "1 : isDecayedLeptonHadron, "
68  "2 : isTauDecayProduct, "
69  "3 : isPromptTauDecayProduct, "
70  "4 : isDirectTauDecayProduct, "
71  "5 : isDirectPromptTauDecayProduct, "
72  "6 : isDirectHadronDecayProduct, "
73  "7 : isHardProcess, "
74  "8 : fromHardProcess, "
75  "9 : isHardProcessTauDecayProduct, "
76  "10 : isDirectHardProcessTauDecayProduct, "
77  "11 : fromHardProcessBeforeFSR, "
78  "12 : isFirstCopy, "
79  "13 : isLastCopy, "
80  "14 : isLastCopyBeforeFSR, ")
81  )),
82  )
83 )
84 
85 (run2_nanoAOD_106Xv1 & ~run2_nanoAOD_devel).toModify( genParticleTable.variables, 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 && 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."))
86 
87 genParticleSequence = cms.Sequence(finalGenParticles)
88 genParticleTables = cms.Sequence(genParticleTable)
def Var(expr, valtype, compression=None, doc=None, mcOnly=False, precision=-1)
Definition: common_cff.py:20