1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
from PhysicsTools.NanoAOD.common_cff import *
from typing import NamedTuple
class DEFAULT_VAL(NamedTuple):
INT: int = -999
INT8: int = -99
INT_POS: int = -1
FLOAT: int = -999.0
FLOAT_POS: int = -1.0
defaults = DEFAULT_VAL()
def DetIdVar(expr, type, doc=None, lazyEval=False):
""" Create a PSet for a DetId variable in the tree:
- expr is the expression to evaluate to compute the variable,
- type of the value (int, bool, or a string that the table producer understands),
- doc is a docstring, that will be passed to the table producer
"""
if type == float: type = "float"
elif type == bool: type = "bool"
elif type == int: type = "int"
return cms.PSet(
type = cms.string(type),
expr = cms.string(expr),
doc = cms.string(doc if doc else expr),
lazyEval = cms.untracked.bool(lazyEval)
)
def GlobGeomVar(expr, doc=None, precision=-1, lazyEval=False):
""" Create a PSet for a Global position/direction variable in the tree ,
- expr is the expression to evaluate to compute the variable,
- doc is a docstring, that will be passed to the table producer,
- precision is an int handling mantissa reduction.
"""
return cms.PSet(
expr = cms.string(expr),
doc = cms.string(doc if doc else expr),
precision = cms.string(precision) if type(precision)==str else cms.int32(precision),
lazyEval = cms.untracked.bool(lazyEval)
)
|