1 from __future__
import print_function
7 from PhysicsTools.SelectorUtils.centralIDRegistry
import central_id_registry
8 from PhysicsTools.SelectorUtils.VIDCutFlowResult
import VIDCutFlowResult
9 import DataFormats.FWLite
12 ROOT.gSystem.Load(
"libFWCoreFWLite.so");
13 ROOT.gSystem.Load(
"libDataFormatsFWLite.so");
14 ROOT.FWLiteEnabler.enable()
17 import FWCore.ParameterSet.Config as cms
19 from PhysicsTools.SelectorUtils.centralIDRegistry import central_id_registry
27 """ turn a python cms.PSet into a VID ID """
28 idname = pythonpset.idName.value().
replace(
'-',
'_') + suffix
29 escaped_pset = config_template%(idname, pythonpset)
31 return builder(escaped_pset,idname)
33 def id_generator(size=6, chars=string.ascii_uppercase + string.digits):
34 return ''.
join(random.choice(chars)
for _
in range(size))
37 def __init__(self, vidSelectorBuilder, ptrMaker, printer, pythonpset = None):
44 if pythonpset
is not None:
45 if hasattr(pythonpset,
'isPOGApproved'):
46 approved = pythonpset.isPOGApproved.value()
48 sys.stderr.write(
'This ID is not POG approved and likely under development!!!!\n')
49 sys.stderr.write(
'Please make sure to report your progress with this ID'\
50 ' at the next relevant POG meeting.\n')
51 del pythonpset.isPOGApproved
53 sys.stderr.write(
'This ID is not POG approved and likely under development!!!!\n')
54 sys.stderr.write(
'Please make sure to report your progress with this ID'\
55 ' at the next relevant POG meeting.\n')
57 expectedmd5 = central_id_registry.getMD5FromName(pythonpset.idName)
59 sys.stderr.write(
"ID: %s\n"%self.
name())
60 sys.stderr.write(
"The expected md5: %s does not match the md5\n"%expectedmd5)
61 sys.stderr.write(
"calculated by the ID: %s please\n"%self.
md5String())
62 sys.stderr.write(
"update your python configuration or determine the source\n")
63 sys.stderr.write(
"of transcription error!\n")
71 if( len(args) == 2
and isinstance(args[1],DataFormats.FWLite.Events) ):
73 elif( len(args) == 2
and isinstance(args[1], int) ):
77 if( len(args) == 3
and isinstance(args[1], int)
and isinstance(args[2], DataFormats.FWLite.Events) ):
82 raise ValueError(
'VIDSelectorBase __call__ with args: "%s" is not a valid call pattern'%(
','.
join([repr(arg)
for arg
in args])))
87 print(
'VID Selector is already initialized, doing nothing!')
89 del process.__instance
90 if hasattr(pythonpset,
'isPOGApproved'):
91 approved = pythonpset.isPOGApproved.value()
93 sys.stderr.write(
'This ID is not POG approved and likely under development!!!!\n')
94 sys.stderr.write(
'Please make sure to report your progress with this ID'\
95 ' at the next relevant POG meeting.\n')
96 del pythonpset.isPOGApproved
98 sys.stderr.write(
'This ID is not POG approved and likely under development!!!!\n')
99 sys.stderr.write(
'Please make sure to report your progress with this ID'\
100 ' at the next relevant POG meeting.\n')
102 expectedmd5 = central_id_registry.getMD5FromName(pythonpset.idName)
104 sys.stderr.write(
"ID: %s\n"%self.
name())
105 sys.stderr.write(
"The expected md5: %s does not match the md5\n"%expectedmd5)
106 sys.stderr.write(
"calculated by the ID: %s please\n"%self.
md5String())
107 sys.stderr.write(
"update your python configuration or determine the source\n")
108 sys.stderr.write(
"of transcription error!\n")