Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-03-17 11:16:09

0001 import FWCore.ParameterSet.Config as cms
0002 from  PhysicsTools.NanoAOD.common_cff import *
0003 from PhysicsTools.NanoAOD.simpleCandidateFlatTableProducer_cfi import simpleCandidateFlatTableProducer
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 ##################### Tables for final output and docs ##########################
0032 genParticleTable = simpleCandidateFlatTableProducer.clone(
0033     src = cms.InputTag("finalGenParticles"),
0034     name= cms.string("GenPart"),
0035     doc = cms.string("interesting gen particles "),
0036     variables = cms.PSet(
0037          pt  = Var("pt",  float, precision=8),
0038          phi = Var("phi", float,precision=8),
0039          eta  = Var("eta",  float,precision=8),
0040          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."),
0041          pdgId  = Var("pdgId", int, doc="PDG id"),
0042          status  = Var("status", int, doc="Particle status. 1=stable"),
0043          genPartIdxMother = Var("?numberOfMothers>0?motherRef(0).key():-1", "int16", doc="index of the mother particle"),
0044          statusFlags = (Var(
0045             "statusFlags().isLastCopyBeforeFSR()                  * 16384 +"
0046             "statusFlags().isLastCopy()                           * 8192  +"
0047             "statusFlags().isFirstCopy()                          * 4096  +"
0048             "statusFlags().fromHardProcessBeforeFSR()             * 2048  +"
0049             "statusFlags().isDirectHardProcessTauDecayProduct()   * 1024  +"
0050             "statusFlags().isHardProcessTauDecayProduct()         * 512   +"
0051             "statusFlags().fromHardProcess()                      * 256   +"
0052             "statusFlags().isHardProcess()                        * 128   +"
0053             "statusFlags().isDirectHadronDecayProduct()           * 64    +"
0054             "statusFlags().isDirectPromptTauDecayProduct()        * 32    +"
0055             "statusFlags().isDirectTauDecayProduct()              * 16    +"
0056             "statusFlags().isPromptTauDecayProduct()              * 8     +"
0057             "statusFlags().isTauDecayProduct()                    * 4     +"
0058             "statusFlags().isDecayedLeptonHadron()                * 2     +"
0059             "statusFlags().isPrompt()                             * 1      ",
0060             "uint16", doc=("gen status flags stored bitwise, bits are: "
0061                 "0 : isPrompt, "
0062                 "1 : isDecayedLeptonHadron, "
0063                 "2 : isTauDecayProduct, "
0064                 "3 : isPromptTauDecayProduct, "
0065                 "4 : isDirectTauDecayProduct, "
0066                 "5 : isDirectPromptTauDecayProduct, "
0067                 "6 : isDirectHadronDecayProduct, "
0068                 "7 : isHardProcess, "
0069                 "8 : fromHardProcess, "
0070                 "9 : isHardProcessTauDecayProduct, "
0071                 "10 : isDirectHardProcessTauDecayProduct, "
0072                 "11 : fromHardProcessBeforeFSR, "
0073                 "12 : isFirstCopy, "
0074                 "13 : isLastCopy, "
0075                 "14 : isLastCopyBeforeFSR, ")
0076             )),
0077     )
0078 )
0079 
0080 genParticleTask = cms.Task(finalGenParticles)
0081 genParticleTablesTask = cms.Task(genParticleTable)
0082