File indexing completed on 2023-05-20 02:14:19
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 def Var(expr, valtype, doc=None, precision=-1):
0017 """Create a PSet for a variable computed with the string parser
0018
0019 expr is the expression to evaluate to compute the variable
0020 (in case of bools, it's a cut and not a function)
0021
0022 see OVar above for all the other arguments
0023 """
0024 return OVar(valtype, doc=(doc if doc else expr), precision=precision).clone(
0025 expr = cms.string(expr))
0026
0027 def ExtVar(tag, valtype, doc=None, precision=-1):
0028 """Create a PSet for a variable read from the event
0029
0030 tag is the InputTag to the variable.
0031
0032 see OVar in common_cff for all the other arguments
0033 """
0034 return OVar(valtype, precision=precision, doc=(doc if doc else tag.encode())).clone(
0035 src = tag if isinstance(tag, cms.InputTag) else cms.InputTag(tag),
0036 )
0037
0038
0039 PTVars = cms.PSet(
0040 pt = Var("pt", float, precision=-1),
0041 phi = Var("phi", float, precision=12),
0042 )
0043 P3Vars = cms.PSet(PTVars,
0044 eta = Var("eta", float,precision=12),
0045 )
0046 P4Vars = cms.PSet(P3Vars,
0047 mass = Var("mass", float,precision=10),
0048 )
0049 CandVars = cms.PSet(P4Vars,
0050 pdgId = Var("pdgId", int, doc="PDG code assigned by the event reconstruction (not by MC truth)"),
0051 charge = Var("charge", int, doc="electric charge"),
0052 )
0053
0054
0055
0056