5 import FWCore.ParameterSet.Config
as cms
7 from RecoTracker.Configuration.customiseEarlyDeleteForSeeding
import customiseEarlyDeleteForSeeding
8 from CommonTools.ParticleFlow.Isolation.customiseEarlyDeleteForCandIsoDeposits
import customiseEarlyDeleteForCandIsoDeposits
12 for name
in pset.parameterNames_():
13 value = getattr(pset,name)
14 if isinstance(value, cms.PSet):
16 elif isinstance(value, cms.VPSet):
19 elif isinstance(value, cms.VInputTag):
22 if not isinstance(t, cms.InputTag):
24 for i,moduleLabel
in enumerate(moduleLabels):
25 if result[i]:
continue
26 if t2.getModuleLabel() == moduleLabel:
28 elif isinstance(value, cms.InputTag):
29 for i,moduleLabel
in enumerate(moduleLabels):
30 if result[i]:
continue
31 if value.getModuleLabel() == moduleLabel:
33 elif isinstance(value, cms.string)
and name ==
"refToPSet_":
35 ps = getattr(process, value.value())
36 except AttributeError:
37 raise RuntimeError(
"Module %s has a 'PSet(refToPSet_ = cms.string(\"%s\"))', but the referenced-to PSet does not exist in the Process." % (psetModLabel, value.value()))
44 products = collections.defaultdict(list)
51 if not hasattr(process.options,
"canDeleteEarly"):
52 process.options.canDeleteEarly = cms.untracked.vstring()
55 for branches
in six.itervalues(products):
56 for branch
in branches:
58 process.options.canDeleteEarly.extend(
list(branchSet))
61 for prod
in six.itervalues(process.producers_()):
62 if prod.type_() ==
"LogErrorHarvester":
63 if not hasattr(prod,
'excludeModules'):
64 prod.excludeModules = cms.untracked.vstring()
65 t = prod.excludeModules.value()
66 t.extend([b.split(
'_')[1]
for b
in branchSet])
67 prod.excludeModules = t
72 for producer, branches
in six.iteritems(products):
73 producers.append(producer)
74 branchesList.append(branches)
76 for moduleType
in [process.producers_(), process.filters_(), process.analyzers_()]:
77 for name, module
in six.iteritems(moduleType):
79 for producer
in producers:
83 for i
in range(len(result)):
86 if hasattr(module,
"mightGet")
and module.mightGet:
87 module.mightGet.extend(branchesList[i])
89 module.mightGet = cms.untracked.vstring(branchesList[i])
93 if __name__==
"__main__":
102 p.pset = cms.PSet(a=cms.InputTag(
"a"),a2=cms.untracked.InputTag(
"a2"))
103 p.prod = cms.EDProducer(
"Producer",
104 foo = cms.InputTag(
"foo"),
105 foo2 = cms.InputTag(
"foo2",
"instance"),
106 foo3 = cms.InputTag(
"foo3",
"instance",
"PROCESS"),
107 foo4 = cms.untracked.InputTag(
"foo4"),
109 bar = cms.InputTag(
"bar"),
110 bar2 = cms.untracked.InputTag(
"bar2"),
112 nested2 = cms.untracked.PSet(
113 bar3 = cms.untracked.InputTag(
"bar3"),
115 flintstones = cms.VPSet(
116 cms.PSet(fred=cms.InputTag(
"fred")),
117 cms.PSet(wilma=cms.InputTag(
"wilma"))
119 flintstones2 = cms.VPSet(
120 cms.PSet(fred2=cms.untracked.InputTag(
"fred2")),
121 cms.PSet(wilma2=cms.InputTag(
"wilma2"))
124 refToPSet_ = cms.string(
"pset")
126 ref2 = cms.untracked.PSet(
127 refToPSet_ = cms.string(
"pset")
130 p.prod2 = cms.EDProducer(
"Producer2",
132 refToPSet_ = cms.string(
"nonexistent")
136 result=[
False,
False,
False,
False,
False,
False,
False,
False,
False,
False,
False,
False,
False,
False]
137 _hasInputTagModuleLabel(p, p.prod,
"prod", [
"foo",
"foo2",
"foo3",
"bar",
"fred",
"wilma",
"a",
"foo4",
"bar2",
"bar3",
"fred2",
"wilma2",
"a2",
"joe"], result)
138 for i
in range (0,13):
139 self.assert_(result[i])
140 self.assert_(
not result[13])
143 self.assertRaises(RuntimeError, _hasInputTagModuleLabel, p, p.prod2,
"prod2", [
"foo"], result)