Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:32:47

0001 import FWCore.ParameterSet.Config as cms
0002 def OVar(valtype, compression=None, doc=None, mcOnly=False,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            compression is not currently used,
0007            doc is a docstring, that will be passed to the table producer,
0008            mcOnly can be set to True for variables that exist only in MC samples and not in data ones. 
0009     """
0010     if   valtype == float: valtype = "float"
0011     elif valtype == int:   valtype = "int"
0012     elif valtype == bool:  valtype = "bool"
0013     return cms.PSet( 
0014                 type = cms.string(valtype),
0015                 compression = cms.string(compression if compression else "none"),
0016                 doc = cms.string(doc if doc else expr),
0017                 mcOnly = cms.bool(mcOnly),
0018             precision=cms.string(precision) if type(precision)==str else cms.int32(precision)
0019            )
0020 def Var(expr, valtype, compression=None, doc=None, mcOnly=False,precision=-1):
0021     """Create a PSet for a variable computed with the string parser
0022 
0023        expr is the expression to evaluate to compute the variable 
0024        (in case of bools, it's a cut and not a function)
0025 
0026        see OVar above for all the other arguments
0027     """
0028     return OVar(valtype, compression=compression, doc=(doc if doc else expr), mcOnly=mcOnly,precision=precision).clone(
0029                 expr = cms.string(expr))
0030 
0031 def ExtVar(tag, valtype, compression=None, doc=None, mcOnly=False,precision=-1):
0032     """Create a PSet for a variable read from the event
0033 
0034        tag is the InputTag to the variable. 
0035 
0036        see OVar in common_cff for all the other arguments
0037     """
0038     return OVar(valtype, compression=compression,precision=precision, doc=(doc if doc else tag.encode()), mcOnly=mcOnly).clone(
0039                 src = tag if isinstance(tag, cms.InputTag) else cms.InputTag(tag),
0040           )
0041            
0042 
0043 PTVars = cms.PSet(
0044     pt  = Var("pt",  float, precision=-1),
0045     phi = Var("phi", float, precision=12),
0046 )
0047 P3Vars = cms.PSet(PTVars,
0048     eta  = Var("eta",  float,precision=12),
0049 )
0050 P4Vars = cms.PSet(P3Vars,
0051     mass = Var("mass", float,precision=10),
0052 )
0053 CandVars = cms.PSet(P4Vars,
0054     pdgId  = Var("pdgId", int, doc="PDG code assigned by the event reconstruction (not by MC truth)"),
0055     charge = Var("charge", int, doc="electric charge"),
0056 )
0057 
0058 
0059 
0060