File indexing completed on 2024-04-25 02:14:03
0001 import FWCore.ParameterSet.Config as cms
0002 def OVar(valtype, doc=None, precision=-1):
0003 """ Create a PSet for a variable in the tree (without specifying how it is computed)
0004
0005 valtype is the type of the value (float, int, bool, or a string that the table producer understands),
0006 doc is a docstring, that will be passed to the table producer,
0007 """
0008 if valtype == float: valtype = "float"
0009 elif valtype == int: valtype = "int"
0010 elif valtype == bool: valtype = "bool"
0011 return cms.PSet(
0012 type = cms.string(valtype),
0013 doc = cms.string(doc if doc else expr),
0014 precision=cms.optional.allowed(cms.string, cms.int32, default = (cms.string(precision) if type(precision)==str else cms.int32(precision)))
0015 )
0016
0017 def Var(expr, valtype, doc=None, precision=-1, lazyEval=False):
0018 """Create a PSet for a variable computed with the string parser
0019
0020 expr is the expression to evaluate to compute the variable
0021 (in case of bools, it's a cut and not a function)
0022
0023 see OVar above for all the other arguments
0024 """
0025 return OVar(valtype, doc=(doc if doc else expr), precision=precision).clone(
0026 expr = cms.string(expr), lazyEval=cms.untracked.bool(lazyEval))
0027
0028 def ExtVar(tag, valtype, doc=None, precision=-1):
0029 """Create a PSet for a variable read from the event
0030
0031 tag is the InputTag to the variable.
0032
0033 see OVar in common_cff for all the other arguments
0034 """
0035 return OVar(valtype, precision=precision, doc=(doc if doc else tag.encode())).clone(
0036 src = tag if isinstance(tag, cms.InputTag) else cms.InputTag(tag),
0037 )
0038
0039
0040 PTVars = cms.PSet(
0041 pt = Var("pt", float, precision=-1),
0042 phi = Var("phi", float, precision=12),
0043 )
0044 P3Vars = cms.PSet(PTVars,
0045 eta = Var("eta", float,precision=12),
0046 )
0047 P4Vars = cms.PSet(P3Vars,
0048 mass = Var("mass", float,precision=10),
0049 )
0050 CandVars = cms.PSet(P4Vars,
0051 pdgId = Var("pdgId", int, doc="PDG code assigned by the event reconstruction (not by MC truth)"),
0052 charge = Var("charge", int, doc="electric charge"),
0053 )
0054
0055
0056
0057