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, doc=None, 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  doc is a docstring, that will be passed to the table producer,
7  """
8  if valtype == float: valtype = "float"
9  elif valtype == int: valtype = "int"
10  elif valtype == bool: valtype = "bool"
11  return cms.PSet(
12  type = cms.string(valtype),
13  doc = cms.string(doc if doc else expr),
14  precision=cms.string(precision) if type(precision)==str else cms.int32(precision)
15  )
16 def Var(expr, valtype, doc=None, precision=-1):
17  """Create a PSet for a variable computed with the string parser
18 
19  expr is the expression to evaluate to compute the variable
20  (in case of bools, it's a cut and not a function)
21 
22  see OVar above for all the other arguments
23  """
24  return OVar(valtype, doc=(doc if doc else expr), precision=precision).clone(
25  expr = cms.string(expr))
26 
27 def ExtVar(tag, valtype, doc=None, precision=-1):
28  """Create a PSet for a variable read from the event
29 
30  tag is the InputTag to the variable.
31 
32  see OVar in common_cff for all the other arguments
33  """
34  return OVar(valtype, precision=precision, doc=(doc if doc else tag.encode())).clone(
35  src = tag if isinstance(tag, cms.InputTag) else cms.InputTag(tag),
36  )
37 
38 
39 PTVars = cms.PSet(
40  pt = Var("pt", float, precision=-1),
41  phi = Var("phi", float, precision=12),
42 )
43 P3Vars = cms.PSet(PTVars,
44  eta = Var("eta", float,precision=12),
45 )
46 P4Vars = cms.PSet(P3Vars,
47  mass = Var("mass", float,precision=10),
48 )
49 CandVars = cms.PSet(P4Vars,
50  pdgId = Var("pdgId", int, doc="PDG code assigned by the event reconstruction (not by MC truth)"),
51  charge = Var("charge", int, doc="electric charge"),
52 )
53 
54 
55 
56 
def ExtVar(tag, valtype, doc=None, precision=-1)
Definition: common_cff.py:27
def Var(expr, valtype, doc=None, precision=-1)
Definition: common_cff.py:16
def OVar(valtype, doc=None, precision=-1)
Definition: common_cff.py:2
TEveGeoShape * clone(const TEveElement *element, TEveElement *parent)
Definition: eve_macros.cc:135