Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-07-29 01:21:39

0001 import FWCore.ParameterSet.Config as cms
0002 from  PhysicsTools.NanoAOD.common_cff import *
0003 
0004 
0005 
0006 ##################### User floats producers, selectors ##########################
0007 
0008 finalGenParticles = cms.EDProducer("GenParticlePruner",
0009     src = cms.InputTag("prunedGenParticles"),
0010     select = cms.vstring(
0011     "drop *",
0012         "keep++ abs(pdgId) == 15 & (pt > 15 ||  isPromptDecayed() )",#  keep full tau decay chain for some taus
0013     #"drop status==1 & pt < 1", #drop soft stable particle in tau decay
0014         "keep+ abs(pdgId) == 15 ",  #  keep first gen decay product for all tau
0015         "+keep pdgId == 22 && status == 1 && (pt > 10 || isPromptFinalState())", # keep gamma above 10 GeV (or all prompt) and its first parent
0016     "+keep abs(pdgId) == 11 || abs(pdgId) == 13 || abs(pdgId) == 15", #keep leptons, with at most one mother back in the history
0017     "drop abs(pdgId)= 2212 && abs(pz) > 1000", #drop LHC protons accidentally added by previous keeps
0018         "keep (400 < abs(pdgId) < 600) || (4000 < abs(pdgId) < 6000)", #keep all B and C hadrons
0019         "keep abs(pdgId) == 12 || abs(pdgId) == 14 || abs(pdgId) == 16",   # keep neutrinos
0020     "keep status == 3 || (status > 20 && status < 30)", #keep matrix element summary
0021         "keep isHardProcess() ||  fromHardProcessDecayed()  || fromHardProcessFinalState() || (statusFlags().fromHardProcess() && statusFlags().isLastCopy())",  #keep event summary based on status flags
0022     "keep  (status > 70 && status < 80 && pt > 15) ", # keep high pt partons right before hadronization
0023         "keep abs(pdgId) == 23 || abs(pdgId) == 24 || abs(pdgId) == 25 || abs(pdgId) == 37 ",   # keep VIP(articles)s
0024         #"keep abs(pdgId) == 310 && abs(eta) < 2.5 && pt > 1 ",                                                     # keep K0
0025         "keep (1000001 <= abs(pdgId) <= 1000039 ) || ( 2000001 <= abs(pdgId) <= 2000015)", #keep SUSY fiction particles
0026         
0027    )
0028 )
0029 
0030 
0031 
0032 ##################### Tables for final output and docs ##########################
0033 genParticleTable = cms.EDProducer("SimpleCandidateFlatTableProducer",
0034     src = cms.InputTag("finalGenParticles"),
0035     cut = cms.string(""), #we should not filter after pruning
0036     name= cms.string("GenPart"),
0037     doc = cms.string("interesting gen particles "),
0038     singleton = cms.bool(False), # the number of entries is variable
0039     extension = cms.bool(False), # this is the main table for the taus
0040     variables = cms.PSet(
0041          pt  = Var("pt",  float, precision=8),
0042          phi = Var("phi", float,precision=8),
0043          eta  = Var("eta",  float,precision=8),
0044          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."),
0045          pdgId  = Var("pdgId", int, doc="PDG id"),
0046          status  = Var("status", int, doc="Particle status. 1=stable"),
0047          genPartIdxMother = Var("?numberOfMothers>0?motherRef(0).key():-1", int, doc="index of the mother particle"),
0048          statusFlags = (Var(
0049             "statusFlags().isLastCopyBeforeFSR()                  * 16384 +"
0050             "statusFlags().isLastCopy()                           * 8192  +"
0051             "statusFlags().isFirstCopy()                          * 4096  +"
0052             "statusFlags().fromHardProcessBeforeFSR()             * 2048  +"
0053             "statusFlags().isDirectHardProcessTauDecayProduct()   * 1024  +"
0054             "statusFlags().isHardProcessTauDecayProduct()         * 512   +"
0055             "statusFlags().fromHardProcess()                      * 256   +"
0056             "statusFlags().isHardProcess()                        * 128   +"
0057             "statusFlags().isDirectHadronDecayProduct()           * 64    +"
0058             "statusFlags().isDirectPromptTauDecayProduct()        * 32    +"
0059             "statusFlags().isDirectTauDecayProduct()              * 16    +"
0060             "statusFlags().isPromptTauDecayProduct()              * 8     +"
0061             "statusFlags().isTauDecayProduct()                    * 4     +"
0062             "statusFlags().isDecayedLeptonHadron()                * 2     +"
0063             "statusFlags().isPrompt()                             * 1      ",
0064             int, doc=("gen status flags stored bitwise, bits are: "
0065                 "0 : isPrompt, "
0066                 "1 : isDecayedLeptonHadron, "
0067                 "2 : isTauDecayProduct, "
0068                 "3 : isPromptTauDecayProduct, "
0069                 "4 : isDirectTauDecayProduct, "
0070                 "5 : isDirectPromptTauDecayProduct, "
0071                 "6 : isDirectHadronDecayProduct, "
0072                 "7 : isHardProcess, "
0073                 "8 : fromHardProcess, "
0074                 "9 : isHardProcessTauDecayProduct, "
0075                 "10 : isDirectHardProcessTauDecayProduct, "
0076                 "11 : fromHardProcessBeforeFSR, "
0077                 "12 : isFirstCopy, "
0078                 "13 : isLastCopy, "
0079                 "14 : isLastCopyBeforeFSR, ")
0080             )),
0081     )
0082 )
0083 
0084 genParticleTask = cms.Task(finalGenParticles)
0085 genParticleTablesTask = cms.Task(genParticleTable)
0086