Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mass precision in NanoGen + NanoAod, fix customization functions (10_6_X) #33688

Merged
merged 4 commits into from
May 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions PhysicsTools/NanoAOD/python/genparticles_cff.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import FWCore.ParameterSet.Config as cms
from PhysicsTools.NanoAOD.common_cff import *


from Configuration.Eras.Modifier_run2_nanoAOD_106Xv1_cff import run2_nanoAOD_106Xv1
from Configuration.Eras.Modifier_run2_nanoAOD_devel_cff import run2_nanoAOD_devel

##################### User floats producers, selectors ##########################

Expand Down Expand Up @@ -41,7 +42,7 @@
pt = Var("pt", float, precision=8),
phi = Var("phi", float,precision=8),
eta = Var("eta", float,precision=8),
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."),
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."),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need to protect the v8 production in 106X

add something like
(run2_nanoAOD_106Xv1 & ~run2_nanoAOD_devel).toModify(genParticleTable, variables.mass = ... old text ...)

pdgId = Var("pdgId", int, doc="PDG id"),
status = Var("status", int, doc="Particle status. 1=stable"),
genPartIdxMother = Var("?numberOfMothers>0?motherRef(0).key():-1", int, doc="index of the mother particle"),
Expand Down Expand Up @@ -81,5 +82,7 @@
)
)

(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."))

genParticleSequence = cms.Sequence(finalGenParticles)
genParticleTables = cms.Sequence(genParticleTable)
22 changes: 15 additions & 7 deletions PhysicsTools/NanoAOD/python/nanogen_cff.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ def nanoGenCommonCustomize(process):
setGenPtPrecision(process, CandVars.pt.precision)
setGenEtaPrecision(process, CandVars.eta.precision)
setGenPhiPrecision(process, CandVars.phi.precision)
setGenMassPrecision(process, CandVars.mass.precision)

def customizeNanoGENFromMini(process):
process.nanogenSequence.insert(0, process.genParticles2HepMCHiggsVtx)
Expand Down Expand Up @@ -107,9 +108,8 @@ def customizeNanoGEN(process):

# Prune gen particles with tight conditions applied in usual NanoAOD
def pruneGenParticlesNano(process):
process.finalGenParticles = finalGenParticles.clone()
process.genParticleTable.src = "prunedGenParticles"
process.patJetPartons.particles = "prunedGenParticles"
process.finalGenParticles.src = process.genParticleTable.src.getModuleLabel()
process.genParticleTable.src = "finalGenParticles"
process.nanogenSequence.insert(0, process.finalGenParticles)
return process

Expand All @@ -120,15 +120,18 @@ def pruneGenParticlesMini(process):
"Use a different customization.")
from PhysicsTools.PatAlgos.slimming.prunedGenParticles_cfi import prunedGenParticles
process.prunedGenParticles = prunedGenParticles.clone()
process.prunedGenParticles.src = "genParticles"
process.genParticleTable.src = "prunedGenParticles"
process.patJetPartons.particles = "prunedGenParticles"

process.nanogenSequence.insert(0, process.prunedGenParticles)
return process

def setGenFullPrecision(process):
setGenPtPrecision(process, 23)
setGenEtaPrecision(process, 23)
setGenPhiPrecision(process, 23)
process = setGenPtPrecision(process, 23)
process = setGenEtaPrecision(process, 23)
process = setGenPhiPrecision(process, 23)
process = setGenMassPrecision(process, 23)
return process

def setGenPtPrecision(process, precision):
process.genParticleTable.variables.pt.precision = precision
Expand All @@ -147,6 +150,11 @@ def setGenPhiPrecision(process, precision):
process.metMCTable.variables.phi.precision = precision
return process

def setGenMassPrecision(process, precision):
process.genParticleTable.variables.mass.precision = precision
process.genJetTable.variables.mass.precision = precision
return process

def setLHEFullPrecision(process):
process.lheInfoTable.precision = 23
return process
Expand Down