CMS 3D CMS Logo

common_cff.py
Go to the documentation of this file.
1 import FWCore.ParameterSet.Config as cms
2 def OVar(valtype, compression=None, doc=None, mcOnly=False,precision=-1):
3  """ Create a PSet for a variable in the tree (without specifying how it is computed)
4 
5  valtype is the type of the value (float, int, bool, or a string that the table producer understands),
6  compression is not currently used,
7  doc is a docstring, that will be passed to the table producer,
8  mcOnly can be set to True for variables that exist only in MC samples and not in data ones.
9  """
10  if valtype == float: valtype = "float"
11  elif valtype == int: valtype = "int"
12  elif valtype == bool: valtype = "bool"
13  return cms.PSet(
14  type = cms.string(valtype),
15  compression = cms.string(compression if compression else "none"),
16  doc = cms.string(doc if doc else expr),
17  mcOnly = cms.bool(mcOnly),
18  precision=cms.string(precision) if type(precision)==str else cms.int32(precision)
19  )
20 def Var(expr, valtype, compression=None, doc=None, mcOnly=False,precision=-1):
21  """Create a PSet for a variable computed with the string parser
22 
23  expr is the expression to evaluate to compute the variable
24  (in case of bools, it's a cut and not a function)
25 
26  see OVar above for all the other arguments
27  """
28  return OVar(valtype, compression=compression, doc=(doc if doc else expr), mcOnly=mcOnly,precision=precision).clone(
29  expr = cms.string(expr))
30 
31 def ExtVar(tag, valtype, compression=None, doc=None, mcOnly=False,precision=-1):
32  """Create a PSet for a variable read from the event
33 
34  tag is the InputTag to the variable.
35 
36  see OVar in common_cff for all the other arguments
37  """
38  return OVar(valtype, compression=compression,precision=precision, doc=(doc if doc else tag.encode()), mcOnly=mcOnly).clone(
39  src = tag if isinstance(tag, cms.InputTag) else cms.InputTag(tag),
40  )
41 
42 
43 PTVars = cms.PSet(
44  pt = Var("pt", float, precision=-1),
45  phi = Var("phi", float, precision=12),
46 )
47 P3Vars = cms.PSet(PTVars,
48  eta = Var("eta", float,precision=12),
49 )
50 P4Vars = cms.PSet(P3Vars,
51  mass = Var("mass", float,precision=10),
52 )
53 CandVars = cms.PSet(P4Vars,
54  pdgId = Var("pdgId", int, doc="PDG code assigned by the event reconstruction (not by MC truth)"),
55  charge = Var("charge", int, doc="electric charge"),
56 )
57 
58 
59 
60 
def ExtVar(tag, valtype, compression=None, doc=None, mcOnly=False, precision=-1)
Definition: common_cff.py:31
def Var(expr, valtype, compression=None, doc=None, mcOnly=False, precision=-1)
Definition: common_cff.py:20
def OVar(valtype, compression=None, doc=None, mcOnly=False, precision=-1)
Definition: common_cff.py:2
TEveGeoShape * clone(const TEveElement *element, TEveElement *parent)
Definition: eve_macros.cc:135